X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/f311fbc3e1436bf248c54225f0743cfa671c4bd7..3bbc311e444c1ef9ac66dd6861fb0acb13ddb72a:/ConnectionItem.cpp?ds=sidebyside diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index eaf46c2..c99d489 100644 --- a/ConnectionItem.cpp +++ b/ConnectionItem.cpp @@ -12,8 +12,7 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, InterfaceItem* _iface2, Dispatcher* _dispatcher, - Parameters* _params, - QGraphicsItem *_parent) : QGraphicsItem(_parent) { + Parameters* _params) : QGraphicsItem() { dispatcher = _dispatcher; @@ -25,6 +24,8 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, case 1 : ref1 is group interface, and ref2 block interface of a block within the group case 2 : the opposite of case 1 case 3 : ref1 and ref2 are block interface of blocks that are both within the same parent group. + case 4 : ref1 is source interface and ref2 interface of top group + case 5 : the opposite of case 4 */ if (ref1->getOwner() == ref2->getOwner()->getParent()) { @@ -72,6 +73,14 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, fromInterfaceItem = _iface1; } } + else if ((ref1->getOwner()->isSourceBlock()) && (ref2->getOwner()->isTopGroupBlock())) { + fromInterfaceItem = _iface1; + toInterfaceItem = _iface2; + } + else if ((ref2->getOwner()->isSourceBlock()) && (ref1->getOwner()->isTopGroupBlock())) { + fromInterfaceItem = _iface2; + toInterfaceItem = _iface1; + } // adding this to interface items fromInterfaceItem->addConnectionItem(this); toInterfaceItem->addConnectionItem(this); @@ -84,6 +93,13 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, setFlag(ItemSendsGeometryChanges); setCursor(Qt::PointingHandCursor); setZValue(0); + + if (fromInterfaceItem->refInter->getPurpose() == AbstractInterface::Data) { + visible = true; + } + else { + visible = false; + } setPath(); } @@ -133,6 +149,8 @@ void ConnectionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + if (!visible) return; + painter->setPen(Qt::blue); if(selected){ painter->setPen(Qt::red); @@ -150,8 +168,30 @@ void ConnectionItem::setPath() { // signals to the scene that this connection is going to change of shape. prepareGeometryChange(); - pointFrom = fromInterfaceItem->getEndPointInGroup(); - pointTo = toInterfaceItem->getEndPointInGroup(); + bool withinGroup = false; + /* NB: four cases + 1: from group input iface to box input iface + 2: from output box iface to group output iface + 3: from output box iface to input box iface + 4: from source output iface to input group iface + + For cases 1 & 2, the position of group iface is given by getStartPosition + For all other cases, the iface from and to position is given by getEndPosition + */ + if ((fromInterfaceItem->getOwner()->isGroupItem()) && (toInterfaceItem->getOwner()->isBoxItem())) { + pointFrom = fromInterfaceItem->getStartPosition(); + pointTo = toInterfaceItem->getEndPosition(); + withinGroup = true; + } + else if ((toInterfaceItem->getOwner()->isGroupItem()) && (fromInterfaceItem->getOwner()->isBoxItem())) { + pointFrom = fromInterfaceItem->getEndPosition(); + pointTo = toInterfaceItem->getStartPosition(); + withinGroup = true; + } + else { + pointFrom = fromInterfaceItem->getEndPosition(); + pointTo = toInterfaceItem->getEndPosition(); + } int oriFrom, oriTo; oriFrom = fromInterfaceItem->getOrientation(); @@ -160,36 +200,38 @@ void ConnectionItem::setPath() { /* NB: if src or dest is onwed by a GroupItem the orientation must be changed as it is a block. */ - if(fromInterfaceItem->owner->isGroupItem()){ - switch(fromInterfaceItem->getOrientation()){ - case Parameters::North : - oriFrom = Parameters::South; - break; - case Parameters::South : - oriFrom = Parameters::North; - break; - case Parameters::East : - oriFrom = Parameters::West; - break; - case Parameters::West : - oriFrom = Parameters::East; - break; - } - } - if(toInterfaceItem->owner->isGroupItem()){ - switch(toInterfaceItem->getOrientation()){ - case Parameters::North : - oriTo = Parameters::South; - break; - case Parameters::South : - oriTo = Parameters::North; - break; - case Parameters::East : - oriTo = Parameters::West; - break; - case Parameters::West : - oriTo = Parameters::East; - break; + if (withinGroup) { + if(fromInterfaceItem->owner->isGroupItem()){ + switch(fromInterfaceItem->getOrientation()){ + case Parameters::North : + oriFrom = Parameters::South; + break; + case Parameters::South : + oriFrom = Parameters::North; + break; + case Parameters::East : + oriFrom = Parameters::West; + break; + case Parameters::West : + oriFrom = Parameters::East; + break; + } + } + else if(toInterfaceItem->owner->isGroupItem()){ + switch(toInterfaceItem->getOrientation()){ + case Parameters::North : + oriTo = Parameters::South; + break; + case Parameters::South : + oriTo = Parameters::North; + break; + case Parameters::East : + oriTo = Parameters::West; + break; + case Parameters::West : + oriTo = Parameters::East; + break; + } } } double gap1 = 0.0;