linkablemapobj.h
author insilmaril
Mon, 20 Nov 2006 12:12:00 +0000
changeset 403 7c3ee77f4449
parent 388 3a58c9ef4a18
child 406 1c8ff1928b97
permissions -rw-r--r--
historywindow moved to mainwindow. Started to get rid of Q3PtrList finally
insilmaril@0
     1
#ifndef LINKABLEMAPOBJ_H
insilmaril@0
     2
#define LINKABLEMAPOBJ_H
insilmaril@0
     3
insilmaril@0
     4
#include "frameobj.h"
insilmaril@0
     5
#include "noteobj.h"
insilmaril@0
     6
#include "headingobj.h"
insilmaril@0
     7
#include "flagrowobj.h"
insilmaril@366
     8
//Added by qt3to4:
insilmaril@366
     9
#include <Q3PointArray>
insilmaril@366
    10
#include <Q3PtrList>
insilmaril@0
    11
insilmaril@0
    12
#define MAX_DEPTH 999
insilmaril@0
    13
insilmaril@0
    14
enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
insilmaril@0
    15
enum LinkStyle {
insilmaril@0
    16
	StyleUndef,
insilmaril@0
    17
	StyleLine, 
insilmaril@0
    18
	StyleParabel, 
insilmaril@0
    19
	StylePolyLine,
insilmaril@0
    20
	StylePolyParabel
insilmaril@0
    21
};
insilmaril@0
    22
enum LinkPos {LinkMiddle,LinkBottom};
insilmaril@0
    23
enum LinkColorHint {DefaultColor,HeadingColor};
insilmaril@0
    24
insilmaril@0
    25
