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@777
|
74 |
FrameObj* OrnamentedObj::getFrame()
|
insilmaril@777
|
75 |
{
|
insilmaril@777
|
76 |
return frame;
|
insilmaril@777
|
77 |
}
|
insilmaril@777
|
78 |
|
insilmaril@476
|
79 |
FrameObj::FrameType OrnamentedObj::getFrameType()
|
insilmaril@442
|
80 |
{
|
insilmaril@442
|
81 |
return frame->getFrameType();
|
insilmaril@442
|
82 |
}
|
insilmaril@442
|
83 |
|
insilmaril@476
|
84 |
QString OrnamentedObj::getFrameTypeName()
|
insilmaril@476
|
85 |
{
|
insilmaril@476
|
86 |
return frame->getFrameTypeName();
|
insilmaril@476
|
87 |
}
|
insilmaril@476
|
88 |
|
insilmaril@476
|
89 |
void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
|
insilmaril@442
|
90 |
{
|
insilmaril@442
|
91 |
frame->setFrameType(t);
|
insilmaril@476
|
92 |
if (t == FrameObj::NoFrame)
|
insilmaril@798
|
93 |
{
|
insilmaril@476
|
94 |
linkpos=LinkableMapObj::Bottom;
|
insilmaril@798
|
95 |
useBottomline=true;
|
insilmaril@798
|
96 |
} else
|
insilmaril@798
|
97 |
{
|
insilmaril@476
|
98 |
linkpos=LinkableMapObj::Middle;
|
insilmaril@798
|
99 |
useBottomline=false;
|
insilmaril@798
|
100 |
}
|
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@785
|
166 |
//#include <iostream>
|
insilmaril@785
|
167 |
//using namespace std;
|
insilmaril@785
|
168 |
void OrnamentedObj::positionContents() //FIXME-4 called multiple times for each object after moving an image with mouse
|
insilmaril@0
|
169 |
{
|
insilmaril@785
|
170 |
//cout << "OO::positionContents topPad="<<topPad<<" botPad="<<botPad<<" "<<treeItem->getHeadingStd()<<endl;
|
insilmaril@476
|
171 |
double d=frame->getPadding()/2;
|
insilmaril@177
|
172 |
double x=absPos.x();
|
insilmaril@177
|
173 |
double y=absPos.y();
|
insilmaril@227
|
174 |
|
insilmaril@227
|
175 |
double ox,oy; // Offset due to padding
|
insilmaril@227
|
176 |
|
insilmaril@227
|
177 |
ox=leftPad + d;
|
insilmaril@227
|
178 |
oy=topPad + d;
|
insilmaril@227
|
179 |
|
insilmaril@766
|
180 |
systemFlags-> move (ox +x , oy + y );
|
insilmaril@0
|
181 |
|
insilmaril@0
|
182 |
// vertical align heading to bottom
|
insilmaril@227
|
183 |
heading->move (ox + x + systemFlags->getBBox().width(),
|
insilmaril@227
|
184 |
oy + y + ornamentsBBox.height() - heading->getHeight()
|
insilmaril@0
|
185 |
);
|
insilmaril@766
|
186 |
standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
|
insilmaril@227
|
187 |
|
insilmaril@785
|
188 |
ornamentsBBox.moveTopLeft ( QPointF (ox+x,oy+y));
|
insilmaril@785
|
189 |
clickBox.moveTopLeft (QPointF (ox + x, oy + y));
|
insilmaril@177
|
190 |
}
|
insilmaril@0
|
191 |
|
insilmaril@177
|
192 |
void OrnamentedObj::move (double x, double y)
|
insilmaril@177
|
193 |
{
|
insilmaril@177
|
194 |
MapObj::move (x,y);
|
insilmaril@177
|
195 |
positionContents();
|
insilmaril@779
|
196 |
updateLinkGeometry();
|
insilmaril@0
|
197 |
requestReposition();
|
insilmaril@0
|
198 |
}
|
insilmaril@0
|
199 |
|
insilmaril@408
|
200 |
void OrnamentedObj::move (QPointF p)
|
insilmaril@0
|
201 |
{
|
insilmaril@0
|
202 |
move (p.x(), p.y());
|
insilmaril@0
|
203 |
}
|
insilmaril@0
|
204 |
|
insilmaril@0
|
205 |
void OrnamentedObj::moveBy (double x, double y)
|
insilmaril@0
|
206 |
{
|
insilmaril@0
|
207 |
|
insilmaril@0
|
208 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
209 |
frame->moveBy (x,y);
|
insilmaril@0
|
210 |
systemFlags->moveBy (x,y);
|
insilmaril@0
|
211 |
standardFlags->moveBy (x,y);
|
insilmaril@0
|
212 |
heading->moveBy (x,y);
|
insilmaril@779
|
213 |
updateLinkGeometry();
|
insilmaril@0
|
214 |
requestReposition();
|
insilmaril@0
|
215 |
}
|
insilmaril@0
|
216 |
|
insilmaril@408
|
217 |
void OrnamentedObj::moveBy (QPointF p)
|
insilmaril@0
|
218 |
{
|
insilmaril@0
|
219 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
220 |
}
|
insilmaril@0
|
221 |
|
insilmaril@0
|
222 |
void OrnamentedObj::move2RelPos(double x, double y)
|
insilmaril@0
|
223 |
{
|
insilmaril@694
|
224 |
setRelPos (QPointF(x,y));
|
insilmaril@388
|
225 |
if (parObj)
|
insilmaril@388
|
226 |
{
|
insilmaril@408
|
227 |
QPointF p=parObj->getChildPos();
|
insilmaril@388
|
228 |
move (p.x()+x, p.y() +y);
|
insilmaril@388
|
229 |
}
|
insilmaril@0
|
230 |
}
|
insilmaril@0
|
231 |
|
insilmaril@408
|
232 |
void OrnamentedObj::move2RelPos(QPointF p)
|
insilmaril@0
|
233 |
{
|
insilmaril@218
|
234 |
move2RelPos (p.x(),p.y());
|
insilmaril@0
|
235 |
}
|
insilmaril@0
|
236 |
|
insilmaril@767
|
237 |
void OrnamentedObj::activateStandardFlag(Flag *flag)
|
insilmaril@243
|
238 |
{
|
insilmaril@767
|
239 |
standardFlags->activate(flag);
|
insilmaril@0
|
240 |
calcBBoxSize();
|
insilmaril@0
|
241 |
positionBBox();
|
insilmaril@0
|
242 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
243 |
forceReposition();
|
insilmaril@0
|
244 |
}
|
insilmaril@0
|
245 |
|
insilmaril@766
|
246 |
void OrnamentedObj::deactivateStandardFlag(const QString &name)
|
insilmaril@366
|
247 |
{
|
insilmaril@766
|
248 |
standardFlags->deactivate(name);
|
insilmaril@366
|
249 |
calcBBoxSize();
|
insilmaril@366
|
250 |
positionBBox();
|
insilmaril@366
|
251 |
move (absPos.x(), absPos.y() );
|
insilmaril@366
|
252 |
forceReposition();
|
insilmaril@366
|
253 |
}
|
insilmaril@366
|
254 |
|
insilmaril@296
|
255 |
|
insilmaril@776
|
256 |
QString OrnamentedObj::getSystemFlagName(const QPointF &p) //FIXME-3
|
insilmaril@0
|
257 |
{
|
insilmaril@0
|
258 |
return systemFlags->getFlagName(p);
|
insilmaril@0
|
259 |
}
|
insilmaril@0
|
260 |
|