linkablemapobj.h
author insilmaril
Tue, 05 Sep 2006 09:47:13 +0000
changeset 365 1cc73bd7ee1f
parent 226 5e684bfe5bb1
child 366 e95081c21da2
permissions -rw-r--r--
Moved the qt4-port branch to HEAD
     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 
    38 	virtual void setUseRelPos (const bool&);
    39 	virtual void setRelPos();				// set relPos to current parentPos
    40 	virtual void setRelPos(const QPoint&);	
    41 	virtual void setUseOrientation (const bool &);
    42 
    43 
    44 	virtual int getTopPad();
    45 	virtual int getLeftPad();
    46 	virtual int getRightPad();
    47 	LinkStyle getDefLinkStyle();
    48     void setLinkStyle(LinkStyle);            
    49 	LinkStyle getLinkStyle();
    50 	void setHideLinkUnselected(bool);
    51 	bool getHideLinkUnselected();
    52 	void setLinkPos (LinkPos);
    53 	LinkPos getLinkPos ();
    54 
    55 	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    56 	virtual void setLinkColor(QColor);
    57 	QColor getLinkColor();
    58 	virtual FrameType getFrameType ();
    59 	virtual void setFrameType (const FrameType &);
    60 	virtual void setFrameType (const QString &);
    61 	virtual void setVisibility (bool);
    62     virtual void updateLink();				// update parPos and childPos
    63 											// depending on pos
    64 											// redraw link with given style
    65     LinkableMapObj* getChildObj();			// returns pointer to fromObj
    66     LinkableMapObj* getParObj();			// returns pointer to toObj
    67     virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
    68 	virtual void setDockPos();				// sets childPos and parPos
    69     QPoint getChildPos();					// returns pos where childs dock
    70     QPoint getParPos();						// returns pos where parents dock
    71     QPoint getRelPos();						// get position relative to parent (or (0,0))
    72     LinkOrient getOrientation();			// get orientation
    73     virtual int getDepth();					// return depth
    74 	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    75 	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    76 	virtual QPoint getRandPos();			// make randomised position
    77 
    78     virtual void alignRelativeTo(const QPoint );
    79 	virtual void reposition();
    80 	virtual void requestReposition();		// do reposition after next user event
    81 	virtual void forceReposition();			// to force a reposition now (outside
    82 											// of mapeditor e.g. in noteeditor
    83 	virtual bool repositionRequested();
    84 
    85 	virtual QRect getTotalBBox()=0;			// return BBox including childs			
    86 	virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs  
    87 	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    88 
    89 	virtual void setSelBox();
    90     virtual void select();
    91     virtual void unselect();
    92 	virtual	QString getSelectString()=0;
    93 	virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir
    94 
    95 protected:
    96 	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
    97 	QString getLinkAttr();
    98 
    99     QPoint childPos;
   100     QPoint parPos;
   101 	bool link2ParPos;				// While moving around, sometimes link to parent
   102 	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
   103     LinkOrient orientation;     
   104     int linkwidth;					// width of a link
   105     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
   106 	QRect bboxTotal;				// bounding box including childs
   107 
   108     LinkableMapObj* childObj;
   109     LinkableMapObj* parObj;
   110     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
   111     int bottomlineY;                // vertical offset of dockpos to pos
   112 
   113 	int thickness_start;			// for StylePoly*	
   114     LinkStyle style;				// Current style
   115 	LinkPos linkpos;				// Link at bottom of object or middle of height
   116     QColor linkcolor;               // Link color
   117     QCanvasLine* l;                 // line style
   118 	QCanvasPolygon* p;				// poly styles
   119     int arcsegs;                    // arc: number of segments
   120     QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
   121 	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
   122 	QPointArray pa1;				// For drawing of PolyParabel 
   123 	QPointArray pa2;				// For drawing of PolyParabel	
   124     QCanvasLine* 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 	QCanvasRectangle* selbox;
   130 	FrameObj *frame;				// frame around object
   131 	int topPad, botPad,
   132 		leftPad, rightPad;          // padding within bbox
   133 
   134 	QPoint relPos;					// position relative to childPos of parent
   135 	bool useRelPos;
   136 	bool useOrientation;
   137 };
   138 #endif