linkablemapobj.h
branchrelease-1-12-maintained
changeset 77 bdfc1079a723
child 2 608f976aa7bb
child 95 f688a9913724
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/linkablemapobj.h	Mon Nov 16 09:07:17 2009 +0000
     1.3 @@ -0,0 +1,113 @@
     1.4 +#ifndef LINKABLEMAPOBJ_H
     1.5 +#define LINKABLEMAPOBJ_H
     1.6 +
     1.7 +#include "frameobj.h"
     1.8 +#include "noteobj.h"
     1.9 +#include "headingobj.h"
    1.10 +#include "flagrowobj.h"
    1.11 +
    1.12 +#define MAX_DEPTH 999
    1.13 +
    1.14 +enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
    1.15 +enum LinkStyle {
    1.16 +	StyleUndef,
    1.17 +	StyleLine, 
    1.18 +	StyleParabel, 
    1.19 +	StylePolyLine,
    1.20 +	StylePolyParabel
    1.21 +};
    1.22 +enum LinkPos {LinkMiddle,LinkBottom};
    1.23 +enum LinkColorHint {DefaultColor,HeadingColor};
    1.24 +
    1.25 +class LinkableMapObj:public QObject, public MapObj {
    1.26 +	Q_OBJECT
    1.27 +public:
    1.28 +    LinkableMapObj ();
    1.29 +    LinkableMapObj (QCanvas*);
    1.30 +    LinkableMapObj (LinkableMapObj*);
    1.31 +    ~LinkableMapObj ();
    1.32 +	virtual void delLink();
    1.33 +    virtual void init ();
    1.34 +    virtual void copy (LinkableMapObj*);
    1.35 +    void setChildObj (LinkableMapObj*);
    1.36 +    virtual void setParObj (LinkableMapObj*);
    1.37 +    virtual void setParObjTmp (LinkableMapObj*,QPoint,int);	// Only for moving Obj around
    1.38 +	virtual void unsetParObjTmp();						// reuse original ParObj
    1.39 +	LinkStyle getDefLinkStyle();
    1.40 +    void setLinkStyle(LinkStyle);            
    1.41 +	LinkStyle getLinkStyle();
    1.42 +	void setLinkPos (LinkPos);
    1.43 +	LinkPos getLinkPos ();
    1.44 +
    1.45 +	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    1.46 +	virtual void setLinkColor(QColor);
    1.47 +	QColor getLinkColor();
    1.48 +	virtual FrameType getFrameType ();
    1.49 +	virtual void setFrameType (const FrameType &);
    1.50 +	virtual void setFrameType (const QString &);
    1.51 +	virtual void setVisibility (bool);
    1.52 +    virtual void updateLink();				// update parPos and childPos
    1.53 +											// depending on pos
    1.54 +											// redraw link with given style
    1.55 +    LinkableMapObj* getChildObj();			// returns pointer to fromObj
    1.56 +    LinkableMapObj* getParObj();			// returns pointer to toObj
    1.57 +    QPoint getChildPos();					// returns pos where childs dock
    1.58 +    QPoint getParPos();						// returns pos where parents dock
    1.59 +    QPoint getRelPos();						// get position relative to parent (or (0,0))
    1.60 +    LinkOrient getOrientation();			// get orientation
    1.61 +    virtual int getDepth();					// return depth
    1.62 +	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    1.63 +	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    1.64 +	virtual QPoint getRandPos();			// make randomised position
    1.65 +
    1.66 +    virtual void alignRelativeTo(const QPoint );
    1.67 +	virtual void reposition();
    1.68 +	virtual void requestReposition();		// do reposition after next user event
    1.69 +	virtual void forceReposition();			// to force a reposition now (outside
    1.70 +											// of mapeditor e.g. in noteeditor
    1.71 +	virtual bool repositionRequested();
    1.72 +
    1.73 +	virtual QRect getTotalBBox()=0;			// return BBox including childs			
    1.74 +	virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs  
    1.75 +	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    1.76 +
    1.77 +	virtual void setSelBox();
    1.78 +    virtual void select();
    1.79 +    virtual void unselect();
    1.80 +	virtual	QString getSelectString()=0;
    1.81 +
    1.82 +protected:
    1.83 +	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
    1.84 +    QPoint childPos;
    1.85 +    QPoint parPos;
    1.86 +	bool link2ParPos;				// While moving around, sometimes link to parent
    1.87 +	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
    1.88 +    LinkOrient orientation;     
    1.89 +    int linkwidth;					// width of a link
    1.90 +    int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
    1.91 +	QRect bboxTotal;				// bounding box including childs
    1.92 +
    1.93 +    LinkableMapObj* childObj;
    1.94 +    LinkableMapObj* parObj;
    1.95 +    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
    1.96 +    int offset;                     // vertical offset of dockpos to pos
    1.97 +
    1.98 +	int thickness_start;			// for StylePoly*	
    1.99 +    LinkStyle style;
   1.100 +	LinkPos linkpos;
   1.101 +    QColor linkcolor;               // Link color
   1.102 +    QCanvasLine* l;                 // line style
   1.103 +	QCanvasPolygon* p;				// poly styles
   1.104 +    int arcsegs;                    // arc: number of segments
   1.105 +    QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
   1.106 +	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
   1.107 +	QPointArray pa1;				// For drawing of PolyParabel 
   1.108 +	QPointArray pa2;				// For drawing of PolyParabel	
   1.109 +    QCanvasLine* bottomline;        // on bottom of BBox
   1.110 +	bool repositionRequest;			// 
   1.111 +
   1.112 +	bool selected;					// Used for marking the selection
   1.113 +	QCanvasRectangle* selbox;
   1.114 +	FrameObj *frame;				// frame around object
   1.115 +};
   1.116 +#endif