X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/819b9aaf8a357efbf4d095ef9268cbcbb46c52e9..624231601a0f5daea9b8809993ad3503beafce4f:/ConnectionItem.cpp diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index 78a3651..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); @@ -159,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(); @@ -169,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;