insilmaril@0
|
1 |
#include "ornamentedobj.h"
|
insilmaril@0
|
2 |
#include "linkablemapobj.h"
|
insilmaril@776
|
3 |
#include "vymmodel.h"
|
insilmaril@0
|
4 |
|
insilmaril@0
|
5 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
6 |
// OrnamentedObj
|
insilmaril@0
|
7 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
8 |
|
insilmaril@0
|
9 |
|
insilmaril@790
|
10 |
OrnamentedObj::OrnamentedObj(QGraphicsScene* s,TreeItem *ti) :LinkableMapObj(s,ti)
|
insilmaril@0
|
11 |
{
|
insilmaril@408
|
12 |
// cout << "Const OrnamentedObj (s)\n";
|
insilmaril@0
|
13 |
init ();
|
insilmaril@0
|
14 |
}
|
insilmaril@0
|
15 |
|
insilmaril@408
|
16 |
OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
|
insilmaril@0
|
17 |
{
|
insilmaril@0
|
18 |
copy (lmo);
|
insilmaril@0
|
19 |
}
|
insilmaril@0
|
20 |
|
insilmaril@0
|
21 |
OrnamentedObj::~OrnamentedObj()
|
insilmaril@0
|
22 |
{
|
insilmaril@442
|
23 |
delete heading;
|
insilmaril@442
|
24 |
delete systemFlags;
|
insilmaril@442
|
25 |
delete standardFlags;
|
insilmaril@442
|
26 |
delete frame;
|
insilmaril@0
|
27 |
}
|
insilmaril@0
|
28 |
|
insilmaril@0
|
29 |
|
insilmaril@0
|
30 |
void OrnamentedObj::init ()
|
insilmaril@0
|
31 |
{
|
insilmaril@408
|
32 |
heading = new HeadingObj(scene);
|
insilmaril@0
|
33 |
heading->move (absPos.x(), absPos.y());
|
insilmaril@0
|
34 |
|
insilmaril@408
|
35 |
systemFlags=new FlagRowObj(scene);
|
insilmaril@408
|
36 |
standardFlags=new FlagRowObj(scene);
|
insilmaril@628
|
37 |
|
insilmaril@442
|
38 |
frame = new FrameObj (scene);
|
insilmaril@0
|
39 |
}
|
insilmaril@0
|
40 |
|
insilmaril@0
|
41 |
void OrnamentedObj::copy (OrnamentedObj* other)
|
insilmaril@0
|
42 |
{
|
insilmaril@0
|
43 |
LinkableMapObj::copy(other);
|
insilmaril@0
|
44 |
heading->copy(other->heading);
|
insilmaril@243
|
45 |
setColor (other->heading->getColor());
|
insilmaril@0
|
46 |
|
insilmaril@0
|
47 |
systemFlags->copy (other->systemFlags);
|
insilmaril@0
|
48 |
standardFlags->copy (other->standardFlags);
|
insilmaril@0
|
49 |
|
insilmaril@227
|
50 |
ornamentsBBox=other->ornamentsBBox;
|
insilmaril@0
|
51 |
}
|
insilmaril@0
|
52 |
|
insilmaril@0
|
53 |
void OrnamentedObj::setLinkColor()
|
insilmaril@0
|
54 |
{
|
insilmaril@773
|
55 |
VymModel *model=treeItem->getModel();
|
insilmaril@773
|
56 |
if (!model) return;
|
insilmaril@721
|
57 |
if (model->getMapLinkColorHint()==HeadingColor)
|
insilmaril@0
|
58 |
LinkableMapObj::setLinkColor (heading->getColor());
|
insilmaril@0
|
59 |
else
|
insilmaril@721
|
60 |
LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
|
insilmaril@0
|
61 |
}
|
insilmaril@0
|
62 |
|
insilmaril@243
|
63 |
void OrnamentedObj::setColor (QColor col)
|
insilmaril@243
|
64 |
{
|
insilmaril@243
|
65 |
heading->setColor(col);
|
insilmaril@243
|
66 |
setLinkColor();
|
insilmaril@243
|
67 |
}
|
insilmaril@243
|
68 |
|
insilmaril@0
|
69 |
QColor OrnamentedObj::getColor ()
|
insilmaril@0
|
70 |
{
|
insilmaril@0
|
71 |
return heading->getColor();
|
insilmaril@0
|
72 |
}
|
insilmaril@0
|
73 |
|
insilmaril@819
|
74 |
QRectF OrnamentedObj::getBBoxHeading()
|
insilmaril@819
|
75 |
{
|
insilmaril@819
|
76 |
return heading->getBBox();
|
insilmaril@819
|
77 |
}
|
insilmaril@819
|
78 |
|
insilmaril@777
|
79 |
FrameObj* OrnamentedObj::getFrame()
|
insilmaril@777
|
80 |
{
|
insilmaril@777
|
81 |
return frame;
|
insilmaril@777
|
82 |
}
|
insilmaril@777
|
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@798
|
98 |
{
|
insilmaril@476
|
99 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@798
|
100 |
useBottomline=true;
|
insilmaril@798
|
101 |
} else
|
insilmaril@798
|
102 |
{
|
insilmaril@476
|
103 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@798
|
104 |
useBottomline=false;
|
insilmaril@798
|
105 |
}
|
insilmaril@442
|
106 |
|
insilmaril@442
|
107 |
calcBBoxSize();
|
insilmaril@442
|
108 |
positionBBox();
|
insilmaril@442
|
109 |
requestReposition();
|
insilmaril@442
|
110 |
}
|
insilmaril@442
|
111 |
|
insilmaril@442
|
112 |
void OrnamentedObj::setFrameType(const QString &t)
|
insilmaril@442
|
113 |
{
|
insilmaril@442
|
114 |
frame->setFrameType(t);
|
insilmaril@476
|
115 |
if (frame->getFrameType() == FrameObj::NoFrame)
|
insilmaril@476
|
116 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@442
|
117 |
else
|
insilmaril@476
|
118 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@442
|
119 |
|
insilmaril@442
|
120 |
calcBBoxSize();
|
insilmaril@442
|
121 |
positionBBox();
|
insilmaril@442
|
122 |
requestReposition();
|
insilmaril@442
|
123 |
}
|
insilmaril@442
|
124 |
|
insilmaril@476
|
125 |
void OrnamentedObj::setFramePadding (const int &i)
|
insilmaril@476
|
126 |
{
|
insilmaril@476
|
127 |
frame->setPadding (i);
|
insilmaril@476
|
128 |
calcBBoxSize();
|
insilmaril@476
|
129 |
positionBBox();
|
insilmaril@476
|
130 |
requestReposition();
|
insilmaril@476
|
131 |
}
|
insilmaril@476
|
132 |
|
insilmaril@476
|
133 |
int OrnamentedObj::getFramePadding ()
|
insilmaril@476
|
134 |
{
|
insilmaril@476
|
135 |
return frame->getPadding();
|
insilmaril@476
|
136 |
}
|
insilmaril@476
|
137 |
|
insilmaril@476
|
138 |
void OrnamentedObj::setFrameBorderWidth (const int &i)
|
insilmaril@476
|
139 |
{
|
insilmaril@476
|
140 |
frame->setBorderWidth(i);
|
insilmaril@476
|
141 |
calcBBoxSize();
|
insilmaril@476
|
142 |
positionBBox();
|
insilmaril@476
|
143 |
requestReposition();
|
insilmaril@476
|
144 |
}
|
insilmaril@476
|
145 |
|
insilmaril@476
|
146 |
int OrnamentedObj::getFrameBorderWidth()
|
insilmaril@476
|
147 |
{
|
insilmaril@476
|
148 |
return frame->getBorderWidth();
|
insilmaril@476
|
149 |
}
|
insilmaril@476
|
150 |
|
insilmaril@442
|
151 |
void OrnamentedObj::setFramePenColor(QColor col)
|
insilmaril@442
|
152 |
{
|
insilmaril@442
|
153 |
frame->setPenColor (col);
|
insilmaril@442
|
154 |
}
|
insilmaril@442
|
155 |
|
insilmaril@442
|
156 |
QColor OrnamentedObj::getFramePenColor()
|
insilmaril@442
|
157 |
{
|
insilmaril@442
|
158 |
return frame->getPenColor ();
|
insilmaril@442
|
159 |
}
|
insilmaril@442
|
160 |
|
insilmaril@442
|
161 |
void OrnamentedObj::setFrameBrushColor(QColor col)
|
insilmaril@442
|
162 |
{
|
insilmaril@442
|
163 |
frame->setBrushColor (col);
|
insilmaril@442
|
164 |
}
|
insilmaril@442
|
165 |
|
insilmaril@442
|
166 |
QColor OrnamentedObj::getFrameBrushColor()
|
insilmaril@442
|
167 |
{
|
insilmaril@442
|
168 |
return frame->getBrushColor ();
|
insilmaril@442
|
169 |
}
|
insilmaril@0
|
170 |
|
insilmaril@785
|
171 |
//#include <iostream>
|
insilmaril@785
|
172 |
//using namespace std;
|
insilmaril@785
|
173 |
void OrnamentedObj::positionContents() //FIXME-4 called multiple times for each object after moving an image with mouse
|
insilmaril@0
|
174 |
{
|
insilmaril@785
|
175 |
//cout << "OO::positionContents topPad="<<topPad<<" botPad="<<botPad<<" "<<treeItem->getHeadingStd()<<endl;
|
insilmaril@476
|
176 |
double d=frame->getPadding()/2;
|
insilmaril@177
|
177 |
double x=absPos.x();
|
insilmaril@177
|
178 |
double y=absPos.y();
|
insilmaril@227
|
179 |
|
insilmaril@227
|
180 |
double ox,oy; // Offset due to padding
|
insilmaril@227
|
181 |
|
insilmaril@227
|
182 |
ox=leftPad + d;
|
insilmaril@227
|
183 |
oy=topPad + d;
|
insilmaril@227
|
184 |
|
insilmaril@766
|
185 |
systemFlags-> move (ox +x , oy + y );
|
insilmaril@0
|
186 |
|
insilmaril@0
|
187 |
// vertical align heading to bottom
|
insilmaril@227
|
188 |
heading->move (ox + x + systemFlags->getBBox().width(),
|
insilmaril@227
|
189 |
oy + y + ornamentsBBox.height() - heading->getHeight()
|
insilmaril@0
|
190 |
);
|
insilmaril@766
|
191 |
standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
|
insilmaril@227
|
192 |
|
insilmaril@785
|
193 |
ornamentsBBox.moveTopLeft ( QPointF (ox+x,oy+y));
|
insilmaril@785
|
194 |
clickBox.moveTopLeft (QPointF (ox + x, oy + y));
|
insilmaril@177
|
195 |
}
|
insilmaril@0
|
196 |
|
insilmaril@177
|
197 |
void OrnamentedObj::move (double x, double y)
|
insilmaril@177
|
198 |
{
|
insilmaril@177
|
199 |
MapObj::move (x,y);
|
insilmaril@177
|
200 |
positionContents();
|
insilmaril@779
|
201 |
updateLinkGeometry();
|
insilmaril@0
|
202 |
requestReposition();
|
insilmaril@0
|
203 |
}
|
insilmaril@0
|
204 |
|
insilmaril@408
|
205 |
void OrnamentedObj::move (QPointF p)
|
insilmaril@0
|
206 |
{
|
insilmaril@0
|
207 |
move (p.x(), p.y());
|
insilmaril@0
|
208 |
}
|
insilmaril@0
|
209 |
|
insilmaril@0
|
210 |
void OrnamentedObj::moveBy (double x, double y)
|
insilmaril@0
|
211 |
{
|
insilmaril@0
|
212 |
|
insilmaril@0
|
213 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
214 |
frame->moveBy (x,y);
|
insilmaril@0
|
215 |
systemFlags->moveBy (x,y);
|
insilmaril@0
|
216 |
standardFlags->moveBy (x,y);
|
insilmaril@0
|
217 |
heading->moveBy (x,y);
|
insilmaril@779
|
218 |
updateLinkGeometry();
|
insilmaril@0
|
219 |
requestReposition();
|
insilmaril@0
|
220 |
}
|
insilmaril@0
|
221 |
|
insilmaril@408
|
222 |
void OrnamentedObj::moveBy (QPointF p)
|
insilmaril@0
|
223 |
{
|
insilmaril@0
|
224 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
225 |
}
|
insilmaril@0
|
226 |
|
insilmaril@0
|
227 |
void OrnamentedObj::move2RelPos(double x, double y)
|
insilmaril@0
|
228 |
{
|
insilmaril@694
|
229 |
setRelPos (QPointF(x,y));
|
insilmaril@388
|
230 |
if (parObj)
|
insilmaril@388
|
231 |
{
|
insilmaril@408
|
232 |
QPointF p=parObj->getChildPos();
|
insilmaril@388
|
233 |
move (p.x()+x, p.y() +y);
|
insilmaril@388
|
234 |
}
|
insilmaril@0
|
235 |
}
|
insilmaril@0
|
236 |
|
insilmaril@408
|
237 |
void OrnamentedObj::move2RelPos(QPointF p)
|
insilmaril@0
|
238 |
{
|
insilmaril@218
|
239 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
240 |
}
|
insilmaril@0
|
241 |
|
insilmaril@767
|
242 |
void OrnamentedObj::activateStandardFlag(Flag *flag)
|
insilmaril@243
|
243 |
{
|
insilmaril@767
|
244 |
standardFlags->activate(flag);
|
insilmaril@0
|
245 |
calcBBoxSize();
|
insilmaril@0
|
246 |
positionBBox();
|
insilmaril@0
|
247 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
248 |
forceReposition();
|
insilmaril@0
|
249 |
}
|
insilmaril@0
|
250 |
|
insilmaril@766
|
251 |
void OrnamentedObj::deactivateStandardFlag(const QString &name)
|
insilmaril@366
|
252 |
{
|
insilmaril@766
|
253 |
standardFlags->deactivate(name);
|
insilmaril@366
|
254 |
calcBBoxSize();
|
insilmaril@366
|
255 |
positionBBox();
|
insilmaril@819
|
256 |
move (absPos.x(),absPos.y() );
|
insilmaril@366
|
257 |
forceReposition();
|
insilmaril@366
|
258 |
}
|
insilmaril@366
|
259 |
|
insilmaril@296
|
260 |
|
insilmaril@819
|
261 |
QString OrnamentedObj::getSystemFlagName(const QPointF &p)
|
insilmaril@0
|
262 |
{
|
insilmaril@0
|
263 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
264 |
}
|
insilmaril@0
|
265 |
|
insilmaril@819
|
266 |
QRectF OrnamentedObj::getBBoxFlag (const QString &s)
|
insilmaril@819
|
267 |
{
|
insilmaril@819
|
268 |
FlagObj *fo=systemFlags->findFlag (s);
|
insilmaril@819
|
269 |
if (fo) return fo->getBBox();
|
insilmaril@819
|
270 |
fo=standardFlags->findFlag (s);
|
insilmaril@819
|
271 |
if (fo) return fo->getBBox();
|
insilmaril@819
|
272 |
return QRectF();
|
insilmaril@819
|
273 |
}
|
insilmaril@819
|
274 |
|