linkablemapobj.cpp
author insilmaril
Thu, 23 Mar 2006 12:38:54 +0000
changeset 257 199f2626fe70
parent 250 0e994bf2346b
child 260 69d648a0a15b
permissions -rw-r--r--
Version 1.7.12
     1 #include <math.h>
     2 
     3 #include "linkablemapobj.h"
     4 #include "branchobj.h"
     5 #include "mapeditor.h"
     6 
     7 #include "version.h"
     8 
     9 
    10 /////////////////////////////////////////////////////////////////
    11 // LinkableMapObj
    12 /////////////////////////////////////////////////////////////////
    13 
    14 LinkableMapObj::LinkableMapObj():MapObj()
    15 {
    16   //  cout << "Const LinkableMapObj ()\n";
    17     init ();
    18 }
    19 
    20 LinkableMapObj::LinkableMapObj(QCanvas* c) :MapObj(c)
    21 {
    22 //    cout << "Const LinkableMapObj\n";
    23     init ();
    24 }
    25 
    26 LinkableMapObj::LinkableMapObj (LinkableMapObj* lmo) : MapObj (lmo->canvas)
    27 {
    28     copy (lmo);
    29 }
    30 
    31 LinkableMapObj::~LinkableMapObj()
    32 {
    33     delete (bottomline);
    34     delete (selbox);
    35 	delete (frame);
    36 	delLink();
    37 }
    38 
    39 void LinkableMapObj::delLink()
    40 {
    41 	switch (style)
    42 	{
    43 		case StyleLine:
    44 			delete (l);
    45 			break;
    46 		case StyleParabel:
    47 			segment.clear();
    48 			break;
    49 		case StylePolyLine:
    50 			delete (p);
    51 			delete (l);
    52 			break;
    53 		case StylePolyParabel:
    54 			delete (p);
    55 			segment.clear();
    56 			break;
    57 		default:
    58 			break;
    59 	}		
    60 }
    61 
    62 void LinkableMapObj::init ()
    63 {
    64     depth=-1;	
    65 	mapEditor=NULL;
    66     childObj=NULL;
    67     parObj=NULL;
    68     parObjTmpBuf=NULL;
    69     parPos=QPoint(0,0);
    70     childPos=QPoint(0,0);
    71 	link2ParPos=false;
    72     l=NULL;
    73     orientation=OrientUndef;
    74     linkwidth=20;		
    75 	thickness_start=8;
    76     style=StyleUndef;
    77 	linkpos=LinkBottom;
    78     segment.setAutoDelete (TRUE);
    79     arcsegs=13;
    80 	QPointArray pa(arcsegs*2+2);
    81     
    82     bottomline=new QCanvasLine(canvas);
    83     bottomline->setPen( QPen(linkcolor, 1) );
    84     bottomline->setZ(Z_LINK);
    85     bottomline->show();
    86 
    87     // Prepare showing the selection of a MapObj
    88     selbox = new QCanvasRectangle (canvas);
    89     selbox->setZ(Z_SELBOX);
    90     selbox->setBrush( QColor(255,255,0) );
    91     selbox->setPen( QPen(QColor(255,255,0) ));
    92     selbox->hide();
    93     selected=false;
    94 
    95 	hideLinkUnselected=false;
    96 
    97 	topPad=botPad=leftPad=rightPad=0;
    98 
    99 	// initialize frame
   100 	frame = new FrameObj (canvas);
   101 	
   102 	repositionRequest=false;
   103 
   104 	// Rel Positions
   105 	relPos=QPoint(0,0);
   106 	useRelPos=false;
   107 	useOrientation=true;
   108 }
   109 
   110 void LinkableMapObj::copy (LinkableMapObj* other)
   111 {
   112     MapObj::copy(other);
   113 	bboxTotal=other->bboxTotal;
   114     setLinkStyle(other->style);
   115     setLinkColor (other->linkcolor);
   116 	relPos=other->relPos;
   117 	useOrientation=other->useOrientation;
   118 
   119 }
   120 
   121 void LinkableMapObj::setChildObj(LinkableMapObj* o)
   122 {
   123     childObj=o;
   124 }
   125 
   126 void LinkableMapObj::setParObj(LinkableMapObj* o)
   127 {
   128     parObj=o;
   129 	mapEditor=parObj->getMapEditor();
   130 }
   131 
   132 void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPoint,int)
   133 {
   134 }
   135 
   136 void LinkableMapObj::unsetParObjTmp()
   137 {
   138 }
   139 
   140 bool LinkableMapObj::hasParObjTmp()
   141 {
   142 	if (parObjTmpBuf) return true;
   143 	return false;
   144 }
   145 
   146 void LinkableMapObj::setUseRelPos (const bool &b)
   147 {
   148 	useRelPos=b;
   149 }
   150 
   151 void LinkableMapObj::setRelPos()
   152 {
   153 	if (parObj)
   154 	{	
   155 		relPos.setX (absPos.x() - parObj->getChildPos().x() );
   156 		relPos.setY (absPos.y() - parObj->getChildPos().y() );
   157 
   158 		parObj->calcBBoxSize();
   159 		parObj->requestReposition();
   160 	}	
   161 }
   162 
   163 void LinkableMapObj::setRelPos(const QPoint &p)
   164 {
   165 	relPos=p;
   166 	if (parObj)
   167 	{	parObj->calcBBoxSize();
   168 		parObj->requestReposition();
   169 	}	
   170 }
   171 
   172 int LinkableMapObj::getTopPad()
   173 {
   174 	return topPad;
   175 }
   176 
   177 int LinkableMapObj::getLeftPad()
   178 {
   179 	return leftPad;
   180 }
   181 
   182 int LinkableMapObj::getRightPad()
   183 {
   184 	return rightPad;
   185 }
   186 
   187 LinkStyle LinkableMapObj::getDefLinkStyle ()
   188 {
   189 	if (!mapEditor) return StyleUndef;
   190 
   191 	LinkStyle ls=mapEditor->getLinkStyle();
   192 	switch (ls)
   193 	{
   194 		case StyleLine: 
   195 			return ls;
   196 			break;
   197 		case StyleParabel:
   198 			return ls;
   199 			break;
   200 		case StylePolyLine:	
   201 			if (depth>1)
   202 				return StyleLine;
   203 			else	
   204 				return ls;
   205 			break;
   206 		case StylePolyParabel:	
   207 			if (depth>1)
   208 				return StyleParabel;
   209 			else	
   210 				return ls;
   211 			break;
   212 		default: 
   213 			break;	
   214 	}	
   215 	return StyleUndef;
   216 }
   217 
   218 void LinkableMapObj::setLinkStyle(LinkStyle newstyle)
   219 {
   220 	//if (newstyle=style) return;
   221 	delLink();
   222 		
   223 	style=newstyle;
   224 
   225     if (childObj!=NULL && parObj != NULL)
   226     {
   227 		int i;
   228 		QCanvasLine* cl;
   229 		switch (style)
   230 		{
   231 			case StyleUndef:
   232 				bottomline->hide();
   233 				break;
   234 			case StyleLine: 
   235 				l = new QCanvasLine(canvas);
   236 				l->setPen( QPen(linkcolor, 1) );
   237 				l->setZ(Z_LINK);
   238 				if (visible)
   239 					l->show();
   240 				else
   241 					l->hide();
   242 				break;
   243 			case StyleParabel:
   244 				for (i=0;i<arcsegs;i++)
   245 				{
   246 					cl = new QCanvasLine(canvas);
   247 					cl->setPen( QPen(linkcolor, 1) );
   248 					cl->setPoints( 0,0,i*10,100);
   249 					cl->setZ(Z_LINK);
   250 					if (visible)
   251 						cl->show();
   252 					else
   253 						cl->hide();
   254 					segment.append(cl);
   255 				}
   256 				pa0.resize (arcsegs+1);
   257 				break;
   258 			case StylePolyLine:	
   259 				p = new QCanvasPolygon(canvas);
   260 				p->setBrush( linkcolor );
   261 				p->setZ(Z_LINK);
   262 				if (visible)
   263 					p->show();
   264 				else
   265 					p->hide();
   266 				pa0.resize (3);
   267 				// TODO a bit awkward: draw the lines additionally to polygon, to avoid
   268 				// missing pixels, when polygon is extremly flat
   269 				l = new QCanvasLine(canvas);
   270 				l->setPen( QPen(linkcolor, 1) );
   271 				l->setZ(Z_LINK);
   272 				if (visible)
   273 					l->show();
   274 				else
   275 					l->hide();
   276 				break;
   277 			case StylePolyParabel:	
   278 				p = new QCanvasPolygon(canvas);
   279 				p->setBrush( linkcolor );
   280 				p->setZ(Z_LINK);
   281 				if (visible)
   282 					p->show();
   283 				else
   284 					p->hide();
   285 				pa0.resize (arcsegs*2+2);
   286 				pa1.resize (arcsegs+1);
   287 				pa2.resize (arcsegs+1);
   288 
   289 				// TODO a bit awkward: draw the lines additionally 
   290 				// to polygon, to avoid missing pixels, 
   291 				// if polygon is extremly flat
   292 				for (i=0;i<arcsegs;i++)
   293 				{
   294 					cl = new QCanvasLine(canvas);
   295 					cl->setPen( QPen(linkcolor, 1) );
   296 					cl->setPoints( 0,0,i*10,100);
   297 					cl->setZ(Z_LINK);
   298 					if (visible)
   299 						cl->show();
   300 					else
   301 						cl->hide();
   302 					segment.append(cl);
   303 				}
   304 				break;
   305 			default: 
   306 				break;	
   307 		}	
   308 	} 
   309 }
   310 
   311 LinkStyle LinkableMapObj::getLinkStyle()
   312 {
   313 	return style;
   314 }
   315 
   316 void LinkableMapObj::setHideLinkUnselected(bool b)
   317 {
   318 	hideLinkUnselected=b;
   319 	setVisibility (visible);
   320 	updateLink();
   321 }
   322 
   323 bool LinkableMapObj::getHideLinkUnselected()
   324 {
   325 	return hideLinkUnselected;
   326 }
   327 
   328 void LinkableMapObj::setLinkPos(LinkPos lp)
   329 {
   330 	linkpos=lp;
   331 }
   332 
   333 LinkPos LinkableMapObj::getLinkPos()
   334 {
   335 	return linkpos;
   336 }
   337 
   338 
   339 void LinkableMapObj::setLinkColor()
   340 {
   341 	// Overloaded in BranchObj and childs
   342 	// here only set default color
   343 	if (mapEditor)
   344 		setLinkColor (mapEditor->getDefLinkColor());
   345 }
   346 
   347 void LinkableMapObj::setLinkColor(QColor col)
   348 {
   349 	linkcolor=col;
   350     bottomline->setPen( QPen(linkcolor, 1) );
   351 	QCanvasLine *cl;
   352 	switch (style)
   353 	{
   354 		case StyleLine:
   355 			l->setPen( QPen(col,1));
   356 			break;	
   357 		case StyleParabel:	
   358 			for (cl=segment.first(); cl; cl=segment.next() )
   359 				cl->setPen( QPen(col,1));
   360 			break;
   361 		case StylePolyLine:
   362 			p->setBrush( QBrush(col));
   363 			l->setPen( QPen(col,1));
   364 			break;
   365 		case StylePolyParabel:	
   366 			p->setBrush( QBrush(col));
   367 			for (cl=segment.first(); cl; cl=segment.next() )
   368 				cl->setPen( QPen(col,1));
   369 			break;
   370 		default:
   371 			break;
   372 	} // switch (style)	
   373 }
   374 
   375 QColor LinkableMapObj::getLinkColor()
   376 {
   377 	return linkcolor;
   378 }
   379 
   380 FrameType LinkableMapObj::getFrameType()
   381 {
   382 	return frame->getFrameType();
   383 }
   384 
   385 void LinkableMapObj::setFrameType(const FrameType &t)
   386 {
   387 	frame->setFrameType(t);
   388 	calcBBoxSize();
   389 	positionBBox();
   390 	requestReposition();
   391 }
   392 
   393 void LinkableMapObj::setFrameType(const QString &t)
   394 {
   395 	frame->setFrameType(t);
   396 	calcBBoxSize();
   397 	positionBBox();
   398 	requestReposition();
   399 }
   400 
   401 void LinkableMapObj::setVisibility (bool v)
   402 {
   403 	QCanvasLine* cl;
   404 	MapObj::setVisibility (v);
   405 	bool visnow=visible;
   406 	if (hideLinkUnselected && !selected)
   407 		visnow=false;
   408 
   409 	if (visnow) 
   410 	{
   411 		bottomline->show();
   412 		switch (style)
   413 		{
   414 			case StyleLine:
   415 				if (l) l->show();
   416 				break;
   417 			case StyleParabel:	
   418 				for (cl=segment.first(); cl; cl=segment.next() )
   419 					cl->show();
   420 				break;	
   421 			case StylePolyLine:
   422 				if (p) p->show();
   423 				if (l) l->show();
   424 				break;
   425 			case StylePolyParabel:	
   426 				for (cl=segment.first(); cl; cl=segment.next() )
   427 					cl->show();
   428 				if (p) p->show();
   429 				break;
   430 			default:
   431 				break;
   432 		}
   433 	} else 
   434 	{
   435 		bottomline->hide();
   436 		switch (style)
   437 		{
   438 			case StyleLine:
   439 				if (l) l->hide();
   440 				break;
   441 			case StyleParabel:	
   442 				for (cl=segment.first(); cl; cl=segment.next() )
   443 					cl->hide();
   444 				break;	
   445 			case StylePolyLine:
   446 				if (p) p->hide();
   447 				if (l) l->hide();
   448 				break;
   449 			case StylePolyParabel:	
   450 				for (cl=segment.first(); cl; cl=segment.next() )
   451 					cl->hide();
   452 				if (p) p->hide();
   453 				break;
   454 			default:
   455 				break;
   456 		}
   457 	}	
   458 }
   459 
   460 void LinkableMapObj::updateLink()
   461 {
   462     // needs:
   463     //	childPos of parent
   464     //	orient   of parent
   465     //	style
   466     // 
   467     // sets:
   468     //	orientation
   469     //	childPos	(by calling setDockPos())
   470     //	parPos		(by calling setDockPos())
   471 	//  bottomlineY
   472     //	drawing of the link itself
   473 
   474 	// updateLink is called from move, but called from constructor we don't
   475 	// have parents yet...
   476 	if (style==StyleUndef) return;	
   477 
   478 	if (frame->getFrameType() == NoFrame)
   479 		linkpos=LinkBottom;
   480 	else	
   481 		linkpos=LinkMiddle;
   482 	switch (linkpos)
   483 	{
   484 		case LinkMiddle:
   485 			bottomlineY=bbox.top()+bbox.height() /2;	// draw link to middle (of frame)
   486 			break;
   487 		default :
   488 			bottomlineY=bbox.bottom()-1;	// draw link to bottom of box
   489 			break;
   490 	}
   491 	
   492     double p2x,p2y;								// Set P2 Before setting
   493 	if (!link2ParPos)
   494 	{
   495 		p2x=QPoint( parObj->getChildPos() ).x();	// P1, we have to look at
   496 		p2y=QPoint( parObj->getChildPos() ).y();	// orientation
   497 	} else	
   498 	{
   499 		p2x=QPoint( parObj->getParPos() ).x();	
   500 		p2y=QPoint( parObj->getParPos() ).y();
   501 	} 
   502 
   503 	LinkOrient orientOld=orientation;
   504 
   505     // Set orientation, first look for orientation of parent
   506     if (parObj->getOrientation() != OrientUndef ) 
   507 		// use the orientation of the parent:
   508 		orientation=parObj->getOrientation();
   509     else
   510     {
   511 		// calc orientation depending on position rel to mapCenter
   512 		if (absPos.x() < QPoint(parObj->getChildPos() ).x() )
   513 			orientation=OrientLeftOfCenter; 
   514 		else
   515 			orientation=OrientRightOfCenter;
   516     }
   517 
   518 	if ((orientation!=orientOld) && (orientOld!= OrientUndef))
   519 	{
   520 		// Orientation just changed. Reorient this subbranch, because move is called
   521 		// before updateLink => Position is still the old one, which could lead to 
   522 		// linking of subranch to itself => segfault
   523 		//
   524 		// Also possible: called in BranchObj::init(), then orientOld==OrientUndef,
   525 		// no need to reposition now
   526 		reposition();
   527 	}
   528 	
   529 	setDockPos();
   530 
   531 	double p1x=parPos.x();	// Link is drawn from P1 to P2
   532 	double p1y=parPos.y();
   533 
   534 	double vx=p2x - p1x;	// V=P2-P1
   535 	double vy=p2y - p1y;
   536 
   537 	// Draw the horizontal line below heading (from ChildPos to ParPos)
   538 	bottomline->setPoints (qRound(childPos.x()),
   539 		qRound(childPos.y()),
   540 		qRound(p1x),
   541 		qRound(p1y) );
   542 
   543 	double a;	// angle
   544 	if (vx > -0.000001 && vx < 0.000001)
   545 		a=M_PI_2;
   546 	else
   547 		a=atan( vy / vx );
   548 	// "turning point" for drawing polygonal links
   549 	QPoint tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start));	
   550 	
   551 	QCanvasLine *cl;
   552 
   553 	int i;
   554 
   555     // Draw the link
   556 	switch (style)
   557 	{
   558 		case StyleLine:
   559 			l->setPoints( qRound (parPos.x()),
   560 				qRound(parPos.y()),
   561 				qRound(p2x),
   562 				qRound(p2y) );
   563 			break;	
   564 		case StyleParabel:	
   565 			parabel (pa0, p1x,p1y,p2x,p2y);
   566 			i=0;
   567 			for (cl=segment.first(); cl; cl=segment.next() )
   568 			{	
   569 				cl->setPoints( pa0.point(i).x(), pa0.point(i).y(),pa0.point(i+1).x(),pa0.point(i+1).y());
   570 				i++;
   571 			}
   572 			break;
   573 		case StylePolyLine:
   574 			pa0[0]=QPoint (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
   575 			pa0[1]=QPoint (qRound(p2x-tp.x()), qRound(p2y-tp.y()));
   576 			pa0[2]=QPoint (qRound (parPos.x()), qRound(parPos.y()) );
   577 			p->setPoints (pa0);
   578 			// here too, draw line to avoid missing pixels
   579 			l->setPoints( qRound (parPos.x()),
   580 				qRound(parPos.y()),
   581 				qRound(p2x),
   582 				qRound(p2y) );
   583 			break;
   584 		case StylePolyParabel:	
   585 			parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y());
   586 			parabel (pa2, p1x,p1y,p2x-tp.x(),p2y-tp.y());
   587 			for (i=0;i<=arcsegs;i++)
   588 			{
   589 				// Combine the arrays to a single one
   590 				pa0[i]=pa1[i];
   591 				pa0[i+arcsegs+1]=pa2[arcsegs-i];
   592 			}	
   593 			p->setPoints (pa0);
   594 			i=0;
   595 			for (cl=segment.first(); cl; cl=segment.next() )
   596 			{	
   597 				cl->setPoints( pa1.point(i).x(), pa1.point(i).y(),pa1.point(i+1).x(),pa1.point(i+1).y());
   598 				i++;
   599 			}
   600 			break;
   601 		default:
   602 			break;
   603 	} // switch (style)	
   604 }
   605 	
   606 LinkableMapObj* LinkableMapObj::getChildObj()
   607 {
   608     return childObj;
   609 }
   610 
   611 LinkableMapObj* LinkableMapObj::getParObj()
   612 {
   613     return parObj;
   614 }
   615 
   616 LinkableMapObj* LinkableMapObj::findObjBySelect (QString s)
   617 {
   618 	LinkableMapObj *lmo=this;
   619 	QString part;
   620 	QString typ;
   621 	QString num;
   622 	while (!s.isEmpty() )
   623 	{
   624 		part=s.section(",",0,0);
   625 		typ=part.left (3);
   626 		num=part.right(part.length() - 3);
   627 		if (typ=="mc:")
   628 		{
   629 			if (depth>0)
   630 				return false;	// in a subtree there is no center
   631 			else
   632 				break;
   633 		} else
   634 			if (typ=="bo:")
   635 				lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
   636 			else
   637 				if (typ=="fi:")
   638 					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
   639 		if (!lmo) break;
   640 		
   641 		if (s.contains(","))
   642 			s=s.right(s.length() - part.length() -1 );
   643 		else	
   644 			break;
   645 	}
   646 	return lmo;
   647 }
   648 
   649 void LinkableMapObj::setDockPos()
   650 {
   651 	cout <<"LMO::setDockPos()\n";
   652 }
   653 
   654 QPoint LinkableMapObj::getChildPos()
   655 {
   656     return childPos;
   657 }
   658 
   659 QPoint LinkableMapObj::getParPos()
   660 {
   661     return parPos;
   662 }
   663 
   664 QPoint LinkableMapObj::getRelPos()
   665 {
   666 	return relPos;
   667 /* FIXME not needed? relPos was moved in 1.7.10 from
   668    floatobj to linkablemapobj. Before we had:
   669 	
   670 	if (!parObj) return QPoint (0,0);
   671     return QPoint(
   672 		absPos.x() - parObj->x(),
   673 		absPos.y() - parObj->y()
   674 	);
   675 */	
   676 }
   677 
   678 
   679 void LinkableMapObj::setUseOrientation (const bool &b)
   680 {	
   681 	if (useOrientation!=b)
   682 	{
   683 		useOrientation=b;
   684 		requestReposition();
   685 	}	
   686 }
   687 
   688 LinkOrient LinkableMapObj::getOrientation()
   689 {
   690     return orientation;
   691 }
   692 
   693 int LinkableMapObj::getDepth()
   694 {
   695     return depth;
   696 }
   697 
   698 void LinkableMapObj::setMapEditor (MapEditor *me)
   699 {
   700 	mapEditor=me;
   701 }
   702 
   703 MapEditor* LinkableMapObj::getMapEditor ()
   704 {
   705 	return mapEditor;
   706 }
   707 
   708 QPoint LinkableMapObj::getRandPos()
   709 {
   710 	// Choose a random position with given distance to parent:
   711 	double a=rand()%360 * 2 * M_PI / 360;
   712     return QPoint ( (int)( + 150*cos (a)),
   713                     (int)( + 150*sin (a)));
   714 }
   715 
   716 void LinkableMapObj::alignRelativeTo (QPoint ref)
   717 {
   718 	// FIXME testing, seems not to be used right now...
   719 	cout << "LMO::alignRelTo   ref="<<ref<<endl;
   720 }
   721 
   722 void LinkableMapObj::reposition()
   723 {
   724 	if (depth==0)
   725 	{
   726 		// only calculate the sizes once. If the deepest LMO changes its height,
   727 		// all upper LMOs have to change, too.
   728 		calcBBoxSizeWithChilds();
   729 
   730 	    alignRelativeTo ( QPoint (absPos.x(),
   731 							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
   732 	} else
   733 	{
   734 		// This is only important for moving branches:
   735 		// For editing a branch it isn't called...
   736 	    alignRelativeTo ( QPoint (absPos.x(),
   737 							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
   738 	}
   739 }
   740 
   741 void LinkableMapObj::requestReposition()
   742 {
   743 	if (!repositionRequest)
   744 	{
   745 		// Pass on the request to parental objects, if this hasn't
   746 		// been done yet
   747 		repositionRequest=true;
   748 		if (parObj) parObj->requestReposition();
   749 	}
   750 }
   751 
   752 void LinkableMapObj::forceReposition()
   753 {
   754 	// Sometimes a reposition has to be done immediatly: For example
   755 	// if the note editor flag changes, there is no user event in mapeditor
   756 	// which could collect requests for a reposition.
   757 	// Then we have to call forceReposition()
   758 	// But no rule without exception: While loading a map or undoing it,
   759 	// we want to block expensive repositioning, but just do it once at
   760 	// the end, thus check first:
   761 
   762 	if (mapEditor->isRepositionBlocked()) return;
   763 	
   764 	// Pass on the request to parental objects, if this hasn't been done yet
   765 	
   766 	if (parObj) 
   767 		parObj->forceReposition(); 
   768 	else 
   769 		reposition(); 
   770 }
   771 
   772 bool LinkableMapObj::repositionRequested()
   773 {
   774 	return repositionRequest;
   775 }
   776 
   777 
   778 void LinkableMapObj::setSelBox()
   779 {
   780     selbox->setX (clickBox.x() );
   781     selbox->setY (clickBox.y() );
   782     selbox->setSize (clickBox.width(), clickBox.height() );
   783 }
   784 
   785 void LinkableMapObj::select()
   786 {
   787 	setSelBox();
   788     selected=true;
   789     selbox->show();
   790 	setVisibility (visible);
   791 }
   792 
   793 
   794 void LinkableMapObj::unselect()
   795 {
   796     selected=false;
   797     selbox->hide();
   798 	setVisibility (visible);
   799 }
   800 
   801 void LinkableMapObj::parabel (QPointArray &ya, double p1x, double p1y, double p2x, double p2y)
   802 
   803 {
   804 	double vx=p2x - p1x;	// V=P2-P1
   805 	double vy=p2y - p1y;
   806 
   807 	double dx;				// delta x during calculation of parabel
   808 	
   809 	double pnx;				// next point
   810 	double pny;
   811 	double m;
   812 
   813 	if (vx > -0.0001 && vx < 0.0001)
   814 		m=0;
   815 	else	
   816 		m=(vy / (vx*vx));
   817 	dx=vx/(arcsegs);
   818 	int i;
   819 	ya.setPoint (0,QPoint (qRound(p1x),qRound(p1y)));
   820 	for (i=1;i<=arcsegs;i++)
   821 	{	
   822 		pnx=p1x+dx;
   823 		pny=m*(pnx-parPos.x())*(pnx-parPos.x())+parPos.y();
   824 		ya.setPoint (i,QPoint (qRound(pnx),qRound(pny)));
   825 		p1x=pnx;
   826 		p1y=pny;
   827 	}	
   828 }
   829 
   830 QString LinkableMapObj::getLinkAttr ()
   831 {
   832 	if (hideLinkUnselected)
   833 		return attribut ("hideLink","true");
   834 	else
   835 		return attribut ("hideLink","false");
   836 	
   837 }