diff -r 9db3eaa21237 -r 6783e13bb05d linkobj.cpp --- a/linkobj.cpp Tue Feb 08 14:07:19 2005 +0000 +++ b/linkobj.cpp Sat Apr 09 22:50:08 2005 +0000 @@ -8,20 +8,20 @@ LinkObj::LinkObj ():MapObj() { -// cout << "Const LinkObj ()\n"; - init(); + // cout << "Const LinkObj ()\n"; + init(); } LinkObj::LinkObj (QCanvas* c):MapObj(c) { -// cout << "Const LinkObj (c) called from MapCenterObj (c)\n"; - init(); + // cout << "Const LinkObj (c) called from MapCenterObj (c)\n"; + init(); } LinkObj::~LinkObj () { -// cout << "Destr LinkObj\n"; + // cout << "Destr LinkObj\n"; if (linkState!=undefinedLink) deactivate(); delete (line); @@ -31,6 +31,7 @@ { beginBranch=NULL; endBranch=NULL; + visBranch=NULL; linkState=undefinedLink; line=new QCanvasLine (canvas); @@ -91,11 +92,12 @@ void LinkObj::deactivate () { if (beginBranch) - beginBranch->removeLink (this); + beginBranch->removeLinkRef (this); beginBranch=NULL; if (endBranch) - endBranch->removeLink (this); + endBranch->removeLinkRef (this); endBranch=NULL; + visBranch=NULL; linkState=undefinedLink; line->hide(); @@ -112,22 +114,38 @@ void LinkObj::updateLink() { QPoint a,b; - if (beginBranch) - // If a link is just drawed in the editor, - // we have already a beginBranch - a=beginBranch->getChildPos(); - else - // This shouldn't be reached normally... - a=beginPos; - if (linkState==activeLink && endBranch) - b=endBranch->getChildPos(); - else - b=endPos; - - if (line->startPoint()==a && line->endPoint()==b) + if (visBranch) + { + // Only one of the linked branches is visible + a=b=visBranch->getChildPos(); + if (visBranch->getOrientation()==OrientRightOfCenter) + b.setX (b.x()+25); + else + b.setX (b.x()-25); + } else + { + // Both linked branches are visible + if (beginBranch) + // If a link is just drawn in the editor, + // we have already a beginBranch + a=beginBranch->getChildPos(); + else + // This shouldn't be reached normally... + a=beginPos; + if (linkState==activeLink && endBranch) + b=endBranch->getChildPos(); + else + b=endPos; + } + + + if (line->startPoint()==a && line->endPoint()==b && !visBranch) + { // update is called from both branches, so only // update if needed + cout <<"LO__updateL returnung...\n"; return; + } else { beginPos=a; @@ -167,3 +185,31 @@ } } +void LinkObj::setVisibility () +{ + if (beginBranch && endBranch) + { + if(beginBranch->isVisibleObj() && endBranch->isVisibleObj()) + { // Both ends are visible + setVisibility (true); + visBranch=NULL; + } else + { + if(!beginBranch->isVisibleObj() && !endBranch->isVisibleObj()) + { //None of the ends is visible + setVisibility (false); + visBranch=NULL; + } else + { // Just one end is visible, draw a symbol that shows + // that there is a link to a scrolled branch + setVisibility (true); + if (beginBranch->isVisibleObj()) + visBranch=beginBranch; + else + visBranch=endBranch; + + } + } + } +} +