branchobj.cpp
changeset 817 b486ffd0fa11
parent 815 2881c4424190
child 819 8f987e376035
     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  	{