linkablemapobj.h
author insilmaril
Mon Feb 11 12:44:00 2008 +0000 (2008-02-11)
changeset 669 a418fad921a8
parent 594 88d558ce079d
child 683 7df0b7986274
permissions -rw-r--r--
Updated brasilian translation
insilmaril@0
     1
#ifndef LINKABLEMAPOBJ_H
insilmaril@0
     2
#define LINKABLEMAPOBJ_H
insilmaril@0
     3
insilmaril@473
     4
#include "animpoint.h"
insilmaril@0
     5
#include "noteobj.h"
insilmaril@0
     6
#include "headingobj.h"
insilmaril@0
     7
#include "flagrowobj.h"
insilmaril@408
     8
insilmaril@616
     9
#define MAX_DEPTH 999
insilmaril@0
    10
insilmaril@616
    11
class MapEditor;
insilmaril@616
    12
insilmaril@0
    13
insilmaril@473
    14
insilmaril@473
    15
/*! \brief This class adds links to MapObj 
insilmaril@473
    16
insilmaril@473
    17
The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
insilmaril@473
    18
*/
insilmaril@0
    19
insilmaril@0
    20
class LinkableMapObj:public QObject, public MapObj {
insilmaril@0
    21
	Q_OBJECT
insilmaril@0
    22
public:
insilmaril@486
    23
	/*! Orientation of an object depends on the position relative to the parent */
insilmaril@473
    24
	enum Orientation {
insilmaril@473
    25
		UndefinedOrientation, //!< Undefined
insilmaril@473
    26
		LeftOfCenter,			//!< Object is left of center
insilmaril@473
    27
		RightOfCenter			//!< Object is right of center
insilmaril@473
    28
	};
insilmaril@473
    29
insilmaril@473
    30
	/*! Various drawing styles for links */
insilmaril@473
    31
	enum Style {
insilmaril@473
    32
		UndefinedStyle,	//!< Undefined
insilmaril@473
    33
		Line,			//!< Straight line
insilmaril@473
    34
		Parabel,		//!< Parabel
insilmaril@473
    35
		PolyLine,		//!< Polygon (thick line)
insilmaril@473
    36
		PolyParabel		//!< Thick parabel
insilmaril@473
    37
	};
insilmaril@473
    38
insilmaril@473
    39
	/*! Vertical position of link in object */
insilmaril@473
    40
	enum Position {
insilmaril@473
    41
		Middle, //!< Link is drawn in the middle of object
insilmaril@473
    42
		Bottom  //!< Link is drawn at bottom of object
insilmaril@473
    43
	};
insilmaril@473
    44
insilmaril@473
    45
	/*! Hint if link should use the default link color or the color of heading */
insilmaril@473
    46
	enum ColorHint {
insilmaril@473
    47
		DefaultColor,	//!< Link uses the default color
insilmaril@473
    48
		HeadingColor	//!< Link uses the color of heading
insilmaril@473
    49
	};
insilmaril@473
    50
insilmaril@0
    51
    LinkableMapObj ();
insilmaril@408
    52
    LinkableMapObj (QGraphicsScene*);
insilmaril@0
    53
    LinkableMapObj (LinkableMapObj*);
insilmaril@0
    54
    ~LinkableMapObj ();
insilmaril@0
    55
	virtual void delLink();
insilmaril@0
    56
    virtual void init ();
insilmaril@0
    57
    virtual void copy (LinkableMapObj*);
insilmaril@0
    58
    void setChildObj (LinkableMapObj*);
insilmaril@0
    59
    virtual void setParObj (LinkableMapObj*);
insilmaril@408
    60
    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);	// Only for moving Obj around
insilmaril@0
    61
	virtual void unsetParObjTmp();						// reuse original ParObj
insilmaril@164
    62
	virtual bool hasParObjTmp();
insilmaril@218
    63
insilmaril@218
    64
	virtual void setUseRelPos (const bool&);
insilmaril@218
    65
	virtual void setRelPos();				// set relPos to current parentPos
insilmaril@408
    66
	virtual void setRelPos(const QPointF&);	
insilmaril@408
    67
	virtual QPointF getRelPos();
insilmaril@218
    68
	virtual void setUseOrientation (const bool &);
insilmaril@218
    69
insilmaril@218
    70
insilmaril@408
    71
	virtual qreal getTopPad();
insilmaril@408
    72
	virtual qreal getLeftPad();
insilmaril@408
    73
	virtual qreal getRightPad();
insilmaril@473
    74
	Style getDefLinkStyle();
insilmaril@473
    75
    void setLinkStyle(Style);            
insilmaril@473
    76
	Style getLinkStyle();
insilmaril@160
    77
	void setHideLinkUnselected(bool);
insilmaril@160
    78
	bool getHideLinkUnselected();
insilmaril@473
    79
	void setLinkPos (Position);
insilmaril@473
    80
	Position getLinkPos ();
insilmaril@0
    81
insilmaril@531
    82
	virtual void setID (const QString &s);
insilmaril@531
    83
	virtual QString getID ();
insilmaril@531
    84
insilmaril@0
    85
	virtual void setLinkColor();					// sets color according to colorhint, overloaded
insilmaril@0
    86
	virtual void setLinkColor(QColor);
insilmaril@0
    87
	QColor getLinkColor();
insilmaril@0
    88
	virtual void setVisibility (bool);
insilmaril@388
    89
	virtual void setOrientation();
