4 #include "branchitem.h"
10 /////////////////////////////////////////////////////////////////
12 /////////////////////////////////////////////////////////////////
14 int XLinkObj::arrowSize=10; // make instances
16 XLinkObj::XLinkObj (QGraphicsScene* scene, TreeItem* ti):MapObj(scene,ti)
18 //cout << "Const XLinkObj (s)\n";
23 XLinkObj::~XLinkObj ()
25 //cout << "Destr XLinkObj\n";
31 void XLinkObj::init ()
33 XLinkItem *xli=(XLinkItem*)treeItem;
36 pen.setColor ( xli->getColor() );
37 pen.setWidth ( xli->getWidth() );
38 pen.setCapStyle ( Qt::RoundCap );
39 line=scene->addLine(QLineF(1,1,1,1),pen);
40 line->setZValue (Z_XLINK);
41 poly=scene->addPolygon(QPolygonF(),pen, xli->getColor());
42 poly->setZValue (Z_XLINK);
46 void XLinkObj::setEnd (QPointF p)
52 void XLinkObj::updateXLink()
58 // Only one of the linked branches is visible
59 BranchObj *bo=(BranchObj*)(visBranch->getLMO());
62 a=b=bo->getChildPos();
63 if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
68 pa<< QPointF(b.x(),b.y())<<
69 QPointF(b.x()-arrowSize,b.y()-arrowSize)<<
70 QPointF(b.x()-arrowSize,b.y()+arrowSize);
76 pa<< QPointF(b.x(),b.y())<<
77 QPointF(b.x()+arrowSize,b.y()-arrowSize)<<
78 QPointF(b.x()+arrowSize,b.y()+arrowSize);
79 poly->setPolygon (pa);
83 // Both linked branches are visible
84 BranchItem *bi=((XLinkItem*)treeItem)->getBegin();
87 // If a link is just drawn in the editor,
88 // we have already a beginBranch
89 BranchObj *bo=(BranchObj*)(bi->getLMO());
96 // This shouldn't be reached normally...
99 // FIXME-3 try to get rid of xLinkstate if (xLinkState==activeXLink && endBranch)
100 bi=((XLinkItem*)treeItem)->getEnd();
103 BranchObj *bo=(BranchObj*)(bi->getLMO());
115 XLinkItem *xli=(XLinkItem*)treeItem;
116 pen.setColor ( xli->getColor() );
117 pen.setWidth ( xli->getWidth() );
118 poly->setBrush (xli->getColor() );
120 line->setLine(a.x(), a.y(), b.x(), b.y());
123 void XLinkObj::positionBBox()
127 void XLinkObj::calcBBoxSize()
131 void XLinkObj::setVisibility (bool b)
133 MapObj::setVisibility (b);
149 void XLinkObj::setVisibility ()
151 BranchItem* beginBI=((XLinkItem*)treeItem)->getBegin();
152 BranchObj* beginBO=NULL;
153 if (beginBI) beginBO=(BranchObj*)(beginBI->getLMO());
155 BranchObj* endBO=NULL;
156 BranchItem* endBI=((XLinkItem*)treeItem)->getEnd();
157 if (endBI) endBO=(BranchObj*)(endBI->getLMO());
158 if (beginBO && endBO)
160 if(beginBO->isVisibleObj() && endBO->isVisibleObj())
161 { // Both ends are visible
163 setVisibility (true);
166 if(!beginBO->isVisibleObj() && !endBO->isVisibleObj())
167 { //None of the ends is visible
169 setVisibility (false);
171 { // Just one end is visible, draw a symbol that shows
172 // that there is a link to a scrolled branch
173 if (beginBO->isVisibleObj())
177 setVisibility (true);