1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/floatobj.cpp Sun Jan 30 12:58:47 2005 +0000
1.3 @@ -0,0 +1,163 @@
1.4 +#include "floatobj.h"
1.5 +
1.6 +extern QAction* actionEditToggleFloatExport;
1.7 +
1.8 +/////////////////////////////////////////////////////////////////
1.9 +// FloatObj
1.10 +/////////////////////////////////////////////////////////////////
1.11 +
1.12 +FloatObj::FloatObj ():LinkableMapObj()
1.13 +{
1.14 +// cout << "Const FloatObj ()\n";
1.15 + setParObj (this);
1.16 + init();
1.17 + depth=-1;
1.18 +}
1.19 +
1.20 +FloatObj::FloatObj (QCanvas* c):LinkableMapObj(c)
1.21 +{
1.22 +// cout << "Const FloatObj (c) called from MapCenterObj (c)\n";
1.23 + setParObj (this);
1.24 + init();
1.25 + depth=-1;
1.26 +}
1.27 +
1.28 +FloatObj::FloatObj (QCanvas* c, LinkableMapObj* p):LinkableMapObj (c)
1.29 +{
1.30 +// cout << "Const FloatObj (c,p)\n";
1.31 + setParObj (p);
1.32 + depth=p->getDepth()+1;
1.33 + init();
1.34 +}
1.35 +
1.36 +FloatObj::~FloatObj ()
1.37 +{
1.38 +// cout << "Destr FloatObj\n";
1.39 +}
1.40 +
1.41 +void FloatObj::init ()
1.42 +{
1.43 + setChildObj(this);
1.44 + relPos=getRandPos();
1.45 + useOrientation=true;
1.46 + floatExport=true;
1.47 + zPlane=Z_ICON;
1.48 +}
1.49 +
1.50 +void FloatObj::copy (FloatObj* other)
1.51 +{
1.52 + LinkableMapObj::copy (other);
1.53 + relPos=other->relPos;
1.54 + useOrientation=other->useOrientation;
1.55 + setVisibility (other->visible);
1.56 +}
1.57 +
1.58 +void FloatObj::setRelPos()
1.59 +{
1.60 + if (useOrientation)
1.61 + {
1.62 + if (parObj->getOrientation()==OrientLeftOfCenter)
1.63 + relPos.setX ( parObj->x() +parObj->width() - bbox.width() -absPos.x());
1.64 + else
1.65 + relPos.setX (absPos.x() - parObj->x() );
1.66 + }
1.67 + else
1.68 + relPos.setX (absPos.x() - parObj->x() );
1.69 + relPos.setY (absPos.y() - parObj->y() );
1.70 +}
1.71 +
1.72 +void FloatObj::setRelPos(const QPoint &p)
1.73 +{
1.74 + relPos=p;
1.75 +}
1.76 +
1.77 +void FloatObj::setZ(const int &i)
1.78 +{
1.79 + zPlane=i;
1.80 +}
1.81 +
1.82 +int FloatObj::z()
1.83 +{
1.84 + return zPlane;
1.85 +}
1.86 +
1.87 +
1.88 +void FloatObj::setUseOrientation (const bool &b)
1.89 +{
1.90 + if (useOrientation!=b)
1.91 + {
1.92 + useOrientation=b;
1.93 + requestReposition();
1.94 + }
1.95 +}
1.96 +
1.97 +void FloatObj::setFloatExport(const bool& b)
1.98 +{
1.99 + floatExport=b;
1.100 +}
1.101 +
1.102 +bool FloatObj::getFloatExport()
1.103 +{
1.104 + return floatExport;
1.105 +}
1.106 +
1.107 +void FloatObj::move (double x, double y)
1.108 +{
1.109 + MapObj::move(x,y);
1.110 + selbox->move(x,y);
1.111 +}
1.112 +
1.113 +void FloatObj::move (QPoint p)
1.114 +{
1.115 + move (p.x(), p.y());
1.116 +}
1.117 +
1.118 +void FloatObj::reposition()
1.119 +{
1.120 + if (useOrientation)
1.121 + {
1.122 + if (parObj->getOrientation()==OrientLeftOfCenter)
1.123 + move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y());
1.124 + else
1.125 + move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
1.126 + }
1.127 + else
1.128 + move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
1.129 + updateLink();
1.130 +}
1.131 +
1.132 +QRect FloatObj::getTotalBBox()
1.133 +{
1.134 + return bbox;
1.135 +}
1.136 +
1.137 +QRect FloatObj::getBBoxSizeWithChilds()
1.138 +{
1.139 + return bboxTotal;
1.140 +}
1.141 +
1.142 +void FloatObj::select()
1.143 +{
1.144 + LinkableMapObj::select();
1.145 + // Temporary draw the link while FO is selected
1.146 + if (style==StyleUndef)
1.147 + {
1.148 + setLinkStyle(getDefLinkStyle());
1.149 + setLinkColor(parObj->getLinkColor());
1.150 + }
1.151 +
1.152 + // Update FloatExport switch in context menu
1.153 + if (floatExport)
1.154 + actionEditToggleFloatExport->setEnabled (true);
1.155 + else
1.156 + actionEditToggleFloatExport->setEnabled (true);
1.157 +
1.158 +
1.159 +}
1.160 +
1.161 +void FloatObj::unselect()
1.162 +{
1.163 + LinkableMapObj::unselect();
1.164 + setLinkStyle (StyleUndef);
1.165 +}
1.166 +