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