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 setModel (VymModel *vm);
61 virtual VymModel* getModel ();
63 void setChildObj (LinkableMapObj*);
64 virtual void setParObj (LinkableMapObj*);
65 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
66 virtual void unsetParObjTmp(); // reuse original ParObj
67 virtual bool hasParObjTmp();
69 virtual void setUseRelPos (const bool&);
70 virtual void setRelPos(); // set relPos to current parentPos
71 virtual void setRelPos(const QPointF&);
72 virtual QPointF getRelPos();
73 virtual void setUseOrientation (const bool &);
76 virtual qreal getTopPad();
77 virtual qreal getLeftPad();
78 virtual qreal getRightPad();
79 Style getDefLinkStyle();
80 void setLinkStyle(Style);
82 void setHideLinkUnselected(bool);
83 bool getHideLinkUnselected();
84 void setLinkPos (Position);
85 Position getLinkPos ();
87 virtual void setID (const QString &s);
88 virtual QString getID ();
90 virtual void setLinkColor(); // sets color according to colorhint, overloaded
91 virtual void setLinkColor(QColor);
92 QColor getLinkColor();
93 virtual void setVisibility (bool);
94 virtual void setOrientation();
95 virtual void updateLink(); // update parPos and childPos
97 // redraw link with given style
98 LinkableMapObj* getChildObj(); // returns pointer to fromObj
99 LinkableMapObj* getParObj(); // returns pointer to toObj
100 virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
101 virtual void setDockPos()=0; // sets childPos and parPos
102 QPointF getChildPos(); // returns pos where children dock
103 QPointF getParPos(); // returns pos where parents dock
104 Orientation getOrientation(); // get orientation
105 virtual int getDepth(); // return depth
106 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) FIXME not needed
107 virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent); FIXME not needed
108 virtual QPointF getRandPos(); // make randomised position
110 virtual void reposition();
111 virtual void requestReposition(); // do reposition after next user event
112 virtual void forceReposition(); // to force a reposition now (outside
113 // of mapeditor e.g. in noteeditor
114 virtual bool repositionRequested();
116 virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
118 virtual void select();
119 virtual void unselect();
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 FIXME should not be needed with model available
129 // and mapEditor->updateActions()
130 // and mapEditor->updateSelection()
133 Orientation orientation;
134 qreal linkwidth; // width of a link
135 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
136 QRectF bboxTotal; // bounding box including children
138 LinkableMapObj* childObj;
139 LinkableMapObj* parObj;
140 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
141 qreal bottomlineY; // vertical offset of dockpos to pos
143 int thickness_start; // for StylePoly*
144 Style style; // Current style
145 Position linkpos; // Link at bottom of object or middle of height
146 QColor linkcolor; // Link color
148 QGraphicsLineItem* l; // line style
149 QGraphicsPolygonItem* p; // poly styles
150 int arcsegs; // arc: number of segments
151 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
152 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
153 QPolygonF pa1; // For drawing of PolyParabel
154 QPolygonF pa2; // For drawing of PolyParabel
155 QGraphicsLineItem* bottomline; // on bottom of BBox
156 bool repositionRequest; //
158 bool selected; // Used for marking the selection
159 bool hideLinkUnselected; // to hide links if unselected
160 qreal topPad, botPad,
161 leftPad, rightPad; // padding within bbox
163 QPointF relPos; // position relative to childPos of parent
164 //AnimPoint relPos; // position relative to childPos of parent
168 QString objID; // id set during load/save currently used for xLinks