linkablemapobj.h
author insilmaril
Tue, 05 Sep 2006 10:03:29 +0000
changeset 369 1f6263d403a0
parent 366 e95081c21da2
child 377 5391ab620c95
permissions -rw-r--r--
Moved 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 //Added by qt3to4:
     9 #include <Q3PointArray>
    10 #include <Q3PtrList>
    11 
    12 #define MAX_DEPTH 999
    13 
    14 enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
    15 enum LinkStyle {
    16 	StyleUndef,
    17 	StyleLine, 
    18 	StyleParabel, 
    19 	StylePolyLine,
    20 	StylePolyParabel
    21 };
    22 enum LinkPos {LinkMiddle,LinkBottom};
    23 enum LinkColorHint {DefaultColor,HeadingColor};
    24 
    25 class LinkableMapObj:public QObject, public MapObj {
    26 	Q_OBJECT
    27 public:
    28     LinkableMapObj ();
    29     LinkableMapObj (Q3Canvas*);
    30     LinkableMapObj (LinkableMapObj*);
    31     ~LinkableMapObj ();
    32 	virtual void delLink();
    33     virtual void init ();
    34     virtual void copy (LinkableMapObj*);
    35     void setChildObj (LinkableMapObj*);
    36     virtual void setParObj (LinkableMapObj*);
    37     virtual void setParObjTmp (LinkableMapObj*,QPoint,int);	// Only for moving Obj around
    38 	virtual void unsetParObjTmp();						// reuse original ParObj
    39 	virtual bool hasParObjTmp();
    40 
    41 	virtual void setUseRelPos (const bool&);
    42 	virtual void setRelPos();				// set relPos to current parentPos
    43 	virtual void setRelPos(const QPoint&);	
    44 	virtual QPoint getRelPos();
    45 	virtual void setUseOrientation (const bool &);
    46 
    47 
    48 	virtual int getTopPad();
    49 	virtual int getLeftPad();
    50 	virtual int getRightPad();
    51 	LinkStyle getDefLinkStyle();
    52     void setLinkStyle(LinkStyle);            
    53 	LinkStyle getLinkStyle();
    54 	void setHideLinkUnselected(bool);
    55 	bool getHideLinkUnselected();
    56 	void setLinkPos (LinkPos);
    57 	LinkPos getLinkPos ();
    58 
    59 	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    60 	virtual void setLinkColor(QColor);
    61 	QColor getLinkColor();
    62 	virtual FrameType getFrameType ();
    63 	virtual void setFrameType (const FrameType &);
    64 	virtual void setFrameType (const QString &);
    65 	virtual void setVisibility (bool);
    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();				// 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()=0;			// return BBox including childs			
    89 	virtual QRect getBBoxSizeWithChilds()=0;// 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&)=0;// Save data to tempdir
    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     Q3PtrList <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