File: linkablemapobj.h

package info (click to toggle)
vym 1.8.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,000 kB
  • ctags: 1,599
  • sloc: cpp: 14,723; sh: 373; xml: 277; perl: 89; makefile: 16
file content (138 lines) | stat: -rw-r--r-- 5,254 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef LINKABLEMAPOBJ_H
#define LINKABLEMAPOBJ_H

#include "frameobj.h"
#include "noteobj.h"
#include "headingobj.h"
#include "flagrowobj.h"

#define MAX_DEPTH 999

enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
enum LinkStyle {
	StyleUndef,
	StyleLine, 
	StyleParabel, 
	StylePolyLine,
	StylePolyParabel
};
enum LinkPos {LinkMiddle,LinkBottom};
enum LinkColorHint {DefaultColor,HeadingColor};

class LinkableMapObj:public QObject, public MapObj {
	Q_OBJECT
public:
    LinkableMapObj ();
    LinkableMapObj (QCanvas*);
    LinkableMapObj (LinkableMapObj*);
    ~LinkableMapObj ();
	virtual void delLink();
    virtual void init ();
    virtual void copy (LinkableMapObj*);
    void setChildObj (LinkableMapObj*);
    virtual void setParObj (LinkableMapObj*);
    virtual void setParObjTmp (LinkableMapObj*,QPoint,int);	// Only for moving Obj around
	virtual void unsetParObjTmp();						// reuse original ParObj
	virtual bool hasParObjTmp();

	virtual void setUseRelPos (const bool&);
	virtual void setRelPos();				// set relPos to current parentPos
	virtual void setRelPos(const QPoint&);	
	virtual void setUseOrientation (const bool &);


	virtual int getTopPad();
	virtual int getLeftPad();
	virtual int getRightPad();
	LinkStyle getDefLinkStyle();
    void setLinkStyle(LinkStyle);            
	LinkStyle getLinkStyle();
	void setHideLinkUnselected(bool);
	bool getHideLinkUnselected();
	void setLinkPos (LinkPos);
	LinkPos getLinkPos ();

	virtual void setLinkColor();					// sets color according to colorhint, overloaded
	virtual void setLinkColor(QColor);
	QColor getLinkColor();
	virtual FrameType getFrameType ();
	virtual void setFrameType (const FrameType &);
	virtual void setFrameType (const QString &);
	virtual void setVisibility (bool);
    virtual void updateLink();				// update parPos and childPos
											// depending on pos
											// redraw link with given style
    LinkableMapObj* getChildObj();			// returns pointer to fromObj
    LinkableMapObj* getParObj();			// returns pointer to toObj
    virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
	virtual void setDockPos();				// sets childPos and parPos
    QPoint getChildPos();					// returns pos where childs dock
    QPoint getParPos();						// returns pos where parents dock
    QPoint getRelPos();						// get position relative to parent (or (0,0))
    LinkOrient getOrientation();			// get orientation
    virtual int getDepth();					// return depth
	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
	virtual QPoint getRandPos();			// make randomised position

    virtual void alignRelativeTo(const QPoint );
	virtual void reposition();
	virtual void requestReposition();		// do reposition after next user event
	virtual void forceReposition();			// to force a reposition now (outside
											// of mapeditor e.g. in noteeditor
	virtual bool repositionRequested();

	virtual QRect getTotalBBox()=0;			// return BBox including childs			
	virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs  
	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly

	virtual void setSelBox();
    virtual void select();
    virtual void unselect();
	virtual	QString getSelectString()=0;
	virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir

protected:
	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
	QString getLinkAttr();

    QPoint childPos;
    QPoint parPos;
	bool link2ParPos;				// While moving around, sometimes link to parent
	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
    LinkOrient orientation;     
    int linkwidth;					// width of a link
    int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
	QRect bboxTotal;				// bounding box including childs

    LinkableMapObj* childObj;
    LinkableMapObj* parObj;
    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
    int bottomlineY;                // vertical offset of dockpos to pos

	int thickness_start;			// for StylePoly*	
    LinkStyle style;				// Current style
	LinkPos linkpos;				// Link at bottom of object or middle of height
    QColor linkcolor;               // Link color
    QCanvasLine* l;                 // line style
	QCanvasPolygon* p;				// poly styles
    int arcsegs;                    // arc: number of segments
    QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
	QPointArray pa1;				// For drawing of PolyParabel 
	QPointArray pa2;				// For drawing of PolyParabel	
    QCanvasLine* bottomline;        // on bottom of BBox
	bool repositionRequest;			// 

	bool selected;					// Used for marking the selection
	bool hideLinkUnselected;		// to hide links if unselected
	QCanvasRectangle* selbox;
	FrameObj *frame;				// frame around object
	int topPad, botPad,
		leftPad, rightPad;          // padding within bbox

	QPoint relPos;					// position relative to childPos of parent
	bool useRelPos;
	bool useOrientation;
};
#endif