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@773
|
65 |
VymModel *model=treeItem->getModel();
|
insilmaril@773
|
66 |
if (!model) return;
|
insilmaril@721
|
67 |
if (model->getMapLinkColorHint()==HeadingColor)
|
insilmaril@0
|
68 |
LinkableMapObj::setLinkColor (heading->getColor());
|
insilmaril@0
|
69 |
else
|
insilmaril@721
|
70 |
LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
|
insilmaril@0
|
71 |
}
|
insilmaril@0
|
72 |
|
insilmaril@243
|
73 |
void OrnamentedObj::setColor (QColor col)
|
insilmaril@243
|
74 |
{
|
insilmaril@243
|
75 |
heading->setColor(col);
|
insilmaril@243
|
76 |
setLinkColor();
|
insilmaril@243
|
77 |
}
|
insilmaril@243
|
78 |
|
insilmaril@0
|
79 |
QColor OrnamentedObj::getColor ()
|
insilmaril@0
|
80 |
{
|
insilmaril@0
|
81 |
return heading->getColor();
|
insilmaril@0
|
82 |
}
|
insilmaril@0
|
83 |
|
insilmaril@476
|
84 |
FrameObj::FrameType OrnamentedObj::getFrameType()
|
insilmaril@442
|
85 |
{
|
insilmaril@442
|
86 |
return frame->getFrameType();
|
insilmaril@442
|
87 |
}
|
insilmaril@442
|
88 |
|
insilmaril@476
|
89 |
QString OrnamentedObj::getFrameTypeName()
|
insilmaril@476
|
90 |
{
|
insilmaril@476
|
91 |
return frame->getFrameTypeName();
|
insilmaril@476
|
92 |
}
|
insilmaril@476
|
93 |
|
insilmaril@476
|
94 |
void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
|
insilmaril@442
|
95 |
{
|
insilmaril@442
|
96 |
frame->setFrameType(t);
|
insilmaril@476
|
97 |
if (t == FrameObj::NoFrame)
|
insilmaril@476
|
98 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@442
|
99 |
else
|
insilmaril@476
|
100 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@442
|
101 |
|
insilmaril@442
|
102 |
calcBBoxSize();
|
insilmaril@442
|
103 |
positionBBox();
|
insilmaril@442
|
104 |
requestReposition();
|
insilmaril@442
|
105 |
}
|
insilmaril@442
|
106 |
|
insilmaril@442
|
107 |
void OrnamentedObj::setFrameType(const QString &t)
|
insilmaril@442
|
108 |
{
|
insilmaril@442
|
109 |
frame->setFrameType(t);
|
insilmaril@476
|
110 |
if (frame->getFrameType() == FrameObj::NoFrame)
|
insilmaril@476
|
111 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@442
|
112 |
else
|
insilmaril@476
|
113 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@442
|
114 |
|
insilmaril@442
|
115 |
calcBBoxSize();
|
insilmaril@442
|
116 |
positionBBox();
|
insilmaril@442
|
117 |
requestReposition();
|
insilmaril@442
|
118 |
}
|
insilmaril@442
|
119 |
|
insilmaril@476
|
120 |
void OrnamentedObj::setFramePadding (const int &i)
|
insilmaril@476
|
121 |
{
|
insilmaril@476
|
122 |
frame->setPadding (i);
|
insilmaril@476
|
123 |
calcBBoxSize();
|
insilmaril@476
|
124 |
positionBBox();
|
insilmaril@476
|
125 |
requestReposition();
|
insilmaril@476
|
126 |
}
|
insilmaril@476
|
127 |
|
insilmaril@476
|
128 |
int OrnamentedObj::getFramePadding ()
|
insilmaril@476
|
129 |
{
|
insilmaril@476
|
130 |
return frame->getPadding();
|
insilmaril@476
|
131 |
}
|
insilmaril@476
|
132 |
|
insilmaril@476
|
133 |
void OrnamentedObj::setFrameBorderWidth (const int &i)
|
insilmaril@476
|
134 |
{
|
insilmaril@476
|
135 |
frame->setBorderWidth(i);
|
insilmaril@476
|
136 |
calcBBoxSize();
|
insilmaril@476
|
137 |
positionBBox();
|
insilmaril@476
|
138 |
requestReposition();
|
insilmaril@476
|
139 |
}
|
insilmaril@476
|
140 |
|
insilmaril@476
|
141 |
int OrnamentedObj::getFrameBorderWidth()
|
insilmaril@476
|
142 |
{
|
insilmaril@476
|
143 |
return frame->getBorderWidth();
|
insilmaril@476
|
144 |
}
|
insilmaril@476
|
145 |
|
insilmaril@442
|
146 |
void OrnamentedObj::setFramePenColor(QColor col)
|
insilmaril@442
|
147 |
{
|
insilmaril@442
|
148 |
frame->setPenColor (col);
|
insilmaril@442
|
149 |
}
|
insilmaril@442
|
150 |
|
insilmaril@442
|
151 |
QColor OrnamentedObj::getFramePenColor()
|
insilmaril@442
|
152 |
{
|
insilmaril@442
|
153 |
return frame->getPenColor ();
|
insilmaril@442
|
154 |
}
|
insilmaril@442
|
155 |
|
insilmaril@442
|
156 |
void OrnamentedObj::setFrameBrushColor(QColor col)
|
insilmaril@442
|
157 |
{
|
insilmaril@442
|
158 |
frame->setBrushColor (col);
|
insilmaril@442
|
159 |
}
|
insilmaril@442
|
160 |
|
insilmaril@442
|
161 |
QColor OrnamentedObj::getFrameBrushColor()
|
insilmaril@442
|
162 |
{
|
insilmaril@442
|
163 |
return frame->getBrushColor ();
|
insilmaril@442
|
164 |
}
|
insilmaril@0
|
165 |
|
insilmaril@177
|
166 |
void OrnamentedObj::positionContents()
|
insilmaril@0
|
167 |
{
|
insilmaril@476
|
168 |
double d=frame->getPadding()/2;
|
insilmaril@177
|
169 |
double x=absPos.x();
|
insilmaril@177
|
170 |
double y=absPos.y();
|
insilmaril@227
|
171 |
|
insilmaril@227
|
172 |
double ox,oy; // Offset due to padding
|
insilmaril@227
|
173 |
|
insilmaril@227
|
174 |
ox=leftPad + d;
|
insilmaril@227
|
175 |
oy=topPad + d;
|
insilmaril@227
|
176 |
|
insilmaril@766
|
177 |
systemFlags-> move (ox +x , oy + y );
|
insilmaril@0
|
178 |
|
insilmaril@0
|
179 |
// vertical align heading to bottom
|
insilmaril@227
|
180 |
heading->move (ox + x + systemFlags->getBBox().width(),
|
insilmaril@227
|
181 |
oy + y + ornamentsBBox.height() - heading->getHeight()
|
insilmaril@0
|
182 |
);
|
insilmaril@766
|
183 |
standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
|
insilmaril@227
|
184 |
|
insilmaril@408
|
185 |
ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
|
insilmaril@408
|
186 |
clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
|
insilmaril@177
|
187 |
}
|
insilmaril@0
|
188 |
|
insilmaril@177
|
189 |
void OrnamentedObj::move (double x, double y)
|
insilmaril@177
|
190 |
{
|
insilmaril@177
|
191 |
MapObj::move (x,y);
|
insilmaril@177
|
192 |
positionContents();
|
insilmaril@0
|
193 |
updateLink();
|
insilmaril@0
|
194 |
requestReposition();
|
insilmaril@0
|
195 |
}
|
insilmaril@0
|
196 |
|
insilmaril@408
|
197 |
void OrnamentedObj::move (QPointF p)
|
insilmaril@0
|
198 |
{
|
insilmaril@0
|
199 |
move (p.x(), p.y());
|
insilmaril@0
|
200 |
}
|
insilmaril@0
|
201 |
|
insilmaril@0
|
202 |
void OrnamentedObj::moveBy (double x, double y)
|
insilmaril@0
|
203 |
{
|
insilmaril@0
|
204 |
|
insilmaril@0
|
205 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
206 |
frame->moveBy (x,y);
|
insilmaril@0
|
207 |
systemFlags->moveBy (x,y);
|
insilmaril@0
|
208 |
standardFlags->moveBy (x,y);
|
insilmaril@0
|
209 |
heading->moveBy (x,y);
|
insilmaril@0
|
210 |
updateLink();
|
insilmaril@0
|
211 |
requestReposition();
|
insilmaril@0
|
212 |
}
|
insilmaril@0
|
213 |
|
insilmaril@408
|
214 |
void OrnamentedObj::moveBy (QPointF p)
|
insilmaril@0
|
215 |
{
|
insilmaril@0
|
216 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
217 |
}
|
insilmaril@0
|
218 |
|
insilmaril@0
|
219 |
void OrnamentedObj::move2RelPos(double x, double y)
|
insilmaril@0
|
220 |
{
|
insilmaril@694
|
221 |
setRelPos (QPointF(x,y));
|
insilmaril@388
|
222 |
if (parObj)
|
insilmaril@388
|
223 |
{
|
insilmaril@408
|
224 |
QPointF p=parObj->getChildPos();
|
insilmaril@388
|
225 |
move (p.x()+x, p.y() +y);
|
insilmaril@388
|
226 |
}
|
insilmaril@0
|
227 |
}
|
insilmaril@0
|
228 |
|
insilmaril@408
|
229 |
void OrnamentedObj::move2RelPos(QPointF p)
|
insilmaril@0
|
230 |
{
|
insilmaril@218
|
231 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
232 |
}
|
insilmaril@0
|
233 |
|
insilmaril@767
|
234 |
void OrnamentedObj::activateStandardFlag(Flag *flag)
|
insilmaril@243
|
235 |
{
|
insilmaril@767
|
236 |
standardFlags->activate(flag);
|
insilmaril@0
|
237 |
calcBBoxSize();
|
insilmaril@0
|
238 |
positionBBox();
|
insilmaril@0
|
239 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
240 |
forceReposition();
|
insilmaril@0
|
241 |
}
|
insilmaril@0
|
242 |
|
insilmaril@766
|
243 |
void OrnamentedObj::deactivateStandardFlag(const QString &name)
|
insilmaril@366
|
244 |
{
|
insilmaril@766
|
245 |
standardFlags->deactivate(name);
|
insilmaril@366
|
246 |
calcBBoxSize();
|
insilmaril@366
|
247 |
positionBBox();
|
insilmaril@366
|
248 |
move (absPos.x(), absPos.y() );
|
insilmaril@366
|
249 |
forceReposition();
|
insilmaril@366
|
250 |
}
|
insilmaril@366
|
251 |
|
insilmaril@296
|
252 |
|
insilmaril@408
|
253 |
QString OrnamentedObj::getSystemFlagName(const QPointF &p)
|
insilmaril@0
|
254 |
{
|
insilmaril@0
|
255 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
256 |
}
|
insilmaril@0
|
257 |
|
insilmaril@746
|
258 |
/* FIXME-3 should move to VymView ?! void OrnamentedObj::getNoteFromTextEditor ()
|
insilmaril@417
|
259 |
{
|
insilmaril@417
|
260 |
note.setFilenameHint (textEditor->getFilename());
|
insilmaril@417
|
261 |
note.setFontHint (textEditor->getFontHint() );
|
insilmaril@417
|
262 |
setNote( textEditor->getText() );
|
insilmaril@417
|
263 |
}
|
insilmaril@746
|
264 |
*/
|
insilmaril@417
|
265 |
|
insilmaril@773
|
266 |
QString OrnamentedObj::getOrnXMLAttr() //FIXME-2 still needed?
|
insilmaril@243
|
267 |
{
|
insilmaril@243
|
268 |
QString posAttr;
|
insilmaril@252
|
269 |
|
insilmaril@755
|
270 |
if (treeItem->depth()==0)
|
insilmaril@388
|
271 |
posAttr=
|
insilmaril@408
|
272 |
attribut("absPosX",QString().setNum(absPos.x())) +
|
insilmaril@408
|
273 |
attribut("absPosY",QString().setNum(absPos.y()));
|
insilmaril@243
|
274 |
else
|
insilmaril@252
|
275 |
{
|
insilmaril@773
|
276 |
/* FIXME-2
|
insilmaril@773
|
277 |
if (treeItem->depth()==1 || typid (*this)==typid (FloatImageObj))
|
insilmaril@635
|
278 |
{
|
insilmaril@635
|
279 |
if (relPos.x()==0 && relPos.y()==0)
|
insilmaril@635
|
280 |
setRelPos();
|
insilmaril@388
|
281 |
posAttr=
|
insilmaril@408
|
282 |
attribut("relPosX",QString().setNum(relPos.x())) +
|
insilmaril@408
|
283 |
attribut("relPosY",QString().setNum(relPos.y()));
|
insilmaril@635
|
284 |
} else
|
insilmaril@252
|
285 |
posAttr="";
|
insilmaril@773
|
286 |
*/
|
insilmaril@252
|
287 |
}
|
insilmaril@243
|
288 |
|
insilmaril@753
|
289 |
/* FIXME-2 QString hideExpAttr;
|
insilmaril@243
|
290 |
if (hideExport)
|
insilmaril@243
|
291 |
hideExpAttr= attribut("hideInExport","true");
|
insilmaril@243
|
292 |
else
|
insilmaril@243
|
293 |
hideExpAttr="";
|
insilmaril@753
|
294 |
*/
|
insilmaril@767
|
295 |
return posAttr +getLinkAttr() ;//+hideExpAttr;
|
insilmaril@243
|
296 |
}
|
insilmaril@243
|
297 |
|