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