1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
6 #include "headingobj.h"
7 #include "flagrowobj.h"
14 /*! \brief This class adds links to MapObj
16 The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
19 class LinkableMapObj:public MapObj {
21 /*! Orientation of an object depends on the position relative to the parent */
23 UndefinedOrientation, //!< Undefined
24 LeftOfCenter, //!< Object is left of center
25 RightOfCenter //!< Object is right of center
28 /*! Various drawing styles for links */
30 UndefinedStyle, //!< Undefined
31 Line, //!< Straight line
33 PolyLine, //!< Polygon (thick line)
34 PolyParabel //!< Thick parabel
37 /*! Vertical position of link in object */
39 Middle, //!< Link is drawn in the middle of object
40 Bottom //!< Link is drawn at bottom of object
44 /*! Hint if link should use the default link color or the color of heading */
46 DefaultColor, //!< Link uses the default color
47 HeadingColor //!< Link uses the color of heading
51 LinkableMapObj (QGraphicsScene*, TreeItem *ti=NULL);
52 LinkableMapObj (LinkableMapObj*);
53 virtual ~LinkableMapObj ();
54 virtual void delLink();
56 virtual void copy (LinkableMapObj*);
58 void setChildObj (LinkableMapObj*);
59 virtual void setParObj (LinkableMapObj*);
60 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
61 virtual void unsetParObjTmp(); // reuse original ParObj
62 virtual bool hasParObjTmp();
64 virtual void setUseRelPos (const bool&);
65 virtual void setRelPos(); // set relPos to current parentPos
66 virtual void setRelPos(const QPointF&);
67 virtual QPointF getRelPos();
69 virtual qreal getTopPad();
70 virtual qreal getLeftPad();
71 virtual qreal getRightPad();
72 Style getDefLinkStyle(TreeItem *parent);
73 void setLinkStyle(Style);
76 void setHideLinkUnselected();
77 void setLinkPos (Position);
78 Position getLinkPos ();
80 virtual void setLinkColor(); // sets color according to colorhint, overloaded
81 virtual void setLinkColor(QColor);
82 QColor getLinkColor();
83 virtual void setVisibility (bool);
84 virtual void setOrientation();
85 virtual void updateVisibility(); //! hides/unhides link depending on selection
87 /*! update parPos, childPos
89 redraw link with given style */
90 virtual void updateLinkGeometry();
92 LinkableMapObj* getChildObj(); // returns pointer to fromObj
93 LinkableMapObj* getParObj(); // returns pointer to toObj
94 virtual void setDockPos()=0; // sets childPos and parPos
95 QPointF getChildPos(); // returns pos where children dock
96 QPointF getParPos(); // returns pos where parents dock
97 Orientation getOrientation(); // get orientation
98 virtual QPointF getRandPos(); // make randomised position
100 virtual void reposition();
101 virtual void requestReposition(); // do reposition after next user event
102 virtual void forceReposition(); // to force a reposition now (outside
103 // of mapeditor e.g. in noteeditor
104 virtual bool repositionRequested();
106 virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
109 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
113 bool link2ParPos; // While moving around, sometimes link to parent
115 Orientation orientation;
116 qreal linkwidth; // width of a link
117 QRectF bboxTotal; // bounding box including children
119 LinkableMapObj* parObj;
120 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
123 int thickness_start; // for StylePoly*
124 Style style; // Current style
125 Position linkpos; // Link at bottom of object or middle of height
126 QColor linkcolor; // Link color
128 QGraphicsLineItem* l; // line style
129 QGraphicsPolygonItem* p; // poly styles
130 int arcsegs; // arc: number of segments
131 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
132 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
133 QPolygonF pa1; // For drawing of PolyParabel
134 QPolygonF pa2; // For drawing of PolyParabel
136 QGraphicsLineItem* bottomline; // on bottom of BBox
137 bool useBottomline; //! Hint if bottomline should be used
138 qreal bottomlineY; // vertical offset of dockpos to pos
140 bool repositionRequest; //
142 qreal topPad, botPad,
143 leftPad, rightPad; // padding within bbox
145 QPointF relPos; // position relative to childPos of parent