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 FrameObj* OrnamentedObj::getFrame()
79 FrameObj::FrameType OrnamentedObj::getFrameType()
81 return frame->getFrameType();
84 QString OrnamentedObj::getFrameTypeName()
86 return frame->getFrameTypeName();
89 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
91 frame->setFrameType(t);
92 if (t == FrameObj::NoFrame)
93 linkpos=LinkableMapObj::Bottom;
95 linkpos=LinkableMapObj::Middle;
102 void OrnamentedObj::setFrameType(const QString &t)
104 frame->setFrameType(t);
105 if (frame->getFrameType() == FrameObj::NoFrame)
106 linkpos=LinkableMapObj::Bottom;
108 linkpos=LinkableMapObj::Middle;
115 void OrnamentedObj::setFramePadding (const int &i)
117 frame->setPadding (i);
123 int OrnamentedObj::getFramePadding ()
125 return frame->getPadding();
128 void OrnamentedObj::setFrameBorderWidth (const int &i)
130 frame->setBorderWidth(i);
136 int OrnamentedObj::getFrameBorderWidth()
138 return frame->getBorderWidth();
141 void OrnamentedObj::setFramePenColor(QColor col)
143 frame->setPenColor (col);
146 QColor OrnamentedObj::getFramePenColor()
148 return frame->getPenColor ();
151 void OrnamentedObj::setFrameBrushColor(QColor col)
153 frame->setBrushColor (col);
156 QColor OrnamentedObj::getFrameBrushColor()
158 return frame->getBrushColor ();
161 //#include <iostream>
162 //using namespace std;
163 void OrnamentedObj::positionContents() //FIXME-4 called multiple times for each object after moving an image with mouse
165 //cout << "OO::positionContents topPad="<<topPad<<" botPad="<<botPad<<" "<<treeItem->getHeadingStd()<<endl;
166 double d=frame->getPadding()/2;
170 double ox,oy; // Offset due to padding
175 systemFlags-> move (ox +x , oy + y );
177 // vertical align heading to bottom
178 heading->move (ox + x + systemFlags->getBBox().width(),
179 oy + y + ornamentsBBox.height() - heading->getHeight()
181 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
183 ornamentsBBox.moveTopLeft ( QPointF (ox+x,oy+y));
184 clickBox.moveTopLeft (QPointF (ox + x, oy + y));
187 void OrnamentedObj::move (double x, double y)
191 updateLinkGeometry();
195 void OrnamentedObj::move (QPointF p)
200 void OrnamentedObj::moveBy (double x, double y)
203 MapObj::moveBy (x,y);
205 systemFlags->moveBy (x,y);
206 standardFlags->moveBy (x,y);
207 heading->moveBy (x,y);
208 updateLinkGeometry();
212 void OrnamentedObj::moveBy (QPointF p)
214 moveBy (p.x(), p.y());
217 void OrnamentedObj::move2RelPos(double x, double y)
219 setRelPos (QPointF(x,y));
222 QPointF p=parObj->getChildPos();
223 move (p.x()+x, p.y() +y);
227 void OrnamentedObj::move2RelPos(QPointF p)
229 move2RelPos (p.x(),p.y());
232 void OrnamentedObj::activateStandardFlag(Flag *flag)
234 standardFlags->activate(flag);
237 move (absPos.x(), absPos.y() );
241 void OrnamentedObj::deactivateStandardFlag(const QString &name)
243 standardFlags->deactivate(name);
246 move (absPos.x(), absPos.y() );
251 QString OrnamentedObj::getSystemFlagName(const QPointF &p) //FIXME-3
253 return systemFlags->getFlagName(p);