00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #include <QtGui>
00023 
00024 #include "grouplink.h"
00025 #include "node.h"
00026 
00027 GroupLink::GroupLink(Node *fromNode, QString fromProp, Node *toNode, QString toProp, bool _input, QGraphicsItem * parent, QGraphicsScene * scene): Link(fromNode, fromProp, toNode, toProp, parent, scene), input(_input)
00028 {
00029         setColor(QColor(255, 127, 0));
00030         QPen dotPen = pen();
00031         dotPen.setStyle(Qt::DashDotLine);
00032         setPen(dotPen);
00033 }
00034 
00035 void GroupLink::trackNodes()
00036 {
00037         
00038         
00039         
00040         double zvalue = (myFromNode->zValue() > myToNode->zValue()) ? myFromNode->zValue() + 1 : myToNode->zValue() + 1;
00041 
00042         
00043         QGraphicsItem *ancestor = myFromNode->parentItem();
00044         QPen myPen = pen();
00045     while (ancestor) {
00046                 setZValue(ancestor->zValue() + 1);
00047                 myPen.setWidthF(myPen.width() * 0.4);
00048                 ancestor = ancestor->parentItem();
00049         }
00050 
00051         
00052         QPointF orig = myFromNode->scenePointPos(myFromProp, input); 
00053         QPointF dest = myToNode->scenePointPos(myToProp, input); 
00054 
00055         if (orig.x() <= dest.x()) {
00056                 setZValue(zvalue);
00057                 setPen(myPen);
00058                 setLine(QLineF(orig, dest));
00059                 line2.hide();
00060                 line3.hide();
00061                 line4.hide();
00062                 line5.hide();
00063         }
00064         else {
00065                 
00066                 double origDesp = 10.0 * (fromNode()->numProps() - fromNode()->propPoint(fromProp(), true) + 1);
00067                 double destDesp = 10.0 * (toNode()->numProps() - toNode()->propPoint(toProp(), true) + 1);
00068 
00069                 
00070                 double origBottom =  fromNode()->sceneBoundingRect().bottom() + origDesp;
00071                 double destBottom =  toNode()->sceneBoundingRect().bottom() + destDesp;
00072                 double bottom = origBottom > destBottom ? origBottom : destBottom;
00073 
00074                 setZValue(zvalue);
00075                 line2.setZValue(zvalue);
00076                 line3.setZValue(zvalue);
00077                 line4.setZValue(zvalue);
00078                 line5.setZValue(zvalue);
00079                 setPen(myPen);
00080                 line2.setPen(myPen);
00081                 line3.setPen(myPen);
00082                 line4.setPen(myPen);
00083                 line5.setPen(myPen);
00084                 setLine(QLineF(orig, orig + QPointF(origDesp, 0.0)));
00085                 line2.setLine(QLineF(orig + QPointF(origDesp, 0.0), QPointF(orig.x() + origDesp, bottom)));
00086                 line3.setLine(QLineF(QPointF(orig.x() + origDesp, bottom), QPointF(dest.x() - destDesp, bottom)));
00087                 line4.setLine(QLineF(QPointF(dest.x() - destDesp, bottom), dest + QPointF(0.0 - destDesp, 0.0)));
00088                 line5.setLine(QLineF(dest + QPointF(0.0 - destDesp, 0.0), dest));
00089                 if ((myFromNode->isVisible()) && (myToNode->isVisible())) {
00090                         line2.show();
00091                         line3.show();
00092                         line4.show();
00093                         line5.show();
00094                 }
00095         }
00096 }
00097 
00098