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