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 {
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 LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
100 virtual void setDockPos()=0; // sets childPos and parPos
101 QPointF getChildPos(); // returns pos where children dock
102 QPointF getParPos(); // returns pos where parents dock
103 Orientation getOrientation(); // get orientation
104 virtual int getDepth(); // return depth
105 virtual QPointF getRandPos(); // make randomised position
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 children recursivly
115 virtual void select();
116 virtual void unselect();
119 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
120 QString getLinkAttr();
124 bool link2ParPos; // While moving around, sometimes link to parent
127 Orientation orientation;
128 qreal linkwidth; // width of a link
129 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
130 QRectF bboxTotal; // bounding box including children
132 LinkableMapObj* childObj;
133 LinkableMapObj* parObj;
134 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
135 qreal bottomlineY; // vertical offset of dockpos to pos
137 int thickness_start; // for StylePoly*
138 Style style; // Current style
139 Position linkpos; // Link at bottom of object or middle of height
140 QColor linkcolor; // Link color
142 QGraphicsLineItem* l; // line style
143 QGraphicsPolygonItem* p; // poly styles
144 int arcsegs; // arc: number of segments
145 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
146 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
147 QPolygonF pa1; // For drawing of PolyParabel
148 QPolygonF pa2; // For drawing of PolyParabel
149 QGraphicsLineItem* bottomline; // on bottom of BBox
150 bool repositionRequest; //
152 bool selected; // Used for marking the selection
153 bool hideLinkUnselected; // to hide links if unselected
154 qreal topPad, botPad,
155 leftPad, rightPad; // padding within bbox
157 QPointF relPos; // position relative to childPos of parent
158 //AnimPoint relPos; // position relative to childPos of parent
162 TreeItem *treeItem; // Crossrefence to treemodel