X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..dd016ff4a3d4c5d4f90277637f86cdc31a7a91f8:/GroupItem.cpp diff --git a/GroupItem.cpp b/GroupItem.cpp index 04d7bca..fa341b2 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -9,6 +9,7 @@ #include "AbstractInterface.h" #include "ConnectedInterface.h" #include "GroupScene.h" +#include "ParametersWindow.h" GroupItem::GroupItem(BoxItem *_parentItem, @@ -17,6 +18,9 @@ GroupItem::GroupItem(BoxItem *_parentItem, Parameters *_params) throw(Exception) :AbstractBoxItem( _refBlock, _dispatcher, _params) { parentItem = _parentItem; + if (parentItem != NULL) { + parentItem->setChildGroupItem(this); + } /* minimumBoxWidth = nameWidth+2*nameMargin; @@ -36,7 +40,8 @@ GroupItem::GroupItem(BoxItem *_parentItem, setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); - updateGeometry(); + + updateGeometry(InterfaceMove); QPointF initPos = QPointF(0.0,0.0) - originPoint; setPos(initPos); cout << "total size of group: " << totalWidth << "," << totalHeight << endl; @@ -155,7 +160,7 @@ void GroupItem::updateMinimumSize() { } void GroupItem::updateShape() { - updateGeometry(); + updateGeometry(InterfaceMove); } bool GroupItem::updateGeometry(ChangeType type) { @@ -163,20 +168,29 @@ bool GroupItem::updateGeometry(ChangeType type) { QPointF oldOrigin = originPoint; QSize oldSize(totalWidth,totalHeight); - updateMinimumSize(); bool boxSizeChanged = false; + + // whatever the change, the minimum size may have changed + updateMinimumSize(); + + if (type == Resize) { + boxSizeChanged = true; + } + // if an internal block has moved, the actual box size may be inadequate if (boxWidth < minimumBoxWidth) { boxWidth = minimumBoxWidth; boxSizeChanged = true; } if (boxHeight < minimumBoxHeight) { boxHeight = minimumBoxHeight; - boxSizeChanged = true; + boxSizeChanged = true; } + if (boxSizeChanged) { updateInterfacesAndConnections(); } + // compute the max. width of interfaces' name for 4 orientations. int maxSouth = 0; int maxNorth = 0; @@ -221,7 +235,7 @@ bool GroupItem::updateGeometry(ChangeType type) { originPoint.setY(y); if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) { - //cout << "must change group item shape" << endl; + cout << "must change group item shape" << endl; prepareGeometryChange(); return true; } @@ -283,7 +297,7 @@ void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { cout << "abnormal case while resizing block" << endl; break; } - updateGeometry(); + updateGeometry(Resize); /* // recompute the geometry of the block updateGeometry(); @@ -302,16 +316,16 @@ void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { } else if(params->editState == Parameters::EditInterfaceMove) { prepareGeometryChange(); - deplaceInterface(event->pos()); + moveInterfaceTo(event->pos()); // recompute the geometry of the block - updateGeometry(); + updateGeometry(InterfaceMove); // update connection from/to the selected interface foreach(ConnectionItem *item, getScene()->getConnectionItems()){ if ((item->getFromInterfaceItem() == currentInterface) || (item->getToInterfaceItem() == currentInterface)) { - item->setPathes(); + item->setPath(); } } - update(); + //update(); } } @@ -327,7 +341,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - dispatcher->setCurrentGroupWidget(getScene()->getGroupWindow()); + dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); /* NOTE : commneted because group interface are normally created and the connected directly to a block within @@ -490,12 +504,19 @@ void GroupItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu menu; + QAction* titleAction = NULL; QAction* showProperties = NULL; QAction* removeAction = NULL; QAction* renameAction = NULL; + QAction* showParameters = NULL; InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y()); - if( ifaceItem != NULL){ + + // menu for interface + if( ifaceItem != NULL) { + titleAction = menu.addAction("Interface operations"); + titleAction->setEnabled(false); + menu.addSeparator(); showProperties = menu.addAction("Show properties"); renameAction = menu.addAction("Rename"); menu.addSeparator(); @@ -510,6 +531,13 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { } } else { + titleAction = menu.addAction("Block operations"); + titleAction->setEnabled(false); + menu.addSeparator(); + + if (refBlock->nbParameters() > 0) { + showParameters = menu.addAction("Show parameters"); + } renameAction = menu.addAction("Rename"); } QAction* selectedAction = menu.exec(event->screenPos()); @@ -518,16 +546,19 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { if(selectedAction == renameAction){ if(ifaceItem != NULL) - dispatcher->rename(ifaceItem); + dispatcher->renameInterface(ifaceItem); else - dispatcher->rename(this); + dispatcher->renameBlockOrGroup(this); } else if(selectedAction == showProperties){ dispatcher->showProperties(ifaceItem); - } + } else if (selectedAction == removeAction) { dispatcher->removeGroupInterface(ifaceItem); } + else if(selectedAction == showParameters) { + new ParametersWindow(refBlock, params, NULL); + } } InterfaceItem* GroupItem::isHoverInterface(QPointF point) {