From 1df76ccc8673a2760af17b88ebfba4bfd7f5c11d Mon Sep 17 00:00:00 2001 From: stephane Domas Date: Thu, 4 May 2017 21:31:01 +0200 Subject: [PATCH] adding show/hide wb ifaces --- AbstractBoxItem.cpp | 59 ++++++++++++++++++++++++++-------- AbstractBoxItem.h | 7 ++-- BoxItem.cpp | 19 +++++++---- Dispatcher.cpp | 15 ++++++--- Dispatcher.h | 3 +- MainWindow.cpp | 7 ++++ ReferenceBlock.cpp | 25 +++++++++----- blast.creator.user | 8 ++--- lib/references/multadd.xml | 2 +- lib/references/references.bmf | Bin 6378 -> 6548 bytes 10 files changed, 105 insertions(+), 40 deletions(-) diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index c4cdae9..a05247f 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -8,6 +8,7 @@ #include "AbstractBlock.h" #include "GroupScene.h" +#include "GroupItem.h" #include "AbstractInterface.h" #include "ConnectedInterface.h" @@ -35,6 +36,7 @@ AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispat selected = false; currentInterface = NULL; rstClkVisible = false; + wishboneVisible = false; setAcceptHoverEvents(true); @@ -63,7 +65,8 @@ AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, Q selected = false; currentInterface = NULL; rstClkVisible = false; - + wishboneVisible = false; + setAcceptHoverEvents(true); // NOTE : initInterfaces() is only called in subclasses @@ -83,6 +86,35 @@ bool AbstractBoxItem::isBoxItem() { bool AbstractBoxItem::isGroupItem() { return false; } +void AbstractBoxItem::setRstClkVisible(bool b) { + rstClkVisible = b; + foreach(InterfaceItem* ifaceItem, interfaces) { + if ((ifaceItem->refInter->getPurpose() == AbstractInterface::Clock) || + (ifaceItem->refInter->getPurpose() == AbstractInterface::Reset) ) { + ifaceItem->visible = b; + } + } + resetInterfacesPosition(); + updateGeometry(InterfaceMove); + update(); + getScene()->updateConnectionItemsShape(); + (getScene()->getGroupItem())->updateShape(); + +} + +void AbstractBoxItem::setWishboneVisible(bool b) { + wishboneVisible = b; + foreach(InterfaceItem* ifaceItem, interfaces) { + if (ifaceItem->refInter->getPurpose() == AbstractInterface::Wishbone) { + ifaceItem->visible = b; + } + } + resetInterfacesPosition(); + updateGeometry(InterfaceMove); + update(); + getScene()->updateConnectionItemsShape(); + (getScene()->getGroupItem())->updateShape(); +} void AbstractBoxItem::setRefBlock(AbstractBlock* _refBlock) { refBlock = _refBlock; @@ -96,18 +128,17 @@ void AbstractBoxItem::initInterfaces() { int orientation = Parameters::West; foreach(AbstractInterface *inter, refBlock->getInterfaces()){ - if(inter->getPurpose() != AbstractInterface::Wishbone){ - InterfaceItem *item; - if(inter->getDirection() == AbstractInterface::Input){ - orientation = Parameters::West; - } else if(inter->getDirection() == AbstractInterface::Output){ - orientation = Parameters::East; - } else if(inter->getDirection() == AbstractInterface::InOut){ - orientation = Parameters::North; - } - item = new InterfaceItem(0.0 , orientation, (ConnectedInterface *)inter, this, params); - interfaces.append(item); + + InterfaceItem *item; + if(inter->getDirection() == AbstractInterface::Input){ + orientation = Parameters::West; + } else if(inter->getDirection() == AbstractInterface::Output){ + orientation = Parameters::East; + } else if(inter->getDirection() == AbstractInterface::InOut){ + orientation = Parameters::North; } + item = new InterfaceItem(0.0 , orientation, (ConnectedInterface *)inter, this, params); + interfaces.append(item); } } @@ -155,7 +186,7 @@ void AbstractBoxItem::resetInterfacesPosition() { foreach(InterfaceItem* inter, interfaces) { // only data interfaces and if needed time and reset - if(inter->refInter->getPurpose() == AbstractInterface::Data || inter->getOwner()->isRstClkVisible()){ + if(inter->visible) { if(inter->getOrientation() == Parameters::North){ nbNorth++; } else if(inter->getOrientation() == Parameters::South){ @@ -170,7 +201,7 @@ void AbstractBoxItem::resetInterfacesPosition() { foreach(InterfaceItem* inter, interfaces) { - if(inter->refInter->getPurpose() == AbstractInterface::Data || inter->getOwner()->isRstClkVisible()){ + if(inter->visible){ if(inter->getOrientation() == Parameters::North){ positionRatio = cntNorth/(double)(nbNorth+1); diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index 98cec58..c061487 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -44,7 +44,8 @@ public: void setRefBlock(AbstractBlock* _refBlock); inline void setId(int _id){ id = _id; } inline void setSelected(bool _selected) { selected = _selected; } - inline void setRstClkVisible(bool b){ rstClkVisible = b;} + void setRstClkVisible(bool b); + void setWishboneVisible(bool b); void setDimension(int x, int y); inline void setCurrentInterface(InterfaceItem* iface) { currentInterface = iface; } @@ -53,6 +54,7 @@ public: virtual bool isGroupItem(); inline bool isSelected() { return selected; } inline bool isRstClkVisible(){ return rstClkVisible;} + inline bool isWishboneVisible(){ return wishboneVisible;} bool isInterfaces(int orientation) const; // others @@ -116,7 +118,8 @@ protected: QPointF originPoint; // the left-top point that is the origin of the bounding box bool selected; - bool rstClkVisible; + bool rstClkVisible; //! true if clock/reset interfaces are visible + bool wishboneVisible; //! true if wishbone interfaces are visible QPointF currentPosition; // the start point for resize diff --git a/BoxItem.cpp b/BoxItem.cpp index a654718..de22f19 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -485,7 +485,8 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { QAction* showProperties = NULL; QAction* cloneInterface = NULL; QAction* openWindow = NULL; - QAction* showRstClkInter = NULL; + QAction* showRstClkIface = NULL; + QAction* showWishboneIface = NULL; QAction* showParameters = NULL; InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y()); @@ -559,9 +560,12 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { } else { duplicateAction = menu.addAction("Duplicate"); - showRstClkInter = menu.addAction("Show reset/clock interfaces"); - showRstClkInter->setCheckable(true); - showRstClkInter->setChecked(rstClkVisible); + showRstClkIface = menu.addAction("Show reset/clock interfaces"); + showRstClkIface->setCheckable(true); + showRstClkIface->setChecked(rstClkVisible); + showWishboneIface = menu.addAction("Show wishbone interfaces"); + showWishboneIface->setCheckable(true); + showWishboneIface->setChecked(wishboneVisible); } removeAction = menu.addAction("Remove"); } @@ -603,8 +607,11 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { else if (selectedAction == openWindow){ dispatcher->showRaiseWindow(this); } - else if(selectedAction == showRstClkInter){ - dispatcher->showRstClkInter(this); + else if(selectedAction == showRstClkIface) { + dispatcher->showRstClkIface(this); + } + else if(selectedAction == showWishboneIface) { + dispatcher->showWishboneIface(this); } else if(selectedAction == showParameters){ new ParametersWindow(refBlock, params, NULL); diff --git a/Dispatcher.cpp b/Dispatcher.cpp index 73577b2..b6495bb 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -449,16 +449,23 @@ void Dispatcher::showRaiseWindow(BoxItem *item) { params->setCurrentScene(currentGroup->getScene()); } -void Dispatcher::showRstClkInter(AbstractBoxItem *item) { - static QString fctName = "Dispatcher::showRstClkInter()"; +void Dispatcher::showRstClkIface(AbstractBoxItem *item) { + static QString fctName = "Dispatcher::showRstClkIface()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif item->setRstClkVisible(!item->isRstClkVisible()); - item->resetInterfacesPosition(); + +} + +void Dispatcher::showWishboneIface(AbstractBoxItem *item) { + static QString fctName = "Dispatcher::showWishboneIface()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif - item->getScene()->updateConnectionItemsShape(); + item->setWishboneVisible(!item->isWishboneVisible()); } void Dispatcher::addNewFullGroup() { diff --git a/Dispatcher.h b/Dispatcher.h index e79ad60..61c41cb 100644 --- a/Dispatcher.h +++ b/Dispatcher.h @@ -43,7 +43,8 @@ public: GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL); void destroyScene(GroupScene* scene); void showRaiseWindow(BoxItem *item); - void showRstClkInter(AbstractBoxItem *item); + void showRstClkIface(AbstractBoxItem *item); + void showWishboneIface(AbstractBoxItem *item); GroupWidget *addNewEmptyGroup(GroupScene *scene, bool show = true); void addNewFullGroup(); diff --git a/MainWindow.cpp b/MainWindow.cpp index 6afabcd..4be284b 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -292,6 +292,7 @@ void MainWindow::slotNewProject(){ GroupWidget* topGroup = dispatcher->createTopScene(); addTopGroup(topGroup); library->updateComboScene(); + library->show(); params->isCurrentProject = true; } @@ -319,6 +320,9 @@ bool MainWindow::slotCloseProject(){ break; } } + else { + doClose = true; + } if (doClose) { // removing the GroupWidget from stack QWidget *widget = stackedWidget->widget(1); @@ -390,6 +394,9 @@ void MainWindow::closeEvent(QCloseEvent *event) { slotCloseProject(); event->ignore(); } + else { + library->deleteLater(); + } } diff --git a/ReferenceBlock.cpp b/ReferenceBlock.cpp index a0a8220..722fc12 100644 --- a/ReferenceBlock.cpp +++ b/ReferenceBlock.cpp @@ -169,11 +169,16 @@ void ReferenceBlock::loadParameters(QDomElement &elt) throw(Exception) { int duration = 0; QString wbValue = ""; QStringList listWb = wbStr.split(","); + cout << "wb param has:"; + foreach(QString s, listWb) { + cout << qPrintable(s) << " | "; + } + cout << endl; if (listWb.at(0) == "r") { access = BlockParameter::Read; } - else if (wbStr == "w") { + else if (listWb.at(0) == "w") { access = BlockParameter::Write; bool ok; wbValue = listWb.at(1).toInt(&ok); @@ -246,7 +251,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) { nameStr = eltOutput.attribute("name","none"); typeStr = eltOutput.attribute("type","none"); widthStr = eltOutput.attribute("width","none"); - purposeStr = eltOutput.attribute("type","none"); + purposeStr = eltOutput.attribute("purpose","none"); purpose = ReferenceInterface::translatePurpose(purposeStr); multStr = eltOutput.attribute("multiplicity","none"); mult = ReferenceInterface::translateMultiplicity(multStr); @@ -263,7 +268,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) { nameStr = eltBidir.attribute("name","none"); typeStr = eltBidir.attribute("type","none"); widthStr = eltBidir.attribute("width","none"); - purposeStr = eltBidir.attribute("type","none"); + purposeStr = eltBidir.attribute("purpose","none"); purpose = ReferenceInterface::translatePurpose(purposeStr); multStr = eltBidir.attribute("multiplicity","none"); mult = ReferenceInterface::translateMultiplicity(multStr); @@ -278,17 +283,21 @@ void ReferenceBlock::createInterfaceForParameters() throw(Exception){ foreach(BlockParameter* param, params) { if (param->isWishboneParameter()) { - BlockParameterWishbone* p = (BlockParameterWishbone*)param; - int orientation = -1; + + BlockParameterWishbone* p = (BlockParameterWishbone*)param; + cout << "creating interface for parameter wb " << qPrintable(p->getName()) << endl; + if (p->getWBAccess() == BlockParameter::Read) { - iface = new ReferenceInterface(this,p->getName(),p->getType(),p->getWidth(), AbstractInterface::Output, AbstractInterface::Wishbone,1); + iface = new ReferenceInterface(this,p->getName(),p->getTypeString(),p->getWidth(), AbstractInterface::Output, AbstractInterface::Wishbone,1); outputs.append(iface); } else if (p->getWBAccess() == BlockParameter::Write) { - iface = new ReferenceInterface(this,p->getName(),p->getType(),p->getWidth(), AbstractInterface::Input, AbstractInterface::Wishbone,1); + iface = new ReferenceInterface(this,p->getName(),p->getTypeString(),p->getWidth(), AbstractInterface::Input, AbstractInterface::Wishbone,1); inputs.append(iface); } - ReferenceInterface* iface = new ReferenceInterface(this,p->getName(),p->getType(),p->getWidth(), orientation, AbstractInterface::Wishbone,1); + else { + throw (Exception(BLOCKFILE_CORRUPTED)); + } } } } diff --git a/blast.creator.user b/blast.creator.user index 5ea7a3a..95c4b8a 100755 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {1d077e47-e3a1-47fd-8b12-4de650e39df5} + {c8006d66-d34f-42be-ad10-d0207752286d} ProjectExplorer.Project.ActiveTarget @@ -60,12 +60,12 @@ Desktop Desktop - {451ee8a3-56ff-4aba-8a8e-3da882cc142e} + {2c9bf876-3476-44eb-8065-1f0844704dda} 0 0 0 - /localhome/sdomas/Projet/Blast/code/blast + /home/sdomas/Projet/Blast/code/blast diff --git a/lib/references/multadd.xml b/lib/references/multadd.xml index 7ef16bd..873216e 100644 --- a/lib/references/multadd.xml +++ b/lib/references/multadd.xml @@ -4,7 +4,7 @@ block multiply/add - + This block multiplies 2 input values, adding the result to a third one. diff --git a/lib/references/references.bmf b/lib/references/references.bmf index 9bc3ec7bc6825962deb0dcc9e809f0036b5d4f69..a5ec5ae4323a138aa8e519fea0d953fca3da8a5b 100644 GIT binary patch delta 483 zcmaE5IK`NSfkAS@Mwau8jLefASfm+QHh*CBXM%Ai+p$+~zRuzW7uamaZpaLm?cuu2 z$T~TJ+Y(65;`~P!e9u*sSGAS+7Kw33UqcdP@NHj!Q>}m;esG9aR5~$0v((P zWHU~75nl=wEnz5PCOdVKOHacfaFAd3yCJBJ|~BnC8(fdLx6lj9_!IYHh6c{+LW z2X19!P=J8k3c>m?c!qoi1_mYuLmih9sQw z91P_Qsi?A>i+F?)mVaQZ+pHk)8Sb>n2Er>D1vcLjKFH+B1hj}1h#eSAfQA?YaT1V~ z2&ByzOo6l+gC)>u$qWWSku;#3DUg){#3n$t5l|MyGX?5Pn*2m8oD*me1Wfi3Uy8(I klCTy9h93hP(4-uOY#