Bugfix for relinking mainbranches
authorinsilmaril
Mon Dec 14 10:17:55 2009 +0000 (2009-12-14)
changeset 817b486ffd0fa11
parent 816 3086ee01554a
child 818 25ee6b988b73
Bugfix for relinking mainbranches
branchobj.cpp
branchobj.h
mapeditor.cpp
tex/vym.changelog
version.h
     1.1 --- a/branchobj.cpp	Thu Dec 10 17:04:48 2009 +0000
     1.2 +++ b/branchobj.cpp	Mon Dec 14 10:17:55 2009 +0000
     1.3 @@ -69,16 +69,6 @@
     1.4  	clear();
     1.5  }
     1.6  
     1.7 -bool BranchObj::operator< ( const BranchObj & other )
     1.8 -{
     1.9 -    return  angle < other.angle;
    1.10 -}
    1.11 -
    1.12 -bool BranchObj::operator== ( const BranchObj & other )
    1.13 -{
    1.14 -    return angle == other.angle;
    1.15 -}
    1.16 -
    1.17  void BranchObj::init () 
    1.18  {
    1.19  	if (parObj)
    1.20 @@ -94,8 +84,6 @@
    1.21  
    1.22  	setVisibility (other->visible);
    1.23  
    1.24 -	angle=other->angle;
    1.25 -
    1.26      positionBBox();
    1.27  }
    1.28  
    1.29 @@ -107,14 +95,6 @@
    1.30  		delete xlink.takeFirst();
    1.31  }
    1.32  
    1.33 -bool isAbove (BranchObj* a, BranchObj *b)
    1.34 -{
    1.35 -	if (a->angle < b->angle)
    1.36 -		return true;
    1.37 -	else	
    1.38 -		return false;
    1.39 -}
    1.40 -
    1.41  void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)	//FIXME-1 when moving a mainbranch to a branch it still has relPos, not moved as child
    1.42  {
    1.43  	// Temporary link to dst
    1.44 @@ -146,7 +126,6 @@
    1.45  	// Usually the positioning would be done by reposition(),
    1.46  	// but then also the destination branch would "Jump" around...
    1.47  	// Better just do it approximately
    1.48 -	cout << "BO::setTmp ";
    1.49  	if (dsti->depth()==0)	
    1.50  	{	// new parent is a mapcenter
    1.51  		Vector v= ( m - bodst->getChildPos());
    1.52 @@ -154,7 +133,6 @@
    1.53  		v.normalize();
    1.54  		v.scale (100);
    1.55  		move2RelPos (v.toQPointF());
    1.56 -		cout << "  v="<<v<<endl;
    1.57  	} else
    1.58  	{	
    1.59  		qreal y;
    1.60 @@ -168,8 +146,6 @@
    1.61  				y=t.y();
    1.62  
    1.63  			y=t.bottom();
    1.64 -			cout << "  y="<<y;		
    1.65 -			cout << "  t.h="<<t.height();
    1.66  
    1.67  		} else
    1.68  		{
    1.69 @@ -183,7 +159,6 @@
    1.70  				// Don't try to find that branch, guess 12 pixels
    1.71  				y=bodst->getChildPos().y()  -height() + 12; 
    1.72  		}	
    1.73 -		cout << "  pos="<<getAbsPos()<<" cPos="<<bodst->getChildPos()<<endl;
    1.74  		if (bodst->getOrientation()==LinkableMapObj::LeftOfCenter)
    1.75  			move ( bodst->getChildPos().x() - linkwidth, y );
    1.76  		else	
    1.77 @@ -480,13 +455,6 @@
    1.78  	updateContentSize();
    1.79  }
    1.80  
    1.81 -void BranchObj::savePosInAngle ()
    1.82 -{
    1.83 -	// Save position in angle
    1.84 -	for (int i=0; i<treeItem->branchCount(); ++i)
    1.85 -		treeItem->getBranchObjNum(i)->angle=i;
    1.86 -}
    1.87 -
    1.88  void BranchObj::setDefAttr (BranchModification mod)
    1.89  {
    1.90  	int fontsize;
    1.91 @@ -527,21 +495,23 @@
    1.92  void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
    1.93  {
    1.94  	qreal th = bboxTotal.height();	
    1.95 -	int depth=treeItem->depth();	// FIXME-3 needed to recursively calc depth?
    1.96 +	int depth=0;
    1.97 +	if (parObj)	depth=1 + parObj->getTreeItem()->depth();
    1.98  // TODO testing
    1.99  /*
   1.100 -
   1.101 -	QString h=QString (depth,' ');
   1.102 +	QString h=QString (depth+1,' ');
   1.103  	h+=treeItem->getHeading();
   1.104  	h+=QString (15,' ');
   1.105  	h.truncate (15);
   1.106 -	QPointF pp; if (parObj) pp=parObj->getChildPos();
   1.107 +	QPointF pp; 
   1.108 +	if (parObj) pp=parObj->getChildPos();
   1.109  	cout << "BO::alignRelTo ";
   1.110  	cout<<h.toStdString();
   1.111 -	cout << "    d="<<depth<<
   1.112 +	cout << "    d="<<depth;
   1.113 +	cout <<"  parO="<<parObj;
   1.114  //cout<<  "  ref="<<ref<<
   1.115 -      	"  bbox.tL="<<bboxTotal.topLeft()<<
   1.116 -		"  absPos="<<absPos<<
   1.117 +//cout <<	"  bbox.tL="<<bboxTotal.topLeft();
   1.118 +cout<<	"  absPos="<<absPos<<
   1.119  		"  relPos="<<relPos<<
   1.120  //		"  parPos="<<pp<<
   1.121  //		"  w="<<bbox.width()<<
   1.122 @@ -551,24 +521,13 @@
   1.123  //		"  scrolled="<<((BranchItem*)treeItem)->isScrolled()<<
   1.124  //		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
   1.125  //		"  hidden="<<hidden<<
   1.126 -		"  th="<<th<<
   1.127 +//		"  th="<<th<<
   1.128  		endl;
   1.129  */
   1.130  
   1.131  	setOrientation();
   1.132  	//updateLinkGeometry();
   1.133  
   1.134 -	if (depth==1 && parObj)
   1.135 -	{
   1.136 -		// Position relatively, if needed
   1.137 -		//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
   1.138 -
   1.139 -		// Calc angle to mapCenter if I am a mainbranch
   1.140 -		// needed for reordering the mainbranches clockwise 
   1.141 -		// around mapcenter 
   1.142 -		angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), 
   1.143 -								(int)(y() - parObj->getChildPos().y() ) ) );
   1.144 -	}							
   1.145  	if (depth==1)
   1.146  	{
   1.147  		move2RelPos (getRelPos() );
   1.148 @@ -651,7 +610,6 @@
   1.149  
   1.150  	    alignRelativeTo ( QPointF (absPos.x(),
   1.151  			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
   1.152 -		//FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
   1.153  		positionBBox();	// Reposition bbox and contents
   1.154  	} else
   1.155  	{
     2.1 --- a/branchobj.h	Thu Dec 10 17:04:48 2009 +0000
     2.2 +++ b/branchobj.h	Mon Dec 14 10:17:55 2009 +0000
     2.3 @@ -6,8 +6,6 @@
     2.4  #include "ornamentedobj.h"
     2.5  #include "xlinkobj.h"
     2.6  
     2.7 -bool isAbove(BranchObj*,BranchObj*);
     2.8 -
     2.9  /*! \brief A branch visible in the map */
    2.10  
    2.11  /////////////////////////////////////////////////////////////////////////////
    2.12 @@ -18,8 +16,6 @@
    2.13  
    2.14      BranchObj (QGraphicsScene*,TreeItem *ti=NULL);
    2.15      ~BranchObj ();
    2.16 -	bool operator< ( const BranchObj & );
    2.17 -	bool operator== ( const BranchObj & );
    2.18      virtual void init ();
    2.19      virtual void copy (BranchObj*);
    2.20      void clear();
    2.21 @@ -43,8 +39,6 @@
    2.22      
    2.23      virtual void updateData();	//! Update represantatio of heading, flags, etc.
    2.24  
    2.25 -protected:	
    2.26 -	virtual void savePosInAngle();					// write pos in angle for resorting			
    2.27  public:	
    2.28  	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
    2.29  
    2.30 @@ -65,9 +59,6 @@
    2.31  	QList<XLinkObj*> xlink;			// xlinks to other branches
    2.32  
    2.33  	AnimPoint anim;
    2.34 -
    2.35 -public:	
    2.36 -	float angle;					// used in mainbranch to reorder mainbranches
    2.37  };
    2.38  
    2.39  
     3.1 --- a/mapeditor.cpp	Thu Dec 10 17:04:48 2009 +0000
     3.2 +++ b/mapeditor.cpp	Mon Dec 14 10:17:55 2009 +0000
     3.3 @@ -1051,10 +1051,11 @@
     3.4  			// Take care of xLink
     3.5  			if (ti->xlinkCount()>0 && lmo->getBBox().width()>30)
     3.6  			{
     3.7 -				if ((lmo->getOrientation()==LinkableMapObj::RightOfCenter && p.x() > lmo->getBBox().right()-20)  ||
     3.8 -				    (lmo->getOrientation()==LinkableMapObj::LeftOfCenter && p.x() < lmo->getBBox().left()+20) ) 
     3.9 +				if ((lmo->getOrientation()!=LinkableMapObj::RightOfCenter && p.x() < lmo->getBBox().left()+20)  ||
    3.10 +				    (lmo->getOrientation()!=LinkableMapObj::LeftOfCenter && p.x() > lmo->getBBox().right()-20) ) 
    3.11  				{
    3.12 -					if (ti->xlinkCount()>1)
    3.13 +					// FIXME-4 if (ti->xlinkCount()>1)
    3.14 +					if (true)
    3.15  					{
    3.16  						QMenu menu;
    3.17  						QList <QAction*> alist;
     4.1 --- a/tex/vym.changelog	Thu Dec 10 17:04:48 2009 +0000
     4.2 +++ b/tex/vym.changelog	Mon Dec 14 10:17:55 2009 +0000
     4.3 @@ -1,3 +1,8 @@
     4.4 +-------------------------------------------------------------------
     4.5 +Mon Dec 14 11:16:57 CET 2009 - vym@insilmaril.de
     4.6 +
     4.7 +- Bugfix: Wrong tmp position when relinking a mainbranch
     4.8 +
     4.9  -------------------------------------------------------------------
    4.10  Thu Dec  7 23:17:57 CET 2009 - vym@insilmaril.de
    4.11  
     5.1 --- a/version.h	Thu Dec 10 17:04:48 2009 +0000
     5.2 +++ b/version.h	Mon Dec 14 10:17:55 2009 +0000
     5.3 @@ -7,7 +7,7 @@
     5.4  #define __VYM_VERSION "1.13.0"
     5.5  //#define __VYM_CODENAME "Codename: RC-1"
     5.6  #define __VYM_CODENAME "Codename: development version, not for production!"
     5.7 -#define __VYM_BUILD_DATE "2009-12-10"
     5.8 +#define __VYM_BUILD_DATE "2009-12-14"
     5.9  
    5.10  
    5.11  bool checkVersion(const QString &);