linkablemapobj.h
author insilmaril
Thu, 06 Aug 2009 10:42:17 +0000
changeset 786 6269016c9905
parent 780 fe839bdfd10c
child 790 133e2ed6b9c5
permissions -rw-r--r--
First changes to allow attributes
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
insilmaril@0
    63
    void setChildObj (LinkableMapObj*);
insilmaril@0
    64
    virtual void setParObj (LinkableMapObj*);
insilmaril@408
    65
    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);	// Only for moving Obj around
insilmaril@0
    66
	virtual void unsetParObjTmp();						// reuse original ParObj
insilmaril@164
    67
	virtual bool hasParObjTmp();
insilmaril@218
    68
insilmaril@218
    69
	virtual void setUseRelPos (const bool&);
insilmaril@218
    70
	virtual void setRelPos();				// set relPos to current parentPos
insilmaril@408
    71
	virtual void setRelPos(const QPointF&);	
insilmaril@408
    72
	virtual QPointF getRelPos();
insilmaril@218
    73
insilmaril@408
    74
	virtual qreal getTopPad();
insilmaril@408
    75
	virtual qreal getLeftPad();
insilmaril@408
    76
	virtual qreal getRightPad();
insilmaril@786
    77
	Style getDefLinkStyle(TreeItem *parent);
insilmaril@473
    78
    void setLinkStyle(Style);            
insilmaril@473
    79
	Style getLinkStyle();
insilmaril@779
    80
insilmaril@779
    81
	void setHideLinkUnselected();
insilmaril@473
    82
	void setLinkPos (Position);
insilmaril@473
    83
	Position getLinkPos ();
insilmaril@0
    84
insilmaril@779
    85
	virtual void setLinkColor();			// sets color according to colorhint, overloaded
insilmaril@0
    86
	virtual void setLinkColor(QColor);
insilmaril@0
    87
	QColor getLinkColor();
insilmaril@0
    88
	virtual void setVisibility (bool);
insilmaril@388
    89
	virtual void setOrientation();
insilmaril@779
    90
    virtual void updateVisibility();		//! hides/unhides link depending on selection
insilmaril@779
    91
insilmaril@779
    92
    /*! update parPos, childPos 
insilmaril@779
    93
		depending on pos
insilmaril@779
    94
		redraw link with given style */
insilmaril@779
    95
    virtual void updateLinkGeometry();		
insilmaril@779
    96
insilmaril@0
    97
    LinkableMapObj* getChildObj();			// returns pointer to fromObj
insilmaril@0
    98
    LinkableMapObj* getParObj();			// returns pointer to toObj
insilmaril@388
    99
	virtual void setDockPos()=0;				// sets childPos and parPos
insilmaril@721
   100
    QPointF getChildPos();					// returns pos where children dock
insilmaril@408
   101
    QPointF getParPos();						// returns pos where parents dock
insilmaril@473
   102
    Orientation getOrientation();			// get orientation
insilmaril@408
   103
	virtual QPointF getRandPos();			// make randomised position
insilmaril@0
   104
insilmaril@0
   105
	virtual void reposition();
insilmaril@0
   106
	virtual void requestReposition();		// do reposition after next user event
insilmaril@0
   107
	virtual void forceReposition();			// to force a reposition now (outside
insilmaril@0
   108
											// of mapeditor e.g. in noteeditor
insilmaril@0
   109
	virtual bool repositionRequested();
insilmaril@0
   110
insilmaril@721
   111
	virtual void calcBBoxSizeWithChildren()=0;// calc size of  BBox including children recursivly
insilmaril@0
   112
insilmaril@0
   113
protected:
insilmaril@408
   114
	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
insilmaril@160
   115
insilmaril@408
   116
    QPointF childPos;
insilmaril@408
   117
    QPointF parPos;
insilmaril@0
   118
	bool link2ParPos;				// While moving around, sometimes link to parent
insilmaril@721
   119
insilmaril@473
   120
    Orientation orientation;     
insilmaril@408
   121
    qreal linkwidth;				// width of a link
insilmaril@721
   122
	QRectF bboxTotal;				// bounding box including children
insilmaril@0
   123
insilmaril@773
   124
    LinkableMapObj* parObj;		
insilmaril@0
   125
    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
insilmaril@408
   126
    qreal bottomlineY;              // vertical offset of dockpos to pos
insilmaril@0
   127
insilmaril@0
   128
	int thickness_start;			// for StylePoly*	
insilmaril@473
   129
    Style style;					// Current style
insilmaril@473
   130
	Position linkpos;				// Link at bottom of object or middle of height
insilmaril@0
   131
    QColor linkcolor;               // Link color
insilmaril@408
   132
	QPen pen;
insilmaril@408
   133
    QGraphicsLineItem* l;           // line style
insilmaril@408
   134
	QGraphicsPolygonItem* p;		// poly styles
insilmaril@0
   135
    int arcsegs;                    // arc: number of segments
insilmaril@408
   136
    QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
insilmaril@408
   137
	QPolygonF pa0;					// For drawing of PolyParabel and PolyLine
insilmaril@408
   138
	QPolygonF pa1;					// For drawing of PolyParabel 
insilmaril@408
   139
	QPolygonF pa2;					// For drawing of PolyParabel	
insilmaril@408
   140
    QGraphicsLineItem* bottomline;  // on bottom of BBox
insilmaril@0
   141
	bool repositionRequest;			// 
insilmaril@0
   142
insilmaril@408
   143
	qreal topPad, botPad,
insilmaril@175
   144
		leftPad, rightPad;          // padding within bbox
insilmaril@175
   145
insilmaril@473
   146
	QPointF	 relPos;				// position relative to childPos of parent
insilmaril@218
   147
	bool useRelPos;
insilmaril@531
   148
insilmaril@726
   149
	TreeItem *treeItem;				// Crossrefence to treemodel
insilmaril@0
   150
};
insilmaril@0
   151
#endif