linkablemapobj.h
author insilmaril
Mon, 16 Oct 2006 12:42:54 +0000
changeset 390 0e1aeb21cb78
parent 388 3a58c9ef4a18
child 406 1c8ff1928b97
permissions -rw-r--r--
Code simplifications
     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 setOrientation();
    67     virtual void updateLink();				// update parPos and childPos
    68 											// depending on pos
    69 											// redraw link with given style
    70     LinkableMapObj* getChildObj();			// returns pointer to fromObj
    71     LinkableMapObj* getParObj();			// returns pointer to toObj
    72     virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
    73 	virtual void setDockPos()=0;				// sets childPos and parPos
    74     QPoint getChildPos();					// returns pos where childs dock
    75     QPoint getParPos();						// returns pos where parents dock
    76     LinkOrient getOrientation();			// get orientation
    77     virtual int getDepth();					// return depth
    78 	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    79 	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    80 	virtual QPoint getRandPos();			// make randomised position
    81 
    82     //virtual void alignRelativeTo(const QPoint );
    83 	virtual void reposition();
    84 	virtual void requestReposition();		// do reposition after next user event
    85 	virtual void forceReposition();			// to force a reposition now (outside
    86 											// of mapeditor e.g. in noteeditor
    87 	virtual bool repositionRequested();
    88 
    89 	//virtual QRect getTotalBBox();			// return BBox including childs			
    90 	//virtual QRect getBBoxSizeWithChilds();// return size of BBox including childs  
    91 	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    92 
    93 	virtual void setSelBox();
    94     virtual void select();
    95     virtual void unselect();
    96 	virtual	QString getSelectString()=0;
    97 	//virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data to XML
    98 
    99 protected:
   100 	void parabel(Q3PointArray &,double,double,double,double);	// Create Parabel connecting two points
   101 	QString getLinkAttr();
   102 
   103     QPoint childPos;
   104     QPoint parPos;
   105 	bool link2ParPos;				// While moving around, sometimes link to parent
   106 	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
   107     LinkOrient orientation;     
   108     int linkwidth;					// width of a link
   109     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
   110 	QRect bboxTotal;				// bounding box including childs
   111 
   112     LinkableMapObj* childObj;
   113     LinkableMapObj* parObj;
   114     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
   115     int bottomlineY;                // vertical offset of dockpos to pos
   116 
   117 	int thickness_start;			// for StylePoly*	
   118     LinkStyle style;				// Current style
   119 	LinkPos linkpos;				// Link at bottom of object or middle of height
   120     QColor linkcolor;               // Link color
   121     Q3CanvasLine* l;                 // line style
   122 	Q3CanvasPolygon* p;				// poly styles
   123     int arcsegs;                    // arc: number of segments
   124     Q3PtrList <Q3CanvasLine> segment; // a part of e.g. the parabel
   125 	Q3PointArray pa0;				// For drawing of PolyParabel and PolyLine
   126 	Q3PointArray pa1;				// For drawing of PolyParabel 
   127 	Q3PointArray pa2;				// For drawing of PolyParabel	
   128     Q3CanvasLine* bottomline;        // on bottom of BBox
   129 	bool repositionRequest;			// 
   130 
   131 	bool selected;					// Used for marking the selection
   132 	bool hideLinkUnselected;		// to hide links if unselected
   133 	Q3CanvasRectangle* selbox;
   134 	FrameObj *frame;				// frame around object
   135 	int topPad, botPad,
   136 		leftPad, rightPad;          // padding within bbox
   137 
   138 	QPoint relPos;					// position relative to childPos of parent
   139 	bool useRelPos;
   140 	bool useOrientation;
   141 };
   142 #endif