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 alignRelativeTo(const QPointF );
106 virtual void reposition();
107 virtual void requestReposition(); // do reposition after next user event
108 virtual void forceReposition(); // to force a reposition now (outside
109 // of mapeditor e.g. in noteeditor
110 virtual bool repositionRequested();
112 //virtual QRectF getTotalBBox(); // return BBox including childs
113 //virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs
114 virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly
116 virtual void select();
117 virtual void unselect();
118 virtual QString getSelectString()=0;
119 //virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
122 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
123 QString getLinkAttr();
127 bool link2ParPos; // While moving around, sometimes link to parent
128 MapEditor* mapEditor; // for and toggleScroll(), get default styles
129 // and mapEditor->updateActions()
130 // and mapEditor->updateSelection()
131 Orientation orientation;
132 qreal linkwidth; // width of a link
133 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
134 QRectF bboxTotal; // bounding box including childs
136 LinkableMapObj* childObj;
137 LinkableMapObj* parObj;
138 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
139 qreal bottomlineY; // vertical offset of dockpos to pos
141 int thickness_start; // for StylePoly*
142 Style style; // Current style
143 Position linkpos; // Link at bottom of object or middle of height
144 QColor linkcolor; // Link color
146 QGraphicsLineItem* l; // line style
147 QGraphicsPolygonItem* p; // poly styles
148 int arcsegs; // arc: number of segments
149 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
150 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
151 QPolygonF pa1; // For drawing of PolyParabel
152 QPolygonF pa2; // For drawing of PolyParabel
153 QGraphicsLineItem* bottomline; // on bottom of BBox
154 bool repositionRequest; //
156 bool selected; // Used for marking the selection
157 bool hideLinkUnselected; // to hide links if unselected
158 qreal topPad, botPad,
159 leftPad, rightPad; // padding within bbox
161 QPointF relPos; // position relative to childPos of parent
162 //AnimPoint relPos; // position relative to childPos of parent
166 QString objID; // id set during load/save currently used for xLinks