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