insilmaril@0
    90
    virtual void updateLink();				// update parPos and childPos
insilmaril@0
    91
											// depending on pos
insilmaril@0
    92
											// redraw link with given style
insilmaril@0
    93
    LinkableMapObj* getChildObj();			// returns pointer to fromObj
insilmaril@0
    94
    LinkableMapObj* getParObj();			// returns pointer to toObj
insilmaril@106
    95
    virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
insilmaril@388
    96
	virtual void setDockPos()=0;				// sets childPos and parPos
insilmaril@408
    97
    QPointF getChildPos();					// returns pos where childs dock
insilmaril@408
    98
    QPointF getParPos();						// returns pos where parents dock
insilmaril@473
    99
    Orientation getOrientation();			// get orientation
insilmaril@0
   100
    virtual int getDepth();					// return depth
insilmaril@0
   101
	virtual void setMapEditor(MapEditor*);	// set MapEditor (needed in LMO::updateNoteFlag)
insilmaril@0
   102
	virtual MapEditor* getMapEditor();		// get MapEditor (usually from parent);
insilmaril@408
   103
	virtual QPointF getRandPos();			// make randomised position
insilmaril@0
   104
insilmaril@408
   105
    //virtual void alignRelativeTo(const QPointF );
insilmaril@0
   106
	virtual void reposition();
insilmaril@0
   107
	virtual void requestReposition();		// do reposition after next user event
insilmaril@0
   108
	virtual void forceReposition();			// to force a reposition now (outside
insilmaril@0
   109
											// of mapeditor e.g. in noteeditor
insilmaril@0
   110
	virtual bool repositionRequested();
insilmaril@0
   111
insilmaril@408
   112
	//virtual QRectF getTotalBBox();			// return BBox including childs			
insilmaril@408
   113
	//virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs  
insilmaril@0
   114
	virtual void calcBBoxSizeWithChilds()=0;// calc size of  BBox including childs recursivly
insilmaril@0
   115
insilmaril@0
   116
    virtual void select();
insilmaril@0
   117
    virtual void unselect();
insilmaril@0
   118
	virtual	QString getSelectString()=0;
insilmaril@408
   119
	//virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML
insilmaril@0
   120
insilmaril@0
   121
protected:
insilmaril@408
   122
	void parabel(QPolygonF &,double,double,double,double);	// Create Parabel connecting two points
insilmaril@160
   123
	QString getLinkAttr();
insilmaril@160
   124
insilmaril@408
   125
    QPointF childPos;
insilmaril@408
   126
    QPointF parPos;
insilmaril@0
   127
	bool link2ParPos;				// While moving around, sometimes link to parent
insilmaril@442
   128
	MapEditor* mapEditor;			// for and toggleScroll(), get default styles
insilmaril@442
   129
									// and mapEditor->updateActions()
insilmaril@442
   130
									// and mapEditor->updateSelection()
insilmaril@473
   131
    Orientation orientation;     
insilmaril@408
   132
    qreal linkwidth;				// width of a link
insilmaril@0
   133
    int depth;						// depth: undef=-1 mapCenter=0 branch=1..n
insilmaril@408
   134
	QRectF bboxTotal;				// bounding box including childs
insilmaril@0
   135
insilmaril@0
   136
    LinkableMapObj* childObj;
insilmaril@0
   137
    LinkableMapObj* parObj;
insilmaril@0
   138
    LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
insilmaril@408
   139
    qreal bottomlineY;              // vertical offset of dockpos to pos
insilmaril@0
   140
insilmaril@0
   141
	int thickness_start;			// for StylePoly*	
insilmaril@473
   142
    Style style;					// Current style
insilmaril@473
   143
	Position linkpos;				// Link at bottom of object or middle of height
insilmaril@0
   144
    QColor linkcolor;               // Link color
insilmaril@408
   145
	QPen pen;
insilmaril@408
   146
    QGraphicsLineItem* l;           // line style
insilmaril@408
   147
	QGraphicsPolygonItem* p;		// poly styles
insilmaril@0
   148
    int arcsegs;                    // arc: number of segments
insilmaril@408
   149
    QList <QGraphicsLineItem*> segment; // a part of e.g. the parabel
insilmaril@408
   150
	QPolygonF pa0;					// For drawing of PolyParabel and PolyLine
insilmaril@408
   151
	QPolygonF pa1;					// For drawing of PolyParabel 
insilmaril@408
   152
	QPolygonF pa2;					// For drawing of PolyParabel	
insilmaril@408
   153
    QGraphicsLineItem* bottomline;  // on bottom of BBox
insilmaril@0
   154
	bool repositionRequest;			// 
insilmaril@0
   155
insilmaril@0
   156
	bool selected;					// Used for marking the selection
insilmaril@160
   157
	bool hideLinkUnselected;		// to hide links if unselected
insilmaril@408
   158
	qreal topPad, botPad,
insilmaril@175
   159
		leftPad, rightPad;          // padding within bbox
insilmaril@175
   160
insilmaril@473
   161
	QPointF	 relPos;				// position relative to childPos of parent
insilmaril@473
   162
	//AnimPoint relPos;				// position relative to childPos of parent
insilmaril@218
   163
	bool useRelPos;
insilmaril@218
   164
	bool useOrientation;
insilmaril@531
   165
insilmaril@594
   166
	QString objID;					// id set during load/save currently used for xLinks
insilmaril@0
   167
};
insilmaril@0
   168
#endif