linkablemapobj.h
author insilmaril
Mon, 22 Mar 2010 15:37:23 +0000
changeset 841 46553c106c52
parent 835 31841b366d5e
permissions -rw-r--r--
Fixes for QLineEdit and moving vym.changelog up one level
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@408
     8
insilmaril@616
     9
#define MAX_DEPTH 999
insilmaril@0
    10
insilmaril@721
    11
class VymModel;
insilmaril@790
    12
class TreeItem;
insilmaril@473
    13
insilmaril@473
    14
/*! \brief This class adds links to MapObj 
insilmaril@473
    15
insilmaril@473
    16
The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
insilmaril@473
    17
*/
insilmaril@0
    18
insilmaril@791
    19
class LinkableMapObj:public MapObj {
insilmaril@0
    20
public:
insilmaril@486
    21
	/*! Orientation of an object depends on the position relative to the parent */
insilmaril@473
    22
	enum Orientation {
insilmaril@473
    23
		UndefinedOrientation, //!< Undefined
insilmaril@473
    24
		LeftOfCenter,			//!< Object is left of center
insilmaril@473
    25
		RightOfCenter			//!< Object is right of center
insilmaril@473
    26
	};
insilmaril@473
    27
insilmaril@473
    28
	/*! Various drawing styles for links */
insilmaril@473
    29
	enum Style {
insilmaril@473
    30
		UndefinedStyle,	//!< Undefined
insilmaril@473
    31
		Line,			//!< Straight line
insilmaril@473
    32
		Parabel,		//!< Parabel
insilmaril@473
    33
		PolyLine,		//!< Polygon (thick line)
insilmaril@473
    34
		PolyParabel		//!< Thick parabel
insilmaril@473
    35
	};
insilmaril@473
    36
insilmaril@473
    37
	/*! Vertical position of link in object */
insilmaril@473
    38
	enum Position {
insilmaril@473
    39
		Middle, //!< Link is drawn in the middle of object
insilmaril@473
    40
		Bottom  //!< Link is drawn at bottom of object
insilmaril@473
    41
	};
insilmaril@473
    42
insilmaril@798
    43
insilmaril@473
    44
	/*! Hint if link should use the default link color or the color of heading */
insilmaril@473
    45
	enum ColorHint {
insilmaril@473
    46
		DefaultColor,	//!< Link uses the default color
insilmaril@473
    47
		HeadingColor	//!< Link uses the color of heading
insilmaril@473
    48
	};
insilmaril@473
    49
insilmaril@0
    50
    LinkableMapObj ();
insilmaril@790
    51
    LinkableMapObj (QGraphicsScene*, TreeItem *ti=NULL);
insilmaril@0
    52
    LinkableMapObj (LinkableMapObj*);
insilmaril@791
    53
    virtual ~LinkableMapObj ();
insilmaril@0
    54
	virtual void delLink();
insilmaril@0
    55
    virtual void init ();
insilmaril@0
    56
    virtual void copy (LinkableMapObj*);
insilmaril@721
    57
insilmaril@0
    58
    void setChildObj (LinkableMapObj*);
insilmaril@0
    59
    virtual void setParObj (LinkableMapObj*);
insilmaril@408
    60
    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);	// Only for moving Obj around
insilmaril@0
    61
	virtual void unsetParObjTmp();						// reuse original ParObj
insilmaril@164
    62
	virtual bool hasParObjTmp();
insilmaril@218
    63
insilmaril@218
    64
	virtual void setUseRelPos (const bool&);
insilmaril@835
    65
	virtual bool getUseRelPos();
insilmaril@218
    66
	virtual void setRelPos();				// set relPos to current parentPos
insilmaril@408
    67
	virtual void setRelPos(const QPointF&);	
insilmaril@408
    68
	virtual QPointF getRelPos();
insilmaril@218
    69
insilmaril@408
    70
	virtual qreal getTopPad();
insilmaril@408
    71
	virtual qreal getLeftPad();
insilmaril@408
    72
	virtual qreal getRightPad();
insilmaril@786
    73
	Style getDefLinkStyle(TreeItem *parent);
insilmaril@473
    74
    void setLinkStyle(Style);            
insilmaril@473
    75
	Style getLinkStyle();
insilmaril@779
    76
insilmaril@473
    77
	void setLinkPos (Position);
insilmaril@473
    78
	Position getLinkPos ();
insilmaril@0
    79
