1 #include "ornamentedobj.h"
2 #include "linkablemapobj.h"
5 /////////////////////////////////////////////////////////////////
7 /////////////////////////////////////////////////////////////////
10 OrnamentedObj::OrnamentedObj(QGraphicsScene* s,TreeItem *ti) :LinkableMapObj(s,ti)
12 // cout << "Const OrnamentedObj (s)\n";
16 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
21 OrnamentedObj::~OrnamentedObj()
30 void OrnamentedObj::init ()
32 heading = new HeadingObj(scene);
33 heading->move (absPos.x(), absPos.y());
35 systemFlags=new FlagRowObj(scene);
36 standardFlags=new FlagRowObj(scene);
38 frame = new FrameObj (scene);
41 void OrnamentedObj::copy (OrnamentedObj* other)
43 LinkableMapObj::copy(other);
44 heading->copy(other->heading);
45 setColor (other->heading->getColor());
47 systemFlags->copy (other->systemFlags);
48 standardFlags->copy (other->standardFlags);
50 ornamentsBBox=other->ornamentsBBox;
53 void OrnamentedObj::setLinkColor()
55 VymModel *model=treeItem->getModel();
57 if (model->getMapLinkColorHint()==HeadingColor)
58 LinkableMapObj::setLinkColor (heading->getColor());
60 LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
63 void OrnamentedObj::setColor (QColor col)
65 heading->setColor(col);
69 QColor OrnamentedObj::getColor ()
71 return heading->getColor();
74 QRectF OrnamentedObj::getBBoxHeading()
76 return heading->getBBox();
79 FrameObj* OrnamentedObj::getFrame()
84 FrameObj::FrameType OrnamentedObj::getFrameType()
86 return frame->getFrameType();
89 QString OrnamentedObj::getFrameTypeName()
91 return frame->getFrameTypeName();
94 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
96 frame->setFrameType(t);
97 if (t == FrameObj::NoFrame)
99 linkpos=LinkableMapObj::Bottom;
103 linkpos=LinkableMapObj::Middle;
112 void OrnamentedObj::setFrameType(const QString &t)
114 frame->setFrameType(t);
115 if (frame->getFrameType() == FrameObj::NoFrame)
116 linkpos=LinkableMapObj::Bottom;
118 linkpos=LinkableMapObj::Middle;
125 void OrnamentedObj::setFramePadding (const int &i)
127 frame->setPadding (i);
133 int OrnamentedObj::getFramePadding ()
135 return frame->getPadding();
138 void OrnamentedObj::setFrameBorderWidth (const int &i)
140 frame->setBorderWidth(i);
146 int OrnamentedObj::getFrameBorderWidth()
148 return frame->getBorderWidth();
151 void OrnamentedObj::setFramePenColor(QColor col)
153 frame->setPenColor (col);
156 QColor OrnamentedObj::getFramePenColor()
158 return frame->getPenColor ();
161 void OrnamentedObj::setFrameBrushColor(QColor col)
163 frame->setBrushColor (col);
166 QColor OrnamentedObj::getFrameBrushColor()
168 return frame->getBrushColor ();
171 //#include <iostream>
172 //using namespace std;
173 void OrnamentedObj::positionContents() //FIXME-4 called multiple times for each object after moving an image with mouse
175 //cout << "OO::positionContents topPad="<<topPad<<" botPad="<<botPad<<" "<<treeItem->getHeadingStd()<<endl;
176 double d=frame->getPadding()/2;
180 double ox,oy; // Offset due to padding
185 systemFlags-> move (ox +x , oy + y );
187 // vertical align heading to bottom
188 heading->move (ox + x + systemFlags->getBBox().width(),
189 oy + y + ornamentsBBox.height() - heading->getHeight()
191 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
193 ornamentsBBox.moveTopLeft ( QPointF (ox+x,oy+y));
194 clickBox.moveTopLeft (QPointF (ox + x, oy + y));
197 void OrnamentedObj::move (double x, double y)
201 updateLinkGeometry();
205 void OrnamentedObj::move (QPointF p)
210 void OrnamentedObj::moveBy (double x, double y)
213 MapObj::moveBy (x,y);
215 systemFlags->moveBy (x,y);
216 standardFlags->moveBy (x,y);
217 heading->moveBy (x,y);
218 updateLinkGeometry();
222 void OrnamentedObj::moveBy (QPointF p)
224 moveBy (p.x(), p.y());
227 void OrnamentedObj::move2RelPos(double x, double y)
229 setRelPos (QPointF(x,y));
232 QPointF p=parObj->getChildPos();
233 move (p.x()+x, p.y() +y);
237 void OrnamentedObj::move2RelPos(QPointF p)
239 move2RelPos (p.x(),p.y());
242 void OrnamentedObj::activateStandardFlag(Flag *flag)
244 standardFlags->activate(flag);
247 move (absPos.x(), absPos.y() );
251 void OrnamentedObj::deactivateStandardFlag(const QString &name)
253 standardFlags->deactivate(name);
256 move (absPos.x(),absPos.y() );
261 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
263 return systemFlags->getFlagName(p);
266 QRectF OrnamentedObj::getBBoxFlag (const QString &s)
268 FlagObj *fo=systemFlags->findFlag (s);
269 if (fo) return fo->getBBox();
270 fo=standardFlags->findFlag (s);
271 if (fo) return fo->getBBox();