linkablemapobj.h
author insilmaril
Fri Dec 29 13:52:17 2006 +0000 (2006-12-29)
changeset 412 8059b6aa74d7
parent 406 1c8ff1928b97
child 442 dfbc371b7280
permissions -rw-r--r--
Removed some FIXMEs. Added translations
     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 
    10 #define MAX_DEPTH 999
    11 
    12 enum LinkOrient {OrientUndef,OrientLeftOfCenter, OrientRightOfCenter};
    13 enum LinkStyle {
    14 	StyleUndef,
    15 	StyleLine, 
    16 	StyleParabel, 
    17 	StylePolyLine,
    18 	StylePolyParabel
    19 };
    20 enum LinkPos {LinkMiddle,LinkBottom};
    21 enum LinkColorHint {DefaultColor,HeadingColor};
    22 
    23 class LinkableMapObj:public QObject, public MapObj {
    24 	Q_OBJECT
    25 public:
    26     LinkableMapObj ();
    27     LinkableMapObj (QGraphicsScene*);
    28     LinkableMapObj (LinkableMapObj*);
    29     ~LinkableMapObj ();
    30 	virtual void delLink();
    31     virtual void init ();
    32     virtual void copy (LinkableMapObj*);
    33     void setChildObj (LinkableMapObj*);
    34     virtual void setParObj (LinkableMapObj*);
    35     virtual void setParObjTmp (LinkableMapObj*,QPointF,int);	// Only for moving Obj around
    36 	virtual void unsetParObjTmp();						// reuse original ParObj
    37 	virtual bool hasParObjTmp();
    38 
    39 	virtual void setUseRelPos (const bool&);
    40 	virtual void setRelPos();				// set relPos to current parentPos
    41 	virtual void setRelPos(const QPointF&);	
    42 	virtual QPointF getRelPos();
    43 	virtual void setUseOrientation (const bool &);
    44 
    45 
    46 	virtual qreal getTopPad();
    47 	virtual qreal getLeftPad();
    48 	virtual qreal getRightPad();
    49 	LinkStyle getDefLinkStyle();
    50     void setLinkStyle(LinkStyle);            
    51 	LinkStyle getLinkStyle();
    52 	void setHideLinkUnselected(bool);
    53 	bool getHideLinkUnselected();
    54 	void setLinkPos (LinkPos);
    55 	LinkPos getLinkPos ();
    56 
    57 	virtual void setLinkColor();					// sets color according to colorhint, overloaded
    58 	virtual void setLinkColor(QColor);
    59 	QColor getLinkColor();
    60 	virtual FrameType getFrameType ();
    61 	virtual void setFrameType (const FrameType &);
    62 	virtual void setFrameType (const QString &);
    63 	virtual void setVisibility (bool);
    64 	virtual void setOrientation();
    65     virtual void updateLink();				// update parPos and childPos
    66 											// depending on pos
    67 											// redraw link with given style
    68     LinkableMapObj* getChildObj();			// returns pointer to fromObj
    69     LinkableMapObj* getParObj();			// returns pointer to toObj
    70     virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
    71 	virtual void setDockPos()=0;				// sets childPos and parPos
    72     QPointF getChildPos();					// returns pos where childs dock
    73     QPointF getParPos();						// returns pos where parents dock
    74     LinkOrient getOrientation();			// get orientation
    75     virtual int getDepth();					// return depth
    76 	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
    77 	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
    78 	virtual QPointF getRandPos();			// make randomised position
    79 
    80     //virtual void alignRelativeTo(const QPointF );
    81 	virtual void reposition();
    82 	virtual void requestReposition();		// do reposition after next user event
    83 	virtual void forceReposition();			// to force a reposition now (outside
    84 											// of mapeditor e.g. in noteeditor
    85 	virtual bool repositionRequested();
    86 
    87 	//virtual QRectF getTotalBBox();			// return BBox including childs			
    88 	//virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs  
    89 	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
    90 
    91 	virtual void setSelBox();
    92     virtual void select();
    93     virtual void unselect();
    94 	virtual	QString getSelectString()=0;
    95 	//virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
    96 
    97 protected:
    98 	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
    99 	QString getLinkAttr();
   100 
   101     QPointF childPos;
   102     QPointF parPos;
   103 	bool link2ParPos;				// While moving around, sometimes link to parent
   104 	MapEditor* mapEditor;			// for updateNoteFlag() and toggleScroll()
   105     LinkOrient orientation;     
   106     qreal linkwidth;				// width of a link
   107     int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
   108 	QRectF bboxTotal;				// bounding box including childs
   109 
   110     LinkableMapObj* childObj;
   111     LinkableMapObj* parObj;
   112     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
   113     qreal bottomlineY;              // vertical offset of dockpos to pos
   114 
   115 	int thickness_start;			// for StylePoly*	
   116     LinkStyle style;				// Current style
   117 	LinkPos linkpos;				// Link at bottom of object or middle of height
   118     QColor linkcolor;               // Link color
   119 	QPen pen;
   120     QGraphicsLineItem* l;           // line style
   121 	QGraphicsPolygonItem* p;		// poly styles
   122     int arcsegs;                    // arc: number of segments
   123     QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
   124 	QPolygonF pa0;					// For drawing of PolyParabel and PolyLine
   125 	QPolygonF pa1;					// For drawing of PolyParabel 
   126 	QPolygonF pa2;					// For drawing of PolyParabel	
   127     QGraphicsLineItem* 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 	QGraphicsRectItem* selbox;
   133 	FrameObj *frame;				// frame around object
   134 	qreal topPad, botPad,
   135 		leftPad, rightPad;          // padding within bbox
   136 
   137 	QPointF relPos;					// position relative to childPos of parent
   138 	bool useRelPos;
   139 	bool useOrientation;
   140 };
   141 #endif