insilmaril@0
|
1 |
#include "frameobj.h"
|
insilmaril@0
|
2 |
|
insilmaril@0
|
3 |
#include <qcolor.h>
|
insilmaril@0
|
4 |
|
insilmaril@0
|
5 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
6 |
// FrameObj
|
insilmaril@0
|
7 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
8 |
FrameObj::FrameObj() : MapObj()
|
insilmaril@0
|
9 |
{
|
insilmaril@0
|
10 |
// cout << "Const FrameObj ()\n";
|
insilmaril@0
|
11 |
init ();
|
insilmaril@0
|
12 |
}
|
insilmaril@0
|
13 |
|
insilmaril@408
|
14 |
FrameObj::FrameObj(QGraphicsScene *s) :MapObj(s)
|
insilmaril@0
|
15 |
{
|
insilmaril@0
|
16 |
// cout << "Const FrameObj\n";
|
insilmaril@0
|
17 |
init ();
|
insilmaril@0
|
18 |
}
|
insilmaril@0
|
19 |
|
insilmaril@0
|
20 |
FrameObj::~FrameObj()
|
insilmaril@0
|
21 |
{
|
insilmaril@0
|
22 |
clear();
|
insilmaril@0
|
23 |
}
|
insilmaril@0
|
24 |
|
insilmaril@0
|
25 |
void FrameObj::init()
|
insilmaril@0
|
26 |
{
|
insilmaril@0
|
27 |
type=NoFrame;
|
insilmaril@0
|
28 |
border=0;
|
insilmaril@0
|
29 |
}
|
insilmaril@0
|
30 |
|
insilmaril@0
|
31 |
void FrameObj::clear()
|
insilmaril@0
|
32 |
{
|
insilmaril@0
|
33 |
switch (type)
|
insilmaril@0
|
34 |
{
|
insilmaril@0
|
35 |
case NoFrame:
|
insilmaril@0
|
36 |
break;
|
insilmaril@0
|
37 |
case Rectangle:
|
insilmaril@0
|
38 |
delete rectFrame;
|
insilmaril@0
|
39 |
break;
|
insilmaril@421
|
40 |
case Ellipse:
|
insilmaril@421
|
41 |
delete ellipseFrame;
|
insilmaril@421
|
42 |
break;
|
insilmaril@0
|
43 |
}
|
insilmaril@0
|
44 |
type=NoFrame;
|
insilmaril@0
|
45 |
border=0;
|
insilmaril@0
|
46 |
}
|
insilmaril@0
|
47 |
|
insilmaril@0
|
48 |
void FrameObj::move(double x, double y)
|
insilmaril@0
|
49 |
{
|
insilmaril@0
|
50 |
switch (type)
|
insilmaril@0
|
51 |
{
|
insilmaril@0
|
52 |
case NoFrame:
|
insilmaril@0
|
53 |
break;
|
insilmaril@0
|
54 |
case Rectangle:
|
insilmaril@408
|
55 |
rectFrame->setPos (x,y);
|
insilmaril@0
|
56 |
break;
|
insilmaril@421
|
57 |
case Ellipse:
|
insilmaril@421
|
58 |
ellipseFrame->setPos (x,y);
|
insilmaril@421
|
59 |
break;
|
insilmaril@0
|
60 |
}
|
insilmaril@0
|
61 |
}
|
insilmaril@0
|
62 |
|
insilmaril@0
|
63 |
void FrameObj::moveBy(double x, double y)
|
insilmaril@0
|
64 |
{
|
insilmaril@0
|
65 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
66 |
}
|
insilmaril@0
|
67 |
|
insilmaril@0
|
68 |
void FrameObj::positionBBox()
|
insilmaril@0
|
69 |
{
|
insilmaril@0
|
70 |
}
|
insilmaril@0
|
71 |
|
insilmaril@0
|
72 |
void FrameObj::calcBBoxSize()
|
insilmaril@0
|
73 |
{
|
insilmaril@0
|
74 |
}
|
insilmaril@0
|
75 |
|
insilmaril@408
|
76 |
void FrameObj::setRect(const QRectF &r)
|
insilmaril@0
|
77 |
{
|
insilmaril@0
|
78 |
bbox=r;
|
insilmaril@0
|
79 |
switch (type)
|
insilmaril@0
|
80 |
{
|
insilmaril@0
|
81 |
case NoFrame:
|
insilmaril@0
|
82 |
break;
|
insilmaril@0
|
83 |
case Rectangle:
|
insilmaril@408
|
84 |
rectFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ));
|
insilmaril@0
|
85 |
break;
|
insilmaril@421
|
86 |
case Ellipse:
|
insilmaril@421
|
87 |
ellipseFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ));
|
insilmaril@421
|
88 |
break;
|
insilmaril@0
|
89 |
}
|
insilmaril@0
|
90 |
}
|
insilmaril@0
|
91 |
|
insilmaril@0
|
92 |
int FrameObj::getBorder()
|
insilmaril@0
|
93 |
{
|
insilmaril@0
|
94 |
return border;
|
insilmaril@0
|
95 |
}
|
insilmaril@0
|
96 |
|
insilmaril@0
|
97 |
FrameType FrameObj::getFrameType()
|
insilmaril@0
|
98 |
{
|
insilmaril@0
|
99 |
return type;
|
insilmaril@0
|
100 |
}
|
insilmaril@0
|
101 |
|
insilmaril@0
|
102 |
QString FrameObj::getFrameTypeName()
|
insilmaril@0
|
103 |
{
|
insilmaril@0
|
104 |
switch (type)
|
insilmaril@0
|
105 |
{
|
insilmaril@0
|
106 |
case Rectangle:
|
insilmaril@0
|
107 |
return "Rectangle";
|
insilmaril@0
|
108 |
break;
|
insilmaril@421
|
109 |
case Ellipse:
|
insilmaril@421
|
110 |
return "Ellipse";
|
insilmaril@421
|
111 |
break;
|
insilmaril@0
|
112 |
default:
|
insilmaril@0
|
113 |
return "NoFrame";
|
insilmaril@0
|
114 |
}
|
insilmaril@0
|
115 |
}
|
insilmaril@0
|
116 |
|
insilmaril@0
|
117 |
void FrameObj::setFrameType(const FrameType &t)
|
insilmaril@0
|
118 |
{
|
insilmaril@0
|
119 |
if (t!=type)
|
insilmaril@0
|
120 |
{
|
insilmaril@0
|
121 |
clear();
|
insilmaril@0
|
122 |
type=t;
|
insilmaril@0
|
123 |
switch (type)
|
insilmaril@0
|
124 |
{
|
insilmaril@0
|
125 |
case NoFrame:
|
insilmaril@0
|
126 |
border=0;
|
insilmaril@0
|
127 |
break;
|
insilmaril@0
|
128 |
case Rectangle:
|
insilmaril@0
|
129 |
border=10;
|
insilmaril@408
|
130 |
rectFrame = scene->addRect(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white"));
|
insilmaril@408
|
131 |
rectFrame->setZValue(Z_FRAME);
|
insilmaril@421
|
132 |
break;
|
insilmaril@421
|
133 |
case Ellipse:
|
insilmaril@421
|
134 |
border=10;
|
insilmaril@421
|
135 |
ellipseFrame = scene->addEllipse(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white"));
|
insilmaril@421
|
136 |
ellipseFrame->setZValue(Z_FRAME);
|
insilmaril@0
|
137 |
break;
|
insilmaril@0
|
138 |
}
|
insilmaril@140
|
139 |
setVisibility (visible);
|
insilmaril@0
|
140 |
}
|
insilmaril@0
|
141 |
}
|
insilmaril@0
|
142 |
|
insilmaril@0
|
143 |
void FrameObj::setFrameType(const QString &t)
|
insilmaril@0
|
144 |
{
|
insilmaril@0
|
145 |
if (t=="Rectangle")
|
insilmaril@0
|
146 |
FrameObj::setFrameType (Rectangle);
|
insilmaril@421
|
147 |
else if (t=="Ellipse")
|
insilmaril@421
|
148 |
FrameObj::setFrameType (Ellipse);
|
insilmaril@0
|
149 |
else
|
insilmaril@0
|
150 |
FrameObj::setFrameType (NoFrame);
|
insilmaril@0
|
151 |
}
|
insilmaril@0
|
152 |
|
insilmaril@0
|
153 |
void FrameObj::setVisibility (bool v)
|
insilmaril@0
|
154 |
{
|
insilmaril@0
|
155 |
MapObj::setVisibility(v);
|
insilmaril@140
|
156 |
switch (type)
|
insilmaril@140
|
157 |
{
|
insilmaril@140
|
158 |
case NoFrame:
|
insilmaril@140
|
159 |
break;
|
insilmaril@140
|
160 |
case Rectangle:
|
insilmaril@140
|
161 |
if (visible)
|
insilmaril@140
|
162 |
rectFrame->show();
|
insilmaril@140
|
163 |
else
|
insilmaril@140
|
164 |
rectFrame->hide();
|
insilmaril@140
|
165 |
break;
|
insilmaril@421
|
166 |
case Ellipse:
|
insilmaril@421
|
167 |
if (visible)
|
insilmaril@421
|
168 |
ellipseFrame->show();
|
insilmaril@421
|
169 |
else
|
insilmaril@421
|
170 |
ellipseFrame->hide();
|
insilmaril@421
|
171 |
break;
|
insilmaril@140
|
172 |
}
|
insilmaril@0
|
173 |
}
|
insilmaril@0
|
174 |
|
insilmaril@421
|
175 |
QString FrameObj::saveToDir ()
|
insilmaril@421
|
176 |
{
|
insilmaril@421
|
177 |
QString frameTypeAttr=attribut ("frameType",getFrameTypeName());
|
insilmaril@421
|
178 |
return singleElement ("frame",frameTypeAttr);
|
insilmaril@421
|
179 |
}
|
insilmaril@421
|
180 |
|