X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/0d3590739ff5a4ca9e87c052ac142f5d1d3a68ab..14cd6d834ab531525a51c6a6992583b3e9143e02:/BoxItem.cpp?ds=inline diff --git a/BoxItem.cpp b/BoxItem.cpp index 6e6f15a..9ff42a8 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(); } @@ -280,6 +280,15 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { } break; } + case Title: + cout << "abnormal case while resizing block" << endl; + break; + case BorderWest: + cout << "abnormal case while resizing block" << endl; + break; + case BorderNorth: + cout << "abnormal case while resizing block" << endl; + break; case NoBorder: cout << "abnormal case while resizing block" << endl; break; @@ -293,7 +302,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 +332,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) { @@ -342,9 +351,9 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } } else if (mode == GroupScene::ItemEdition) { - setZValue(zValue()+100); + //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); @@ -373,7 +382,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - setZValue(zValue()-100); + //setZValue(zValue()-100); int mode = getScene()->getEditionMode(); @@ -394,10 +403,12 @@ 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; - // no update needed since the whole scene will be repainted + update(iface1->boundingRect()); + iface2->selected = false; + update(iface2->boundingRect()); getScene()->setSelectedInterface(1,NULL); getScene()->setSelectedInterface(2,NULL); params->setEditState(Parameters::EditNoOperation); @@ -427,7 +438,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); @@ -441,7 +452,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); @@ -483,29 +494,31 @@ void BoxItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) { } } } - QGraphicsItem::hoverMoveEvent(event); + //QGraphicsItem::hoverMoveEvent(event); + event->ignore(); } -void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { - - event->accept(); +void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { QMenu menu; QAction* titleAction = NULL; 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; + QAction* showModifier = NULL; + QAction* removeModifier = NULL; + QAction* generateVHDL = 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){ @@ -521,7 +534,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"); } @@ -529,22 +541,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; } } @@ -559,6 +563,25 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { } } } + if (iface->getAssociatedIface() != NULL) { + if (iface->getDirection() == AbstractInterface::Output) { + showPatterns = menu.addAction("Show output pattern"); + } + else if (iface->getDirection() == AbstractInterface::Input) { + showPatterns = menu.addAction("Show input pattern"); + } + } + + if (iface->getAssociatedIface() != NULL) { + ConnectedInterface* assoIface = AI_TO_CON(iface->getAssociatedIface()); + if (assoIface->getInputModifier() != NULL) { + removeModifier = menu.addAction("Remove input modifier"); + } + if (assoIface->getInputModifier() != NULL) { + showModifier = menu.addAction("Show input modifier parameters"); + } + } + } // menu for blocks (group or func) else { @@ -584,6 +607,7 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { showWishboneIface->setChecked(wishboneVisible); } removeAction = menu.addAction("Remove"); + generateVHDL = menu.addAction("Generate VHDL"); } QAction* selectedAction = NULL; @@ -621,9 +645,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); } @@ -636,9 +657,22 @@ 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); + } + else if(selectedAction == removeModifier) { + dispatcher->removeModifier(ifaceItem); + } + else if(selectedAction == showModifier) { + dispatcher->showModifier(ifaceItem); + } + else if(selectedAction == generateVHDL) { + dispatcher->generateBlockVHDL(this); + } + } void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { @@ -686,7 +720,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { throw(Exception(PROJECTFILE_CORRUPTED)); } if (referenceMd5 != referenceXml) { - throw(Exception(PROJECTFILE_CORRUPTED)); + reference = referenceXml; } else { reference = referenceMd5; @@ -699,6 +733,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { */ functionalBlock->setName(name); setRefBlock(functionalBlock); + params->blockToItem.insert(functionalBlock,this); setPos(posX,posY); setDimension(dimX,dimY); @@ -743,7 +778,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { functionalBlock->addInterface(functionalInterface); // searching for control interface - QString ctlRefName = refName+"_ctl"; + QString ctlRefName = refName+"_enb"; ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName)); if (ctlRefIface != NULL) { @@ -752,13 +787,24 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { if (! ctlIface->setAssociatedIface(functionalInterface)) { throw(Exception(PROJECTFILE_CORRUPTED)); } - ctlIface->setName(name+"_ctl"); + ctlIface->setName(name+"_enb"); functionalBlock->addInterface(ctlIface); } } + // connect clk and rst to group clk/rst or to clkrstgen + if ((name != "clkrstgen") && (parentGroupBlock != NULL)) { + try { + functionalBlock->connectClkReset(); + } + catch(Exception e) { + AbstractBlock* source = (AbstractBlock *)(e.getSource()); + cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl; + throw(e); + } + } // creating InterfaceItem - initInterfaces(); + initInterfaceItems(); // setting them with saved values for(int i=0; isetId(id); interfaceItem->setOrientation(orientation); interfaceItem->setPositionRatio(position); @@ -834,7 +880,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);