linkablemapobj.h
author insilmaril
Tue, 10 Apr 2007 13:22:52 +0000
changeset 447 72afe12da1c8
parent 442 dfbc371b7280
child 473 8b9cfc26638c
permissions -rw-r--r--
1.8.71 Basic support for macros
     1 #ifndef LINKABLEMAPOBJ_H
     2 #define LINKABLEMAPOBJ_H
     3 
     4 #include "noteobj.h"
     5 #include "headingobj.h"
     6 #include "flagrowobj.h"
     7 
     8 
     9 #define MAX_DEPTH 999
    10 
    11 enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
    12 enum LinkStyle {
    13 	StyleUndef,
    14 	StyleLine, 
    15 	StyleParabel, 
    16 	StylePolyLine,
    17 	StylePolyParabel
    18 };
    19 enum LinkPos {LinkMiddle,LinkBottom};
    20 enum LinkColorHint {DefaultColor,HeadingColor};
    21 
    22 class LinkableMapObj:public QObject, public MapObj {
    23 	Q_OBJECT
    24 public:
    25     LinkableMapObj ();
    26     LinkableMapObj (QGraphicsScene*);
    27     LinkableMapObj (LinkableMapObj*);
    28     ~LinkableMapObj ();
    29 	virtual void delLink();
    30     virtual void init ();
    31     virtual void copy (LinkableMapObj*);
    32     void setChildObj (LinkableMapObj*);
    33     virtual void setParObj (LinkableMapObj*);
    34     virtual void setParObjTmp (LinkableMapObj*,QPointF,int);	// Only for moving Obj around
    35 	virtual void unsetParObjTmp();						// reuse original ParObj
    36 	virtual bool hasParObjTmp();
    37 
    38 	virtual void setUseRelPos (const bool&);
    39 	virtual void setRelPos();				// set relPos to current parentPos
    40 	virtual void setRelPos(const QPointF&);	
    41 	virtual QPointF getRelPos();
    42 	virtual void setUseOrientation (const bool &);
    43 
    44 
    45 	virtual qreal getTopPad();
    46 	virtual qreal getLeftPad();
    47 	virtual qreal getRightPad();
    48 	LinkStyle getDefLinkStyle();
    49     void setLinkStyle(LinkStyle);            
    50 	LinkStyle getLinkStyle();
    51 	void setHideLinkUnselected(bool);
    52 	bool getHideLinkUnselected();
    53 	void setLinkPos (LinkPos);
    54 	LinkPos getLinkPos ();
    55 
    56 	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    57 	virtual void setLinkColor(QColor);
    58 	QColor getLinkColor();
    59 	virtual void setVisibility (bool);
    60 	virtual void setOrientation();
    61     virtual void updateLink();				// update parPos and childPos
    62 											// depending on pos
    63 											// redraw link with given style
    64     LinkableMapObj* getChildObj();			// returns pointer to fromObj
    65     LinkableMapObj* getParObj();			// returns pointer to toObj
    66     virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
    67 	virtual void setDockPos()=0;				// sets childPos and parPos
    68     QPointF getChildPos();					// returns pos where childs dock
    69     QPointF getParPos();						// returns pos where parents dock
    70     LinkOrient getOrientation();			// get orientation
    71     virtual int getDepth();					// return depth
    72 	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    73 	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    74 	virtual QPointF getRandPos();			// make randomised position
    75 
    76     //virtual void alignRelativeTo(const QPointF );
    77 	virtual void reposition();
    78 	virtual void requestReposition();		// do reposition after next user event
    79 	virtual void forceReposition();			// to force a reposition now (outside
    80 											// of mapeditor e.g. in noteeditor
    81 	virtual bool repositionRequested();
    82 
    83 	//virtual QRectF getTotalBBox();			// return BBox including childs			
    84 	//virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs  
    85 	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    86 
    87     virtual void select();
    88     virtual void unselect();
    89 	virtual	QString getSelectString()=0;
    90 	//virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
    91 
    92 protected:
    93 	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
    94 	QString getLinkAttr();
    95 
    96     QPointF childPos;
    97     QPointF parPos;
    98 	bool link2ParPos;				// While moving around, sometimes link to parent
    99 	MapEditor* mapEditor;			// for and toggleScroll(), get default styles
   100 									// and mapEditor->updateActions()
   101 									// and mapEditor->updateSelection()
   102     LinkOrient orientation;     
   103     qreal linkwidth;				// width of a link
   104     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
   105 	QRectF bboxTotal;				// bounding box including childs
   106 
   107     LinkableMapObj* childObj;
   108     LinkableMapObj* parObj;
   109     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
   110     qreal bottomlineY;              // vertical offset of dockpos to pos
   111 
   112 	int thickness_start;			// for StylePoly*	
   113     LinkStyle style;				// Current style
   114 	LinkPos linkpos;				// Link at bottom of object or middle of height
   115     QColor linkcolor;               // Link color
   116 	QPen pen;
   117     QGraphicsLineItem* l;           // line style
   118 	QGraphicsPolygonItem* p;		// poly styles
   119     int arcsegs;                    // arc: number of segments
   120     QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
   121 	QPolygonF pa0;					// For drawing of PolyParabel and PolyLine
   122 	QPolygonF pa1;					// For drawing of PolyParabel 
   123 	QPolygonF pa2;					// For drawing of PolyParabel	
   124     QGraphicsLineItem* bottomline;  // on bottom of BBox
   125 	bool repositionRequest;			// 
   126 
   127 	bool selected;					// Used for marking the selection
   128 	bool hideLinkUnselected;		// to hide links if unselected
   129 	qreal topPad, botPad,
   130 		leftPad, rightPad;          // padding within bbox
   131 
   132 	QPointF relPos;					// position relative to childPos of parent
   133 	bool useRelPos;
   134 	bool useOrientation;
   135 };
   136 #endif