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 dependd 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 setLinkColor(); // sets color according to colorhint, overloaded
81 virtual void setLinkColor(QColor);
82 QColor getLinkColor();
83 virtual void setVisibility (bool);
84 virtual void setOrientation();
85 virtual void updateLink(); // update parPos and childPos
87 // redraw link with given style
88 LinkableMapObj* getChildObj(); // returns pointer to fromObj
89 LinkableMapObj* getParObj(); // returns pointer to toObj
90 virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
91 virtual void setDockPos()=0; // sets childPos and parPos
92 QPointF getChildPos(); // returns pos where childs dock
93 QPointF getParPos(); // returns pos where parents dock
94 Orientation getOrientation(); // get orientation
95 virtual int getDepth(); // return depth
96 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag)
97 virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent);
98 virtual QPointF getRandPos(); // make randomised position
100 //virtual void alignRelativeTo(const QPointF );
101 virtual void reposition();
102 virtual void requestReposition(); // do reposition after next user event
103 virtual void forceReposition(); // to force a reposition now (outside
104 // of mapeditor e.g. in noteeditor
105 virtual bool repositionRequested();
107 //virtual QRectF getTotalBBox(); // return BBox including childs
108 //virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs
109 virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly
111 virtual void select();
112 virtual void unselect();
113 virtual QString getSelectString()=0;
114 //virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
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