1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
6 #include "headingobj.h"
7 #include "flagrowobj.h"
16 /*! \brief This class adds links to MapObj
18 The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
21 class LinkableMapObj:public QObject, public MapObj {
22 Q_OBJECT // FIXME-3 really needed here?
24 /*! Orientation of an object depends on the position relative to the parent */
26 UndefinedOrientation, //!< Undefined
27 LeftOfCenter, //!< Object is left of center
28 RightOfCenter //!< Object is right of center
31 /*! Various drawing styles for links */
33 UndefinedStyle, //!< Undefined
34 Line, //!< Straight line
36 PolyLine, //!< Polygon (thick line)
37 PolyParabel //!< Thick parabel
40 /*! Vertical position of link in object */
42 Middle, //!< Link is drawn in the middle of object
43 Bottom //!< Link is drawn at bottom of object
46 /*! Hint if link should use the default link color or the color of heading */
48 DefaultColor, //!< Link uses the default color
49 HeadingColor //!< Link uses the color of heading
53 LinkableMapObj (QGraphicsScene*);
54 LinkableMapObj (LinkableMapObj*);
56 virtual void delLink();
58 virtual void copy (LinkableMapObj*);
60 virtual void setTreeItem(TreeItem *);
61 virtual TreeItem* getTreeItem() const;
62 virtual void setModel (VymModel *vm);
63 virtual VymModel* getModel ();
65 void setChildObj (LinkableMapObj*);
66 virtual void setParObj (LinkableMapObj*);
67 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
68 virtual void unsetParObjTmp(); // reuse original ParObj
69 virtual bool hasParObjTmp();
71 virtual void setUseRelPos (const bool&);
72 virtual void setRelPos(); // set relPos to current parentPos
73 virtual void setRelPos(const QPointF&);
74 virtual QPointF getRelPos();
75 virtual void setUseOrientation (const bool &);
78 virtual qreal getTopPad();
79 virtual qreal getLeftPad();
80 virtual qreal getRightPad();
81 Style getDefLinkStyle();
82 void setLinkStyle(Style);
84 void setHideLinkUnselected(bool);
85 bool getHideLinkUnselected();
86 void setLinkPos (Position);
87 Position getLinkPos ();
89 virtual void setLinkColor(); // sets color according to colorhint, overloaded
90 virtual void setLinkColor(QColor);
91 QColor getLinkColor();
92 virtual void setVisibility (bool);
93 virtual void setOrientation();
94 virtual void updateLink(); // update parPos and childPos
96 // redraw link with given style
97 LinkableMapObj* getChildObj(); // returns pointer to fromObj
98 LinkableMapObj* getParObj(); // returns pointer to toObj
99 virtual void setDockPos()=0; // sets childPos and parPos
100 QPointF getChildPos(); // returns pos where children dock
101 QPointF getParPos(); // returns pos where parents dock
102 Orientation getOrientation(); // get orientation
103 virtual QPointF getRandPos(); // make randomised position
105 virtual void reposition();
106 virtual void requestReposition(); // do reposition after next user event
107 virtual void forceReposition(); // to force a reposition now (outside
108 // of mapeditor e.g. in noteeditor
109 virtual bool repositionRequested();
111 virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
113 virtual void select();
114 virtual void unselect();
117 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
118 QString getLinkAttr();
122 bool link2ParPos; // While moving around, sometimes link to parent
125 Orientation orientation;
126 qreal linkwidth; // width of a link
127 QRectF bboxTotal; // bounding box including children
129 LinkableMapObj* childObj;
130 LinkableMapObj* parObj; // FIXME-2 really still needed? Better get from TreeItem
131 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
132 qreal bottomlineY; // vertical offset of dockpos to pos
134 int thickness_start; // for StylePoly*
135 Style style; // Current style
136 Position linkpos; // Link at bottom of object or middle of height
137 QColor linkcolor; // Link color
139 QGraphicsLineItem* l; // line style
140 QGraphicsPolygonItem* p; // poly styles
141 int arcsegs; // arc: number of segments
142 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
143 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
144 QPolygonF pa1; // For drawing of PolyParabel
145 QPolygonF pa2; // For drawing of PolyParabel
146 QGraphicsLineItem* bottomline; // on bottom of BBox
147 bool repositionRequest; //
149 bool selected; // Used for marking the selection
150 bool hideLinkUnselected; // to hide links if unselected
151 qreal topPad, botPad,
152 leftPad, rightPad; // padding within bbox
154 QPointF relPos; // position relative to childPos of parent
155 //AnimPoint relPos; // position relative to childPos of parent
159 TreeItem *treeItem; // Crossrefence to treemodel