1 #ifndef LINKABLEMAPOBJ_H
2 #define LINKABLEMAPOBJ_H
6 #include "headingobj.h"
7 #include "flagrowobj.h"
12 enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
20 enum LinkPos {LinkMiddle,LinkBottom};
21 enum LinkColorHint {DefaultColor,HeadingColor};
23 class LinkableMapObj:public QObject, public MapObj {
27 LinkableMapObj (QGraphicsScene*);
28 LinkableMapObj (LinkableMapObj*);
30 virtual void delLink();
32 virtual void copy (LinkableMapObj*);
33 void setChildObj (LinkableMapObj*);
34 virtual void setParObj (LinkableMapObj*);
35 virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around
36 virtual void unsetParObjTmp(); // reuse original ParObj
37 virtual bool hasParObjTmp();
39 virtual void setUseRelPos (const bool&);
40 virtual void setRelPos(); // set relPos to current parentPos
41 virtual void setRelPos(const QPointF&);
42 virtual QPointF getRelPos();
43 virtual void setUseOrientation (const bool &);
46 virtual qreal getTopPad();
47 virtual qreal getLeftPad();
48 virtual qreal getRightPad();
49 LinkStyle getDefLinkStyle();
50 void setLinkStyle(LinkStyle);
51 LinkStyle getLinkStyle();
52 void setHideLinkUnselected(bool);
53 bool getHideLinkUnselected();
54 void setLinkPos (LinkPos);
55 LinkPos getLinkPos ();
57 virtual void setLinkColor(); // sets color according to colorhint, overloaded
58 virtual void setLinkColor(QColor);
59 QColor getLinkColor();
60 virtual FrameType getFrameType ();
61 virtual void setFrameType (const FrameType &);
62 virtual void setFrameType (const QString &);
63 virtual void setVisibility (bool);
64 virtual void setOrientation();
65 virtual void updateLink(); // update parPos and childPos
67 // redraw link with given style
68 LinkableMapObj* getChildObj(); // returns pointer to fromObj
69 LinkableMapObj* getParObj(); // returns pointer to toObj
70 virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring
71 virtual void setDockPos()=0; // sets childPos and parPos
72 QPointF getChildPos(); // returns pos where childs dock
73 QPointF getParPos(); // returns pos where parents dock
74 LinkOrient getOrientation(); // get orientation
75 virtual int getDepth(); // return depth
76 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag)
77 virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent);
78 virtual QPointF getRandPos(); // make randomised position
80 //virtual void alignRelativeTo(const QPointF );
81 virtual void reposition();
82 virtual void requestReposition(); // do reposition after next user event
83 virtual void forceReposition(); // to force a reposition now (outside
84 // of mapeditor e.g. in noteeditor
85 virtual bool repositionRequested();
87 //virtual QRectF getTotalBBox(); // return BBox including childs
88 //virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs
89 virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly
91 virtual void setSelBox();
92 virtual void select();
93 virtual void unselect();
94 virtual QString getSelectString()=0;
95 //virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
98 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
99 QString getLinkAttr();
103 bool link2ParPos; // While moving around, sometimes link to parent
104 MapEditor* mapEditor; // for updateNoteFlag() and toggleScroll()
105 LinkOrient orientation;
106 qreal linkwidth; // width of a link
107 int depth; // depth: undef=-1 mapCenter=0 branch=1..n
108 QRectF bboxTotal; // bounding box including childs
110 LinkableMapObj* childObj;
111 LinkableMapObj* parObj;
112 LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent
113 qreal bottomlineY; // vertical offset of dockpos to pos
115 int thickness_start; // for StylePoly*
116 LinkStyle style; // Current style
117 LinkPos linkpos; // Link at bottom of object or middle of height
118 QColor linkcolor; // Link color
120 QGraphicsLineItem* l; // line style
121 QGraphicsPolygonItem* p; // poly styles
122 int arcsegs; // arc: number of segments
123 QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
124 QPolygonF pa0; // For drawing of PolyParabel and PolyLine
125 QPolygonF pa1; // For drawing of PolyParabel
126 QPolygonF pa2; // For drawing of PolyParabel
127 QGraphicsLineItem* bottomline; // on bottom of BBox
128 bool repositionRequest; //
130 bool selected; // Used for marking the selection
131 bool hideLinkUnselected; // to hide links if unselected
132 QGraphicsRectItem* selbox;
133 FrameObj *frame; // frame around object
134 qreal topPad, botPad,
135 leftPad, rightPad; // padding within bbox
137 QPointF relPos; // position relative to childPos of parent