linkablemapobj.h
author insilmaril
Tue, 03 Jan 2006 09:44:41 +0000
changeset 167 f7efd8c7c407
parent 166 325958acb69b
child 175 728f51b71e71
permissions -rw-r--r--
1.7.6 New features for floatimages and fixes
     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 	virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir
    83 
    84 protected:
    85 	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
    86 	QString getLinkAttr();
    87 
    88     QPoint childPos;
    89     QPoint parPos;
    90 	bool link2ParPos;				// While moving around, sometimes link to parent
    91 	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
    92     LinkOrient orientation;     
    93     int linkwidth;					// width of a link
    94     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
    95 	QRect bboxTotal;				// bounding box including childs
    96 
    97     LinkableMapObj* childObj;
    98     LinkableMapObj* parObj;
    99     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
   100     int offset;                     // vertical offset of dockpos to pos
   101 
   102 	int thickness_start;			// for StylePoly*	
   103     LinkStyle style;				// Current style
   104 	LinkPos linkpos;
   105     QColor linkcolor;               // Link color
   106     QCanvasLine* l;                 // line style
   107 	QCanvasPolygon* p;				// poly styles
   108     int arcsegs;                    // arc: number of segments
   109     QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
   110 	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
   111 	QPointArray pa1;				// For drawing of PolyParabel 
   112 	QPointArray pa2;				// For drawing of PolyParabel	
   113     QCanvasLine* bottomline;        // on bottom of BBox
   114 	bool repositionRequest;			// 
   115 
   116 	bool selected;					// Used for marking the selection
   117 	bool hideLinkUnselected;		// to hide links if unselected
   118 	QCanvasRectangle* selbox;
   119 	FrameObj *frame;				// frame around object
   120 };
   121 #endif