linkablemapobj.h
author insilmaril
Tue, 24 Jan 2006 15:09:48 +0000
changeset 183 97e0bd468439
parent 175 728f51b71e71
child 218 160459d924a1
permissions -rw-r--r--
Introduced basic export to Open Document format
     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 	virtual int getTopPad();
    38 	virtual int getLeftPad();
    39 	virtual int getRightPad();
    40 	LinkStyle getDefLinkStyle();
    41     void setLinkStyle(LinkStyle);            
    42 	LinkStyle getLinkStyle();
    43 	void setHideLinkUnselected(bool);
    44 	bool getHideLinkUnselected();
    45 	void setLinkPos (LinkPos);
    46 	LinkPos getLinkPos ();
    47 
    48 	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    49 	virtual void setLinkColor(QColor);
    50 	QColor getLinkColor();
    51 	virtual FrameType getFrameType ();
    52 	virtual void setFrameType (const FrameType &);
    53 	virtual void setFrameType (const QString &);
    54 	virtual void setVisibility (bool);
    55     virtual void updateLink();				// update parPos and childPos
    56 											// depending on pos
    57 											// redraw link with given style
    58     LinkableMapObj* getChildObj();			// returns pointer to fromObj
    59     LinkableMapObj* getParObj();			// returns pointer to toObj
    60     virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
    61     QPoint getChildPos();					// returns pos where childs dock
    62     QPoint getParPos();						// returns pos where parents dock
    63     QPoint getRelPos();						// get position relative to parent (or (0,0))
    64     LinkOrient getOrientation();			// get orientation
    65     virtual int getDepth();					// return depth
    66 	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    67 	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    68 	virtual QPoint getRandPos();			// make randomised position
    69 
    70     virtual void alignRelativeTo(const QPoint );
    71 	virtual void reposition();
    72 	virtual void requestReposition();		// do reposition after next user event
    73 	virtual void forceReposition();			// to force a reposition now (outside
    74 											// of mapeditor e.g. in noteeditor
    75 	virtual bool repositionRequested();
    76 
    77 	virtual QRect getTotalBBox()=0;			// return BBox including childs			
    78 	virtual QRect getBBoxSizeWithChilds()=0;// return size of BBox including childs  
    79 	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    80 
    81 	virtual void setSelBox();
    82     virtual void select();
    83     virtual void unselect();
    84 	virtual	QString getSelectString()=0;
    85 	virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir
    86 
    87 protected:
    88 	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
    89 	QString getLinkAttr();
    90 
    91     QPoint childPos;
    92     QPoint parPos;
    93 	bool link2ParPos;				// While moving around, sometimes link to parent
    94 	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
    95     LinkOrient orientation;     
    96     int linkwidth;					// width of a link
    97     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
    98 	QRect bboxTotal;				// bounding box including childs
    99 
   100     LinkableMapObj* childObj;
   101     LinkableMapObj* parObj;
   102     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
   103     int bottomlineY;                // vertical offset of dockpos to pos
   104 
   105 	int thickness_start;			// for StylePoly*	
   106     LinkStyle style;				// Current style
   107 	LinkPos linkpos;
   108     QColor linkcolor;               // Link color
   109     QCanvasLine* l;                 // line style
   110 	QCanvasPolygon* p;				// poly styles
   111     int arcsegs;                    // arc: number of segments
   112     QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
   113 	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
   114 	QPointArray pa1;				// For drawing of PolyParabel 
   115 	QPointArray pa2;				// For drawing of PolyParabel	
   116     QCanvasLine* bottomline;        // on bottom of BBox
   117 	bool repositionRequest;			// 
   118 
   119 	bool selected;					// Used for marking the selection
   120 	bool hideLinkUnselected;		// to hide links if unselected
   121 	QCanvasRectangle* selbox;
   122 	FrameObj *frame;				// frame around object
   123 	int topPad, botPad,
   124 		leftPad, rightPad;          // padding within bbox
   125 
   126 };
   127 #endif