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;
63 void setChildObj (LinkableMapObj*);
64 virtual void setParObj (LinkableMapObj*);
65 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
66 virtual void unsetParObjTmp(); // reuse original ParObj
67 virtual bool hasParObjTmp();
69 virtual void setUseRelPos (const bool&);
70 virtual void setRelPos(); // set relPos to current parentPos
71 virtual void setRelPos(const QPointF&);
72 virtual QPointF getRelPos();
73 virtual void setUseOrientation (const bool &);
76 virtual qreal getTopPad();
77 virtual qreal getLeftPad();
78 virtual qreal getRightPad();
79 Style getDefLinkStyle();
80 void setLinkStyle(Style);
82 void setHideLinkUnselected(bool);
83 bool getHideLinkUnselected();
84 void setLinkPos (Position);
85 Position getLinkPos ();
87 virtual void setLinkColor(); // sets color according to colorhint, overloaded
88 virtual void setLinkColor(QColor);
89 QColor getLinkColor();
90 virtual void setVisibility (bool);
91 virtual void setOrientation();
92 virtual void updateLink(); // update parPos and childPos
94 // redraw link with given style
95 LinkableMapObj* getChildObj(); // returns pointer to fromObj
96 LinkableMapObj* getParObj(); // returns pointer to toObj
97 virtual void setDockPos()=0; // sets childPos and parPos
98 QPointF getChildPos(); // returns pos where children dock
99 QPointF getParPos(); // returns pos where parents dock
100 Orientation getOrientation(); // get orientation
101 virtual QPointF getRandPos(); // make randomised position
103 virtual void reposition();
104 virtual void requestReposition(); // do reposition after next user event
105 virtual void forceReposition(); // to force a reposition now (outside
106 // of mapeditor e.g. in noteeditor
107 virtual bool repositionRequested();
109 virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
111 virtual void select(); // FIXME-3 show/hide links...
112 virtual void unselect();
115 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
116 QString getLinkAttr();
120 bool link2ParPos; // While moving around, sometimes link to parent
122 Orientation orientation;
123 qreal linkwidth; // width of a link
124 QRectF bboxTotal; // bounding box including children
126 LinkableMapObj* parObj;
127 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
128 qreal bottomlineY; // vertical offset of dockpos to pos
130 int thickness_start; // for StylePoly*
131 Style style; // Current style
132 Position linkpos; // Link at bottom of object or middle of height
133 QColor linkcolor; // Link color
135 QGraphicsLineItem* l; // line style
136 QGraphicsPolygonItem* p; // poly styles
137 int arcsegs; // arc: number of segments
138 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
139 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
140 QPolygonF pa1; // For drawing of PolyParabel
141 QPolygonF pa2; // For drawing of PolyParabel
142 QGraphicsLineItem* bottomline; // on bottom of BBox
143 bool repositionRequest; //
145 bool selected; // Used for marking the selection
146 bool hideLinkUnselected; // to hide links if unselected
147 qreal topPad, botPad,
148 leftPad, rightPad; // padding within bbox
150 QPointF relPos; // position relative to childPos of parent
154 TreeItem *treeItem; // Crossrefence to treemodel