1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
6 #include "headingobj.h"
7 #include "flagrowobj.h"
15 /*! \brief This class adds links to MapObj
17 The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
20 class LinkableMapObj:public QObject, public MapObj {
23 /*! 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 */
47 DefaultColor, //!< Link uses the default color
48 HeadingColor //!< Link uses the color of heading
52 LinkableMapObj (QGraphicsScene*);
53 LinkableMapObj (LinkableMapObj*);
55 virtual void delLink();
57 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();
68 virtual void setUseOrientation (const bool &);
71 virtual qreal getTopPad();
72 virtual qreal getLeftPad();
73 virtual qreal getRightPad();
74 Style getDefLinkStyle();
75 void setLinkStyle(Style);
77 void setHideLinkUnselected(bool);
78 bool getHideLinkUnselected();
79 void setLinkPos (Position);
80 Position getLinkPos ();
82 virtual void setID (const QString &s);
83 virtual QString getID ();
85 virtual void setLinkColor(); // sets color according to colorhint, overloaded
86 virtual void setLinkColor(QColor);
87 QColor getLinkColor();
88 virtual void setVisibility (bool);
89 virtual void setOrientation();
90 virtual void updateLink(); // update parPos and childPos
92 // redraw link with given style
93 LinkableMapObj* getChildObj(); // returns pointer to fromObj
94 LinkableMapObj* getParObj(); // returns pointer to toObj
95 virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
96 virtual void setDockPos()=0; // sets childPos and parPos
97 QPointF getChildPos(); // returns pos where childs dock
98 QPointF getParPos(); // returns pos where parents dock
99 Orientation getOrientation(); // get orientation
100 virtual int getDepth(); // return depth
101 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag)
102 virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent);
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 calcBBoxSizeWithChilds()=0;// calc size of BBox including childs 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
123 MapEditor* mapEditor; // for and toggleScroll(), get default styles
124 // and mapEditor->updateActions()
125 // and mapEditor->updateSelection()
126 Orientation orientation;
127 qreal linkwidth; // width of a link
128 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
129 QRectF bboxTotal; // bounding box including childs
131 LinkableMapObj* childObj;
132 LinkableMapObj* parObj;
133 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
134 qreal bottomlineY; // vertical offset of dockpos to pos
136 int thickness_start; // for StylePoly*
137 Style style; // Current style
138 Position linkpos; // Link at bottom of object or middle of height
139 QColor linkcolor; // Link color
141 QGraphicsLineItem* l; // line style
142 QGraphicsPolygonItem* p; // poly styles
143 int arcsegs; // arc: number of segments
144 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
145 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
146 QPolygonF pa1; // For drawing of PolyParabel
147 QPolygonF pa2; // For drawing of PolyParabel
148 QGraphicsLineItem* bottomline; // on bottom of BBox
149 bool repositionRequest; //
151 bool selected; // Used for marking the selection
152 bool hideLinkUnselected; // to hide links if unselected
153 qreal topPad, botPad,
154 leftPad, rightPad; // padding within bbox
156 QPointF relPos; // position relative to childPos of parent
157 //AnimPoint relPos; // position relative to childPos of parent
161 QString objID; // id set during load/save currently used for xLinks