insilmaril@611
|
1 |
#include <typeinfo>
|
insilmaril@611
|
2 |
|
insilmaril@0
|
3 |
#include "ornamentedobj.h"
|
insilmaril@0
|
4 |
#include "texteditor.h"
|
insilmaril@0
|
5 |
#include "mapeditor.h"
|
insilmaril@0
|
6 |
#include "linkablemapobj.h"
|
insilmaril@0
|
7 |
|
insilmaril@0
|
8 |
extern TextEditor *textEditor;
|
insilmaril@0
|
9 |
|
insilmaril@0
|
10 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
11 |
// OrnamentedObj
|
insilmaril@0
|
12 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
13 |
|
insilmaril@0
|
14 |
OrnamentedObj::OrnamentedObj():LinkableMapObj()
|
insilmaril@0
|
15 |
{
|
insilmaril@0
|
16 |
// cout << "Const OrnamentedObj ()\n";
|
insilmaril@0
|
17 |
init ();
|
insilmaril@0
|
18 |
}
|
insilmaril@0
|
19 |
|
insilmaril@408
|
20 |
OrnamentedObj::OrnamentedObj(QGraphicsScene* s) :LinkableMapObj(s)
|
insilmaril@0
|
21 |
{
|
insilmaril@408
|
22 |
// cout << "Const OrnamentedObj (s)\n";
|
insilmaril@0
|
23 |
init ();
|
insilmaril@0
|
24 |
}
|
insilmaril@0
|
25 |
|
insilmaril@408
|
26 |
OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
|
insilmaril@0
|
27 |
{
|
insilmaril@0
|
28 |
copy (lmo);
|
insilmaril@0
|
29 |
}
|
insilmaril@0
|
30 |
|
insilmaril@0
|
31 |
OrnamentedObj::~OrnamentedObj()
|
insilmaril@0
|
32 |
{
|
insilmaril@442
|
33 |
delete heading;
|
insilmaril@442
|
34 |
delete systemFlags;
|
insilmaril@442
|
35 |
delete standardFlags;
|
insilmaril@442
|
36 |
delete frame;
|
insilmaril@0
|
37 |
}
|
insilmaril@0
|
38 |
|
insilmaril@0
|
39 |
|
insilmaril@0
|
40 |
void OrnamentedObj::init ()
|
insilmaril@0
|
41 |
{
|
insilmaril@408
|
42 |
heading = new HeadingObj(scene);
|
insilmaril@0
|
43 |
heading->move (absPos.x(), absPos.y());
|
insilmaril@0
|
44 |
|
insilmaril@408
|
45 |
systemFlags=new FlagRowObj(scene);
|
insilmaril@408
|
46 |
standardFlags=new FlagRowObj(scene);
|
insilmaril@628
|
47 |
|
insilmaril@442
|
48 |
frame = new FrameObj (scene);
|
insilmaril@0
|
49 |
}
|
insilmaril@0
|
50 |
|
insilmaril@0
|
51 |
void OrnamentedObj::copy (OrnamentedObj* other)
|
insilmaril@0
|
52 |
{
|
insilmaril@0
|
53 |
LinkableMapObj::copy(other);
|
insilmaril@0
|
54 |
heading->copy(other->heading);
|
insilmaril@243
|
55 |
setColor (other->heading->getColor());
|
insilmaril@0
|
56 |
|
insilmaril@0
|
57 |
systemFlags->copy (other->systemFlags);
|
insilmaril@0
|
58 |
standardFlags->copy (other->standardFlags);
|
insilmaril@0
|
59 |
|
insilmaril@227
|
60 |
ornamentsBBox=other->ornamentsBBox;
|
insilmaril@0
|
61 |
}
|
insilmaril@0
|
62 |
|
insilmaril@0
|
63 |
void OrnamentedObj::setLinkColor()
|
insilmaril@0
|
64 |
{
|
insilmaril@721
|
65 |
if (model->getMapLinkColorHint()==HeadingColor)
|
insilmaril@0
|
66 |
LinkableMapObj::setLinkColor (heading->getColor());
|
insilmaril@0
|
67 |
else
|
insilmaril@721
|
68 |
LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
|
insilmaril@0
|
69 |
}
|
insilmaril@0
|
70 |
|
insilmaril@243
|
71 |
void OrnamentedObj::setColor (QColor col)
|
insilmaril@243
|
72 |
{
|
insilmaril@243
|
73 |
heading->setColor(col);
|
insilmaril@243
|
74 |
setLinkColor();
|
insilmaril@243
|
75 |
}
|
insilmaril@243
|
76 |
|
insilmaril@0
|
77 |
QColor OrnamentedObj::getColor ()
|
insilmaril@0
|
78 |
{
|
insilmaril@0
|
79 |
return heading->getColor();
|
insilmaril@0
|
80 |
}
|
insilmaril@0
|
81 |
|
insilmaril@476
|
82 |
FrameObj::FrameType OrnamentedObj::getFrameType()
|
insilmaril@442
|
83 |
{
|
insilmaril@442
|
84 |
return frame->getFrameType();
|
insilmaril@442
|
85 |
}
|
insilmaril@442
|
86 |
|
insilmaril@476
|
87 |
QString OrnamentedObj::getFrameTypeName()
|
insilmaril@476
|
88 |
{
|
insilmaril@476
|
89 |
return frame->getFrameTypeName();
|
insilmaril@476
|
90 |
}
|
insilmaril@476
|
91 |
|
insilmaril@476
|
92 |
void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
|
insilmaril@442
|
93 |
{
|
insilmaril@442
|
94 |
frame->setFrameType(t);
|
insilmaril@476
|
95 |
if (t == FrameObj::NoFrame)
|
insilmaril@476
|
96 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@442
|
97 |
else
|
insilmaril@476
|
98 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@442
|
99 |
|
insilmaril@442
|
100 |
calcBBoxSize();
|
insilmaril@442
|
101 |
positionBBox();
|
insilmaril@442
|
102 |
requestReposition();
|
insilmaril@442
|
103 |
}
|
insilmaril@442
|
104 |
|
insilmaril@442
|
105 |
void OrnamentedObj::setFrameType(const QString &t)
|
insilmaril@442
|
106 |
{
|
insilmaril@442
|
107 |
frame->setFrameType(t);
|
insilmaril@476
|
108 |
if (frame->getFrameType() == FrameObj::NoFrame)
|
insilmaril@476
|
109 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@442
|
110 |
else
|
insilmaril@476
|
111 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@442
|
112 |
|
insilmaril@442
|
113 |
calcBBoxSize();
|
insilmaril@442
|
114 |
positionBBox();
|
insilmaril@442
|
115 |
requestReposition();
|
insilmaril@442
|
116 |
}
|
insilmaril@442
|
117 |
|
insilmaril@476
|
118 |
void OrnamentedObj::setFramePadding (const int &i)
|
insilmaril@476
|
119 |
{
|
insilmaril@476
|
120 |
frame->setPadding (i);
|
insilmaril@476
|
121 |
calcBBoxSize();
|
insilmaril@476
|
122 |
positionBBox();
|
insilmaril@476
|
123 |
requestReposition();
|
insilmaril@476
|
124 |
}
|
insilmaril@476
|
125 |
|
insilmaril@476
|
126 |
int OrnamentedObj::getFramePadding ()
|
insilmaril@476
|
127 |
{
|
insilmaril@476
|
128 |
return frame->getPadding();
|
insilmaril@476
|
129 |
}
|
insilmaril@476
|
130 |
|
insilmaril@476
|
131 |
void OrnamentedObj::setFrameBorderWidth (const int &i)
|
insilmaril@476
|
132 |
{
|
insilmaril@476
|
133 |
frame->setBorderWidth(i);
|
insilmaril@476
|
134 |
calcBBoxSize();
|
insilmaril@476
|
135 |
positionBBox();
|
insilmaril@476
|
136 |
requestReposition();
|
insilmaril@476
|
137 |
}
|
insilmaril@476
|
138 |
|
insilmaril@476
|
139 |
int OrnamentedObj::getFrameBorderWidth()
|
insilmaril@476
|
140 |
{
|
insilmaril@476
|
141 |
return frame->getBorderWidth();
|
insilmaril@476
|
142 |
}
|
insilmaril@476
|
143 |
|
insilmaril@442
|
144 |
void OrnamentedObj::setFramePenColor(QColor col)
|
insilmaril@442
|
145 |
{
|
insilmaril@442
|
146 |
frame->setPenColor (col);
|
insilmaril@442
|
147 |
}
|
insilmaril@442
|
148 |
|
insilmaril@442
|
149 |
QColor OrnamentedObj::getFramePenColor()
|
insilmaril@442
|
150 |
{
|
insilmaril@442
|
151 |
return frame->getPenColor ();
|
insilmaril@442
|
152 |
}
|
insilmaril@442
|
153 |
|
insilmaril@442
|
154 |
void OrnamentedObj::setFrameBrushColor(QColor col)
|
insilmaril@442
|
155 |
{
|
insilmaril@442
|
156 |
frame->setBrushColor (col);
|
insilmaril@442
|
157 |
}
|
insilmaril@442
|
158 |
|
insilmaril@442
|
159 |
QColor OrnamentedObj::getFrameBrushColor()
|
insilmaril@442
|
160 |
{
|
insilmaril@442
|
161 |
return frame->getBrushColor ();
|
insilmaril@442
|
162 |
}
|
insilmaril@0
|
163 |
|
insilmaril@177
|
164 |
void OrnamentedObj::positionContents()
|
insilmaril@0
|
165 |
{
|
insilmaril@476
|
166 |
double d=frame->getPadding()/2;
|
insilmaril@177
|
167 |
double x=absPos.x();
|
insilmaril@177
|
168 |
double y=absPos.y();
|
insilmaril@227
|
169 |
|
insilmaril@227
|
170 |
double ox,oy; // Offset due to padding
|
insilmaril@227
|
171 |
|
insilmaril@227
|
172 |
ox=leftPad + d;
|
insilmaril@227
|
173 |
oy=topPad + d;
|
insilmaril@227
|
174 |
|
insilmaril@766
|
175 |
systemFlags-> move (ox +x , oy + y );
|
insilmaril@0
|
176 |
|
insilmaril@0
|
177 |
// vertical align heading to bottom
|
insilmaril@227
|
178 |
heading->move (ox + x + systemFlags->getBBox().width(),
|
insilmaril@227
|
179 |
oy + y + ornamentsBBox.height() - heading->getHeight()
|
insilmaril@0
|
180 |
);
|
insilmaril@766
|
181 |
standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
|
insilmaril@227
|
182 |
|
insilmaril@408
|
183 |
ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
|
insilmaril@408
|
184 |
clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
|
insilmaril@177
|
185 |
}
|
insilmaril@0
|
186 |
|
insilmaril@177
|
187 |
void OrnamentedObj::move (double x, double y)
|
insilmaril@177
|
188 |
{
|
insilmaril@177
|
189 |
MapObj::move (x,y);
|
insilmaril@177
|
190 |
positionContents();
|
insilmaril@0
|
191 |
updateLink();
|
insilmaril@0
|
192 |
requestReposition();
|
insilmaril@0
|
193 |
}
|
insilmaril@0
|
194 |
|
insilmaril@408
|
195 |
void OrnamentedObj::move (QPointF p)
|
insilmaril@0
|
196 |
{
|
insilmaril@0
|
197 |
move (p.x(), p.y());
|
insilmaril@0
|
198 |
}
|
insilmaril@0
|
199 |
|
insilmaril@0
|
200 |
void OrnamentedObj::moveBy (double x, double y)
|
insilmaril@0
|
201 |
{
|
insilmaril@0
|
202 |
|
insilmaril@0
|
203 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
204 |
frame->moveBy (x,y);
|
insilmaril@0
|
205 |
systemFlags->moveBy (x,y);
|
insilmaril@0
|
206 |
standardFlags->moveBy (x,y);
|
insilmaril@0
|
207 |
heading->moveBy (x,y);
|
insilmaril@0
|
208 |
updateLink();
|
insilmaril@0
|
209 |
requestReposition();
|
insilmaril@0
|
210 |
}
|
insilmaril@0
|
211 |
|
insilmaril@408
|
212 |
void OrnamentedObj::moveBy (QPointF p)
|
insilmaril@0
|
213 |
{
|
insilmaril@0
|
214 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
215 |
}
|
insilmaril@0
|
216 |
|
insilmaril@0
|
217 |
void OrnamentedObj::move2RelPos(double x, double y)
|
insilmaril@0
|
218 |
{
|
insilmaril@694
|
219 |
setRelPos (QPointF(x,y));
|
insilmaril@388
|
220 |
if (parObj)
|
insilmaril@388
|
221 |
{
|
insilmaril@408
|
222 |
QPointF p=parObj->getChildPos();
|
insilmaril@388
|
223 |
move (p.x()+x, p.y() +y);
|
insilmaril@388
|
224 |
}
|
insilmaril@0
|
225 |
}
|
insilmaril@0
|
226 |
|
insilmaril@408
|
227 |
void OrnamentedObj::move2RelPos(QPointF p)
|
insilmaril@0
|
228 |
{
|
insilmaril@218
|
229 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
230 |
}
|
insilmaril@0
|
231 |
|
insilmaril@767
|
232 |
void OrnamentedObj::activateStandardFlag(Flag *flag)
|
insilmaril@243
|
233 |
{
|
insilmaril@767
|
234 |
standardFlags->activate(flag);
|
insilmaril@0
|
235 |
calcBBoxSize();
|
insilmaril@0
|
236 |
positionBBox();
|
insilmaril@0
|
237 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
238 |
forceReposition();
|
insilmaril@0
|
239 |
}
|
insilmaril@0
|
240 |
|
insilmaril@766
|
241 |
void OrnamentedObj::deactivateStandardFlag(const QString &name)
|
insilmaril@366
|
242 |
{
|
insilmaril@766
|
243 |
standardFlags->deactivate(name);
|
insilmaril@366
|
244 |
calcBBoxSize();
|
insilmaril@366
|
245 |
positionBBox();
|
insilmaril@366
|
246 |
move (absPos.x(), absPos.y() );
|
insilmaril@366
|
247 |
forceReposition();
|
insilmaril@366
|
248 |
}
|
insilmaril@366
|
249 |
|
insilmaril@296
|
250 |
|
insilmaril@408
|
251 |
QString OrnamentedObj::getSystemFlagName(const QPointF &p)
|
insilmaril@0
|
252 |
{
|
insilmaril@0
|
253 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
254 |
}
|
insilmaril@0
|
255 |
|
insilmaril@746
|
256 |
/* FIXME-3 should move to VymView ?! void OrnamentedObj::getNoteFromTextEditor ()
|
insilmaril@417
|
257 |
{
|
insilmaril@417
|
258 |
note.setFilenameHint (textEditor->getFilename());
|
insilmaril@417
|
259 |
note.setFontHint (textEditor->getFontHint() );
|
insilmaril@417
|
260 |
setNote( textEditor->getText() );
|
insilmaril@417
|
261 |
}
|
insilmaril@746
|
262 |
*/
|
insilmaril@417
|
263 |
|
insilmaril@767
|
264 |
QString OrnamentedObj::getOrnXMLAttr() //FIXME-2
|
insilmaril@243
|
265 |
{
|
insilmaril@243
|
266 |
QString posAttr;
|
insilmaril@252
|
267 |
|
insilmaril@755
|
268 |
if (treeItem->depth()==0)
|
insilmaril@388
|
269 |
posAttr=
|
insilmaril@408
|
270 |
attribut("absPosX",QString().setNum(absPos.x())) +
|
insilmaril@408
|
271 |
attribut("absPosY",QString().setNum(absPos.y()));
|
insilmaril@243
|
272 |
else
|
insilmaril@252
|
273 |
{
|
insilmaril@755
|
274 |
if (treeItem->depth()==1 || typeid (*this)==typeid (FloatImageObj))
|
insilmaril@635
|
275 |
{
|
insilmaril@635
|
276 |
if (relPos.x()==0 && relPos.y()==0)
|
insilmaril@635
|
277 |
setRelPos();
|
insilmaril@388
|
278 |
posAttr=
|
insilmaril@408
|
279 |
attribut("relPosX",QString().setNum(relPos.x())) +
|
insilmaril@408
|
280 |
attribut("relPosY",QString().setNum(relPos.y()));
|
insilmaril@635
|
281 |
} else
|
insilmaril@252
|
282 |
posAttr="";
|
insilmaril@252
|
283 |
}
|
insilmaril@243
|
284 |
|
insilmaril@753
|
285 |
/* FIXME-2 QString hideExpAttr;
|
insilmaril@243
|
286 |
if (hideExport)
|
insilmaril@243
|
287 |
hideExpAttr= attribut("hideInExport","true");
|
insilmaril@243
|
288 |
else
|
insilmaril@243
|
289 |
hideExpAttr="";
|
insilmaril@753
|
290 |
*/
|
insilmaril@767
|
291 |
return posAttr +getLinkAttr() ;//+hideExpAttr;
|
insilmaril@243
|
292 |
}
|
insilmaril@243
|
293 |
|