-
Notifications
You must be signed in to change notification settings - Fork 1
/
metaelement.cpp
123 lines (108 loc) · 2.16 KB
/
metaelement.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* PGR 2013 project
* Used for drawing and resizing elements in scene
*
* @author xskota05 Klara Vankova
* xsimet00 Vojtech Simetka
* @date 2013/11/26
* @version 1
* @file metaelement.cpp
*/
#include "metaelement.h"
#include <QDebug>
/**
* @brief MetaElement constructor
*/
MetaElement::MetaElement()
:origin(0,0)
{
this->clear();
}
/**
* @brief MetaElement destructor
*/
MetaElement::~MetaElement()
{
}
/**
* @brief Tests if there any element is being drawn or resized
* @return True if an element is being drawn or resized
*/
bool MetaElement::isEmpty()
{
return this->element == NULL;
}
/**
* @brief Initializes metaelement for drawing/resizing
* @param element Element to be modified
* @param x Origin coordinate x
* @param y Origin coordinate y
*/
void MetaElement::init(Element *element, float x, float y)
{
this->element = element;
this->origin.setX(x);
this->origin.setY(y);
}
/**
* @brief Paints the element that is being modified
*/
void MetaElement::paintMe()
{
if (this->element != NULL)
{
this->element->paintMe();
this->element->paintPoints();
}
}
/**
* @brief Highlight the element that is being modified
*/
void MetaElement::highlightMe()
{
this->element->highlightMe();
}
/**
* @brief Dehighlight the element that is being modified
*/
void MetaElement::deHighlightMe()
{
this->element->deHighlightMe();
}
/**
* @brief Resizes element from origin to point with coordinates x and y
* @param x Coordinate x for resizing
* @param y Coordinate y for resizing
*/
void MetaElement::resizeTo(float x, float y)
{
this->element->resize(origin.getX(),origin.getY(),x,y);
}
/**
* @brief Clears the metaelement
*/
void MetaElement::clear()
{
this->element = NULL;
}
/**
* @brief Gets element that is being modified
* @return Element being modified
*/
Element *MetaElement::getElement()
{
return this->element;
}
/**
* @brief Gets origin point of the element
* @return Point of origin
*/
Point MetaElement::getOrigin() const
{
return origin;
}
void MetaElement::set(Element * e, float x, float y)
{
this->element = e;
this->origin.setLocation(x,y);
}