linkablemapobj.h
author insilmaril
Mon, 05 Sep 2005 11:56:31 +0000
changeset 160 72cc3873306a
parent 106 4083860dd82e
child 164 d442a66e9121
permissions -rw-r--r--
Version 1.7.4, various bugfixes
     1 #ifndef LINKABLEMAPOBJ_H
     2 #define LINKABLEMAPOBJ_H
     3 
     4 #include "frameobj.h"
     5 #include "noteobj.h"
     6 #include "headingobj.h"
     7 #include "flagrowobj.h"
     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 (QCanvas*);
    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*,QPoint,int);	// Only for moving Obj around
    35 	virtual void unsetParObjTmp();						// reuse original ParObj
    36 	LinkStyle getDefLinkStyle();
    37     void setLinkStyle(LinkStyle);            
    38 	LinkStyle getLinkStyle();
    39 	void setHideLinkUnselected(bool);
    40 	bool getHideLinkUnselected();
    41 	void setLinkPos (LinkPos);
    42 	LinkPos getLinkPos ();
    43 
    44 	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    45 	virtual void setLinkColor(QColor);
    46 	QColor getLinkColor();
    47 	virtual FrameType getFrameType ();
    48 	virtual void setFrameType (const FrameType &);
    49 	virtual void setFrameType (const QString &);
    50 	virtual void setVisibility (bool);
    51     virtual void updateLink();				// update parPos and childPos
    52 											// depending on pos
    53 											// redraw link with given style
    54     LinkableMapObj* getChildObj();			// returns pointer to fromObj
    55     LinkableMapObj* getParObj();			// returns pointer to toObj
    56     virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
    57     QPoint getChildPos();					// returns pos where childs dock
    58     QPoint getParPos();						// returns pos where parents dock
    59     QPoint getRelPos();						// get position relative to parent (or (0,0))
    60     LinkOrient getOrientation();			// get orientation
    61     virtual int getDepth();					// return depth
    62 	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    63 	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    64 	virtual QPoint getRandPos();			// make randomised position
    65 
    66     virtual void alignRelativeTo(const QPoint );
    67 	virtual void reposition();
    68 	virtual void requestReposition();		// do reposition after next user event
    69 	virtual void forceReposition();			// to force a reposition now (outside
    70 											// of mapeditor e.g. in noteeditor
    71 	virtual bool repositionRequested();
    72 
    73 	virtual QRect getTotalBBox()=0;			// return BBox including childs			
    74 	virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs  
    75 	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    76 
    77 	virtual void setSelBox();
    78     virtual void select();
    79     virtual void unselect();
    80 	virtual	QString getSelectString()=0;
    81 
    82 protected:
    83 	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
    84 	QString getLinkAttr();
    85 
    86     QPoint childPos;
    87     QPoint parPos;
    88 	bool link2ParPos;				// While moving around, sometimes link to parent
    89 	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
    90     LinkOrient orientation;     
    91     int linkwidth;					// width of a link
    92     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
    93 	QRect bboxTotal;				// bounding box including childs
    94 
    95     LinkableMapObj* childObj;
    96     LinkableMapObj* parObj;
    97     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
    98     int offset;                     // vertical offset of dockpos to pos
    99 
   100 	int thickness_start;			// for StylePoly*	
   101     LinkStyle style;				// Current style
   102 	LinkPos linkpos;
   103     QColor linkcolor;               // Link color
   104     QCanvasLine* l;                 // line style
   105 	QCanvasPolygon* p;				// poly styles
   106     int arcsegs;                    // arc: number of segments
   107     QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
   108 	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
   109 	QPointArray pa1;				// For drawing of PolyParabel 
   110 	QPointArray pa2;				// For drawing of PolyParabel	
   111     QCanvasLine* bottomline;        // on bottom of BBox
   112 	bool repositionRequest;			// 
   113 
   114 	bool selected;					// Used for marking the selection
   115 	bool hideLinkUnselected;		// to hide links if unselected
   116 	QCanvasRectangle* selbox;
   117 	FrameObj *frame;				// frame around object
   118 };
   119 #endif