6 #include "branchitem.h"
8 /////////////////////////////////////////////////////////////////
10 /////////////////////////////////////////////////////////////////
12 int XLinkObj::arrowSize=10; // make instances
14 XLinkObj::XLinkObj (QGraphicsScene* scene,Link *l):MapObj(scene)
16 //qDebug()<< "Const XLinkObj (s,Link)";
23 XLinkObj::~XLinkObj ()
25 //qDebug() << "Destr XLinkObj";
31 void XLinkObj::init ()
35 pen.setColor ( link->getColor() );
36 pen.setWidth ( link->getWidth() );
37 pen.setCapStyle ( Qt::RoundCap );
38 line=scene->addLine(QLineF(1,1,1,1),pen);
39 line->setZValue (Z_LINK);
40 poly=scene->addPolygon(QPolygonF(),pen, link->getColor());
41 poly->setZValue (Z_LINK);
45 void XLinkObj::setEnd (QPointF p)
51 void XLinkObj::updateXLink()
57 // Only one of the linked branches is visible
58 BranchObj *bo=(BranchObj*)(visBranch->getLMO());
61 a=b=bo->getChildPos();
62 if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
67 pa<< QPointF(b.x(),b.y())<<
68 QPointF(b.x()-arrowSize,b.y()-arrowSize)<<
69 QPointF(b.x()-arrowSize,b.y()+arrowSize);
75 pa<< QPointF(b.x(),b.y())<<
76 QPointF(b.x()+arrowSize,b.y()-arrowSize)<<
77 QPointF(b.x()+arrowSize,b.y()+arrowSize);
78 poly->setPolygon (pa);
82 // Both linked branches are visible
83 BranchItem *bi=link->getBeginBranch();
86 // If a link is just drawn in the editor,
87 // we have already a beginBranch
88 BranchObj *bo=(BranchObj*)(bi->getLMO());
95 // This shouldn't be reached normally...
98 bi=link->getEndBranch();
101 BranchObj *bo=(BranchObj*)(bi->getLMO());
113 pen.setColor ( link->getColor() );
114 pen.setWidth ( link->getWidth() );
115 poly->setBrush (link->getColor() );
117 line->setLine(a.x(), a.y(), b.x(), b.y());
120 void XLinkObj::positionBBox()
124 void XLinkObj::calcBBoxSize()
128 void XLinkObj::setVisibility (bool b)
130 MapObj::setVisibility (b);
146 void XLinkObj::setVisibility ()
148 BranchItem* beginBI=link->getBeginBranch();
149 BranchObj* beginBO=NULL;
150 if (beginBI) beginBO=(BranchObj*)(beginBI->getLMO());
152 BranchObj* endBO=NULL;
153 BranchItem* endBI=link->getEndBranch();
154 if (endBI) endBO=(BranchObj*)(endBI->getLMO());
155 if (beginBO && endBO)
157 if(beginBO->isVisibleObj() && endBO->isVisibleObj())
158 { // Both ends are visible
160 setVisibility (true);
163 if(!beginBO->isVisibleObj() && !endBO->isVisibleObj())
164 { //None of the ends is visible
166 setVisibility (false);
168 { // Just one end is visible, draw a symbol that shows
169 // that there is a link to a scrolled branch
170 if (beginBO->isVisibleObj())
174 setVisibility (true);