3 #include "branchitem.h"
4 #include "ornamentedobj.h"
5 #include "linkablemapobj.h"
10 /////////////////////////////////////////////////////////////////
12 /////////////////////////////////////////////////////////////////
14 OrnamentedObj::OrnamentedObj(QGraphicsItem *parent,TreeItem *ti) :LinkableMapObj(parent,ti)
16 //qDebug()<< "Const OrnamentedObj (s,ti) ti="<<ti;
21 OrnamentedObj::~OrnamentedObj()
30 void OrnamentedObj::init ()
32 heading = new HeadingObj(this);
33 heading->setTreeItem (treeItem);
34 heading->move (absPos.x(), absPos.y());
36 systemFlags=new FlagRowObj(this);
37 standardFlags=new FlagRowObj(this);
39 frame = new FrameObj (this);
40 frame->setTreeItem (treeItem);
45 void OrnamentedObj::copy (OrnamentedObj* other)
47 LinkableMapObj::copy(other);
48 heading->copy(other->heading);
49 setColor (other->heading->getColor());
51 systemFlags->copy (other->systemFlags);
52 standardFlags->copy (other->standardFlags);
54 ornamentsBBox=other->ornamentsBBox;
57 void OrnamentedObj::setLinkColor()
59 VymModel *model=treeItem->getModel();
61 if (model->getMapLinkColorHint()==HeadingColor)
62 LinkableMapObj::setLinkColor (heading->getColor());
64 LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
67 void OrnamentedObj::setColor (QColor col)
69 heading->setColor(col);
73 QColor OrnamentedObj::getColor ()
75 return heading->getColor();
78 QRectF OrnamentedObj::getBBoxHeading()
80 return heading->getBBox();
83 void OrnamentedObj::setRotation (const qreal &a)
85 MapObj::setRotation (a);
86 heading->setRotation(a); // FIXME-4 duplicated code...
89 FrameObj* OrnamentedObj::getFrame()
94 FrameObj::FrameType OrnamentedObj::getFrameType()
96 return frame->getFrameType();
99 QString OrnamentedObj::getFrameTypeName()
101 return frame->getFrameTypeName();
104 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
106 frame->setFrameType(t);
107 if (t == FrameObj::NoFrame)
109 linkpos=LinkableMapObj::Bottom;
113 linkpos=LinkableMapObj::Middle;
116 updateVisibility(); // Update bottomline
122 void OrnamentedObj::setFrameType(const QString &s)
124 setFrameType(frame->getFrameType (s));
127 void OrnamentedObj::setFramePadding (const int &i)
129 frame->setPadding (i);
135 int OrnamentedObj::getFramePadding ()
137 return frame->getPadding();
140 void OrnamentedObj::setFrameBorderWidth (const int &i)
142 frame->setBorderWidth(i);
148 int OrnamentedObj::getFrameBorderWidth()
150 return frame->getBorderWidth();
153 void OrnamentedObj::setFramePenColor(QColor col)
155 frame->setPenColor (col);
158 QColor OrnamentedObj::getFramePenColor()
160 return frame->getPenColor ();
163 void OrnamentedObj::setFrameBrushColor(QColor col)
165 frame->setBrushColor (col);
168 QColor OrnamentedObj::getFrameBrushColor()
170 return frame->getBrushColor ();
173 void OrnamentedObj::setFrameIncludeChildren(bool b)
175 calcBBoxSizeWithChildren();
176 frame->setFrameIncludeChildren (b);
180 bool OrnamentedObj::getFrameIncludeChildren()
182 return frame->getFrameIncludeChildren ();
185 QRectF OrnamentedObj::getOrnamentsBBox()
187 return ornamentsBBox;
190 void OrnamentedObj::positionContents()
194 double dp=frame->getTotalPadding();
196 double ox=leftPad + dp;
197 double oy=topPad + dp;
199 // vertical align heading to bottom
200 heading->setZValue (dZ_TEXT);
201 heading->setTransformOriginPoint (
202 QPointF ( ox + systemFlags->getBBox().width(),
203 oy + ornamentsBBox.height() - heading->getHeight()
205 heading->move (ox + x + systemFlags->getBBox().width(),
206 oy + y + ornamentsBBox.height() - heading->getHeight()
209 systemFlags-> move (ox +x , oy + y );
210 systemFlags->setZValue (dZ_ICON);
211 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
212 standardFlags->setZValue (dZ_ICON);
214 ornamentsBBox.moveTopLeft ( QPointF (ox+x,oy+y));
215 clickPoly=QPolygonF (ornamentsBBox);
217 // Update bboxTotal coordinate (size set already)
218 if (orientation==LinkableMapObj::LeftOfCenter )
220 bbox.x()+(bbox.width() - bboxTotal.width()) ,
221 bbox.y()+bbox.height()/2 - bboxTotal.height()/2,
227 bbox.y()+bbox.height()/2 - bboxTotal.height()/2,
232 dp=frame->getXPadding();
234 frame->setZValue (dZ_FRAME_LOW);
236 treeItem->isBranchLikeType() &&
237 ((BranchItem*)treeItem)->getFrameIncludeChildren()
239 frame->setRect( QRectF(
242 bboxTotal.width()-dp,
243 bboxTotal.height()-dp));
245 frame->setRect( QRectF(
248 bbox.width() - 2 * dp,
249 bbox.height() - 2 * dp));
252 void OrnamentedObj::move (double x, double y)
258 void OrnamentedObj::move (QPointF p)
263 void OrnamentedObj::moveBy (double x, double y)
265 MapObj::moveBy (x,y);
267 systemFlags->moveBy (x,y);
268 standardFlags->moveBy (x,y);
269 heading->moveBy (x,y);
270 updateLinkGeometry();
274 void OrnamentedObj::moveBy (QPointF p)
276 moveBy (p.x(), p.y());
279 void OrnamentedObj::move2RelPos(double x, double y)
281 setRelPos (QPointF(x,y));
284 QPointF p=parObj->getChildRefPos();
285 move (p.x() + x, p.y() + y);
289 void OrnamentedObj::move2RelPos(QPointF p)
291 move2RelPos (p.x(), p.y());
294 void OrnamentedObj::activateStandardFlag(Flag *flag)
296 standardFlags->activate(flag);
299 move (absPos.x(), absPos.y() );
303 void OrnamentedObj::deactivateStandardFlag(const QString &name)
305 standardFlags->deactivate(name);
308 move (absPos.x(),absPos.y() );
313 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
315 return systemFlags->getFlagName(p);
318 QRectF OrnamentedObj::getBBoxFlag (const QString &s)
320 FlagObj *fo=systemFlags->findFlag (s);
321 if (fo) return fo->getBBox();
322 fo=standardFlags->findFlag (s);
323 if (fo) return fo->getBBox();