class LinkableMapObj:public QObject, public MapObj {
insilmaril@0
    26
	Q_OBJECT
insilmaril@0
    27
public:
insilmaril@0
    28
    LinkableMapObj ();
insilmaril@366
    29
    LinkableMapObj (Q3Canvas*);
insilmaril@0
    30
    LinkableMapObj (LinkableMapObj*);
insilmaril@0
    31
    ~LinkableMapObj ();
insilmaril@0
    32
	virtual void delLink();
insilmaril@0
    33
    virtual void init ();
insilmaril@0
    34
    virtual void copy (LinkableMapObj*);
insilmaril@0
    35
    void setChildObj (LinkableMapObj*);
insilmaril@0
    36
    virtual void setParObj (LinkableMapObj*);
insilmaril@0
    37
    virtual void setParObjTmp (LinkableMapObj*,QPoint,int);	// Only for moving Obj around
insilmaril@0
    38
	virtual void unsetParObjTmp();						// reuse original ParObj
insilmaril@164
    39
	virtual bool hasParObjTmp();
insilmaril@218
    40
insilmaril@218
    41
	virtual void setUseRelPos (const bool&);
insilmaril@218
    42
	virtual void setRelPos();				// set relPos to current parentPos
insilmaril@218
    43
	virtual void setRelPos(const QPoint&);	
insilmaril@366
    44
	virtual QPoint getRelPos();
insilmaril@218
    45
	virtual void setUseOrientation (const bool &);
insilmaril@218
    46
insilmaril@218
    47
insilmaril@175
    48
	virtual int getTopPad();
insilmaril@175
    49
	virtual int getLeftPad();
insilmaril@175
    50
	virtual int getRightPad();
insilmaril@0
    51
	LinkStyle getDefLinkStyle();
insilmaril@0
    52
    void setLinkStyle(LinkStyle);            
insilmaril@0
    53
	LinkStyle getLinkStyle();
insilmaril@160
    54
	void setHideLinkUnselected(bool);
insilmaril@160
    55
	bool getHideLinkUnselected();
insilmaril@0
    56
	void setLinkPos (LinkPos);
insilmaril@0
    57
	LinkPos getLinkPos ();
insilmaril@0
    58
insilmaril@0
    59
	virtual void setLinkColor();					// sets color according to colorhint, overloaded
insilmaril@0
    60
	virtual void setLinkColor(QColor);
insilmaril@0
    61
	QColor getLinkColor();
insilmaril@0
    62
	virtual FrameType getFrameType ();
insilmaril@0
    63
	virtual void setFrameType (const FrameType &);
insilmaril@0
    64
	virtual void setFrameType (const QString &);
insilmaril@0
    65
	virtual void setVisibility (bool);
insilmaril@388
    66
	virtual void setOrientation();
insilmaril@0
    67
    virtual void updateLink();				// update parPos and childPos
insilmaril@0
    68
											// depending on pos
insilmaril@0
    69
											// redraw link with given style
insilmaril@0
    70
    LinkableMapObj* getChildObj();			// returns pointer to fromObj
insilmaril@0
    71
    LinkableMapObj* getParObj();			// returns pointer to toObj
insilmaril@106
    72
    virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
insilmaril@388
    73
	virtual void setDockPos()=0;				// sets childPos and parPos
insilmaril@0
    74
    QPoint getChildPos();					// returns pos where childs dock
insilmaril@0
    75
    QPoint getParPos();						// returns pos where parents dock
insilmaril@0
    76
    LinkOrient getOrientation();			// get orientation
insilmaril@0
    77
    virtual int getDepth();					// return depth
insilmaril@0
    78
	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
insilmaril@0
    79
	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
insilmaril@0
    80
	virtual QPoint getRandPos();			// make randomised position
insilmaril@0
    81
insilmaril@388
    82
    //virtual void alignRelativeTo(const QPoint );
insilmaril@0
    83
	virtual void reposition();
insilmaril@0
    84
	virtual void requestReposition();		// do reposition after next user event
insilmaril@0
    85
	virtual void forceReposition();			// to force a reposition now (outside
insilmaril@0
    86
											// of mapeditor e.g. in noteeditor
insilmaril@0
    87
	virtual bool repositionRequested();
insilmaril@0
    88
insilmaril@377
    89
	//virtual QRect getTotalBBox();			// return BBox including childs			
insilmaril@377
    90
	//virtual QRect getBBoxSizeWithChilds();// return size of BBox including childs  
insilmaril@0
    91
	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
insilmaril@0
    92
insilmaril@0
    93
	virtual void setSelBox();
insilmaril@0
    94
    virtual void select();
insilmaril@0
    95
    virtual void unselect();
insilmaril@0
    96
	virtual	QString getSelectString()=0;
insilmaril@377
    97
	//virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data to XML
insilmaril@0
    98
insilmaril@0
    99
protected:
insilmaril@366
   100
	void parabel(Q3PointArray &,double,double,double,double);	// Create Parabel connecting two points
insilmaril@160
   101
	QString getLinkAttr();
insilmaril@160
   102
insilmaril@0
   103
    QPoint childPos;
insilmaril@0
   104
    QPoint parPos;
insilmaril@0
   105
	bool link2ParPos;				// While moving around, sometimes link to parent
insilmaril@0
   106
	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
insilmaril@0
   107
    LinkOrient orientation;     
insilmaril@0
   108
    int linkwidth;					// width of a link
insilmaril@0
   109
    int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
insilmaril@0
   110
	QRect bboxTotal;				// bounding box including childs
insilmaril@0
   111
insilmaril@0
   112
    LinkableMapObj* childObj;
insilmaril@0
   113
    LinkableMapObj* parObj;
insilmaril@0
   114
    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
insilmaril@175
   115
    int bottomlineY;                // vertical offset of dockpos to pos
insilmaril@0
   116
insilmaril@0
   117
	int thickness_start;			// for StylePoly*	
insilmaril@160
   118
    LinkStyle style;				// Current style
insilmaril@226
   119
	LinkPos linkpos;				// Link at bottom of object or middle of height
insilmaril@0
   120
    QColor linkcolor;               // Link color
insilmaril@366
   121
    Q3CanvasLine* l;                 // line style
insilmaril@366
   122
	Q3CanvasPolygon* p;				// poly styles
insilmaril@0
   123
    int arcsegs;                    // arc: number of segments
insilmaril@366
   124
    Q3PtrList <Q3CanvasLine> segment; // a part of e.g. the parabel
insilmaril@366
   125
	Q3PointArray pa0;				// For drawing of PolyParabel and PolyLine
insilmaril@366
   126
	Q3PointArray pa1;				// For drawing of PolyParabel 
insilmaril@366
   127
	Q3PointArray pa2;				// For drawing of PolyParabel	
insilmaril@366
   128
    Q3CanvasLine* bottomline;        // on bottom of BBox
insilmaril@0
   129
	bool repositionRequest;			// 
insilmaril@0
   130
insilmaril@0
   131
	bool selected;					// Used for marking the selection
insilmaril@160
   132
	bool hideLinkUnselected;		// to hide links if unselected
insilmaril@366
   133
	Q3CanvasRectangle* selbox;
insilmaril@0
   134
	FrameObj *frame;				// frame around object
insilmaril@175
   135
	int topPad, botPad,
insilmaril@175
   136
		leftPad, rightPad;          // padding within bbox
insilmaril@175
   137
insilmaril@226
   138
	QPoint relPos;					// position relative to childPos of parent
insilmaril@218
   139
	bool useRelPos;
insilmaril@218
   140
	bool useOrientation;
insilmaril@0
   141
};
insilmaril@0
   142
#endif