xlinkobj.cpp
changeset 847 43268373032d
parent 790 133e2ed6b9c5
     1.1 --- a/xlinkobj.cpp	Fri Apr 09 14:24:04 2010 +0000
     1.2 +++ b/xlinkobj.cpp	Wed Jun 09 13:14:08 2010 +0000
     1.3 @@ -1,11 +1,9 @@
     1.4 +#include <QDebug>
     1.5 +
     1.6  #include "xlinkobj.h"
     1.7  
     1.8  #include "branchobj.h"
     1.9  #include "branchitem.h"
    1.10 -#include "xlinkitem.h"
    1.11 -
    1.12 -#include <iostream>
    1.13 -using namespace std;
    1.14  
    1.15  /////////////////////////////////////////////////////////////////
    1.16  // XLinkObj
    1.17 @@ -13,16 +11,18 @@
    1.18  
    1.19  int XLinkObj::arrowSize=10;					// make instances
    1.20  
    1.21 -XLinkObj::XLinkObj (QGraphicsScene* scene, TreeItem* ti):MapObj(scene,ti)
    1.22 +XLinkObj::XLinkObj (QGraphicsScene* scene,Link *l):MapObj(scene)
    1.23  {
    1.24 -	//cout << "Const XLinkObj (s)\n";
    1.25 +	//qDebug()<< "Const XLinkObj (s,Link)";
    1.26 +	link=l;
    1.27  	init();
    1.28  }
    1.29  
    1.30  
    1.31 +
    1.32  XLinkObj::~XLinkObj ()
    1.33  {
    1.34 -	//cout << "Destr XLinkObj\n";
    1.35 +	//qDebug() << "Destr XLinkObj";
    1.36  	delete (line);
    1.37  	delete (poly);
    1.38  }
    1.39 @@ -30,16 +30,15 @@
    1.40  
    1.41  void XLinkObj::init () 
    1.42  {
    1.43 -	XLinkItem *xli=(XLinkItem*)treeItem;
    1.44  	visBranch=NULL;
    1.45  
    1.46 -	pen.setColor ( xli->getColor() );
    1.47 -	pen.setWidth ( xli->getWidth() );
    1.48 +	pen.setColor ( link->getColor() );
    1.49 +	pen.setWidth ( link->getWidth() );
    1.50  	pen.setCapStyle (  Qt::RoundCap );
    1.51  	line=scene->addLine(QLineF(1,1,1,1),pen);
    1.52 -    line->setZValue (Z_XLINK);
    1.53 -	poly=scene->addPolygon(QPolygonF(),pen, xli->getColor());
    1.54 -    poly->setZValue (Z_XLINK);
    1.55 +	line->setZValue (Z_LINK);
    1.56 +	poly=scene->addPolygon(QPolygonF(),pen, link->getColor());
    1.57 +	poly->setZValue (Z_LINK);
    1.58  	setVisibility (true);
    1.59  }
    1.60  
    1.61 @@ -53,7 +52,7 @@
    1.62  {
    1.63  	QPointF a,b;
    1.64  	QPolygonF pa;
    1.65 -	if (visBranch)
    1.66 +	if (visBranch)   
    1.67  	{
    1.68  		// Only one of the linked branches is visible
    1.69  		BranchObj *bo=(BranchObj*)(visBranch->getLMO());
    1.70 @@ -81,7 +80,7 @@
    1.71  	} else
    1.72  	{
    1.73  		// Both linked branches are visible
    1.74 -		BranchItem *bi=((XLinkItem*)treeItem)->getBegin();
    1.75 +		BranchItem *bi=link->getBeginBranch();
    1.76  		if ( bi)
    1.77  		{
    1.78  			// If a link is just drawn in the editor,
    1.79 @@ -96,8 +95,7 @@
    1.80  			// This shouldn't be reached normally...
    1.81  			a=beginPos;
    1.82  
    1.83 -		// FIXME-3 try to get rid of xLinkstate if (xLinkState==activeXLink && endBranch)
    1.84 -		bi=((XLinkItem*)treeItem)->getEnd();
    1.85 +		bi=link->getEndBranch();
    1.86  		if (bi)
    1.87  		{
    1.88  			BranchObj *bo=(BranchObj*)(bi->getLMO());
    1.89 @@ -112,10 +110,9 @@
    1.90  
    1.91  	beginPos=a;
    1.92  	endPos=b;
    1.93 -	XLinkItem *xli=(XLinkItem*)treeItem;
    1.94 -	pen.setColor ( xli->getColor() );
    1.95 -	pen.setWidth ( xli->getWidth() );
    1.96 -	poly->setBrush (xli->getColor() );
    1.97 +	pen.setColor ( link->getColor() );
    1.98 +	pen.setWidth ( link->getWidth() );
    1.99 +	poly->setBrush (link->getColor() );
   1.100  	line->setPen (pen);
   1.101  	line->setLine(a.x(), a.y(), b.x(), b.y());
   1.102  }
   1.103 @@ -148,12 +145,12 @@
   1.104  
   1.105  void XLinkObj::setVisibility ()
   1.106  {
   1.107 -	BranchItem* beginBI=((XLinkItem*)treeItem)->getBegin();
   1.108 +	BranchItem* beginBI=link->getBeginBranch();
   1.109  	BranchObj* beginBO=NULL;
   1.110  	if (beginBI) beginBO=(BranchObj*)(beginBI->getLMO());
   1.111  
   1.112  	BranchObj* endBO=NULL;
   1.113 -	BranchItem* endBI=((XLinkItem*)treeItem)->getEnd();
   1.114 +	BranchItem* endBI=link->getEndBranch();
   1.115  	if (endBI) endBO=(BranchObj*)(endBI->getLMO());
   1.116  	if (beginBO && endBO)
   1.117  	{