1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
6 #include "headingobj.h"
7 #include "flagrowobj.h"
13 /*! \brief This class adds links to MapObj
15 The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
18 class LinkableMapObj:public QObject, 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
43 /*! Hint if link should use the default link color or the color of heading */
45 DefaultColor, //!< Link uses the default color
46 HeadingColor //!< Link uses the color of heading
50 LinkableMapObj (QGraphicsScene*);
51 LinkableMapObj (LinkableMapObj*);
53 virtual void delLink();
55 virtual void copy (LinkableMapObj*);
56 void setChildObj (LinkableMapObj*);
57 virtual void setParObj (LinkableMapObj*);
58 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
59 virtual void unsetParObjTmp(); // reuse original ParObj
60 virtual bool hasParObjTmp();
62 virtual void setUseRelPos (const bool&);
63 virtual void setRelPos(); // set relPos to current parentPos
64 virtual void setRelPos(const QPointF&);
65 virtual QPointF getRelPos();
66 virtual void setUseOrientation (const bool &);
69 virtual qreal getTopPad();
70 virtual qreal getLeftPad();
71 virtual qreal getRightPad();
72 Style getDefLinkStyle();
73 void setLinkStyle(Style);
75 void setHideLinkUnselected(bool);
76 bool getHideLinkUnselected();
77 void setLinkPos (Position);
78 Position getLinkPos ();
80 virtual void setID (const QString &s);
81 virtual QString getID ();
83 virtual void setLinkColor(); // sets color according to colorhint, overloaded
84 virtual void setLinkColor(QColor);
85 QColor getLinkColor();
86 virtual void setVisibility (bool);
87 virtual void setOrientation();
88 virtual void updateLink(); // update parPos and childPos
90 // redraw link with given style
91 LinkableMapObj* getChildObj(); // returns pointer to fromObj
92 LinkableMapObj* getParObj(); // returns pointer to toObj
93 virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
94 virtual void setDockPos()=0; // sets childPos and parPos
95 QPointF getChildPos(); // returns pos where childs dock
96 QPointF getParPos(); // returns pos where parents dock
97 Orientation getOrientation(); // get orientation
98 virtual int getDepth(); // return depth
99 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag)
100 virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent);
101 virtual QPointF getRandPos(); // make randomised position
103 //virtual void alignRelativeTo(const QPointF );
104 virtual void reposition();
105 virtual void requestReposition(); // do reposition after next user event
106 virtual void forceReposition(); // to force a reposition now (outside
107 // of mapeditor e.g. in noteeditor
108 virtual bool repositionRequested();
110 //virtual QRectF getTotalBBox(); // return BBox including childs
111 //virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs
112 virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly
114 virtual void select();
115 virtual void unselect();
116 virtual QString getSelectString()=0;
117 //virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
120 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
121 QString getLinkAttr();
125 bool link2ParPos; // While moving around, sometimes link to parent
126 MapEditor* mapEditor; // for and toggleScroll(), get default styles
127 // and mapEditor->updateActions()
128 // and mapEditor->updateSelection()
129 Orientation orientation;
130 qreal linkwidth; // width of a link
131 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
132 QRectF bboxTotal; // bounding box including childs
134 LinkableMapObj* childObj;
135 LinkableMapObj* parObj;
136 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
137 qreal bottomlineY; // vertical offset of dockpos to pos
139 int thickness_start; // for StylePoly*
140 Style style; // Current style
141 Position linkpos; // Link at bottom of object or middle of height
142 QColor linkcolor; // Link color
144 QGraphicsLineItem* l; // line style
145 QGraphicsPolygonItem* p; // poly styles
146 int arcsegs; // arc: number of segments
147 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
148 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
149 QPolygonF pa1; // For drawing of PolyParabel
150 QPolygonF pa2; // For drawing of PolyParabel
151 QGraphicsLineItem* bottomline; // on bottom of BBox
152 bool repositionRequest; //
154 bool selected; // Used for marking the selection
155 bool hideLinkUnselected; // to hide links if unselected
156 qreal topPad, botPad,
157 leftPad, rightPad; // padding within bbox
159 QPointF relPos; // position relative to childPos of parent
160 //AnimPoint relPos; // position relative to childPos of parent
164 QString id; // id set during load/save currently used for xLinks