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