xlinkobj.cpp
changeset 442 dfbc371b7280
parent 406 1c8ff1928b97
child 477 a9ac5dea9561
     1.1 --- a/xlinkobj.cpp	Thu Nov 23 13:53:08 2006 +0000
     1.2 +++ b/xlinkobj.cpp	Sat Mar 31 09:28:27 2007 +0000
     1.3 @@ -1,8 +1,6 @@
     1.4  #include "xlinkobj.h"
     1.5  #include "branchobj.h"
     1.6  #include "mapeditor.h"
     1.7 -//Added by qt3to4:
     1.8 -#include <Q3PointArray>
     1.9  
    1.10  
    1.11  /////////////////////////////////////////////////////////////////
    1.12 @@ -17,9 +15,9 @@
    1.13  	init();
    1.14  }
    1.15  
    1.16 -XLinkObj::XLinkObj (Q3Canvas* c):MapObj(c)
    1.17 +XLinkObj::XLinkObj (QGraphicsScene* s):MapObj(s)
    1.18  {
    1.19 -	//	cout << "Const XLinkObj (c)  called from MapCenterObj (c)\n";
    1.20 +	//	cout << "Const XLinkObj (s)  called from MapCenterObj (s)\n";
    1.21  	init();
    1.22  }
    1.23  
    1.24 @@ -42,15 +40,14 @@
    1.25  	xLinkState=undefinedXLink;
    1.26  
    1.27  	color=QColor (180,180,180);
    1.28 -	line=new Q3CanvasLine (canvas);
    1.29  	width=1;
    1.30 -	line->setPen (QPen(color, width));
    1.31 -	line->setZ (Z_XLINK);
    1.32 -
    1.33 -	poly=new Q3CanvasPolygon (canvas);
    1.34 -	poly->setBrush( color );
    1.35 -	poly->setZ (Z_XLINK);
    1.36 -
    1.37 +	pen.setColor (color);
    1.38 +	pen.setWidth (width);
    1.39 +	pen.setCapStyle (  Qt::RoundCap );
    1.40 +	line=scene->addLine(QLineF(1,1,1,1),pen);
    1.41 +    line->setZValue (Z_XLINK);
    1.42 +	poly=scene->addPolygon(QPolygonF(),pen,color);
    1.43 +    poly->setZValue (Z_XLINK);
    1.44  	setVisibility (false);
    1.45  }
    1.46  
    1.47 @@ -62,6 +59,7 @@
    1.48  	beginBranch=other->beginBranch;
    1.49  	endBranch=other->endBranch;
    1.50  	width=other->width;
    1.51 +
    1.52  }
    1.53  
    1.54  void XLinkObj::setBegin (BranchObj *bo)
    1.55 @@ -97,27 +95,29 @@
    1.56  void XLinkObj::setWidth (int w)
    1.57  {
    1.58  	width=w;
    1.59 +	pen.setWidth (w);
    1.60  	setColor (color);
    1.61  }
    1.62  
    1.63  int XLinkObj::getWidth()
    1.64  {
    1.65 -	return width;
    1.66 +	return pen.width();
    1.67  }
    1.68  
    1.69  void XLinkObj::setColor(QColor c)
    1.70  {
    1.71  	color=c;
    1.72 -	line->setPen (QPen(color, width));
    1.73 +	pen.setColor (c);
    1.74 +	line->setPen (pen);
    1.75  	poly->setBrush( color );
    1.76  }
    1.77  
    1.78  QColor XLinkObj::getColor()
    1.79  {
    1.80 -	return color;
    1.81 +	return pen.color();
    1.82  }
    1.83  
    1.84 -void XLinkObj::setEnd (QPoint p)
    1.85 +void XLinkObj::setEnd (QPointF p)
    1.86  {
    1.87  	endPos=p;
    1.88  }
    1.89 @@ -160,8 +160,8 @@
    1.90  
    1.91  void XLinkObj::updateXLink()
    1.92  {
    1.93 -	QPoint a,b;
    1.94 -	Q3PointArray pa (3);
    1.95 +	QPointF a,b;
    1.96 +	QPolygonF pa;
    1.97  	if (visBranch)
    1.98  	{
    1.99  		// Only one of the linked branches is visible
   1.100 @@ -169,20 +169,20 @@
   1.101  		if (visBranch->getOrientation()==OrientRightOfCenter)
   1.102  		{
   1.103  			b.setX (b.x()+25);
   1.104 -			pa.putPoints (0,3,
   1.105 -				b.x(),b.y(),
   1.106 -				b.x()-arrowSize,b.y()-arrowSize,
   1.107 -				b.x()-arrowSize,b.y()+arrowSize
   1.108 -			);
   1.109 -			poly->setPoints (pa);
   1.110 +			
   1.111 +			pa.clear();
   1.112 +			pa<< QPointF(b.x(),b.y())<<
   1.113 +				QPointF(b.x()-arrowSize,b.y()-arrowSize)<<
   1.114 +				QPointF(b.x()-arrowSize,b.y()+arrowSize);
   1.115 +			poly->setPolygon(pa);
   1.116  		} else
   1.117  		{
   1.118  			b.setX (b.x()-25);
   1.119 -			pa.putPoints (0,3,
   1.120 -				b.x(),b.y(),
   1.121 -				b.x()+arrowSize,b.y()-arrowSize,
   1.122 -				b.x()+arrowSize,b.y()+arrowSize);
   1.123 -			poly->setPoints (pa);
   1.124 +			pa.clear();
   1.125 +			pa<< QPointF(b.x(),b.y())<<
   1.126 +				QPointF(b.x()+arrowSize,b.y()-arrowSize)<<
   1.127 +				QPointF(b.x()+arrowSize,b.y()+arrowSize);
   1.128 +			poly->setPolygon (pa);
   1.129  		}	
   1.130  	} else
   1.131  	{
   1.132 @@ -201,7 +201,7 @@
   1.133  	}
   1.134  
   1.135  
   1.136 -	if (line->startPoint()==a && line->endPoint()==b && !visBranch)
   1.137 +	if (line->line().p1()==a && line->line().p2()==b && !visBranch)
   1.138  	{
   1.139  		// update is called from both branches, so only
   1.140  		// update if something has changed
   1.141 @@ -211,8 +211,8 @@
   1.142  	{
   1.143  		beginPos=a;
   1.144  		endPos=b;
   1.145 -		line->setPen (QPen(color, width));
   1.146 -		line->setPoints (a.x(), a.y(), b.x(), b.y());
   1.147 +		line->setPen (pen);
   1.148 +		line->setLine(a.x(), a.y(), b.x(), b.y());
   1.149  	}
   1.150  }
   1.151