1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
6 #include "headingobj.h"
7 #include "flagrowobj.h"
17 /*! \brief This class adds links to MapObj
19 The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
22 class LinkableMapObj:public QObject, public MapObj {
25 /*! Orientation of an object depends on the position relative to the parent */
27 UndefinedOrientation, //!< Undefined
28 LeftOfCenter, //!< Object is left of center
29 RightOfCenter //!< Object is right of center
32 /*! Various drawing styles for links */
34 UndefinedStyle, //!< Undefined
35 Line, //!< Straight line
37 PolyLine, //!< Polygon (thick line)
38 PolyParabel //!< Thick parabel
41 /*! Vertical position of link in object */
43 Middle, //!< Link is drawn in the middle of object
44 Bottom //!< Link is drawn at bottom of object
47 /*! Hint if link should use the default link color or the color of heading */
49 DefaultColor, //!< Link uses the default color
50 HeadingColor //!< Link uses the color of heading
54 LinkableMapObj (QGraphicsScene*);
55 LinkableMapObj (LinkableMapObj*);
57 virtual void delLink();
59 virtual void copy (LinkableMapObj*);
61 virtual void setTreeItem(TreeItem *);
62 virtual TreeItem* getTreeItem() const;
63 virtual void setModel (VymModel *vm);
64 virtual VymModel* getModel ();
66 void setChildObj (LinkableMapObj*);
67 virtual void setParObj (LinkableMapObj*);
68 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
69 virtual void unsetParObjTmp(); // reuse original ParObj
70 virtual bool hasParObjTmp();
72 virtual void setUseRelPos (const bool&);
73 virtual void setRelPos(); // set relPos to current parentPos
74 virtual void setRelPos(const QPointF&);
75 virtual QPointF getRelPos();
76 virtual void setUseOrientation (const bool &);
79 virtual qreal getTopPad();
80 virtual qreal getLeftPad();
81 virtual qreal getRightPad();
82 Style getDefLinkStyle();
83 void setLinkStyle(Style);
85 void setHideLinkUnselected(bool);
86 bool getHideLinkUnselected();
87 void setLinkPos (Position);
88 Position getLinkPos ();
90 virtual void setID (const QString &s);
91 virtual QString getID ();
93 virtual void setLinkColor(); // sets color according to colorhint, overloaded
94 virtual void setLinkColor(QColor);
95 QColor getLinkColor();
96 virtual void setVisibility (bool);
97 virtual void setOrientation();
98 virtual void updateLink(); // update parPos and childPos
100 // redraw link with given style
101 LinkableMapObj* getChildObj(); // returns pointer to fromObj
102 LinkableMapObj* getParObj(); // returns pointer to toObj
103 virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
104 virtual void setDockPos()=0; // sets childPos and parPos
105 QPointF getChildPos(); // returns pos where children dock
106 QPointF getParPos(); // returns pos where parents dock
107 Orientation getOrientation(); // get orientation
108 virtual int getDepth(); // return depth
109 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) FIXME not needed
110 virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent); FIXME not needed
111 virtual QPointF getRandPos(); // make randomised position
113 virtual void reposition();
114 virtual void requestReposition(); // do reposition after next user event
115 virtual void forceReposition(); // to force a reposition now (outside
116 // of mapeditor e.g. in noteeditor
117 virtual bool repositionRequested();
119 virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
121 virtual void select();
122 virtual void unselect();
125 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
126 QString getLinkAttr();
130 bool link2ParPos; // While moving around, sometimes link to parent
131 MapEditor* mapEditor; // for and toggleScroll(), get default styles FIXME should not be needed with model available
132 // and mapEditor->updateActions()
133 // and mapEditor->updateSelection()
136 Orientation orientation;
137 qreal linkwidth; // width of a link
138 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
139 QRectF bboxTotal; // bounding box including children
141 LinkableMapObj* childObj;
142 LinkableMapObj* parObj;
143 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
144 qreal bottomlineY; // vertical offset of dockpos to pos
146 int thickness_start; // for StylePoly*
147 Style style; // Current style
148 Position linkpos; // Link at bottom of object or middle of height
149 QColor linkcolor; // Link color
151 QGraphicsLineItem* l; // line style
152 QGraphicsPolygonItem* p; // poly styles
153 int arcsegs; // arc: number of segments
154 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
155 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
156 QPolygonF pa1; // For drawing of PolyParabel
157 QPolygonF pa2; // For drawing of PolyParabel
158 QGraphicsLineItem* bottomline; // on bottom of BBox
159 bool repositionRequest; //
161 bool selected; // Used for marking the selection
162 bool hideLinkUnselected; // to hide links if unselected
163 qreal topPad, botPad,
164 leftPad, rightPad; // padding within bbox
166 QPointF relPos; // position relative to childPos of parent
167 //AnimPoint relPos; // position relative to childPos of parent
171 QString objID; // id set during load/save currently used for xLinks
173 TreeItem *treeItem; // Crossrefence to treemodel