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)
34 linkState=undefinedLink;
36 line=new QCanvasLine (canvas);
37 line->setPoints (0,0,200,200);
38 line->setPen (QPen(QColor(200,200,200), 1));
40 setVisibility (false);
43 void LinkObj::copy (LinkObj* other)
45 // FIXME copy not used yet
46 cout << "LO::copy called\n";
48 setVisibility (other->visible);
49 beginBranch=other->beginBranch;
50 endBranch=other->endBranch;
53 void LinkObj::setBegin (BranchObj *bo)
59 beginPos=beginBranch->getChildPos();
63 void LinkObj::setEnd (BranchObj *bo)
69 endPos=endBranch->getChildPos();
73 void LinkObj::setEnd (QPoint p)
78 bool LinkObj::activate ()
80 if (beginBranch && endBranch)
83 beginBranch->addLink (this);
84 endBranch->addLink (this);
91 void LinkObj::deactivate ()
94 beginBranch->removeLink (this);
97 endBranch->removeLink (this);
99 linkState=undefinedLink;
104 bool LinkObj::isUsed()
106 if (beginBranch || endBranch || linkState!=undefinedLink)
112 void LinkObj::updateLink()
116 // If a link is just drawed in the editor,
117 // we have already a beginBranch
118 a=beginBranch->getChildPos();
120 // This shouldn't be reached normally...
122 if (linkState==activeLink && endBranch)
123 b=endBranch->getChildPos();
127 if (line->startPoint()==a && line->endPoint()==b)
128 // update is called from both branches, so only
135 line->setPoints (a.x(), a.y(), b.x(), b.y());
139 BranchObj* LinkObj::otherBranch(BranchObj* thisBranch)
141 if (!beginBranch && !endBranch)
143 if (thisBranch==beginBranch)
149 void LinkObj::positionBBox()
153 void LinkObj::calcBBoxSize()
157 void LinkObj::setVisibility (bool b)
159 MapObj::setVisibility (b);