X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/d111eaf49741a0a79d372445f97c314a637e331e..7b1c7e44123b9b2626205a89e27b2a4712ea30c6:/BoxItem.cpp diff --git a/BoxItem.cpp b/BoxItem.cpp index 1902003..c473e6f 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -33,9 +33,9 @@ BoxItem::BoxItem(AbstractBlock *_refBlock, setZValue(100); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); - initInterfaces(); + initInterfaceItems(); updateGeometry(InterfaceMove); - resetInterfacesPosition(); + resetInterfaceItemsPosition(); QPointF initPos = QPointF(0.0,0.0) - originPoint; setPos(initPos); //cout << "total size of block: " << totalWidth << "," << totalHeight << endl; @@ -173,7 +173,7 @@ bool BoxItem::updateGeometry(ChangeType type) { } } if (boxSizeChanged) { - updateInterfacesAndConnections(); + updateInterfaceAndConnectionItems(); } @@ -293,7 +293,7 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { } else if(params->editState == Parameters::EditInterfaceMove) { prepareGeometryChange(); - moveInterfaceTo(event->pos()); + moveInterfaceItemTo(event->pos()); // recompute the geometry of the block if (updateGeometry(InterfaceMove)) { //cout << "must recompute group item geometry" << endl; @@ -323,7 +323,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { - InterfaceItem *inter = getInterfaceFromCursor(x,y); + InterfaceItem *inter = getInterfaceItemFromCursor(x,y); if (inter != NULL) { if (params->editState == Parameters::EditNoOperation) { @@ -344,7 +344,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { else if (mode == GroupScene::ItemEdition) { //setZValue(zValue()+100); if (params->cursorState == Parameters::CursorOnInterface) { - InterfaceItem *inter = getInterfaceFromCursor(x,y); + InterfaceItem *inter = getInterfaceItemFromCursor(x,y); if (inter != NULL) { if (inter == currentInterface) { params->setEditState(Parameters::EditInterfaceDeselect); @@ -394,7 +394,7 @@ void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { else if (params->editState == Parameters::EditCloseConnection) { InterfaceItem* iface1 = getScene()->getSelectedInterface(1); InterfaceItem* iface2 = getScene()->getSelectedInterface(2); - bool ok = dispatcher->createConnectionItem(iface1,iface2); + bool ok = dispatcher->createConnection(iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); @@ -429,7 +429,7 @@ void BoxItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) { int mode = getScene()->getEditionMode(); if (mode == GroupScene::AddConnection) { - InterfaceItem* iface = getInterfaceFromCursor(x,y); + InterfaceItem* iface = getInterfaceItemFromCursor(x,y); if (iface != NULL) { params->cursorState = Parameters::CursorOnInterface; setCursor(Qt::PointingHandCursor); @@ -443,7 +443,7 @@ void BoxItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) { int marginE = 5; int marginS = 5; - InterfaceItem* iface = getInterfaceFromCursor(x,y); + InterfaceItem* iface = getInterfaceItemFromCursor(x,y); if (iface != NULL) { params->cursorState = Parameters::CursorOnInterface; setCursor(Qt::PointingHandCursor); @@ -497,16 +497,16 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { QAction* removeAction = NULL; QAction* duplicateAction = NULL; QAction* renameAction = NULL; - QAction* connectToGroup = NULL; - QAction* disconnectFromGroup = NULL; + QAction* connectToGroup = NULL; QAction* showProperties = NULL; QAction* cloneInterface = NULL; QAction* openWindow = NULL; QAction* showRstClkIface = NULL; QAction* showWishboneIface = NULL; QAction* showParameters = NULL; + QAction* showPatterns = NULL; - InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y()); + InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y()); // menu for interface if( ifaceItem != NULL){ @@ -522,7 +522,6 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { ConnectedInterface* ifaceGroup = NULL; bool canRemove = true; - if ((iface->getDirection() == AbstractInterface::Input) && (iface->getConnectedFrom() == NULL)) { connectToGroup = menu.addAction("Connect to group input"); } @@ -530,22 +529,14 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { connectToGroup = menu.addAction("Connect to group output"); } else if (iface->getConnectionFromParentGroup() != NULL) { - ifaceGroup = iface->getConnectionFromParentGroup(); - //if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) { - if (!ifaceGroup->isConnectedFrom()) { - disconnectFromGroup = menu.addAction("Disconnect from group"); - } - else { + ifaceGroup = iface->getConnectionFromParentGroup(); + if (ifaceGroup->isConnectedFrom()) { canRemove = false; } } else if (iface->getConnectionToParentGroup() != NULL) { - ifaceGroup = iface->getConnectionToParentGroup(); - //if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) { - if (!ifaceGroup->isConnectedTo()) { - disconnectFromGroup = menu.addAction("Disconnect from group"); - } - else { + ifaceGroup = iface->getConnectionToParentGroup(); + if (ifaceGroup->isConnectedTo()) { canRemove = false; } } @@ -560,6 +551,9 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { } } } + if ((iface->getAssociatedIface() != NULL) && (iface->getDirection() == AbstractInterface::Output)) { + showPatterns = menu.addAction("Show patterns"); + } } // menu for blocks (group or func) else { @@ -622,9 +616,6 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { else if (selectedAction == connectToGroup){ dispatcher->connectInterToGroup(ifaceItem); } - else if (selectedAction == disconnectFromGroup) { - dispatcher->disconnectInterFromGroup(ifaceItem); - } else if (selectedAction == cloneInterface){ dispatcher->duplicateInterfaceItem(ifaceItem); } @@ -637,9 +628,12 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { else if(selectedAction == showWishboneIface) { dispatcher->showWishboneIface(this); } - else if(selectedAction == showParameters){ + else if(selectedAction == showParameters) { new ParametersWindow(refBlock, params, NULL); - } + } + else if(selectedAction == showPatterns) { + dispatcher->showPatterns(ifaceItem); + } } void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { @@ -759,7 +753,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { } // creating InterfaceItem - initInterfaces(); + initInterfaceItems(); // setting them with saved values for(int i=0; isetId(id); interfaceItem->setOrientation(orientation); interfaceItem->setPositionRatio(position); @@ -835,7 +829,7 @@ void BoxItem::save(QXmlStreamWriter &writer) { writer.writeAttribute("id",QString::number(id)); writer.writeAttribute("inside_group",QString::number(childGroupItem->getId())); - QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y())); + QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y()))); writer.writeAttribute("position",attrPos); QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight())); writer.writeAttribute("dimension",attrDim);