xlinkobj.h
author insilmaril
Wed Oct 29 17:42:34 2008 +0000 (2008-10-29)
changeset 727 96402b172173
parent 478 f4aae4fdc1bc
child 790 133e2ed6b9c5
permissions -rw-r--r--
subtrees can be deleted now
insilmaril@95
     1
#ifndef XLINKOBJ_H
insilmaril@95
     2
#define XLINKOBJ_H
insilmaril@95
     3
insilmaril@95
     4
#include "linkablemapobj.h"
insilmaril@95
     5
insilmaril@621
     6
class BranchObj;
insilmaril@621
     7
insilmaril@95
     8
enum XLinkState {undefinedXLink,initXLink,activeXLink,deleteXLink};
insilmaril@95
     9
insilmaril@478
    10
/*! \brief xlinks are used to draw arbitrary connections between branches (BranchObj) in the map. */
insilmaril@478
    11
insilmaril@95
    12
/////////////////////////////////////////////////////////////////////////////
insilmaril@95
    13
class XLinkObj:public MapObj {
insilmaril@95
    14
public:
insilmaril@95
    15
    XLinkObj ();
insilmaril@408
    16
    XLinkObj (QGraphicsScene*);
insilmaril@95
    17
    ~XLinkObj ();
insilmaril@95
    18
    virtual void init ();
insilmaril@95
    19
    virtual void copy (XLinkObj*);
insilmaril@95
    20
	void setBegin (BranchObj*);
insilmaril@299
    21
	BranchObj* getBegin();
insilmaril@95
    22
	void setEnd   (BranchObj*);
insilmaril@408
    23
	void setEnd   (QPointF);
insilmaril@299
    24
	BranchObj* getEnd();
insilmaril@95
    25
	void setColor(QColor);
insilmaril@97
    26
	QColor getColor();
insilmaril@97
    27
	void setWidth (int);
insilmaril@97
    28
	int getWidth ();
insilmaril@95
    29
	bool activate ();			// Sets pointers in branchObjects
insilmaril@95
    30
	void deactivate();			// removes those pointers
insilmaril@95
    31
	bool isUsed();				// true, if at least on branch uses it
insilmaril@95
    32
	void updateXLink();
insilmaril@95
    33
	BranchObj* otherBranch (BranchObj*);
insilmaril@95
    34
	void positionBBox();
insilmaril@95
    35
	void calcBBoxSize();
insilmaril@95
    36
	void setVisibility (bool);
insilmaril@95
    37
	void setVisibility ();
insilmaril@95
    38
	QString saveToDir ();
insilmaril@95
    39
insilmaril@95
    40
private:
insilmaril@95
    41
	static int arrowSize;
insilmaril@408
    42
	QPen pen;
insilmaril@97
    43
	QColor color;
insilmaril@97
    44
	int width;
insilmaril@408
    45
	QGraphicsLineItem *line;
insilmaril@408
    46
	QGraphicsPolygonItem *poly;
insilmaril@95
    47
	BranchObj *beginBranch;
insilmaril@95
    48
	BranchObj *endBranch;
insilmaril@95
    49
	BranchObj *visBranch;	// the "visible" part of a partially scrolled link
insilmaril@95
    50
	XLinkState xLinkState;	// init during drawing or active
insilmaril@408
    51
	QPointF beginPos;
insilmaril@408
    52
	QPointF   endPos;
insilmaril@95
    53
};
insilmaril@95
    54
insilmaril@95
    55
#endif