1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
5 #include "flagrowobj.h"
6 #include "headingobj.h"
14 /*! \brief This class adds links to MapObj
16 The links are connecting the branches (BranchObj) and images (FloatImageObj) in
20 class LinkableMapObj : public MapObj {
22 /*! Orientation of an object depends on the position relative to the parent
25 UndefinedOrientation, //!< Undefined
26 LeftOfCenter, //!< Object is left of center
27 RightOfCenter //!< Object is right of center
30 /*! Various drawing styles for links */
32 UndefinedStyle, //!< Undefined
33 Line, //!< Straight line
35 PolyLine, //!< Polygon (thick line)
36 PolyParabel //!< Thick parabel
39 /*! Vertical position of link in object */
41 Middle, //!< Link is drawn in the middle of object
42 Bottom //!< Link is drawn at bottom of object
45 /*! 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(QGraphicsItem *, TreeItem *ti = NULL);
54 virtual ~LinkableMapObj();
58 virtual void createBottomLine();
61 virtual void delLink();
62 virtual void copy(LinkableMapObj *);
64 void setChildObj(LinkableMapObj *);
65 virtual void setParObj(LinkableMapObj *);
66 virtual void setParObjTmp(LinkableMapObj *, QPointF,
67 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 bool getUseRelPos();
73 virtual void setRelPos(); // set relPos to current parentPos
74 virtual void setRelPos(const QPointF &);
75 virtual QPointF getRelPos();
77 virtual qreal getTopPad();
78 virtual qreal getLeftPad();
79 virtual qreal getRightPad();
80 Style getDefLinkStyle(TreeItem *parent);
81 void setLinkStyle(Style);
84 void setLinkPos(Position);
85 Position getLinkPos();
88 setLinkColor(); // sets color according to colorhint, overloaded
89 virtual void setLinkColor(QColor);
90 QColor getLinkColor();
91 virtual void setVisibility(bool);
92 virtual void setOrientation();
94 updateVisibility(); //! hides/unhides link depending on selection
96 /*! update parPos, childRefPos
98 redraw link with given style */
99 virtual void updateLinkGeometry();
101 virtual void setDockPos() = 0; // sets childRefPos and parPos
102 QPointF getChildRefPos(); // returns pos where children dock
103 QPointF getFloatRefPos(); // returns pos where floats dock
104 QPointF getParPos(); // returns pos where parents dock
105 Orientation getOrientation(); // get orientation
107 virtual void reposition();
108 virtual void requestReposition(); // do reposition after next user event
109 virtual void forceReposition(); // to force a reposition now (outside
110 // of mapeditor e.g. in noteeditor
111 virtual bool repositionRequested();
113 virtual void calcBBoxSizeWithChildren() = 0; // calc size of BBox including
114 // children recursivly
117 void parabel(QPolygonF &, qreal, qreal, qreal,
118 qreal); // Create Parabel connecting two points
123 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 *parObj;
130 LinkableMapObj *parObjTmpBuf; // temporary buffer the original parent
133 int thickness_start; // for StylePoly*
134 Style style; // Current style
135 Position linkpos; // Link at bottom of object or middle of height
136 QColor linkcolor; // Link color
138 QGraphicsLineItem *l; // line style
139 QGraphicsPolygonItem *p; // poly styles
140 int arcsegs; // arc: number of segments
141 QList<QGraphicsLineItem *> segment; // a part of e.g. the parabel
142 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
143 QPolygonF pa1; // For drawing of PolyParabel
144 QPolygonF pa2; // For drawing of PolyParabel
146 QGraphicsLineItem *bottomline; // on bottom of BBox
147 bool useBottomline; //! Hint if bottomline should be used
148 qreal bottomlineY; // vertical offset of dockpos to pos
150 bool repositionRequest; //
152 qreal topPad, botPad, leftPad, rightPad; // padding within bbox
154 QPointF relPos; // position relative to childRefPos of parent