insilmaril@779
    80
	virtual void setLinkColor();			// sets color according to colorhint, overloaded
insilmaril@0
    81
	virtual void setLinkColor(QColor);
insilmaril@0
    82
	QColor getLinkColor();
insilmaril@0
    83
	virtual void setVisibility (bool);
insilmaril@388
    84
	virtual void setOrientation();
insilmaril@779
    85
    virtual void updateVisibility();		//! hides/unhides link depending on selection
insilmaril@779
    86
insilmaril@779
    87
    /*! update parPos, childPos 
insilmaril@779
    88
		depending on pos
insilmaril@779
    89
		redraw link with given style */
insilmaril@779
    90
    virtual void updateLinkGeometry();		
insilmaril@779
    91
insilmaril@0
    92
    LinkableMapObj* getChildObj();			// returns pointer to fromObj
insilmaril@0
    93
    LinkableMapObj* getParObj();			// returns pointer to toObj
insilmaril@388
    94
	virtual void setDockPos()=0;				// sets childPos and parPos
insilmaril@721
    95
    QPointF getChildPos();					// returns pos where children dock
insilmaril@408
    96
    QPointF getParPos();						// returns pos where parents dock
insilmaril@473
    97
    Orientation getOrientation();			// get orientation
insilmaril@408
    98
	virtual QPointF getRandPos();			// make randomised position
insilmaril@0
    99
insilmaril@0
   100
	virtual void reposition();
insilmaril@0
   101
	virtual void requestReposition();		// do reposition after next user event
insilmaril@0
   102
	virtual void forceReposition();			// to force a reposition now (outside
insilmaril@0
   103
											// of mapeditor e.g. in noteeditor
insilmaril@0
   104
	virtual bool repositionRequested();
insilmaril@0
   105
insilmaril@721
   106
	virtual void calcBBoxSizeWithChildren()=0;// calc size of  BBox including children recursivly
insilmaril@0
   107
insilmaril@0
   108
protected:
insilmaril@408
   109
	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
insilmaril@160
   110
insilmaril@408
   111
    QPointF childPos;
insilmaril@408
   112
    QPointF parPos;
insilmaril@0
   113
	bool link2ParPos;				// While moving around, sometimes link to parent
insilmaril@721
   114
insilmaril@473
   115
    Orientation orientation;     
insilmaril@408
   116
    qreal linkwidth;				// width of a link
insilmaril@721
   117
	QRectF bboxTotal;				// bounding box including children
insilmaril@0
   118
insilmaril@773
   119
    LinkableMapObj* parObj;		
insilmaril@0
   120
    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
insilmaril@798
   121
	bool tmpParent;
insilmaril@0
   122
insilmaril@0
   123
	int thickness_start;			// for StylePoly*	
insilmaril@473
   124
    Style style;					// Current style
insilmaril@473
   125
	Position linkpos;				// Link at bottom of object or middle of height
insilmaril@0
   126
    QColor linkcolor;               // Link color
insilmaril@408
   127
	QPen pen;
insilmaril@408
   128
    QGraphicsLineItem* l;           // line style
insilmaril@408
   129
	QGraphicsPolygonItem* p;		// poly styles
insilmaril@0
   130
    int arcsegs;                    // arc: number of segments
insilmaril@408
   131
    QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
insilmaril@408
   132
	QPolygonF pa0;					// For drawing of PolyParabel and PolyLine
insilmaril@408
   133
	QPolygonF pa1;					// For drawing of PolyParabel 
insilmaril@408
   134
	QPolygonF pa2;					// For drawing of PolyParabel	
insilmaril@798
   135
insilmaril@408
   136
    QGraphicsLineItem* bottomline;  // on bottom of BBox
insilmaril@798
   137
	bool useBottomline;				//! Hint if bottomline should be used
insilmaril@798
   138
    qreal bottomlineY;              // vertical offset of dockpos to pos
insilmaril@798
   139
insilmaril@0
   140
	bool repositionRequest;			// 
insilmaril@0
   141
insilmaril@408
   142
	qreal topPad, botPad,
insilmaril@175
   143
		leftPad, rightPad;          // padding within bbox
insilmaril@175
   144
insilmaril@473
   145
	QPointF	 relPos;				// position relative to childPos of parent
insilmaril@218
   146
	bool useRelPos;
insilmaril@531
   147
insilmaril@0
   148
};
insilmaril@0
   149
#endif