author | insilmaril |
Mon, 10 Oct 2005 11:20:25 +0000 | |
changeset 166 | 325958acb69b |
parent 160 | 72cc3873306a |
child 173 | 309609406650 |
permissions | -rw-r--r-- |
insilmaril@0 | 1 |
#include "floatobj.h" |
insilmaril@0 | 2 |
|
insilmaril@0 | 3 |
extern QAction* actionEditToggleFloatExport; |
insilmaril@0 | 4 |
|
insilmaril@0 | 5 |
///////////////////////////////////////////////////////////////// |
insilmaril@0 | 6 |
// FloatObj |
insilmaril@0 | 7 |
///////////////////////////////////////////////////////////////// |
insilmaril@0 | 8 |
|
insilmaril@0 | 9 |
FloatObj::FloatObj ():LinkableMapObj() |
insilmaril@0 | 10 |
{ |
insilmaril@0 | 11 |
// cout << "Const FloatObj ()\n"; |
insilmaril@0 | 12 |
setParObj (this); |
insilmaril@0 | 13 |
init(); |
insilmaril@0 | 14 |
depth=-1; |
insilmaril@0 | 15 |
} |
insilmaril@0 | 16 |
|
insilmaril@0 | 17 |
FloatObj::FloatObj (QCanvas* c):LinkableMapObj(c) |
insilmaril@0 | 18 |
{ |
insilmaril@0 | 19 |
// cout << "Const FloatObj (c) called from MapCenterObj (c)\n"; |
insilmaril@0 | 20 |
setParObj (this); |
insilmaril@0 | 21 |
init(); |
insilmaril@0 | 22 |
depth=-1; |
insilmaril@0 | 23 |
} |
insilmaril@0 | 24 |
|
insilmaril@0 | 25 |
FloatObj::FloatObj (QCanvas* c, LinkableMapObj* p):LinkableMapObj (c) |
insilmaril@0 | 26 |
{ |
insilmaril@0 | 27 |
// cout << "Const FloatObj (c,p)\n"; |
insilmaril@0 | 28 |
setParObj (p); |
insilmaril@0 | 29 |
depth=p->getDepth()+1; |
insilmaril@0 | 30 |
init(); |
insilmaril@0 | 31 |
} |
insilmaril@0 | 32 |
|
insilmaril@0 | 33 |
FloatObj::~FloatObj () |
insilmaril@0 | 34 |
{ |
insilmaril@0 | 35 |
// cout << "Destr FloatObj\n"; |
insilmaril@0 | 36 |
} |
insilmaril@0 | 37 |
|
insilmaril@0 | 38 |
void FloatObj::init () |
insilmaril@0 | 39 |
{ |
insilmaril@0 | 40 |
setChildObj(this); |
insilmaril@0 | 41 |
relPos=getRandPos(); |
insilmaril@0 | 42 |
useOrientation=true; |
insilmaril@0 | 43 |
floatExport=true; |
insilmaril@0 | 44 |
zPlane=Z_ICON; |
insilmaril@160 | 45 |
setLinkStyle (StyleParabel); |
insilmaril@160 | 46 |
setHideLinkUnselected(true); |
insilmaril@0 | 47 |
} |
insilmaril@0 | 48 |
|
insilmaril@0 | 49 |
void FloatObj::copy (FloatObj* other) |
insilmaril@0 | 50 |
{ |
insilmaril@0 | 51 |
LinkableMapObj::copy (other); |
insilmaril@0 | 52 |
relPos=other->relPos; |
insilmaril@0 | 53 |
useOrientation=other->useOrientation; |
insilmaril@0 | 54 |
setVisibility (other->visible); |
insilmaril@0 | 55 |
} |
insilmaril@0 | 56 |
|
insilmaril@0 | 57 |
void FloatObj::setRelPos() |
insilmaril@0 | 58 |
{ |
insilmaril@0 | 59 |
if (useOrientation) |
insilmaril@0 | 60 |
{ |
insilmaril@0 | 61 |
if (parObj->getOrientation()==OrientLeftOfCenter) |
insilmaril@0 | 62 |
relPos.setX ( parObj->x() +parObj->width() - bbox.width() -absPos.x()); |
insilmaril@0 | 63 |
else |
insilmaril@0 | 64 |
relPos.setX (absPos.x() - parObj->x() ); |
insilmaril@0 | 65 |
} |
insilmaril@0 | 66 |
else |
insilmaril@0 | 67 |
relPos.setX (absPos.x() - parObj->x() ); |
insilmaril@0 | 68 |
relPos.setY (absPos.y() - parObj->y() ); |
insilmaril@0 | 69 |
} |
insilmaril@0 | 70 |
|
insilmaril@0 | 71 |
void FloatObj::setRelPos(const QPoint &p) |
insilmaril@0 | 72 |
{ |
insilmaril@0 | 73 |
relPos=p; |
insilmaril@0 | 74 |
} |
insilmaril@0 | 75 |
|
insilmaril@0 | 76 |
void FloatObj::setZ(const int &i) |
insilmaril@0 | 77 |
{ |
insilmaril@0 | 78 |
zPlane=i; |
insilmaril@0 | 79 |
} |
insilmaril@0 | 80 |
|
insilmaril@0 | 81 |
int FloatObj::z() |
insilmaril@0 | 82 |
{ |
insilmaril@0 | 83 |
return zPlane; |
insilmaril@0 | 84 |
} |
insilmaril@0 | 85 |
|
insilmaril@0 | 86 |
|
insilmaril@0 | 87 |
void FloatObj::setUseOrientation (const bool &b) |
insilmaril@0 | 88 |
{ |
insilmaril@0 | 89 |
if (useOrientation!=b) |
insilmaril@0 | 90 |
{ |
insilmaril@0 | 91 |
useOrientation=b; |
insilmaril@0 | 92 |
requestReposition(); |
insilmaril@0 | 93 |
} |
insilmaril@0 | 94 |
} |
insilmaril@0 | 95 |
|
insilmaril@0 | 96 |
void FloatObj::setFloatExport(const bool& b) |
insilmaril@0 | 97 |
{ |
insilmaril@0 | 98 |
floatExport=b; |
insilmaril@0 | 99 |
} |
insilmaril@0 | 100 |
|
insilmaril@0 | 101 |
bool FloatObj::getFloatExport() |
insilmaril@0 | 102 |
{ |
insilmaril@0 | 103 |
return floatExport; |
insilmaril@0 | 104 |
} |
insilmaril@0 | 105 |
|
insilmaril@0 | 106 |
void FloatObj::move (double x, double y) |
insilmaril@0 | 107 |
{ |
insilmaril@0 | 108 |
MapObj::move(x,y); |
insilmaril@0 | 109 |
selbox->move(x,y); |
insilmaril@0 | 110 |
} |
insilmaril@0 | 111 |
|
insilmaril@0 | 112 |
void FloatObj::move (QPoint p) |
insilmaril@0 | 113 |
{ |
insilmaril@0 | 114 |
move (p.x(), p.y()); |
insilmaril@0 | 115 |
} |
insilmaril@0 | 116 |
|
insilmaril@0 | 117 |
void FloatObj::reposition() |
insilmaril@0 | 118 |
{ |
insilmaril@0 | 119 |
if (useOrientation) |
insilmaril@0 | 120 |
{ |
insilmaril@0 | 121 |
if (parObj->getOrientation()==OrientLeftOfCenter) |
insilmaril@0 | 122 |
move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y()); |
insilmaril@0 | 123 |
else |
insilmaril@0 | 124 |
move (parObj->x()+relPos.x(), parObj->y()+relPos.y()); |
insilmaril@0 | 125 |
} |
insilmaril@0 | 126 |
else |
insilmaril@0 | 127 |
move (parObj->x()+relPos.x(), parObj->y()+relPos.y()); |
insilmaril@0 | 128 |
updateLink(); |
insilmaril@0 | 129 |
} |
insilmaril@0 | 130 |
|
insilmaril@0 | 131 |
QRect FloatObj::getTotalBBox() |
insilmaril@0 | 132 |
{ |
insilmaril@0 | 133 |
return bbox; |
insilmaril@0 | 134 |
} |
insilmaril@0 | 135 |
|
insilmaril@0 | 136 |
QRect FloatObj::getBBoxSizeWithChilds() |
insilmaril@0 | 137 |
{ |
insilmaril@0 | 138 |
return bboxTotal; |
insilmaril@0 | 139 |
} |
insilmaril@0 | 140 |
|
insilmaril@0 | 141 |
void FloatObj::select() |
insilmaril@0 | 142 |
{ |
insilmaril@0 | 143 |
LinkableMapObj::select(); |
insilmaril@0 | 144 |
// Temporary draw the link while FO is selected |
insilmaril@0 | 145 |
if (style==StyleUndef) |
insilmaril@0 | 146 |
{ |
insilmaril@0 | 147 |
setLinkStyle(getDefLinkStyle()); |
insilmaril@0 | 148 |
setLinkColor(parObj->getLinkColor()); |
insilmaril@0 | 149 |
} |
insilmaril@0 | 150 |
|
insilmaril@0 | 151 |
// Update FloatExport switch in context menu |
insilmaril@0 | 152 |
if (floatExport) |
insilmaril@0 | 153 |
actionEditToggleFloatExport->setEnabled (true); |
insilmaril@0 | 154 |
else |
insilmaril@0 | 155 |
actionEditToggleFloatExport->setEnabled (true); |
insilmaril@0 | 156 |
|
insilmaril@0 | 157 |
|
insilmaril@0 | 158 |
} |
insilmaril@0 | 159 |
|
insilmaril@0 | 160 |
void FloatObj::unselect() |
insilmaril@0 | 161 |
{ |
insilmaril@0 | 162 |
LinkableMapObj::unselect(); |
insilmaril@0 | 163 |
setLinkStyle (StyleUndef); |
insilmaril@0 | 164 |
} |
insilmaril@0 | 165 |