branchobj.h
author insilmaril
Fri Mar 05 20:16:46 2010 +0000 (2010-03-05)
branchrelease-1-12-maintained
changeset 80 5c5b4464b24f
parent 0 7a96bd401351
permissions -rw-r--r--
Some changes by Tagg for Win version
insilmaril@0
     1
#ifndef BRANCHOBJ_H
insilmaril@0
     2
#define BRANCHOBJ_H
insilmaril@0
     3
insilmaril@0
     4
#include "floatimageobj.h"
insilmaril@0
     5
#include "linkablemapobj.h"
insilmaril@0
     6
#include "ornamentedobj.h"
insilmaril@41
     7
#include "xlinkobj.h"
insilmaril@0
     8
insilmaril@41
     9
insilmaril@41
    10
bool isAbove(BranchObj*,BranchObj*);
insilmaril@41
    11
insilmaril@41
    12
/*! \brief A branch visible in the map */
insilmaril@41
    13
insilmaril@41
    14
/*! If HideExport is used, this branch and its childs will be hidden in export */
insilmaril@41
    15
enum HideTmpMode {HideNone, HideExport};
insilmaril@41
    16
insilmaril@0
    17
insilmaril@0
    18
/////////////////////////////////////////////////////////////////////////////
insilmaril@0
    19
