linkablemapobj.cpp
changeset 779 1fb50e79661c
parent 775 6e4b586aa88a
child 780 fe839bdfd10c
     1.1 --- a/linkablemapobj.cpp	Mon Jun 29 10:28:28 2009 +0000
     1.2 +++ b/linkablemapobj.cpp	Tue Jul 07 09:34:24 2009 +0000
     1.3 @@ -79,11 +79,6 @@
     1.4      bottomline->setZValue(Z_LINK);
     1.5      bottomline->show();
     1.6  
     1.7 -    // Prepare showing the selection of a MapObj
     1.8 -    selected=false;
     1.9 -
    1.10 -	hideLinkUnselected=false;
    1.11 -
    1.12  	topPad=botPad=leftPad=rightPad=0;
    1.13  
    1.14  	repositionRequest=false;
    1.15 @@ -287,16 +282,10 @@
    1.16  	return style;
    1.17  }
    1.18  
    1.19 -void LinkableMapObj::setHideLinkUnselected(bool b)
    1.20 +void LinkableMapObj::setHideLinkUnselected()
    1.21  {
    1.22 -	hideLinkUnselected=b;
    1.23  	setVisibility (visible);
    1.24 -	updateLink();
    1.25 -}
    1.26 -
    1.27 -bool LinkableMapObj::getHideLinkUnselected()
    1.28 -{
    1.29 -	return hideLinkUnselected;
    1.30 +	updateLinkGeometry();
    1.31  }
    1.32  
    1.33  void LinkableMapObj::setLinkPos(Position lp)
    1.34 @@ -353,10 +342,40 @@
    1.35  void LinkableMapObj::setVisibility (bool v)
    1.36  {
    1.37  	MapObj::setVisibility (v);
    1.38 +	updateVisibility();
    1.39 +}
    1.40 +
    1.41 +void LinkableMapObj::setOrientation()
    1.42 +{
    1.43 +	Orientation orientOld=orientation;
    1.44 +
    1.45 +	if (!parObj) 
    1.46 +	{
    1.47 +		orientation=UndefinedOrientation;
    1.48 +		return;
    1.49 +	}
    1.50 +		
    1.51 +    // Set orientation, first look for orientation of parent
    1.52 +    if (parObj->getOrientation() != UndefinedOrientation ) 
    1.53 +		// use the orientation of the parent:
    1.54 +		orientation=parObj->getOrientation();
    1.55 +    else
    1.56 +    {
    1.57 +		// calc orientation depending on position rel to parent
    1.58 +		if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
    1.59 +			orientation=LeftOfCenter; 
    1.60 +		else
    1.61 +			orientation=RightOfCenter;
    1.62 +    }
    1.63 +	if (orientOld!=orientation) requestReposition();
    1.64 +}
    1.65 +
    1.66 +void LinkableMapObj::updateVisibility()
    1.67 +{
    1.68  	bool visnow=visible;
    1.69  
    1.70 -	// We can hide the link, while object is not selected
    1.71 -	if (hideLinkUnselected && !selected)
    1.72 +	if (((MapItem*)treeItem)->getHideLinkUnselected()
    1.73 +		&& treeItem->getModel()->getSelectedLMO() !=this)
    1.74  		visnow=false;
    1.75  
    1.76  	if (visnow) 
    1.77 @@ -372,11 +391,11 @@
    1.78  					segment.at(i)->show();
    1.79  				break;	
    1.80  			case PolyLine:
    1.81 -				if (!p) cout << "LMO::setVis p==0 (PolyLine)\n"; //FIXME-3
    1.82 +				if (!p) cout << "LMO::updateVis p==0 (PolyLine)\n"; //FIXME-3
    1.83  				if (p) p->show();
    1.84  				break;
    1.85  			case PolyParabel:	
    1.86 -				if (!p) cout << "LMO::setVis p==0 (PolyParabel) "<<treeItem->getHeading().toStdString()<<endl; //FIXME-3
    1.87 +				if (!p) cout << "LMO::updateVis p==0 (PolyParabel) "<<treeItem->getHeading().toStdString()<<endl; //FIXME-3
    1.88  				if (p) p->show();
    1.89  				break;
    1.90  			default:
    1.91 @@ -406,32 +425,7 @@
    1.92  	}	
    1.93  }
    1.94  
    1.95 -void LinkableMapObj::setOrientation()
    1.96 -{
    1.97 -	Orientation orientOld=orientation;
    1.98 -
    1.99 -	if (!parObj) 
   1.100 -	{
   1.101 -		orientation=UndefinedOrientation;
   1.102 -		return;
   1.103 -	}
   1.104 -		
   1.105 -    // Set orientation, first look for orientation of parent
   1.106 -    if (parObj->getOrientation() != UndefinedOrientation ) 
   1.107 -		// use the orientation of the parent:
   1.108 -		orientation=parObj->getOrientation();
   1.109 -    else
   1.110 -    {
   1.111 -		// calc orientation depending on position rel to parent
   1.112 -		if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
   1.113 -			orientation=LeftOfCenter; 
   1.114 -		else
   1.115 -			orientation=RightOfCenter;
   1.116 -    }
   1.117 -	if (orientOld!=orientation) requestReposition();
   1.118 -}
   1.119 -
   1.120 -void LinkableMapObj::updateLink()
   1.121 +void LinkableMapObj::updateLinkGeometry()
   1.122  {
   1.123      // needs:
   1.124      //	childPos of parent
   1.125 @@ -445,7 +439,7 @@
   1.126  	//  bottomlineY
   1.127      //	drawing of the link itself
   1.128  
   1.129 -	// updateLink is called from move, but called from constructor we don't
   1.130 +	// updateLinkGeometry is called from move, but called from constructor we don't
   1.131  	// have parents yet...
   1.132  
   1.133  	if (!parObj)	
   1.134 @@ -456,7 +450,7 @@
   1.135  		parPos=childPos;		
   1.136  		// Redraw links to children
   1.137  		for (int i=0; i<treeItem->branchCount(); ++i)
   1.138 -			treeItem->getBranchObjNum(i)->updateLink();
   1.139 +			treeItem->getBranchObjNum(i)->updateLinkGeometry();
   1.140  		return;	
   1.141  	}
   1.142  
   1.143 @@ -511,7 +505,6 @@
   1.144  	switch (style)
   1.145  	{
   1.146  		case Line:
   1.147 -			//l->prepareGeometryChange();
   1.148  			l->setLine( QLine(qRound (parPos.x()),
   1.149  				qRound(parPos.y()),
   1.150  				qRound(p2x),
   1.151 @@ -520,17 +513,13 @@
   1.152  		case Parabel:	
   1.153  			parabel (pa0, p1x,p1y,p2x,p2y);
   1.154  			for (int i=0; i<segment.size(); ++i)
   1.155 -			{
   1.156 -				//segment.at(i)->prepareGeometryChange();
   1.157  				segment.at(i)->setLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y()));
   1.158 -			}	
   1.159  			break;
   1.160  		case PolyLine:
   1.161  			pa0.clear();
   1.162  			pa0<<QPointF (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
   1.163  			pa0<<QPointF (qRound(p2x-tp.x()), qRound(p2y-tp.y()));
   1.164  			pa0<<QPointF (qRound (parPos.x()), qRound(parPos.y()) );
   1.165 -			//p->prepareGeometryChange();
   1.166  			p->setPolygon(QPolygonF (pa0));
   1.167  			break;
   1.168  		case PolyParabel:	
   1.169 @@ -541,12 +530,11 @@
   1.170  				pa0 << QPointF (pa1.at(i));
   1.171  			for (int i=0;i<=arcsegs;i++)
   1.172  				pa0 << QPointF (pa2.at(arcsegs-i));
   1.173 -			//p->prepareGeometryChange();
   1.174  			p->setPolygon(QPolygonF (pa0));
   1.175  			break;
   1.176  		default:
   1.177  			break;
   1.178 -	} // switch (style)	
   1.179 +	} 
   1.180  }
   1.181  	
   1.182  LinkableMapObj* LinkableMapObj::getParObj()
   1.183 @@ -626,23 +614,6 @@
   1.184  	return repositionRequest;
   1.185  }
   1.186  
   1.187 -
   1.188 -void LinkableMapObj::select()
   1.189 -{
   1.190 -	// select and unselect are still needed to
   1.191 -	// handle hiding of links
   1.192 -    selected=true;
   1.193 -	setVisibility (visible);
   1.194 -}
   1.195 -
   1.196 -
   1.197 -void LinkableMapObj::unselect()
   1.198 -{
   1.199 -    selected=false;
   1.200 -	// Maybe we have to hide the link:
   1.201 -	setVisibility (visible);
   1.202 -}
   1.203 -
   1.204  void LinkableMapObj::parabel (QPolygonF &ya, double p1x, double p1y, double p2x, double p2y)
   1.205  
   1.206  {
   1.207 @@ -672,12 +643,3 @@
   1.208  	}	
   1.209  }
   1.210  
   1.211 -QString LinkableMapObj::getLinkAttr ()
   1.212 -{
   1.213 -	if (hideLinkUnselected)
   1.214 -		return attribut ("hideLink","true");
   1.215 -	else
   1.216 -		return attribut ("hideLink","false");
   1.217 -	
   1.218 -}
   1.219 -