linkablemapobj.h
author insilmaril
Thu, 23 Apr 2009 12:15:31 +0000
changeset 755 ed5b407975b3
parent 754 db0ec4bcf416
child 757 c6908bc17d78
permissions -rw-r--r--
more data in Tree, less in Map
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@726
     8
#include "treeitem.h"
insilmaril@408
     9
insilmaril@616
    10
#define MAX_DEPTH 999
insilmaril@0
    11
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@755
    22
	Q_OBJECT		// FIXME-3 really needed here?
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@726
    60
	virtual void setTreeItem(TreeItem *);
insilmaril@753
    61
	virtual TreeItem* getTreeItem() const;
insilmaril@721
    62
	virtual void setModel (VymModel *vm);
insilmaril@721
    63
	virtual VymModel* getModel ();
insilmaril@721
    64
insilmaril@0
    65
    void setChildObj (LinkableMapObj*);
insilmaril@0
    66
    virtual void setParObj (LinkableMapObj*);
insilmaril@408
    67
    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);	// Only for moving Obj around
insilmaril@0
    68
	virtual void unsetParObjTmp();						// reuse original ParObj
insilmaril@164
    69
	virtual bool hasParObjTmp();
insilmaril@218
    70
insilmaril@218
    71
	virtual void setUseRelPos (const bool&);
insilmaril@218
    72
	virtual void setRelPos();				// set relPos to current parentPos
insilmaril@408
    73
	virtual void setRelPos(const QPointF&);	
insilmaril@408
    74
	virtual QPointF getRelPos();
insilmaril@218
    75
	virtual void setUseOrientation (const bool &);
insilmaril@218
    76
insilmaril@218
    77
insilmaril@408
    78
	virtual qreal getTopPad();
insilmaril@408
    79
	virtual qreal getLeftPad();
insilmaril@408
    80
	virtual qreal getRightPad();
insilmaril@473
    81
	Style getDefLinkStyle();
insilmaril@473
    82
    void setLinkStyle(Style);            
insilmaril@473
    83
	Style getLinkStyle();
insilmaril@160
    84
	void setHideLinkUnselected(bool);
insilmaril@160
    85
	bool getHideLinkUnselected();
insilmaril@473
    86
	void setLinkPos (Position);
insilmaril@473
    87
	Position getLinkPos ();
insilmaril@0
    88
insilmaril@0
    89
	virtual void setLinkColor();					// sets color according to colorhint, overloaded
insilmaril@0
    90
	virtual void setLinkColor(QColor);
insilmaril@0
    91
	QColor getLinkColor();
insilmaril@0
    92
	virtual void setVisibility (bool);
insilmaril@388
    93
	virtual void setOrientation();
insilmaril@0
    94
    virtual void updateLink();				// update parPos and childPos
insilmaril@0
    95
											// depending on pos
insilmaril@0
    96
											// redraw link with given style
insilmaril@0
    97
    LinkableMapObj* getChildObj();			// returns pointer to fromObj
insilmaril@0
    98
    LinkableMapObj* getParObj();			// returns pointer to toObj
insilmaril@106
    99
    virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
insilmaril@388
   100
	virtual void setDockPos()=0;				// sets childPos and parPos
insilmaril@721
   101
    QPointF getChildPos();					// returns pos where children dock
insilmaril@408
   102
    QPointF getParPos();						// returns pos where parents dock
insilmaril@473
   103
    Orientation getOrientation();			// get orientation
insilmaril@408
   104
	virtual QPointF getRandPos();			// make randomised position
insilmaril@0
   105
insilmaril@0
   106
	virtual void reposition();
insilmaril@0
   107
	virtual void requestReposition();		// do reposition after next user event
insilmaril@0
   108
	virtual void forceReposition();			// to force a reposition now (outside
insilmaril@0
   109
											// of mapeditor e.g. in noteeditor
insilmaril@0
   110
	virtual bool repositionRequested();
insilmaril@0
   111
insilmaril@721
   112
	virtual void calcBBoxSizeWithChildren()=0;// calc size of  BBox including children recursivly
insilmaril@0
   113
insilmaril@0
   114
    virtual void select();
insilmaril@0
   115
    virtual void unselect();
insilmaril@0
   116
insilmaril@0
   117
protected:
insilmaril@408
   118
	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
insilmaril@160
   119
	QString getLinkAttr();
insilmaril@160
   120
insilmaril@408
   121
    QPointF childPos;
insilmaril@408
   122
    QPointF parPos;
insilmaril@0
   123
	bool link2ParPos;				// While moving around, sometimes link to parent
insilmaril@721
   124
insilmaril@721
   125
	VymModel* model;												
insilmaril@473
   126
    Orientation orientation;     
insilmaril@408
   127
    qreal linkwidth;				// width of a link
insilmaril@721
   128
	QRectF bboxTotal;				// bounding box including children
insilmaril@0
   129
insilmaril@0
   130
    LinkableMapObj* childObj;
insilmaril@755
   131
    LinkableMapObj* parObj;		// FIXME-2 really still needed? Better get from TreeItem
insilmaril@0
   132
    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
insilmaril@408
   133
    qreal bottomlineY;              // vertical offset of dockpos to pos
insilmaril@0
   134
insilmaril@0
   135
	int thickness_start;			// for StylePoly*	
insilmaril@473
   136
    Style style;					// Current style
insilmaril@473
   137
	Position linkpos;				// Link at bottom of object or middle of height
insilmaril@0
   138
    QColor linkcolor;               // Link color
insilmaril@408
   139
	QPen pen;
insilmaril@408
   140
    QGraphicsLineItem* l;           // line style
insilmaril@408
   141
	QGraphicsPolygonItem* p;		// poly styles
insilmaril@0
   142
    int arcsegs;                    // arc: number of segments
insilmaril@408
   143
    QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
insilmaril@408
   144
	QPolygonF pa0;					// For drawing of PolyParabel and PolyLine
insilmaril@408
   145
	QPolygonF pa1;					// For drawing of PolyParabel 
insilmaril@408
   146
	QPolygonF pa2;					// For drawing of PolyParabel	
insilmaril@408
   147
    QGraphicsLineItem* bottomline;  // on bottom of BBox
insilmaril@0
   148
	bool repositionRequest;			// 
insilmaril@0
   149
insilmaril@0
   150
	bool selected;					// Used for marking the selection
insilmaril@160
   151
	bool hideLinkUnselected;		// to hide links if unselected
insilmaril@408
   152
	qreal topPad, botPad,
insilmaril@175
   153
		leftPad, rightPad;          // padding within bbox
insilmaril@175
   154
insilmaril@473
   155
	QPointF	 relPos;				// position relative to childPos of parent
insilmaril@473
   156
	//AnimPoint relPos;				// position relative to childPos of parent
insilmaril@218
   157
	bool useRelPos;
insilmaril@218
   158
	bool useOrientation;
insilmaril@531
   159
insilmaril@726
   160
	TreeItem *treeItem;				// Crossrefence to treemodel
insilmaril@0
   161
};
insilmaril@0
   162
#endif