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