linkablemapobj.cpp
changeset 406 1c8ff1928b97
parent 404 53efc2562a7d
child 408 c2a05fa925a1
     1.1 --- a/linkablemapobj.cpp	Mon Nov 20 12:12:05 2006 +0000
     1.2 +++ b/linkablemapobj.cpp	Thu Nov 23 13:53:08 2006 +0000
     1.3 @@ -45,7 +45,7 @@
     1.4  			delete (l);
     1.5  			break;
     1.6  		case StyleParabel:
     1.7 -			segment.clear();
     1.8 +			while (!segment.isEmpty()) delete segment.takeFirst();
     1.9  			break;
    1.10  		case StylePolyLine:
    1.11  			delete (p);
    1.12 @@ -53,7 +53,7 @@
    1.13  			break;
    1.14  		case StylePolyParabel:
    1.15  			delete (p);
    1.16 -			segment.clear();
    1.17 +			while (!segment.isEmpty()) delete segment.takeFirst();
    1.18  			break;
    1.19  		default:
    1.20  			break;
    1.21 @@ -76,7 +76,6 @@
    1.22  	thickness_start=8;
    1.23      style=StyleUndef;
    1.24  	linkpos=LinkBottom;
    1.25 -    segment.setAutoDelete (TRUE);
    1.26      arcsegs=13;
    1.27  	Q3PointArray pa(arcsegs*2+2);
    1.28      
    1.29 @@ -198,8 +197,7 @@
    1.30  
    1.31  LinkStyle LinkableMapObj::getDefLinkStyle ()
    1.32  {
    1.33 -	if (!mapEditor) return StyleUndef;
    1.34 -
    1.35 +	if (mapEditor==0) return StyleUndef;
    1.36  	LinkStyle ls=mapEditor->getMapLinkStyle();
    1.37  	switch (ls)
    1.38  	{
    1.39 @@ -257,7 +255,7 @@
    1.40  				{
    1.41  					cl = new Q3CanvasLine(canvas);
    1.42  					cl->setPen( QPen(linkcolor, 1) );
    1.43 -					cl->setPoints( 0,0,i*10,100);
    1.44 +					cl->setPoints( i*5,0,i*10,100);
    1.45  					cl->setZ(Z_LINK);
    1.46  					if (visible)
    1.47  						cl->show();
    1.48 @@ -305,7 +303,7 @@
    1.49  				{
    1.50  					cl = new Q3CanvasLine(canvas);
    1.51  					cl->setPen( QPen(linkcolor, 1) );
    1.52 -					cl->setPoints( 0,0,i*10,100);
    1.53 +					cl->setPoints( 5*i,0,i*10,100);
    1.54  					cl->setZ(Z_LINK);
    1.55  					if (visible)
    1.56  						cl->show();
    1.57 @@ -360,15 +358,14 @@
    1.58  {
    1.59  	linkcolor=col;
    1.60      bottomline->setPen( QPen(linkcolor, 1) );
    1.61 -	Q3CanvasLine *cl;
    1.62  	switch (style)
    1.63  	{
    1.64  		case StyleLine:
    1.65  			l->setPen( QPen(col,1));
    1.66  			break;	
    1.67  		case StyleParabel:	
    1.68 -			for (cl=segment.first(); cl; cl=segment.next() )
    1.69 -				cl->setPen( QPen(col,1));
    1.70 +			for (int i=0; i<segment.size(); ++i)
    1.71 +				segment.at(i)->setPen( QPen(col,1));
    1.72  			break;
    1.73  		case StylePolyLine:
    1.74  			p->setBrush( QBrush(col));
    1.75 @@ -376,8 +373,8 @@
    1.76  			break;
    1.77  		case StylePolyParabel:	
    1.78  			p->setBrush( QBrush(col));
    1.79 -			for (cl=segment.first(); cl; cl=segment.next() )
    1.80 -				cl->setPen( QPen(col,1));
    1.81 +			for (int i=0; i<segment.size(); ++i)
    1.82 +				segment.at(i)->setPen( QPen(col,1));
    1.83  			break;
    1.84  		default:
    1.85  			break;
    1.86 @@ -412,7 +409,6 @@
    1.87  
    1.88  void LinkableMapObj::setVisibility (bool v)
    1.89  {
    1.90 -	Q3CanvasLine* cl;
    1.91  	MapObj::setVisibility (v);
    1.92  	bool visnow=visible;
    1.93  
    1.94 @@ -429,16 +425,16 @@
    1.95  				if (l) l->show();
    1.96  				break;
    1.97  			case StyleParabel:	
    1.98 -				for (cl=segment.first(); cl; cl=segment.next() )
    1.99 -					cl->show();
   1.100 +				for (int i=0; i<segment.size(); ++i)
   1.101 +					segment.at(i)->show();
   1.102  				break;	
   1.103  			case StylePolyLine:
   1.104  				if (p) p->show();
   1.105  				if (l) l->show();
   1.106  				break;
   1.107  			case StylePolyParabel:	
   1.108 -				for (cl=segment.first(); cl; cl=segment.next() )
   1.109 -					cl->show();
   1.110 +				for (int i=0; i<segment.size(); ++i)
   1.111 +					segment.at(i)->show();
   1.112  				if (p) p->show();
   1.113  				break;
   1.114  			default:
   1.115 @@ -453,16 +449,16 @@
   1.116  				if (l) l->hide();
   1.117  				break;
   1.118  			case StyleParabel:	
   1.119 -				for (cl=segment.first(); cl; cl=segment.next() )
   1.120 -					cl->hide();
   1.121 +				for (int i=0; i<segment.size(); ++i)
   1.122 +					segment.at(i)->hide();
   1.123  				break;	
   1.124  			case StylePolyLine:
   1.125  				if (p) p->hide();
   1.126  				if (l) l->hide();
   1.127  				break;
   1.128  			case StylePolyParabel:	
   1.129 -				for (cl=segment.first(); cl; cl=segment.next() )
   1.130 -					cl->hide();
   1.131 +				for (int i=0; i<segment.size(); ++i)
   1.132 +					segment.at(i)->hide();
   1.133  				if (p) p->hide();
   1.134  				break;
   1.135  			default:
   1.136 @@ -562,10 +558,6 @@
   1.137  	// "turning point" for drawing polygonal links
   1.138  	QPoint tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start));	
   1.139  	
   1.140 -	Q3CanvasLine *cl;
   1.141 -
   1.142 -	int i;
   1.143 -
   1.144      // Draw the link
   1.145  	switch (style)
   1.146  	{
   1.147 @@ -577,12 +569,8 @@
   1.148  			break;	
   1.149  		case StyleParabel:	
   1.150  			parabel (pa0, p1x,p1y,p2x,p2y);
   1.151 -			i=0;
   1.152 -			for (cl=segment.first(); cl; cl=segment.next() )
   1.153 -			{	
   1.154 -				cl->setPoints( pa0.point(i).x(), pa0.point(i).y(),pa0.point(i+1).x(),pa0.point(i+1).y());
   1.155 -				i++;
   1.156 -			}
   1.157 +			for (int i=0; i<segment.size(); ++i)
   1.158 +				segment.at(i)->setPoints( pa0.point(i).x(), pa0.point(i).y(),pa0.point(i+1).x(),pa0.point(i+1).y());
   1.159  			break;
   1.160  		case StylePolyLine:
   1.161  			pa0[0]=QPoint (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
   1.162 @@ -598,19 +586,15 @@
   1.163  		case StylePolyParabel:	
   1.164  			parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y());
   1.165  			parabel (pa2, p1x,p1y,p2x-tp.x(),p2y-tp.y());
   1.166 -			for (i=0;i<=arcsegs;i++)
   1.167 +			for (int i=0;i<=arcsegs;i++)
   1.168  			{
   1.169  				// Combine the arrays to a single one
   1.170  				pa0[i]=pa1[i];
   1.171  				pa0[i+arcsegs+1]=pa2[arcsegs-i];
   1.172  			}	
   1.173  			p->setPoints (pa0);
   1.174 -			i=0;
   1.175 -			for (cl=segment.first(); cl; cl=segment.next() )
   1.176 -			{	
   1.177 -				cl->setPoints( pa1.point(i).x(), pa1.point(i).y(),pa1.point(i+1).x(),pa1.point(i+1).y());
   1.178 -				i++;
   1.179 -			}
   1.180 +			for (int i=0; i<segment.size(); ++i)
   1.181 +				segment.at(i)->setPoints( pa1.point(i).x(), pa1.point(i).y(),pa1.point(i+1).x(),pa1.point(i+1).y());
   1.182  			break;
   1.183  		default:
   1.184  			break;
   1.185 @@ -646,7 +630,7 @@
   1.186  				break;
   1.187  		} else
   1.188  			if (typ=="bo:")
   1.189 -				lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
   1.190 +				lmo=((BranchObj*)(lmo))->getBranchNum (num.toInt());
   1.191  			else
   1.192  				if (typ=="fi:")
   1.193  					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());