5 /////////////////////////////////////////////////////////////////
7 /////////////////////////////////////////////////////////////////
9 LinkObj::LinkObj ():MapObj()
11 // cout << "Const LinkObj ()\n";
15 LinkObj::LinkObj (QCanvas* c):MapObj(c)
17 // cout << "Const LinkObj (c) called from MapCenterObj (c)\n";
24 // cout << "Destr LinkObj\n";
25 if (linkState!=undefinedLink)
35 linkState=undefinedLink;
37 line=new QCanvasLine (canvas);
38 line->setPoints (0,0,200,200);
39 line->setPen (QPen(QColor(200,200,200), 1));
41 setVisibility (false);
44 void LinkObj::copy (LinkObj* other)
46 // FIXME copy not used yet
47 cout << "LO::copy called\n";
49 setVisibility (other->visible);
50 beginBranch=other->beginBranch;
51 endBranch=other->endBranch;
54 void LinkObj::setBegin (BranchObj *bo)
60 beginPos=beginBranch->getChildPos();
64 void LinkObj::setEnd (BranchObj *bo)
70 endPos=endBranch->getChildPos();
74 void LinkObj::setEnd (QPoint p)
79 bool LinkObj::activate ()
81 if (beginBranch && endBranch)
84 beginBranch->addLink (this);
85 endBranch->addLink (this);
92 void LinkObj::deactivate ()
95 beginBranch->removeLinkRef (this);
98 endBranch->removeLinkRef (this);
101 linkState=undefinedLink;
106 bool LinkObj::isUsed()
108 if (beginBranch || endBranch || linkState!=undefinedLink)
114 void LinkObj::updateLink()
119 // Only one of the linked branches is visible
120 a=b=visBranch->getChildPos();
121 if (visBranch->getOrientation()==OrientRightOfCenter)
127 // Both linked branches are visible
129 // If a link is just drawn in the editor,
130 // we have already a beginBranch
131 a=beginBranch->getChildPos();
133 // This shouldn't be reached normally...
135 if (linkState==activeLink && endBranch)
136 b=endBranch->getChildPos();
142 if (line->startPoint()==a && line->endPoint()==b && !visBranch)
144 // update is called from both branches, so only
146 cout <<"LO__updateL returnung...\n";
153 line->setPoints (a.x(), a.y(), b.x(), b.y());
157 BranchObj* LinkObj::otherBranch(BranchObj* thisBranch)
159 if (!beginBranch && !endBranch)
161 if (thisBranch==beginBranch)
167 void LinkObj::positionBBox()
171 void LinkObj::calcBBoxSize()
175 void LinkObj::setVisibility (bool b)
177 MapObj::setVisibility (b);
188 void LinkObj::setVisibility ()
190 if (beginBranch && endBranch)
192 if(beginBranch->isVisibleObj() && endBranch->isVisibleObj())
193 { // Both ends are visible
194 setVisibility (true);
198 if(!beginBranch->isVisibleObj() && !endBranch->isVisibleObj())
199 { //None of the ends is visible
200 setVisibility (false);
203 { // Just one end is visible, draw a symbol that shows
204 // that there is a link to a scrolled branch
205 setVisibility (true);
206 if (beginBranch->isVisibleObj())
207 visBranch=beginBranch;