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