From: stephane Domas Date: Fri, 20 Apr 2018 14:47:52 +0000 (+0200) Subject: added context to dispatcher op. X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/1b7818e18ed7bcf3464e307b97c6e0e6d72cc69b?ds=inline added context to dispatcher op. --- diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index c1c3c38..3c3dd55 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -59,7 +59,7 @@ bool AbstractBlock::isSourceBlock() { } /* NB: a generator is a block that has no data inputs * and has at least one data output. - * By the way, blokcs that have no data input/output + * By the way, blocks that have no data input/output * (like clkrstgen) are not generators ! */ bool AbstractBlock::isGeneratorBlock() { diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index 925cd6f..9fafc8f 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -13,10 +13,11 @@ #include "ConnectedInterface.h" -AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem *parent) : QGraphicsItem(parent) { +AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, LockType _lock, QGraphicsItem *parent) : QGraphicsItem(parent) { dispatcher = _dispatcher; params = _params; refBlock = _refBlock; + lock = _lock; QFontMetrics fmId(params->defaultBlockFont); nameWidth = fmId.width(refBlock->getName()); nameHeight = fmId.height(); @@ -43,10 +44,11 @@ AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispat // NOTE : initInterfaces() is only called in subclasses } -AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent) : QGraphicsItem(parent) { +AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, LockType _lock, QGraphicsItem* parent) : QGraphicsItem(parent) { dispatcher = _dispatcher; - params = _params; + params = _params; refBlock = NULL; + lock = _lock; nameWidth = 0; nameHeight = 0; nameMargin = 10; diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index fb2bdcc..84a4fbc 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -24,9 +24,10 @@ public: enum BorderType { NoBorder = 0, BorderEast, BorderNorth, BorderWest, BorderSouth, CornerSouthEast, Title}; enum ChangeType { Resize = 0, InterfaceMove }; + enum LockType { NoLock = 0, Position = 1, Dimension = 2, Interfaces = 4, Names = 8}; - AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent = Q_NULLPTR); - AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent = Q_NULLPTR); + AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, LockType _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR); + AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, LockType _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR); virtual ~AbstractBoxItem(); @@ -52,6 +53,15 @@ public: void setWishboneVisible(bool b); void setDimension(int x, int y); inline void setCurrentInterface(InterfaceItem* iface) { currentInterface = iface; } + inline void setLock(int _lock) { lock = _lock; } + inline void lockPosition() { lock = lock | Position; } + inline void unlockPosition() { lock = (lock&Position)^lock; } + inline void lockDimension() { lock = lock | Dimension; } + inline void unlockDimension() { lock = (lock&Dimension)^lock; } + inline void lockInterfaces() { lock = lock | Interfaces; } + inline void unlockInterfaces() { lock = (lock&Interfaces)^lock; } + inline void lockNames() { lock = lock | Names; } + inline void unlockNames() { lock = (lock&Names)^lock; } // testers virtual bool isBoxItem(); @@ -61,7 +71,10 @@ public: inline bool isRstClkVisible(){ return rstClkVisible;} inline bool isWishboneVisible(){ return wishboneVisible;} bool isInterfaces(int orientation) const; - + inline bool isPositionLock() { return (lock&Position)!=0?true:false; } + inline bool isDimensionLock() { return (lock&Dimension)!=0?true:false; } + inline bool isInterfacesLock() { return (lock&Interfaces)!=0?true:false; } + inline bool isNamesLock() { return (lock&Names)!=0?true:false; } // others QRectF boundingRectInScene(); virtual void nameChanged() = 0; // called when an interface or box name have changed @@ -123,6 +136,7 @@ protected: int ifaceMargin; // the margin around each side of interfaces' name QPointF originPoint; // the left-top point that is the origin of the bounding box, in the item coordinates + int lock; bool selected; bool rstClkVisible; //! true if clock/reset interfaces are visible bool wishboneVisible; //! true if wishbone interfaces are visible diff --git a/AbstractInterface.cpp b/AbstractInterface.cpp index 39e672d..6b3d009 100644 --- a/AbstractInterface.cpp +++ b/AbstractInterface.cpp @@ -288,7 +288,7 @@ int AbstractInterface::typeFromString(const QString &_type) { return ret; } -QString AbstractInterface::toVHDL(int context, int flags) throw(Exception) { +QString AbstractInterface::toVHDL(IfaceVHDLContext context, int flags) throw(Exception) { if (isReferenceInterface()) throw(Exception(IFACE_INVALID_TYPE)); diff --git a/AbstractInterface.h b/AbstractInterface.h index 3a3cb25..166fdbe 100644 --- a/AbstractInterface.h +++ b/AbstractInterface.h @@ -78,7 +78,7 @@ public : int typeFromString(const QString &_type); - QString toVHDL(int context, int flags) throw(Exception); + QString toVHDL(IfaceVHDLContext context, int flags) throw(Exception); protected: QString name; diff --git a/BlockLibraryWidget.cpp b/BlockLibraryWidget.cpp index 0d2636d..e8f5c6d 100644 --- a/BlockLibraryWidget.cpp +++ b/BlockLibraryWidget.cpp @@ -91,7 +91,7 @@ void BlockLibraryWidget::addClicked() { int idBlock = item->data(2,Qt::DisplayRole).toInt(); QVariant v = comboScenes->currentData(); cout << "adding block to scene " << v.toInt() << endl; - dispatcher->addBlock(idParent, idBlock, v.toInt()); + dispatcher->addBlock(Dispatcher::Design, idParent, idBlock, v.toInt()); } // only take the first selected diff --git a/BoxItem.cpp b/BoxItem.cpp index 9ff42a8..a7e1181 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -17,12 +17,16 @@ BoxItem::BoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, - Parameters *_params, GroupItem *parent) throw(Exception) : AbstractBoxItem( _refBlock, _dispatcher, _params, parent) { + Parameters *_params, GroupItem *parent, LockType _lock, SpanType _span, Position _hPos, Position _vPos) throw(Exception) : AbstractBoxItem( _refBlock, _dispatcher, _params, _lock, parent) { /* NOTE : _refBlock : mandatory a FunctionalBlock or a GroupBlock */ - if (_refBlock->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE)); + if (_refBlock->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE)); + + span = _span; + hPos = _hPos; + vPos = _vPos; childGroupItem = NULL; //boxWidth = params->defaultBlockWidth; @@ -31,7 +35,14 @@ BoxItem::BoxItem(AbstractBlock *_refBlock, selected = false; setZValue(100); - setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); + QGraphicsItem::GraphicsItemFlags flags = QGraphicsItem::ItemIsSelectable; + if (!isPositionLock()) { + flags |= QGraphicsItem::ItemIsMovable; + } + if (!isDimensionLock()) { + flags |= QGraphicsItem::ItemSendsGeometryChanges; + } + setFlags(flags); initInterfaceItems(); updateGeometry(InterfaceMove); @@ -42,7 +53,11 @@ BoxItem::BoxItem(AbstractBlock *_refBlock, //cout << "pos in group: " << x() << "," << y() << endl; } -BoxItem::BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem *parent) throw(Exception) : AbstractBoxItem(_dispatcher, _params, parent) { +BoxItem::BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem *parent, LockType _lock, SpanType _span, Position _hPos, Position _vPos) throw(Exception) : AbstractBoxItem(_dispatcher, _params, _lock, parent) { + + span = _span; + hPos = _hPos; + vPos = _vPos; refBlock = NULL; childGroupItem = NULL; @@ -50,7 +65,14 @@ BoxItem::BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem *parent selected = false; setZValue(100); - setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); + QGraphicsItem::GraphicsItemFlags flags = QGraphicsItem::ItemIsSelectable; + if (!isPositionLock()) { + flags |= QGraphicsItem::ItemIsMovable; + } + if (!isDimensionLock()) { + flags |= QGraphicsItem::ItemSendsGeometryChanges; + } + setFlags(flags); boxWidth = params->defaultBlockWidth; boxHeight = params->defaultBlockHeight; @@ -329,7 +351,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); + dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget()); if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { InterfaceItem *inter = getInterfaceItemFromCursor(x,y); @@ -403,7 +425,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->createConnection(iface1,iface2); + bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); @@ -617,60 +639,60 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { if (selectedAction == removeAction) { if(ifaceItem != NULL) { - dispatcher->removeFunctionalInterface(ifaceItem); + dispatcher->removeFunctionalInterface(Dispatcher::Design, ifaceItem); } else { - dispatcher->removeBoxItem(this); + dispatcher->removeBoxItem(Dispatcher::Design, this); } } else if (selectedAction == duplicateAction) { - dispatcher->duplicateBoxItem(this); + dispatcher->duplicateBoxItem(Dispatcher::Design, this); } else if(selectedAction == renameAction){ if(ifaceItem != NULL) { - dispatcher->renameInterface(ifaceItem); + dispatcher->renameInterface(Dispatcher::Design, ifaceItem); } else { if (refBlock->isFunctionalBlock()) { - dispatcher->renameFunctionalBlock(this); + dispatcher->renameFunctionalBlock(Dispatcher::Design, this); } else if (refBlock->isGroupBlock()) { - dispatcher->renameGroupBlock(childGroupItem); + dispatcher->renameGroupBlock(Dispatcher::Design, childGroupItem); } } } else if(selectedAction == showProperties){ - dispatcher->showProperties(ifaceItem); + dispatcher->showProperties(Dispatcher::Design, ifaceItem); } else if (selectedAction == connectToGroup){ - dispatcher->connectInterToGroup(ifaceItem); + dispatcher->connectInterToGroup(Dispatcher::Design, ifaceItem); } else if (selectedAction == cloneInterface){ - dispatcher->duplicateInterfaceItem(ifaceItem); + dispatcher->duplicateInterfaceItem(Dispatcher::Design, ifaceItem); } else if (selectedAction == openWindow){ - dispatcher->showRaiseWindow(this); + dispatcher->showRaiseWindow(Dispatcher::Design, this); } else if(selectedAction == showRstClkIface) { - dispatcher->showRstClkIface(this); + dispatcher->showRstClkIface(Dispatcher::Design, this); } else if(selectedAction == showWishboneIface) { - dispatcher->showWishboneIface(this); + dispatcher->showWishboneIface(Dispatcher::Design, this); } else if(selectedAction == showParameters) { new ParametersWindow(refBlock, params, NULL); } else if(selectedAction == showPatterns) { - dispatcher->showPatterns(ifaceItem); + dispatcher->showPatterns(Dispatcher::Design, ifaceItem); } else if(selectedAction == removeModifier) { - dispatcher->removeModifier(ifaceItem); + dispatcher->removeModifier(Dispatcher::Design, ifaceItem); } else if(selectedAction == showModifier) { - dispatcher->showModifier(ifaceItem); + dispatcher->showModifier(Dispatcher::Design, ifaceItem); } else if(selectedAction == generateVHDL) { - dispatcher->generateBlockVHDL(this); + dispatcher->generateBlockVHDL(Dispatcher::Design, this); } } diff --git a/BoxItem.h b/BoxItem.h index c8a942e..4ab2022 100644 --- a/BoxItem.h +++ b/BoxItem.h @@ -30,8 +30,12 @@ using namespace Qt; class BoxItem : public AbstractBoxItem { public: - BoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent) throw(Exception); - BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent) throw(Exception); + + enum Position { Left = 1, Right, Top, Bottom, Center}; + enum SpanType { NoSpan = 0, HSpan = 1, VSpan = 2 }; + + BoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent, LockType _lock = NoLock, SpanType _span = NoSpan, Position _hPos = Center, Position _vPos = Center) throw(Exception); + BoxItem(Dispatcher *_dispatcher, Parameters *_params, GroupItem* parent, LockType _lock = NoLock, SpanType _span = NoSpan, Position _hPos = Center, Position _vPos = Center) throw(Exception); ~BoxItem(); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); @@ -53,6 +57,10 @@ public: protected: + SpanType span; + Position hPos; + Position vPos; + void updateMinimumSize(); // modify the minimum size bool updateGeometry(ChangeType type); // modify the originPoint and the total dimension @@ -65,9 +73,9 @@ protected: private: /* NOTE : - A BlockItem is always graphically within a GroupItem, inside the same scene. + A BoxItem is always graphically within a GroupItem, inside the same scene. - A BlockItem may also be the graphical view of a GroupBlock. In this case, there exists a child scene + A BoxItem may also be the graphical view of a GroupBlock. In this case, there exists a child scene containing a GroupItem. insideGroup atribute refers to this GroupItem and thus, may be NULL if the current blockItem represents a functional block */ diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index 4de86cb..86d0073 100644 --- a/ConnectionItem.cpp +++ b/ConnectionItem.cpp @@ -906,7 +906,7 @@ void ConnectionItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { QAction * selectedAction= menu.exec(event->screenPos()); if(selectedAction == removeAction){ - dispatcher->removeConnection(this); + dispatcher->removeConnection(Dispatcher::Design, this); } } } diff --git a/Dispatcher.cpp b/Dispatcher.cpp index cdf8ee3..da4bae2 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -37,8 +37,8 @@ Dispatcher::Dispatcher(Parameters* _params, MainWindow* _window) { params = _params; mainWindow =_window; params->setDispatcher(this); - currentGroup = NULL; - topGroup = NULL; + currentGroupWidget = NULL; + topGroupWidget = NULL; } GroupWidget *Dispatcher::loadProject(const QString& filename) { @@ -62,7 +62,7 @@ GroupWidget *Dispatcher::loadProject(const QString& filename) { params->setCurrentScene(scene); */ try { - topGroup = params->loadProject(root); + topGroupWidget = params->loadProject(root); } catch(Exception e){ cerr << qPrintable(e.getDefaultMessage()) << endl; @@ -75,8 +75,8 @@ GroupWidget *Dispatcher::loadProject(const QString& filename) { params->projectPath = info.absolutePath(); params->projectName = info.baseName(); cout << "project path = " << qPrintable(params->projectPath) << endl; - groupList.append(topGroup); - return topGroup; + groupList.append(topGroupWidget); + return topGroupWidget; } void Dispatcher::closeCurrentProject() { @@ -86,12 +86,18 @@ void Dispatcher::closeCurrentProject() { } groupList.clear(); params->destroyGraph(); - topGroup = NULL; - currentGroup = NULL; + topGroupWidget = NULL; + currentGroupWidget = NULL; sceneCounter = 0; } -bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2, bool visible) { +void Dispatcher::setSceneCounter(Context context, int value) { + + if (context != Load) return; + sceneCounter = value; +} + +bool Dispatcher::createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible) { ConnectedInterface* ref1 = iface1->refInter; ConnectedInterface* ref2 = iface2->refInter; @@ -114,7 +120,7 @@ bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2, iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2, visible); - unselectAllItems(); + unselectAllItems(context); params->unsaveModif = true; cout << "created a connection from " << qPrintable(ref1->getName()) << " to " << qPrintable(ref2->getName()) << endl; return true; @@ -123,7 +129,7 @@ bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2, } -void Dispatcher::unselectAllItems(int direction){ +void Dispatcher::unselectAllItems(Context context, int direction){ GroupScene *scene = params->getCurrentScene(); @@ -135,14 +141,14 @@ void Dispatcher::unselectAllItems(int direction){ scene->update(); } -void Dispatcher::setCurrentGroupWidget(GroupWidget *win){ +void Dispatcher::setCurrentGroupWidget(Context context, GroupWidget *win){ win->setFocus(); win->changeConnectionMode(-1); - currentGroup = win; + currentGroupWidget = win; params->setCurrentScene(win->getScene()); } -void Dispatcher::changeConnectionMode(int mode){ +void Dispatcher::changeConnectionMode(Context context, int mode){ /* foreach(GroupWidget* win, groupList){ @@ -177,7 +183,7 @@ void Dispatcher::changeConnectionMode(int mode){ */ } -void Dispatcher::generateVHDL() throw(Exception) { +void Dispatcher::generateVHDL(Context context) throw(Exception) { static QString fctName = "Dispatcher::generateVHDL()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -271,7 +277,7 @@ void Dispatcher::generateVHDL() throw(Exception) { } -void Dispatcher::generateBlockVHDL(BoxItem *item){ +void Dispatcher::generateBlockVHDL(Context context, BoxItem *item){ static QString fctName = "Dispatcher::generateBlockVHDL()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -288,7 +294,7 @@ void Dispatcher::generateBlockVHDL(BoxItem *item){ } } -void Dispatcher::renameFunctionalBlock(BoxItem *item){ +void Dispatcher::renameFunctionalBlock(Context context, BoxItem *item){ static QString fctName = "Dispatcher::renameFunctionalBlock()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -327,7 +333,7 @@ void Dispatcher::renameFunctionalBlock(BoxItem *item){ item->nameChanged(); } -void Dispatcher::renameGroupBlock(GroupItem *item){ +void Dispatcher::renameGroupBlock(Context context, GroupItem *item){ static QString fctName = "Dispatcher::renameGroupBlock()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -373,7 +379,7 @@ void Dispatcher::renameGroupBlock(GroupItem *item){ mainWindow->getLibrary()->updateComboScene(); } -void Dispatcher::renameSourceBlock(SourceItem *item){ +void Dispatcher::renameSourceBlock(Context context, SourceItem *item){ static QString fctName = "Dispatcher::renameSourceBlock()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -413,7 +419,7 @@ void Dispatcher::renameSourceBlock(SourceItem *item){ } -void Dispatcher::renameInterface(InterfaceItem *item) { +void Dispatcher::renameInterface(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::renameInterface()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -457,7 +463,7 @@ void Dispatcher::renameInterface(InterfaceItem *item) { item->getOwner()->nameChanged(); } -void Dispatcher::showPatterns(InterfaceItem *item) { +void Dispatcher::showPatterns(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::showPatterns()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -501,7 +507,7 @@ void Dispatcher::showPatterns(InterfaceItem *item) { QMessageBox::information(NULL,"Interface pattern",msg,QMessageBox::Ok,QMessageBox::Ok); } -void Dispatcher::showModifier(InterfaceItem *item) { +void Dispatcher::showModifier(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::showModifier()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -522,7 +528,7 @@ void Dispatcher::showModifier(InterfaceItem *item) { QMessageBox::information(NULL,"Interface pattern",msg,QMessageBox::Ok,QMessageBox::Ok); } -void Dispatcher::removeModifier(InterfaceItem *item) { +void Dispatcher::removeModifier(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::showModifier()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -533,7 +539,7 @@ void Dispatcher::removeModifier(InterfaceItem *item) { } -void Dispatcher::duplicateBoxItem(BoxItem *item){ +void Dispatcher::duplicateBoxItem(Context context, BoxItem *item){ static QString fctName = "Dispatcher::duplicateBoxItem()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -556,7 +562,7 @@ void Dispatcher::duplicateBoxItem(BoxItem *item){ } } -void Dispatcher::duplicateSourceItem(SourceItem *item) { +void Dispatcher::duplicateSourceItem(Context context, SourceItem *item) { static QString fctName = "Dispatcher::duplicateSourceItem()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -579,7 +585,7 @@ void Dispatcher::duplicateSourceItem(SourceItem *item) { } } -void Dispatcher::duplicateInterfaceItem(InterfaceItem *item) { +void Dispatcher::duplicateInterfaceItem(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::duplicateInterfaceItem()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -615,82 +621,95 @@ void Dispatcher::duplicateInterfaceItem(InterfaceItem *item) { } -BoxItem* Dispatcher::addBlock(int idCategory, int idBlock, int idScene) { +BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene) { static QString fctName = "Dispatcher::addBlock()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif bool newSource = false; BoxItem* item = NULL; - GroupScene *scene = getSceneById(idScene); - ReferenceBlock* ref = params->getReferenceBlock(idCategory,idBlock); - // if block has no inputs, propose to add it as a source to top scene - if ((scene->isTopScene()) && (ref->isGeneratorBlock())) { - int ret = QMessageBox::question(NULL,"Adding a block to top scene","Selected block may be used as a source for the top scene. Do you want to add it as a source ?"); - if (ret == QMessageBox::Yes) { - newSource = true; - } - } - if (newSource) { - FunctionalBlock* newOne = params->getGraph()->createSourceBlock(ref); - scene->createSourceItem(newOne); - } - else { - GroupBlock* group = AB_TO_GRP(scene->getGroupItem()->getRefBlock()); - FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref); - item = scene->createBoxItem(newOne); - params->blockToItem.insert(newOne,item); + + /* For now, this method is only used while designing and not loading */ + if (context == Design) { + GroupScene *scene = getSceneById(idScene); + ReferenceBlock* ref = params->getReferenceBlock(idCategory,idBlock); + // if block has no inputs, propose to add it as a source to top scene + if ((scene->isTopScene()) && (ref->isGeneratorBlock())) { + int ret = QMessageBox::question(NULL,"Adding a block to top scene","Selected block may be used as a source for the top scene. Do you want to add it as a source ?"); + if (ret == QMessageBox::Yes) { + newSource = true; + } + } + if (newSource) { + FunctionalBlock* newOne = params->getGraph()->createSourceBlock(ref, true); + scene->createSourceItem(newOne); + } + else { + GroupBlock* group = AB_TO_GRP(scene->getGroupItem()->getRefBlock()); + FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref, true); + item = scene->createBoxItem(newOne); + params->blockToItem.insert(newOne,item); + } + params->unsaveModif = true; } - params->unsaveModif = true; + return item; } -GroupWidget *Dispatcher::createTopScene(){ +GroupWidget *Dispatcher::createTopScene(Context context){ static QString fctName = "Dispatcher::createTopScene()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif - // creating the model part of the group - Graph* graph = params->createGraph(); + bool createIfaces = true; + if (context == Load) { + createIfaces = false; + } + // creating the graph and thus, the topgroup + Graph* graph = params->createGraph(createIfaces); + // get the top group GroupBlock *topBlock = graph->getTopGroup(); - // creating the clkrstgen block - ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen"); - FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref); - ConnectedInterface* fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_clk")); - ConnectedInterface* toIface = AI_TO_CON(newOne->getIfaceFromName("ext_clk")); - fromIface->connectTo(toIface); - fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_reset")); - toIface = AI_TO_CON(newOne->getIfaceFromName("ext_reset")); - fromIface->connectTo(toIface); - - // creating a fake and not connected interface - //AbstractInterface* iface = new GroupInterface(refBlock,"grp_iface",AbstractInterface::Input,AbstractInterface::Top); - - // creating the group widget - topGroup = new GroupWidget(NULL,this,params); - currentGroup = topGroup; + // creating the top group widget + topGroupWidget = new GroupWidget(NULL,this,params); + currentGroupWidget = topGroupWidget; // getting the newly created scene - GroupScene *scene = topGroup->getScene(); + GroupScene *scene = topGroupWidget->getScene(); scene->setId(sceneCounter++); params->setTopScene(scene); params->setCurrentScene(scene); // creating the view part of the group GroupItem *group = new GroupItem(NULL,topBlock,this,params); - + // associate the top scene to the top group iten + scene->setGroupItem(group); // adding the fake interface to the top group item //InterfaceItem* item = new InterfaceItem(0.0 , Parameters::West, (ConnectedInterface*)iface, group, params); //group->addInterface(item,true); - scene->setGroupItem(group); - groupList.append(topGroup); - return topGroup; + if (context == Design) { + // creating the clkrstgen block + ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen"); + FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref, true); + ConnectedInterface* fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_clk")); + ConnectedInterface* toIface = AI_TO_CON(newOne->getIfaceFromName("ext_clk")); + fromIface->connectTo(toIface); + fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_reset")); + toIface = AI_TO_CON(newOne->getIfaceFromName("ext_reset")); + fromIface->connectTo(toIface); + // create the clkrstgen boxitem + BoxItem* item = scene->createBoxItem(newOne, GroupScene::Left, GroupScene::Top, AbstractBoxItem::Position, BoxItem::HSpan); + params->blockToItem.insert(newOne,item); + } + + + groupList.append(topGroupWidget); + return topGroupWidget; } -GroupWidget* Dispatcher::addNewEmptyGroup(GroupScene* scene, bool show) { +GroupWidget* Dispatcher::addNewEmptyGroup(Context context, GroupScene* scene, bool show) { static QString fctName = "Dispatcher::addNewEmptyGroup();"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -706,13 +725,13 @@ GroupWidget* Dispatcher::addNewEmptyGroup(GroupScene* scene, bool show) { params->unsaveModif = true; - GroupWidget* child = createChildScene(scene->getGroupWidget(),newItem); + GroupWidget* child = createChildScene(context, scene->getGroupWidget(),newItem); if (show) child->show(); return child; } -GroupWidget *Dispatcher::createChildScene(GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) { +GroupWidget *Dispatcher::createChildScene(Context context, GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) { static QString fctName = "Dispatcher::createChildScene()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -754,9 +773,9 @@ GroupWidget *Dispatcher::createChildScene(GroupWidget* parentWidget, BoxItem *up return group; } -void Dispatcher::destroyScene(GroupScene *scene) { +void Dispatcher::destroyScene(Context context, GroupScene *scene) { foreach(GroupScene* s, scene->getChildrenScene()) { - destroyScene(s); + destroyScene(context, s); } if (scene->getNbChildScene() == 0) { @@ -773,7 +792,7 @@ void Dispatcher::destroyScene(GroupScene *scene) { } } -void Dispatcher::showRaiseWindow(BoxItem *item) { +void Dispatcher::showRaiseWindow(Context context, BoxItem *item) { static QString fctName = "Dispatcher::showRaiseWindow()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -792,11 +811,11 @@ void Dispatcher::showRaiseWindow(BoxItem *item) { win->raise(); win->activateWindow(); - currentGroup = win; - params->setCurrentScene(currentGroup->getScene()); + currentGroupWidget = win; + params->setCurrentScene(currentGroupWidget->getScene()); } -void Dispatcher::showRstClkIface(AbstractBoxItem *item) { +void Dispatcher::showRstClkIface(Context context, AbstractBoxItem *item) { static QString fctName = "Dispatcher::showRstClkIface()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -806,7 +825,7 @@ void Dispatcher::showRstClkIface(AbstractBoxItem *item) { } -void Dispatcher::showWishboneIface(AbstractBoxItem *item) { +void Dispatcher::showWishboneIface(Context context, AbstractBoxItem *item) { static QString fctName = "Dispatcher::showWishboneIface()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -815,7 +834,7 @@ void Dispatcher::showWishboneIface(AbstractBoxItem *item) { item->setWishboneVisible(!item->isWishboneVisible()); } -void Dispatcher::addNewFullGroup() { +void Dispatcher::addNewFullGroup(Context context) { static QString fctName = "Dispatcher::addNewFullGroup()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -976,12 +995,14 @@ void Dispatcher::addNewFullGroup() { #endif } -void Dispatcher::removeBoxItem(BoxItem *item) { +void Dispatcher::removeBoxItem(Context context, BoxItem *item) { static QString fctName = "Dispatcher::removeBoxItem()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif + if (context != Design) return; + /* a BoxItem (group of func) can be removed only if none of its interfaces is connected to a group interface that is itself connected to another one. @@ -1027,7 +1048,7 @@ void Dispatcher::removeBoxItem(BoxItem *item) { if (ret == QMessageBox::Cancel) { return; } - removeAllBlockConnections(item); + removeAllBlockConnections(context, item); if (item->getRefBlock()->isFunctionalBlock()) { FunctionalBlock* block = AB_TO_FUN(item->getRefBlock()); @@ -1042,7 +1063,7 @@ void Dispatcher::removeBoxItem(BoxItem *item) { // remove all child scenes recursively GroupItem* subgroup = item->getChildGroupItem(); - destroyScene(subgroup->getScene()); + destroyScene(context, subgroup->getScene()); // remove the BoxItem item->getScene()->removeBoxItem(item); // remove the group from the graph @@ -1050,7 +1071,7 @@ void Dispatcher::removeBoxItem(BoxItem *item) { } } -void Dispatcher::removeAllBlockConnections(AbstractBoxItem *item) { +void Dispatcher::removeAllBlockConnections(Context context, AbstractBoxItem *item) { static QString fctName = "Dispatcher::removeAllBlockConnection()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -1058,12 +1079,12 @@ void Dispatcher::removeAllBlockConnections(AbstractBoxItem *item) { foreach(InterfaceItem* ifaceItem, item->getInterfaces()) { foreach(ConnectionItem* conn, ifaceItem->connections) { - removeConnection(conn); + removeConnection(context, conn); } } } -void Dispatcher::removeSourceItem(SourceItem *item) { +void Dispatcher::removeSourceItem(Context context, SourceItem *item) { static QString fctName = "Dispatcher::removeSourceItem()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -1078,7 +1099,7 @@ void Dispatcher::removeSourceItem(SourceItem *item) { if (ret == QMessageBox::Cancel) { return; } - removeAllBlockConnections(item); + removeAllBlockConnections(context, item); FunctionalBlock* block = AB_TO_FUN(item->getRefBlock()); item->getScene()->removeSourceItem(item); @@ -1086,7 +1107,7 @@ void Dispatcher::removeSourceItem(SourceItem *item) { } -void Dispatcher::removeConnection(ConnectionItem *connItem) { +void Dispatcher::removeConnection(Context context, ConnectionItem *connItem) { static QString fctName = "Dispatcher::removeConnection()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -1168,7 +1189,7 @@ void Dispatcher::showBlocksLibrary(){ mainWindow->getLibrary()->raise(); } -void Dispatcher::showProperties(InterfaceItem *inter) { +void Dispatcher::showProperties(Context context, InterfaceItem *inter) { new InterfacePropertiesWindow(inter); } @@ -1178,7 +1199,7 @@ void Dispatcher::showProperties(InterfaceItem *inter) { That action will create a new InterfaceItem on the GroupItem and a connectionItem between the interfaces. */ -void Dispatcher::connectInterToGroup(InterfaceItem *item){ +void Dispatcher::connectInterToGroup(Context context, InterfaceItem *item){ // getting the GroupBlock and GroupItem that are parent of the block that owns item ConnectedInterface *refInter = item->refInter; @@ -1201,7 +1222,7 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){ parentItem->addInterfaceItem(groupIfaceItem,true); // creating the connection, in graph and with an item - createConnection(item, groupIfaceItem); + createConnection(context, item, groupIfaceItem); // if groupItem is not topGroup, must also add a new interface to the parent BlockItem BoxItem* parent2Item = parentItem->getParentItem(); @@ -1212,11 +1233,11 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){ parentItem->getScene()->updateConnectionItemsShape(); - unselectAllItems(); + unselectAllItems(context); params->unsaveModif = true; } -void Dispatcher::removeFunctionalInterface(InterfaceItem *item) { +void Dispatcher::removeFunctionalInterface(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::removeBlockInterface()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -1230,7 +1251,7 @@ void Dispatcher::removeFunctionalInterface(InterfaceItem *item) { that allows to remove an interface. */ foreach(ConnectionItem* conn, item->connections) { - removeConnection(conn); + removeConnection(context, conn); } ConnectedInterface* ref = item->refInter; @@ -1239,7 +1260,7 @@ void Dispatcher::removeFunctionalInterface(InterfaceItem *item) { fun->removeInterface(ref); } -void Dispatcher::removeGroupInterface(InterfaceItem *item) { +void Dispatcher::removeGroupInterface(Context context, InterfaceItem *item) { static QString fctName = "Dispatcher::removeGroupInterface()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -1249,7 +1270,7 @@ void Dispatcher::removeGroupInterface(InterfaceItem *item) { ones to a GroupItem, it is automatically deleted. */ foreach(ConnectionItem* conn, item->connections) { - removeConnection(conn); + removeConnection(context, conn); } } @@ -1317,7 +1338,7 @@ InterfaceItem* Dispatcher::getInterfaceItemById(int id) { return NULL; } -void Dispatcher::findGraphModifications(FunctionalBlock *block) { +void Dispatcher::findGraphModifications(Context context, FunctionalBlock *block) { static QString fctName = "Dispatcher::findGraphModifications()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; diff --git a/Dispatcher.h b/Dispatcher.h index 807c3bb..4354466 100644 --- a/Dispatcher.h +++ b/Dispatcher.h @@ -36,57 +36,73 @@ using namespace Qt; class Dispatcher { public: + /*! + * \brief The Context enum + * Some methods are called while creating a design from scratch or when loading + * a desgin from a project file previously saved. Thus, their behavior may change + * according to the situation. Context is used to specifiy the situation. + * Must be always specified. + */ + enum Context {AnyContext = 0, Design = 1, Load = 2 }; + Dispatcher(Parameters* _params, MainWindow* _window); GroupWidget* loadProject(const QString& filename); - inline int getNumberOfScenes() { return groupList.length(); } - - void unselectAllItems(int direction=0); - void setCurrentGroupWidget(GroupWidget *win); - void changeConnectionMode(int mode = -1); - - - GroupWidget* createTopScene(); - GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL); - void destroyScene(GroupScene* scene); - void showRaiseWindow(BoxItem *item); - void showRstClkIface(AbstractBoxItem *item); - void showWishboneIface(AbstractBoxItem *item); - GroupWidget *addNewEmptyGroup(GroupScene *scene, bool show = true); - void addNewFullGroup(); - inline GroupWidget* getCurrentGroup() { return currentGroup; } - - inline void setSceneCounter(int value) { sceneCounter = value;} bool isCurrentProject; -public slots: - - // graph ops - QMap getAllGroupNames(); - void generateVHDL() throw(Exception); - - // scene ops + /************************** + * scene ops + *************************/ + // getters GroupScene* getSceneById(int id); GroupScene* getSceneByName(QString name); BoxItem* getBoxItemById(int id); GroupItem* getGroupItemById(int id); InterfaceItem* getInterfaceItemById(int id); - - - // block ops - BoxItem* addBlock(int idCategory, int idBlock, int idScene); - void removeBoxItem(BoxItem* item); - void duplicateBoxItem(BoxItem* item); - void renameFunctionalBlock(BoxItem* item); - void generateBlockVHDL(BoxItem* item); - void renameGroupBlock(GroupItem* item); - void renameSourceBlock(SourceItem* item); - void removeSourceItem(SourceItem* item); - void duplicateSourceItem(SourceItem* item); + inline GroupWidget* getCurrentGroup() { return currentGroupWidget; } + inline int getNumberOfScenes() { return groupList.length(); } + // setters + void showRaiseWindow(Context context, BoxItem *item); + void showRstClkIface(Context context, AbstractBoxItem *item); + void showWishboneIface(Context context, AbstractBoxItem *item); + void unselectAllItems(Context context, int direction=0); + void setCurrentGroupWidget(Context context, GroupWidget *win); + void changeConnectionMode(Context context, int mode = -1); + void setSceneCounter(Context context, int value); + // testers + // others + GroupWidget* createTopScene(Context context); + GroupWidget* createChildScene(Context context, GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL); + void destroyScene(Context context, GroupScene* scene); + GroupWidget *addNewEmptyGroup(Context context, GroupScene *scene, bool show = true); + void addNewFullGroup(Context context); + + /************************** + * graph ops + *************************/ + // getters + QMap getAllGroupNames(); + // setters + // testers + // others + void generateVHDL(Context context) throw(Exception); + + /************************** + * block ops + *************************/ + BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene); + void removeBoxItem(Context context, BoxItem* item); + void duplicateBoxItem(Context context, BoxItem* item); + void renameFunctionalBlock(Context context, BoxItem* item); + void generateBlockVHDL(Context context, BoxItem* item); + void renameGroupBlock(Context context, GroupItem* item); + void renameSourceBlock(Context context, SourceItem* item); + void removeSourceItem(Context context, SourceItem* item); + void duplicateSourceItem(Context context, SourceItem* item); // interface ops @@ -99,7 +115,7 @@ public slots: * connect to group in the contextual menu. * Thus, parameter item is always owned by a BoxItem */ - void connectInterToGroup(InterfaceItem* item); + void connectInterToGroup(Context context, InterfaceItem* item); /*! * \brief removeFunctionalInterface * \param item item is always owned by a BoxItem @@ -108,7 +124,7 @@ public slots: * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu. * Thus, parameter item is always owned by a BoxItem */ - void removeFunctionalInterface(InterfaceItem* item); + void removeFunctionalInterface(Context context, InterfaceItem* item); /*! * \brief removeGroupInterface * \param item item is always owned by a GroupItem @@ -117,22 +133,22 @@ public slots: * to a GroupItem and if it is connected only to an inner interface) and chooses remove in the contextual menu. * Thus, parameter item is always owned by a GroupItem */ - void removeGroupInterface(InterfaceItem* item); - void duplicateInterfaceItem(InterfaceItem* item); - void showProperties(InterfaceItem *inter); - void renameInterface(InterfaceItem* item); - void showPatterns(InterfaceItem* item); - void showModifier(InterfaceItem* item); - void removeModifier(InterfaceItem* item); + void removeGroupInterface(Context context, InterfaceItem* item); + void duplicateInterfaceItem(Context context, InterfaceItem* item); + void showProperties(Context context, InterfaceItem *inter); + void renameInterface(Context context, InterfaceItem* item); + void showPatterns(Context context, InterfaceItem* item); + void showModifier(Context context, InterfaceItem* item); + void removeModifier(Context context, InterfaceItem* item); // connection ops - bool createConnection(InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true); - void removeAllBlockConnections(AbstractBoxItem *item); - void removeConnection(ConnectionItem *conn); + bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true); + void removeAllBlockConnections(Context context, AbstractBoxItem *item); + void removeConnection(Context context, ConnectionItem *conn); // analysis ops - void findGraphModifications(FunctionalBlock* block); // find modif so that block has compatible inputs + void findGraphModifications(Context context, FunctionalBlock* block); // find modif so that block has compatible inputs // others void showBlocksLibrary(); @@ -148,8 +164,8 @@ private: // attributes that corresponds to the views MainWindow* mainWindow; QList groupList; - GroupWidget* currentGroup; - GroupWidget *topGroup; + GroupWidget* currentGroupWidget; + GroupWidget *topGroupWidget; static int sceneCounter; }; diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index 1fe7569..65c8df8 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -8,7 +8,7 @@ #include "ArithmeticEvaluator.h" -FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference) throw(Exception) : AbstractBlock() { +FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock() { //if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE)); //if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE)); reference = _reference; @@ -30,6 +30,10 @@ FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference delta = -1; evaluator = NULL; + if (createIfaces) { + populate(); + } + } FunctionalBlock::~FunctionalBlock() { diff --git a/FunctionalBlock.h b/FunctionalBlock.h index 99f8a80..8e0e2ed 100644 --- a/FunctionalBlock.h +++ b/FunctionalBlock.h @@ -26,7 +26,7 @@ using namespace Qt; class FunctionalBlock : public AbstractBlock { public: - FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference) throw(Exception); + FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception); ~FunctionalBlock(); // getters inline ReferenceBlock* getReference() { return reference; } diff --git a/FunctionalInterface.cpp b/FunctionalInterface.cpp index 1237e74..eec7ea8 100644 --- a/FunctionalInterface.cpp +++ b/FunctionalInterface.cpp @@ -108,16 +108,16 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { // first case: interface of blocks within the same group if (getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } // second case: iface = interface of the group that contains owner of this else if (getOwner()->getParent() == iface->getOwner()) { - if ((direction == Output) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if ((getOwner()->isSourceBlock()) && (iface->getOwner()->isTopGroupBlock())) { - if ((direction == Output) && (iface->getDirection() == Input)) return true; + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; } return false; @@ -146,12 +146,12 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { if (getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Input) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (getOwner()->getParent() == iface->getOwner()) { - if ((direction == Input) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } return false; diff --git a/Graph.cpp b/Graph.cpp index 46159ff..a64d8aa 100644 --- a/Graph.cpp +++ b/Graph.cpp @@ -3,8 +3,8 @@ #include "ReferenceBlock.h" #include "FunctionalBlock.h" -Graph::Graph() { - topGroup = new GroupBlock(NULL); +Graph::Graph(bool createTopGroupIface) { + topGroup = new GroupBlock(NULL, createTopGroupIface); topGroup->setName("top group"); groups.append(topGroup); } @@ -18,8 +18,8 @@ QList Graph::getOutsideInterfaces() { return topGroup->getInterfaces(); } -GroupBlock* Graph::createChildGroupBlock(GroupBlock* parent) { - GroupBlock* b = new GroupBlock(parent); +GroupBlock* Graph::createChildGroupBlock(GroupBlock* parent, bool createGroupIface) { + GroupBlock* b = new GroupBlock(parent, createGroupIface); groups.append(b); return b; } @@ -38,10 +38,9 @@ GroupBlock* Graph::getGroupBlockByName(QString name) { return NULL; } -FunctionalBlock* Graph::createFunctionalBlock(GroupBlock* group, ReferenceBlock* ref) { +FunctionalBlock* Graph::createFunctionalBlock(GroupBlock* group, ReferenceBlock* ref, bool createIfaces) { - FunctionalBlock* newBlock = new FunctionalBlock(group,ref); - newBlock->populate(); + FunctionalBlock* newBlock = new FunctionalBlock(group,ref, createIfaces); group->addBlock(newBlock); return newBlock; @@ -53,7 +52,7 @@ FunctionalBlock* Graph::duplicateFunctionalBlock(FunctionalBlock *block) { GroupBlock* group = AB_TO_GRP(block->getParent()); // adding to the graph - FunctionalBlock* newBlock = createFunctionalBlock(group,ref); + FunctionalBlock* newBlock = createFunctionalBlock(group,ref, true); return newBlock; } @@ -78,10 +77,9 @@ FunctionalBlock* Graph::getFunctionalBlockByName(QString name, GroupBlock* paren return block; } -FunctionalBlock* Graph::createSourceBlock(ReferenceBlock* ref) { +FunctionalBlock* Graph::createSourceBlock(ReferenceBlock* ref, bool createIfaces) { - FunctionalBlock* newBlock = new FunctionalBlock(NULL,ref); - newBlock->populate(); + FunctionalBlock* newBlock = new FunctionalBlock(NULL,ref, createIfaces); sources.append(newBlock); return newBlock; } @@ -91,7 +89,7 @@ FunctionalBlock* Graph::duplicateSourceBlock(FunctionalBlock *block) { ReferenceBlock* ref = block->getReference(); // adding to the graph - FunctionalBlock* newBlock = createSourceBlock(ref); + FunctionalBlock* newBlock = createSourceBlock(ref, true); return newBlock; } diff --git a/Graph.h b/Graph.h index 8b2015f..a9b90aa 100644 --- a/Graph.h +++ b/Graph.h @@ -19,7 +19,7 @@ using namespace Qt; class Graph { public: - Graph(); + Graph(bool createTopGroupIface = true); ~Graph(); // getters @@ -27,18 +27,18 @@ public: inline QList getAllGroups() { return groups; } // methods for group blocks - GroupBlock* createChildGroupBlock(GroupBlock* parent); + GroupBlock* createChildGroupBlock(GroupBlock* parent, bool createGroupIface = true); void removeGroupBlock(GroupBlock *group); GroupBlock* getGroupBlockByName(QString name); // methods for functional blocks - FunctionalBlock* createFunctionalBlock(GroupBlock *group, ReferenceBlock *ref); + FunctionalBlock* createFunctionalBlock(GroupBlock *group, ReferenceBlock *ref, bool createIfaces = true); FunctionalBlock* duplicateFunctionalBlock(FunctionalBlock *block); bool removeFunctionalBlock(FunctionalBlock* block); FunctionalBlock* getFunctionalBlockByName(QString name, GroupBlock* parent = NULL); //! if parent = NULL, search in the whole graph // methods for source blocks - FunctionalBlock* createSourceBlock(ReferenceBlock *ref); + FunctionalBlock* createSourceBlock(ReferenceBlock *ref, bool createIfaces = true); FunctionalBlock* duplicateSourceBlock(FunctionalBlock *block); FunctionalBlock* getSourceBlockByName(QString name); bool removeSourceBlock(FunctionalBlock* block); diff --git a/GroupBlock.cpp b/GroupBlock.cpp index ab76563..7945ee7 100644 --- a/GroupBlock.cpp +++ b/GroupBlock.cpp @@ -10,7 +10,7 @@ int GroupBlock::counter = 1; -GroupBlock::GroupBlock(GroupBlock *_parent) throw(Exception) : AbstractBlock() { +GroupBlock::GroupBlock(GroupBlock *_parent, bool createIfaces) throw(Exception) : AbstractBlock() { GroupInterface* clk = NULL; GroupInterface* rst = NULL; diff --git a/GroupBlock.h b/GroupBlock.h index c3b6f9c..63104de 100644 --- a/GroupBlock.h +++ b/GroupBlock.h @@ -17,7 +17,7 @@ using namespace Qt; class GroupBlock : public AbstractBlock { public: - GroupBlock(GroupBlock* _parent) throw(Exception); + GroupBlock(GroupBlock* _parent, bool createIfaces = true) throw(Exception); virtual ~GroupBlock(); // getters diff --git a/GroupInterface.cpp b/GroupInterface.cpp index c611ecf..5f292b6 100644 --- a/GroupInterface.cpp +++ b/GroupInterface.cpp @@ -70,17 +70,17 @@ bool GroupInterface::canConnectTo(AbstractInterface *iface) { if (connIface->getConnectedFrom() != NULL) return false; if (this->getOwner() == iface->getOwner()->getParent()) { - if ((direction == Input) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()) { - if ((direction == Output) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } @@ -110,20 +110,20 @@ bool GroupInterface::canConnectFrom(AbstractInterface *iface) { if (getConnectedFrom() != NULL) return false; if (this->getOwner() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Input) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (this->getOwner()->getParent() == iface->getOwner()) { - if ((direction == Input) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) { - if ((direction == Input) && (iface->getDirection() == Output)) return true; + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; } return false; diff --git a/GroupItem.cpp b/GroupItem.cpp index 3286c14..ebef87c 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -384,7 +384,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); + dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget()); if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { InterfaceItem *inter = getInterfaceItemFromCursor(x,y); @@ -448,7 +448,7 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { else if (params->editState == Parameters::EditCloseConnection) { InterfaceItem* iface1 = getScene()->getSelectedInterface(1); InterfaceItem* iface2 = getScene()->getSelectedInterface(2); - bool ok = dispatcher->createConnection(iface1,iface2); + bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); @@ -585,15 +585,15 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { if(selectedAction == renameAction){ if(ifaceItem != NULL) - dispatcher->renameInterface(ifaceItem); + dispatcher->renameInterface(Dispatcher::Design, ifaceItem); else - dispatcher->renameGroupBlock(this); + dispatcher->renameGroupBlock(Dispatcher::Design, this); } else if(selectedAction == showProperties){ - dispatcher->showProperties(ifaceItem); + dispatcher->showProperties(Dispatcher::Design, ifaceItem); } else if (selectedAction == removeAction) { - dispatcher->removeGroupInterface(ifaceItem); + dispatcher->removeGroupInterface(Dispatcher::Design, ifaceItem); } else if(selectedAction == showParameters) { new ParametersWindow(refBlock, params, NULL); diff --git a/GroupScene.cpp b/GroupScene.cpp index 2ceb21f..0eaa8a1 100644 --- a/GroupScene.cpp +++ b/GroupScene.cpp @@ -103,16 +103,35 @@ int GroupScene::setInterfacesId(int countInit) { return counter; } -BoxItem *GroupScene::createBoxItem(AbstractBlock *block) { +BoxItem *GroupScene::createBoxItem(AbstractBlock *block, BoxItem::Position hPos, BoxItem::Position vPos, AbstractBoxItem::LockType lock, BoxItem::SpanType span) { - BoxItem* item = new BoxItem(block,dispatcher,params,groupItem); + BoxItem* item = new BoxItem(block,dispatcher,params,groupItem, lock, span); item->setZValue(1); // add item from the QList boxItems.append(item); // repainting the group groupItem->updateShape(); // center the new block - QPointF newPos((groupItem->getWidth()-item->getTotalWidth())/2.0, (groupItem->getHeight()-item->getTotalHeight())/2.0); + double x,y; + if (hPos == BoxItem::Left) { + x = 0; + } + else if (hPos == BoxItem::Center) { + x = (groupItem->getWidth()-item->getTotalWidth())/2.0; + } + else if (hPos == BoxItem::Right) { + x = groupItem->getWidth()-item->getTotalWidth(); + } + if (vPos == BoxItem::Top) { + y = 0; + } + else if (vPos == BoxItem::Center) { + y = (groupItem->getHeight()-item->getTotalHeight())/2.0; + } + else if (vPos == BoxItem::Bottom) { + y = groupItem->getHeight()-item->getTotalHeight(); + } + QPointF newPos(x,y); newPos = newPos-item->getOriginPoint(); item->moveTo(newPos); diff --git a/GroupScene.h b/GroupScene.h index e2e4763..bcaa799 100644 --- a/GroupScene.h +++ b/GroupScene.h @@ -10,6 +10,7 @@ class Parameters; class AbstractBlock; class GroupWidget; class GroupItem; +#include "BoxItem.h" class BoxItem; class SourceItem; class AbstractBoxItem; @@ -44,6 +45,7 @@ public: */ enum EditMode { InitState, AddConnection, ItemEdition }; + GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0); ~GroupScene(); @@ -74,7 +76,7 @@ public: // others // BoxItem related - BoxItem* createBoxItem(AbstractBlock* block); //! create a new BoxItem and place it at the center of the scene + BoxItem* createBoxItem(AbstractBlock* block, BoxItem::Position hPos = Center, BoxItem::Position vPos = Center, AbstractBoxItem::LockType lock = AbstractBoxItem::NoLock, BoxItem::SpanType span = BoxItem::NoSpan); //! create a new BoxItem and place it at the center of the scene void addBoxItem(BoxItem* item); //! add an already configured BoxItem in the scene. void removeBoxItem(BoxItem* item); diff --git a/GroupWidget.cpp b/GroupWidget.cpp index 54cdfc1..c530c2b 100644 --- a/GroupWidget.cpp +++ b/GroupWidget.cpp @@ -21,7 +21,7 @@ GroupWidget::GroupWidget(GroupWidget *_upperGroup, Dispatcher *_dispatcher, scene = new GroupScene(NULL, this, dispatcher, params, true); } else { - topGroup = true; + topGroup = false; scene = new GroupScene(upperGroup->getScene(), this, dispatcher, params, false); } @@ -85,7 +85,7 @@ void GroupWidget::enableGroupButton(bool b) { void GroupWidget::mousePressEvent(QMouseEvent *e) { - dispatcher->setCurrentGroupWidget(this); + dispatcher->setCurrentGroupWidget(Dispatcher::Design, this); QWidget::mousePressEvent(e); } @@ -179,7 +179,7 @@ void GroupWidget::createToolbar() { } void GroupWidget::slotEdit() { - dispatcher->unselectAllItems(); + dispatcher->unselectAllItems(Dispatcher::Design); getScene()->setEditionMode(GroupScene::ItemEdition); updateBlockButton(); } @@ -187,13 +187,13 @@ void GroupWidget::slotEdit() { void GroupWidget::slotCopyBlock() { foreach (BoxItem *item, params->getCurrentScene()->getBoxItems()) { if(item->isSelected()){ - dispatcher->duplicateBoxItem(item); + dispatcher->duplicateBoxItem(Dispatcher::Design, item); } } } void GroupWidget::slotAddConnection() { - dispatcher->unselectAllItems(); + dispatcher->unselectAllItems(Dispatcher::Design); getScene()->setEditionMode(GroupScene::AddConnection); updateBlockButton(); } @@ -229,24 +229,24 @@ void GroupWidget::updateBlockButton() { void GroupWidget::slotNewEmptyGroup() { - dispatcher->addNewEmptyGroup(scene); + dispatcher->addNewEmptyGroup(Dispatcher::Design, scene); } void GroupWidget::slotNewGroup() { - dispatcher->addNewFullGroup(); + dispatcher->addNewFullGroup(Dispatcher::Design ); } void GroupWidget::slotDeleteItems() { foreach (BoxItem *item, scene->getBoxItems()) { if(item->isSelected()){ - dispatcher->removeBoxItem(item); + dispatcher->removeBoxItem(Dispatcher::Design, item); } } foreach (ConnectionItem *item, scene->getConnectionItems()) { if(item->isSelected()){ - dispatcher->removeConnection(item); + dispatcher->removeConnection(Dispatcher::Design, item); } } } diff --git a/MainWindow.cpp b/MainWindow.cpp index 166dfa2..2b8584f 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -344,7 +344,7 @@ void MainWindow::slotNewProject(){ if (ret == 1) { enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ); enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ); - GroupWidget* topGroup = dispatcher->createTopScene(); + GroupWidget* topGroup = dispatcher->createTopScene(Dispatcher::Design); addTopGroup(topGroup); library->updateComboScene(); library->show(); @@ -443,7 +443,7 @@ void MainWindow::slotGraphAnalysis() { msg += " is not compatible with its input pattern.\nDo you want to launch automatic modification process to ensure the compatibility ?"; int ret = QMessageBox::question(this,tr("Building references library"),msg, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); if (ret == QMessageBox::Ok) { - dispatcher->findGraphModifications(toBlock); + dispatcher->findGraphModifications(Dispatcher::Design, toBlock); } } } @@ -452,7 +452,7 @@ void MainWindow::slotGraphAnalysis() { void MainWindow::slotGenerateVHDL() { try { - dispatcher->generateVHDL(); + dispatcher->generateVHDL(Dispatcher::Design); } catch(Exception e) { cerr << qPrintable(e.getMessage()) << endl; @@ -486,7 +486,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { void MainWindow::mousePressEvent(QMouseEvent *e) { if (dispatcher->getCurrentGroup() != NULL) { - dispatcher->setCurrentGroupWidget(dispatcher->getCurrentGroup()); + dispatcher->setCurrentGroupWidget(Dispatcher::Design, dispatcher->getCurrentGroup()); } QMainWindow::mousePressEvent(e); } diff --git a/NewProjectDialog.cpp b/NewProjectDialog.cpp index 033b686..d98d04a 100644 --- a/NewProjectDialog.cpp +++ b/NewProjectDialog.cpp @@ -25,32 +25,61 @@ NewProjectDialog::NewProjectDialog(Parameters *_params, QWidget *parent) : Custo layDirProj->addWidget(dirProjEdit); layDirProj->addWidget(dirProjButton); + QHBoxLayout *layClk = new QHBoxLayout; + QLabel* clkLab1 = new QLabel(tr("Main clock freq.")); + QLabel* clkLab2 = new QLabel(tr("MHz")); + clkEdit = new QLineEdit("100"); + layClk->addWidget(clkLab1); + layClk->addWidget(clkEdit); + layClk->addWidget(clkLab2); + + QHBoxLayout *layAuto = new QHBoxLayout; + autoConnClkCheck = new QCheckBox("Auto-connect blocks to main clock"); + autoConnClkCheck->setChecked(true); + QVBoxLayout *layAll = new QVBoxLayout; layAll->addLayout(layNameProj); layAll->addLayout(layDirProj); + layAll->addLayout(layClk); + layAll->addLayout(layAuto); setContent(layAll); connect(dirProjButton,SIGNAL(clicked()),this,SLOT(chooseProjectPath())); connect(nameProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectName(QString))); connect(dirProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectPath(QString))); - } + void NewProjectDialog::checkBeforeAccept() { - if ((!nameProjEdit->text().isEmpty()) && (pathOk)) { - //cout << "all ok" << endl; - params->projectPath = dirProjEdit->text(); - params->projectFile = params->projectPath + "/" + params->projectName + ".xml"; + if ((nameProjEdit->text().isEmpty()) || (!pathOk)) { - accept(); + int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path"); + return; + } + double freq; + bool ok = false; + freq = clkEdit->text().toDouble(&ok); + if (!ok) { + int ret = QMessageBox::warning(this,"Cannot create the project","Invalid main clock frequency (in MHz)"); + return; } - else { - int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path"); + //cout << "all ok" << endl; + params->projectPath = dirProjEdit->text(); + params->projectFile = params->projectPath + "/" + params->projectName + ".xml"; + params->clocks.append(freq); + if (autoConnClkCheck->isChecked()) { + params->autoConnMainClk = true; + } + else { + params->autoConnMainClk = false; } + + accept(); + } void NewProjectDialog::chooseProjectPath() { diff --git a/NewProjectDialog.h b/NewProjectDialog.h index cad5c06..2ac70b3 100644 --- a/NewProjectDialog.h +++ b/NewProjectDialog.h @@ -28,14 +28,16 @@ private: QLineEdit *nameProjEdit; QLineEdit *dirProjEdit; QPushButton *dirProjButton; + QCheckBox *autoConnClkCheck; + QLineEdit *clkEdit; + bool pathOk; private slots: void checkBeforeAccept(); void chooseProjectPath(); void checkProjectPath(QString name); - void checkProjectName(QString name); - + void checkProjectName(QString name); }; diff --git a/Parameters.cpp b/Parameters.cpp index 2ee6255..60d7971 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -69,8 +69,8 @@ void Parameters::clear() { refPathes.clear(); } -Graph* Parameters::createGraph() { - graph = new Graph(); +Graph* Parameters::createGraph(bool createTopGroupIfaces) { + graph = new Graph(createTopGroupIfaces); return graph; } @@ -272,7 +272,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); if (idUpperScene == -1) { - topGroup = dispatcher->createTopScene(); + topGroup = dispatcher->createTopScene(Dispatcher::Load); topScene->setId(idScene); groupItem = topScene->getGroupItem(); cout << "top group added to scene n°" << idScene << endl; @@ -280,7 +280,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { else { cout << "trying to create scene n°" << idScene << " with upper scene n°" <addNewEmptyGroup(upperScene,false); + groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false); groupWidget->getScene()->setId(idScene); groupItem = groupWidget->getScene()->getGroupItem(); } @@ -302,7 +302,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl; } } - dispatcher->setSceneCounter(maxIdScene+1); + dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1); cout << "groupItems loaded and windows created succefully!" << endl; /********************************************************** @@ -457,7 +457,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { InterfaceItem *iface2 = searchInterfaceItemById(to,topScene); if(iface1 != NULL && iface2 != NULL){ - dispatcher->createConnection(iface1,iface2); + dispatcher->createConnection(Dispatcher::Load, iface1,iface2); } else { cout << "interfaces not found, connect canceled!" << endl; } diff --git a/Parameters.h b/Parameters.h index 9b4ee1b..a541ee6 100644 --- a/Parameters.h +++ b/Parameters.h @@ -138,8 +138,10 @@ public : QString projectPath; QString projectName; QString projectFile; // equals to projectPath/projectName.xml + bool autoConnMainClk; // true if auto-connection to main clock (i.e. ext_clk) + QList clocks; // clocks[0] is the main clock. - Graph* createGraph(); + Graph* createGraph(bool createTopGroupIfaces = true); void destroyGraph(); inline Graph* getGraph() { return graph; } ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index diff --git a/SourceItem.cpp b/SourceItem.cpp index 89413b0..d122847 100644 --- a/SourceItem.cpp +++ b/SourceItem.cpp @@ -315,7 +315,7 @@ void SourceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); + dispatcher->setCurrentGroupWidget(Dispatcher::Design, getScene()->getGroupWidget()); if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { InterfaceItem *inter = getInterfaceItemFromCursor(x,y); @@ -389,7 +389,7 @@ void SourceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { else if (params->editState == Parameters::EditCloseConnection) { InterfaceItem* iface1 = getScene()->getSelectedInterface(1); InterfaceItem* iface2 = getScene()->getSelectedInterface(2); - bool ok = dispatcher->createConnection(iface1,iface2); + bool ok = dispatcher->createConnection(Dispatcher::Design, iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); @@ -539,27 +539,27 @@ void SourceItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { if(selectedAction == NULL) return ; if (selectedAction == removeAction) { - dispatcher->removeSourceItem(this); + dispatcher->removeSourceItem(Dispatcher::Design, this); } else if (selectedAction == duplicateAction) { - dispatcher->duplicateSourceItem(this); + dispatcher->duplicateSourceItem(Dispatcher::Design, this); } else if(selectedAction == renameAction){ if(ifaceItem != NULL) { - dispatcher->renameInterface(ifaceItem); + dispatcher->renameInterface(Dispatcher::Design, ifaceItem); } else { - dispatcher->renameSourceBlock(this); + dispatcher->renameSourceBlock(Dispatcher::Design, this); } } else if(selectedAction == showProperties){ - dispatcher->showProperties(ifaceItem); + dispatcher->showProperties(Dispatcher::Design, ifaceItem); } else if(selectedAction == showParameters){ new ParametersWindow(refBlock, params, NULL); } else if(selectedAction == showPatterns) { - dispatcher->showPatterns(ifaceItem); + dispatcher->showPatterns(Dispatcher::Design, ifaceItem); } } diff --git a/blast.creator.user b/blast.creator.user index 0c8b1dc..0cdb798 100644 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/lib/implementations/#toto.txt# b/lib/implementations/#toto.txt# deleted file mode 100644 index 02b0815..0000000 --- a/lib/implementations/#toto.txt# +++ /dev/null @@ -1 +0,0 @@ -((1{$group_size}0{$group_delay-1}){($item_per_line-1)|$group_size}1{1+(($item_per_line-1)%$group_size)}0{$line_delay-1}){$nb_lines} \ No newline at end of file