class BranchObj:public OrnamentedObj {
insilmaril@0
    20
public:
insilmaril@41
    21
	/*! New branches will get use same color for heading as parent */
insilmaril@41
    22
	enum BranchModification {NewBranch, MovedBranch};
insilmaril@41
    23
insilmaril@41
    24
insilmaril@0
    25
    BranchObj ();
insilmaril@41
    26
    BranchObj (QGraphicsScene*);
insilmaril@41
    27
    BranchObj (QGraphicsScene*, LinkableMapObj* parent);
insilmaril@0
    28
    ~BranchObj ();
insilmaril@0
    29
	bool operator< ( const BranchObj & );
insilmaril@0
    30
	bool operator== ( const BranchObj & );
insilmaril@0
    31
    virtual void init ();
insilmaril@0
    32
    virtual void copy (BranchObj*);
insilmaril@0
    33
    void clear();
insilmaril@0
    34
	virtual int getNum();				// return number of this in parent
insilmaril@0
    35
	virtual int getNum(BranchObj*);		// return number of this in parent
insilmaril@0
    36
	virtual int getFloatImageNum(FloatImageObj*);		
insilmaril@0
    37
	virtual int countBranches();		
insilmaril@0
    38
	virtual int countFloatImages();		
insilmaril@41
    39
	virtual int countXLinks();		
insilmaril@41
    40
    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
insilmaril@0
    41
	virtual void unsetParObjTmp();			// reuse original ParObj
insilmaril@0
    42
insilmaril@0
    43
	virtual void unScroll();				
insilmaril@0
    44
	virtual void toggleScroll();			// scroll or unscroll
insilmaril@0
    45
	virtual bool isScrolled();				// returns scroll state
insilmaril@0
    46
	virtual bool hasScrolledParent(BranchObj*);	// true, if any of the parents is scrolled
insilmaril@0
    47
	virtual void tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
insilmaril@0
    48
	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
insilmaril@0
    49
insilmaril@0
    50
	virtual void setVisibility(bool,int);	// set visibility
insilmaril@0
    51
    virtual void setVisibility(bool);	    // set vis. for w
insilmaril@0
    52
	virtual void setLinkColor();			// set the color of link
insilmaril@41
    53
	virtual void setColorSubtree(QColor);	// set the color of heading
insilmaril@0
    54
insilmaril@0
    55
	BranchObj* first ();				// set Iterator to first LMO
insilmaril@0
    56
	BranchObj* next ();					// find next LMO after given one
insilmaril@0
    57
	BranchObj* getLastIterator();		// to interrupt and resume next iteration
insilmaril@0
    58
	void setLastIterator (BranchObj*);	// needed by next() 
insilmaril@0
    59
insilmaril@41
    60
	virtual void positionContents();
insilmaril@0
    61
    virtual void move (double x,double y);
insilmaril@41
    62
    virtual void move (QPointF);
insilmaril@0
    63
    virtual void moveBy (double x,double y);
insilmaril@41
    64
    virtual void moveBy (QPointF);
insilmaril@0
    65
    virtual void positionBBox();
insilmaril@0
    66
    virtual void calcBBoxSize();
insilmaril@41
    67
	virtual void setDockPos();
insilmaril@41
    68
    virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
insilmaril@41
    69
    virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
insilmaril@0
    70
    virtual void setHeading (QString);
insilmaril@41
    71
insilmaril@41
    72
	virtual void setHideTmp (HideTmpMode);
insilmaril@41
    73
	virtual bool hasHiddenExportParent ();
insilmaril@41
    74
insilmaril@41
    75
	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
insilmaril@41
    76
	virtual void addXLink (XLinkObj*);
insilmaril@41
    77
	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
insilmaril@41
    78
	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
insilmaril@41
    79
	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
insilmaril@41
    80
	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
insilmaril@41
    81
	virtual int countXLink ();
insilmaril@41
    82
	virtual BranchObj* XLinkTargetAt (int);
insilmaril@41
    83
	void setIncludeImagesVer(bool);
insilmaril@41
    84
	bool getIncludeImagesVer();
insilmaril@41
    85
	void setIncludeImagesHor(bool);
insilmaril@41
    86
	bool getIncludeImagesHor();
insilmaril@41
    87
	QString getIncludeImageAttr();
insilmaril@41
    88
	virtual FloatImageObj* addFloatImage();
insilmaril@41
    89
	virtual FloatImageObj* addFloatImage(FloatImageObj*);
insilmaril@0
    90
	virtual void removeFloatImage(FloatImageObj*);
insilmaril@0
    91
    virtual FloatImageObj* getFirstFloatImage();
insilmaril@0
    92
    virtual FloatImageObj* getLastFloatImage();
insilmaril@0
    93
	virtual FloatImageObj* getFloatImageNum(const uint &);
insilmaril@0
    94
protected:	
insilmaril@41
    95
	virtual void savePosInAngle();					// write pos in angle for resorting			
insilmaril@41
    96
	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
insilmaril@0
    97
public:	
insilmaril@0
    98
    virtual BranchObj* addBranch();
insilmaril@0
    99
    virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
insilmaril@41
   100
    virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
insilmaril@0
   101
    virtual BranchObj* insertBranch(int);
insilmaril@0
   102
    virtual BranchObj* insertBranch(BranchObj*,int);
insilmaril@41
   103
    virtual BranchObj* insertBranchPtr (BranchObj*,int);
insilmaril@41
   104
    virtual void removeBranchHere(BranchObj*);  
insilmaril@41
   105
    virtual void removeChilds();  
insilmaril@0
   106
    virtual void removeBranch(BranchObj*);  
insilmaril@41
   107
    virtual void removeBranchPtr (BranchObj*);  
insilmaril@0
   108
    virtual void setLastSelectedBranch(BranchObj*);
insilmaril@0
   109
    virtual BranchObj* getLastSelectedBranch();
insilmaril@0
   110
    virtual BranchObj* getFirstBranch();
insilmaril@0
   111
    virtual BranchObj* getLastBranch();
insilmaril@41
   112
	virtual BranchObj* getBranchNum(int);
insilmaril@41
   113
    virtual bool canMoveBranchUp();
insilmaril@0
   114
    virtual BranchObj* moveBranchUp(BranchObj*);
insilmaril@41
   115
    virtual bool canMoveBranchDown();
insilmaril@0
   116
    virtual BranchObj* moveBranchDown(BranchObj*);
insilmaril@41
   117
    virtual void sortChildren();
insilmaril@41
   118
    virtual BranchObj* linkTo (BranchObj*, int);
insilmaril@41
   119
    virtual void alignRelativeTo(const QPointF ref, bool alignSelf=false );
insilmaril@41
   120
	virtual void reposition();
insilmaril@41
   121
	virtual void unsetAllRepositionRequests();
insilmaril@0
   122
insilmaril@41
   123
	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
insilmaril@41
   124
	virtual QRectF getTotalBBox();			// return BBox including childs			
insilmaril@41
   125
	virtual QRectF getBBoxSizeWithChilds();	// return size of BBox including childs  
insilmaril@0
   126
	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
insilmaril@0
   127
insilmaril@0
   128
    virtual void select();
insilmaril@0
   129
    virtual void unselect();
insilmaril@0
   130
	virtual QString getSelectString();
insilmaril@41
   131
	virtual void setAnimation(const AnimPoint &ap);
insilmaril@41
   132
	virtual bool animate();
insilmaril@0
   133
insilmaril@0
   134
protected:
insilmaril@0
   135
	static BranchObj* itLast;		// iterator for first(), next()
insilmaril@41
   136
	static BranchObj* itFirst;		// first iterator for first(), next()
insilmaril@41
   137
    QList<BranchObj*> branch;		// all child branches
insilmaril@41
   138
	QList<FloatImageObj*> floatimage;// child images
insilmaril@41
   139
	QList<XLinkObj*> xlink;			// xlinks to other branches
insilmaril@41
   140
insilmaril@41
   141
	AnimPoint anim;
insilmaril@41
   142
insilmaril@0
   143
public:	
insilmaril@0
   144
	float angle;					// used in mainbranch to reorder mainbranches
insilmaril@0
   145
protected:	
insilmaril@0
   146
    int lastSelectedBranch;			// for going deeper into tree
insilmaril@0
   147
	bool scrolled;					// true if all childs are scrolled and thus invisible
insilmaril@0
   148
	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
insilmaril@41
   149
	bool includeImagesVer;			// include floatimages in bbox vertically
insilmaril@41
   150
	bool includeImagesHor;			// include floatimages in bbox horizontally
insilmaril@41
   151
insilmaril@0
   152
};
insilmaril@0
   153
insilmaril@0
   154
insilmaril@0
   155
#endif
insilmaril@0
   156