branchobj.h
author insilmaril
Tue, 07 Apr 2009 16:15:53 +0000
changeset 753 25a77484ec72
parent 750 ff3b01ce0960
child 754 db0ec4bcf416
permissions -rw-r--r--
more work on screwing up the data structures
     1 #ifndef BRANCHOBJ_H
     2 #define BRANCHOBJ_H
     3 
     4 #include "floatimageobj.h"
     5 #include "linkablemapobj.h"
     6 #include "ornamentedobj.h"
     7 #include "xlinkobj.h"
     8 
     9 
    10 bool isAbove(BranchObj*,BranchObj*);
    11 
    12 /*! \brief A branch visible in the map */
    13 
    14 /////////////////////////////////////////////////////////////////////////////
    15 class BranchObj:public OrnamentedObj {
    16 public:
    17 	/*! New branches will get use same color for heading as parent */
    18 	enum BranchModification {NewBranch, MovedBranch};
    19 
    20 
    21     BranchObj ();
    22     BranchObj (QGraphicsScene*);
    23     BranchObj (QGraphicsScene*, LinkableMapObj* parent);
    24     ~BranchObj ();
    25 	bool operator< ( const BranchObj & );
    26 	bool operator== ( const BranchObj & );
    27     virtual void init ();
    28     virtual void copy (BranchObj*);
    29     void clear();
    30 
    31     virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
    32 	virtual void unsetParObjTmp();			// reuse original ParObj
    33 
    34 	virtual void setVisibility(bool,int);	// set visibility
    35     virtual void setVisibility(bool);	    // set vis. for w
    36 	virtual void setLinkColor();			// set the color of link
    37 	virtual void setColorSubtree(QColor);	// set the color of heading
    38 
    39 	virtual void updateContentSize();
    40 	virtual void positionContents();
    41     virtual void move (double x,double y);
    42     virtual void move (QPointF);
    43     virtual void moveBy (double x,double y);
    44     virtual void moveBy (QPointF);
    45     virtual void positionBBox();
    46     virtual void calcBBoxSize();
    47 	virtual void setDockPos();
    48     virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    49     virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
    50     virtual void updateHeading ();
    51 
    52 	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
    53 
    54 	virtual void addXLink (XLinkObj*);
    55 	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
    56 	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
    57 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    58 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    59 	virtual BranchObj* XLinkTargetAt (int);
    60 
    61 	void setIncludeImagesVer(bool);
    62 	bool getIncludeImagesVer();
    63 	void setIncludeImagesHor(bool);
    64 	bool getIncludeImagesHor();
    65 	QString getIncludeImageAttr();
    66 
    67 	virtual FloatImageObj* addFloatImage();
    68 	virtual FloatImageObj* addFloatImage(FloatImageObj*);
    69 	virtual void removeFloatImage(FloatImageObj*);
    70     virtual FloatImageObj* getFirstFloatImage();
    71     virtual FloatImageObj* getLastFloatImage();
    72 	virtual FloatImageObj* getFloatImageNum(const uint &);
    73 protected:	
    74 	virtual void savePosInAngle();					// write pos in angle for resorting			
    75 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
    76 public:	
    77     virtual BranchObj* addBranch();
    78     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    79     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    80     virtual BranchObj* insertBranch(int);
    81     virtual BranchObj* insertBranch(BranchObj*,int);
    82     virtual BranchObj* insertBranchPtr (BranchObj*,int);
    83     virtual void removeBranchHere(BranchObj*);  
    84     virtual void removeChildren();  
    85     virtual void removeBranch(BranchObj*);  
    86     virtual void removeBranchPtr (BranchObj*);  
    87 
    88     virtual bool canMoveBranchUp();
    89     virtual BranchObj* moveBranchUp(BranchObj*);
    90     virtual bool canMoveBranchDown();
    91     virtual BranchObj* moveBranchDown(BranchObj*);
    92 
    93     virtual void sortChildren();
    94     virtual BranchObj* linkTo (BranchObj*, int);
    95     virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
    96 	virtual void reposition();
    97 	virtual void unsetAllRepositionRequests();
    98 
    99 	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
   100 	virtual QRectF getTotalBBox();			// return BBox including children			
   101 	virtual QRectF getBBoxSizeWithChildren();	// return size of BBox including children  
   102 	virtual void calcBBoxSizeWithChildren();	// calc size of  BBox including children recursivly
   103 
   104 	virtual QString getSelectString();
   105 	virtual void setAnimation(const AnimPoint &ap);
   106 	virtual bool animate();
   107 
   108 protected:
   109 	QList<FloatImageObj*> floatimage;// child images
   110 	QList<XLinkObj*> xlink;			// xlinks to other branches
   111 
   112 	AnimPoint anim;
   113 
   114 public:	
   115 	float angle;					// used in mainbranch to reorder mainbranches
   116 protected:	
   117 //	bool scrolled;					// true if all children are scrolled and thus invisible
   118 //	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   119 	bool includeImagesVer;			// include floatimages in bbox vertically
   120 	bool includeImagesHor;			// include floatimages in bbox horizontally
   121 };
   122 
   123 
   124 #endif
   125