From: Stéphane Domas Date: Wed, 26 Apr 2017 16:52:17 +0000 (+0200) Subject: correcting bugs but still exsitings X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/d30c9cf675ad7141d1c8e31d2e72315267d45cf2?ds=sidebyside correcting bugs but still exsitings --- diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index 0afbe29..ec791fb 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -98,7 +98,7 @@ InterfaceItem* AbstractBoxItem::searchInterfaceByRef(ConnectedInterface *ref) { void AbstractBoxItem::addInterface(InterfaceItem *i, bool resetPosition) { interfaces.append(i); if (resetPosition) resetInterfacesPosition(); - updateGeometry(); + updateGeometry(InterfaceMove); update(); } @@ -108,7 +108,7 @@ void AbstractBoxItem::removeInterface(InterfaceItem *i) { delete i; //resetInterfacesPosition(); - updateGeometry(); + updateGeometry(InterfaceMove); update(); } @@ -158,7 +158,7 @@ void AbstractBoxItem::resetInterfacesPosition() { } } -void AbstractBoxItem::deplaceInterface(QPointF pos) { +void AbstractBoxItem::moveInterfaceTo(QPointF pos) { double positionRatio; if(currentInterface->getOrientation() == Parameters::North || currentInterface->getOrientation() == Parameters::South){ if(pos.x() < 0){ @@ -226,11 +226,12 @@ void AbstractBoxItem::updateInterfacesAndConnections() { foreach(InterfaceItem *item, interfaces){ item->updatePosition(); } + // NB: dunno the utility of this test !! if (getScene() != NULL) { // update all connections from/to this block foreach(ConnectionItem *item, getScene()->getConnectionItems()){ if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) { - item->setPathes(); + item->setPath(); } } } diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index 6eeb46c..375e9dc 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -58,7 +58,28 @@ public: void addInterface(InterfaceItem* i, bool resetPosition = false); void removeInterface(InterfaceItem* i); void resetInterfacesPosition(); - void deplaceInterface(QPointF pos); + /*! + * \brief moveInterfaceTo + * \param pos the new position (in scene) of the interface + * + * This method is called when user moves an InterfaceItem. + * see BoxItem::mouseMoveEvent() and GroupItem::mouseMoveEvent() + */ + void moveInterfaceTo(QPointF pos); + /*! + * \brief updateInterfacesAndConnections + * + * This method allows to recompute the absolute position of the interfaces of this box + * taking into account their relative position (see positionRatio atribute) in the width/height + * of the box border they are located on. It allows update the shape of all ConnectionItem + * connected to this box. + * + * CAUTION: this method supposes that before its call, a call to prepareGeometryChange() hase been + * done for the BoxItem that owns this InterfaceItem, so that the scene will readraw automatically + * the BoxItem. For the connections, the call to prepareGeometryChange() is done within setPath() + * that is called in this method. Thus, there is no need to call update() after the termination of + * this method. + */ void updateInterfacesAndConnections(); InterfaceItem *searchInterfaceByName(QString name); diff --git a/BlockLibraryWidget.cpp b/BlockLibraryWidget.cpp index 0aa9ed1..544a1d1 100644 --- a/BlockLibraryWidget.cpp +++ b/BlockLibraryWidget.cpp @@ -10,10 +10,16 @@ BlockLibraryWidget::BlockLibraryWidget(Dispatcher* _dispatcher, params = _params; // creating the widget : tree, buttons, ... - layout = new QBoxLayout(QBoxLayout::TopToBottom, this); + QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this); tree = new QTreeWidget(this); - buttonAdd = new QPushButton("add", this); + + buttonAdd = new QPushButton("add to", this); buttonAdd->setEnabled(false); + comboScenes = new QComboBox(); + + QHBoxLayout* layBottom = new QHBoxLayout; + layBottom->addWidget(buttonAdd); + layBottom->addWidget(comboScenes); connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(clicked())); connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(doubleClicked())); @@ -24,11 +30,10 @@ BlockLibraryWidget::BlockLibraryWidget(Dispatcher* _dispatcher, QTreeWidgetItem* item = tree->invisibleRootItem(); tree->setHeaderLabel("Blocks list"); - addChild(cat,item); layout->addWidget(tree); - layout->addWidget(buttonAdd); + layout->addLayout(layBottom); this->setLayout(layout); this->setFixedSize(300,230); @@ -81,7 +86,9 @@ void BlockLibraryWidget::addClicked() { if(item->data(1,Qt::DisplayRole).isValid() && item->data(2,Qt::DisplayRole).isValid()){ int idParent = item->data(1,Qt::DisplayRole).toInt(); int idBlock = item->data(2,Qt::DisplayRole).toInt(); - dispatcher->addBlock(idParent, idBlock); + QVariant v = comboScenes->currentData(); + cout << "adding block to scene " << v.toInt() << endl; + dispatcher->addBlock(idParent, idBlock, v.toInt()); } // only take the first selected @@ -89,9 +96,7 @@ void BlockLibraryWidget::addClicked() { // calling dispatcher addBlock() method. } - -void BlockLibraryWidget::clicked() -{ +void BlockLibraryWidget::clicked() { if(tree->selectedItems().length() > 0){ QTreeWidgetItem *item = tree->selectedItems().at(0); if(item->data(1,Qt::DisplayRole).isValid()) @@ -101,7 +106,16 @@ void BlockLibraryWidget::clicked() } } -void BlockLibraryWidget::doubleClicked() -{ +void BlockLibraryWidget::doubleClicked() { addClicked(); } + +void BlockLibraryWidget::updateComboScene() { + comboScenes->clear(); + QMap list = dispatcher->getAllGroupNames(); + QMapIterator iter(list); + while (iter.hasNext()) { + iter.next(); + comboScenes->addItem(iter.value(),QVariant(iter.key())); + } +} diff --git a/BlockLibraryWidget.h b/BlockLibraryWidget.h index f07be4d..43ed5fc 100644 --- a/BlockLibraryWidget.h +++ b/BlockLibraryWidget.h @@ -23,6 +23,9 @@ public: explicit BlockLibraryWidget(Dispatcher* _dispatcher, Parameters* _params, QWidget *parent = 0); ~BlockLibraryWidget(); +public slots: + void updateComboScene(); + private slots: void addClicked(); void clicked(); @@ -34,7 +37,7 @@ private: Dispatcher* dispatcher; QTreeWidget* tree; QPushButton* buttonAdd; - QBoxLayout *layout; + QComboBox* comboScenes; // other attributes void addChild(BlockCategory *catParent, QTreeWidgetItem* itemParent); diff --git a/BoxItem.cpp b/BoxItem.cpp index 77e9533..0b1cd03 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -33,7 +33,7 @@ BoxItem::BoxItem(AbstractBlock *_refBlock, setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); initInterfaces(); - updateGeometry(); + updateGeometry(InterfaceMove); resetInterfacesPosition(); QPointF initPos = QPointF(0.0,0.0) - originPoint; setPos(initPos); @@ -133,27 +133,29 @@ bool BoxItem::updateGeometry(ChangeType type) { bool boxSizeChanged = false; - if ((type == Resize) || (type == InterfaceMove)) { - updateMinimumSize(); - } + // whatever the change, the minimum size may ahve changed + updateMinimumSize(); if (type == Resize) { - prepareGeometryChange(); - updateInterfacesAndConnections(); + // resize implies to move interfaces and to update connections boxSizeChanged = true; } - if (boxWidth < minimumBoxWidth) { - boxWidth = minimumBoxWidth; - boxSizeChanged = true; - } - if (boxHeight < minimumBoxHeight) { - boxHeight = minimumBoxHeight; - boxSizeChanged = true; + else if (type == InterfaceMove) { + // if an interface moves, it may change the box size + if (boxWidth < minimumBoxWidth) { + boxWidth = minimumBoxWidth; + boxSizeChanged = true; + } + if (boxHeight < minimumBoxHeight) { + boxHeight = minimumBoxHeight; + boxSizeChanged = true; + } } if (boxSizeChanged) { updateInterfacesAndConnections(); } + double x = 0.0; double y = 0.0; totalWidth = boxWidth; @@ -208,7 +210,7 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { // update all connections from/to this block foreach(ConnectionItem *item, getScene()->getConnectionItems()){ if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) { - item->setPathes(); + item->setPath(); } } cursorPosition = event->scenePos(); @@ -248,7 +250,7 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { break; } // recompute the geometry of the block and possibly the group item - if (updateGeometry()) { + if (updateGeometry(Resize)) { (getScene()->getGroupItem())->updateShape(); } @@ -256,16 +258,16 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { } else if(params->editState == Parameters::EditInterfaceMove) { prepareGeometryChange(); - deplaceInterface(event->pos()); + moveInterfaceTo(event->pos()); // recompute the geometry of the block - if (updateGeometry()) { + if (updateGeometry(InterfaceMove)) { cout << "must recompute group item geometry" << endl; (getScene()->getGroupItem())->updateShape(); } // update connection from/to the selected interface foreach(ConnectionItem *item, getScene()->getConnectionItems()){ if ((item->getFromInterfaceItem() == currentInterface) || (item->getToInterfaceItem() == currentInterface)) { - item->setPathes(); + item->setPath(); } } } @@ -468,14 +470,26 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { showProperties = menu.addAction("Show properties"); ConnectedInterface* iface = ifaceItem->refInter; + ConnectedInterface* ifaceGroup = NULL; + + if ((iface->getDirection() == AbstractInterface::Input) && (iface->getConnectedFrom() == NULL)) { connectToGroup = menu.addAction("Connect to group input"); } else if ((iface->getDirection() == AbstractInterface::Output) && (!iface->isConnectedTo())) { connectToGroup = menu.addAction("Connect to group output"); } - else if ((iface->getConnectionFromParentGroup() != NULL) || (iface->getConnectionToParentGroup() != NULL)) { - disconnectFromGroup = menu.addAction("Disconnect from group"); + else if (iface->getConnectionFromParentGroup() != NULL) { + ifaceGroup = iface->getConnectionFromParentGroup(); + if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) { + disconnectFromGroup = menu.addAction("Disconnect from group"); + } + } + else if (iface->getConnectionToParentGroup() != NULL) { + ifaceGroup = iface->getConnectionToParentGroup(); + if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) { + disconnectFromGroup = menu.addAction("Disconnect from group"); + } } if (iface->isFunctionalInterface()) { diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index dee71ba..b6d99a5 100644 --- a/ConnectionItem.cpp +++ b/ConnectionItem.cpp @@ -85,7 +85,7 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, setCursor(Qt::PointingHandCursor); setZValue(0); - setPathes(); + setPath(); } @@ -145,8 +145,9 @@ void ConnectionItem::addInterPoint(QPointF point) { } -void ConnectionItem::setPathes() { +void ConnectionItem::setPath() { + // signals to the scene that this connection is going to change of shape. prepareGeometryChange(); pointFrom = fromInterfaceItem->getEndPointInGroup(); diff --git a/ConnectionItem.h b/ConnectionItem.h index 567a31d..867e811 100644 --- a/ConnectionItem.h +++ b/ConnectionItem.h @@ -14,9 +14,9 @@ class InterfaceItem; using namespace std; using namespace Qt; -/* NOTES : +/*! \brief ConnectionItem class - A connection item represent a graphical link between two interface items. + A ConnectionItem represents a graphical link between two interface items. Even if it links two in/out interfaces, it is always oriented. The orientation depends on the type and direction of linked interfaces : @@ -61,7 +61,19 @@ public: void setSelected(bool selected); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - void setPathes(); + + /*! + * \brief setPath + * setPath() allows to compute the graphical shape of the ConnectionItem + * taking into account the position/direction of from and to interface items. + * Depending on their vlaue, it calls on of the dedicated methods. + * + * CAUTION: this method calls prepareGeometryChange() so that the scene + * can automatically updates and redraw the ConnectionItem. Thus, there is + * no need to call update() after the termination of this method. + * + */ + void setPath(); void addInterPoint(QPointF point); static int counter; diff --git a/Dispatcher.cpp b/Dispatcher.cpp index a85b942..810396e 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -24,6 +24,7 @@ #include "InterfacePropertiesWindow.h" +int Dispatcher::sceneCounter = 0; Dispatcher::Dispatcher(Parameters* _params, MainWindow* _window) { params = _params; @@ -48,6 +49,7 @@ GroupWidget *Dispatcher::loadProject(const QString& filename) { currentGroup = topGroup; // getting the newly created scene GroupScene *scene = topGroup->getScene(); + params->setTopScene(scene); params->setCurrentScene(scene); @@ -61,6 +63,7 @@ GroupWidget *Dispatcher::loadProject(const QString& filename) { return NULL; } + groupList.append(topGroup); return topGroup; } @@ -194,6 +197,8 @@ void Dispatcher::rename(AbstractBoxItem *item){ currentGroup->setWindowTitle("blast - "+text); } } + + mainWindow->getLibrary()->updateComboScene(); } else { QMessageBox::warning(NULL,"Error in given name", @@ -221,6 +226,7 @@ void Dispatcher::rename(InterfaceItem *item){ item->refInter->setName(text); } item->setName(text); + } else { QMessageBox::warning(NULL,"Error in given name", @@ -270,9 +276,9 @@ void Dispatcher::duplicateInterface(InterfaceItem *item){ } -void Dispatcher::addBlock(int idCategory, int idBlock) { +void Dispatcher::addBlock(int idCategory, int idBlock, int idScene) { - GroupScene *scene = params->getCurrentScene(); + GroupScene *scene = searchSceneById(idScene); FunctionalBlock* newOne = params->addFunctionalBlock(idCategory, idBlock); scene->createBlockItem(newOne); } @@ -292,6 +298,7 @@ GroupWidget *Dispatcher::createTopScene(){ currentGroup = topGroup; // getting the newly created scene GroupScene *scene = topGroup->getScene(); + scene->setId(sceneCounter++); params->setTopScene(scene); params->setCurrentScene(scene); // creating the view part of the group @@ -303,26 +310,29 @@ GroupWidget *Dispatcher::createTopScene(){ scene->setGroupItem(group); + groupList.append(topGroup); return topGroup; } GroupWidget *Dispatcher::createChildScene(GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) { - GroupBlock* parentBlock = NULL; + // getting back the goup block already created + GroupBlock* groupBlock = NULL; if (upperItemOfGroupItem != NULL) { - parentBlock = AB_TO_GRP(upperItemOfGroupItem->getRefBlock()); - } - // creating the model part of the group - GroupBlock *groupBlock = new GroupBlock(parentBlock); - groupBlock->setName("no name"); + groupBlock = AB_TO_GRP(upperItemOfGroupItem->getRefBlock()); + } // creating the view part of the group GroupItem *groupItem = new GroupItem(upperItemOfGroupItem,groupBlock,this,params); // creating the group widget GroupWidget* group = new GroupWidget(parentWidget, this, params); // getting the newly created scene GroupScene *scene = group->getScene(); + scene->setId(sceneCounter++); // affecting group item to the scene scene->setGroupItem(groupItem); + groupList.append(group); + + mainWindow->getLibrary()->updateComboScene(); return group; } @@ -610,7 +620,9 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){ // getting the GroupBlock and GroupItem that are parent of the block that owns item ConnectedInterface *refInter = item->refInter; + cout << "owner of iface = " << qPrintable(refInter->getOwner()->getName()) << endl; GroupBlock* parentBlock = AB_TO_GRP(refInter->getOwner()->getParent()); + cout << "create iface for parent group = " << qPrintable(parentBlock->getName()) << endl; GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem(); // creating/adding the group interface in the graph model @@ -775,6 +787,15 @@ void Dispatcher::removeGroupInterface(InterfaceItem *item) { } } +QMap Dispatcher::getAllGroupNames() { + + QMap list; + foreach(GroupWidget *group, groupList) { + list.insert(group->getScene()->getId(), group->getScene()->getGroupItem()->getRefBlock()->getName()); + } + return list; +} + GroupScene* Dispatcher::searchSceneById(int id) { foreach(GroupWidget *group, groupList){ if(group->getScene()->getId() == id) diff --git a/Dispatcher.h b/Dispatcher.h index 4475518..fa77360 100644 --- a/Dispatcher.h +++ b/Dispatcher.h @@ -43,6 +43,7 @@ public: GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL); void showRaiseWindow(AbstractBoxItem *item); void showRstClkInter(AbstractBoxItem *item); + void addNewEmptyGroup(); void addNewFullGroup(); inline GroupWidget* getCurrentGroup() { return currentGroup; } @@ -50,8 +51,9 @@ public: bool isCurrentProject; public slots: - + QMap getAllGroupNames(); GroupScene* searchSceneById(int id); + GroupScene* searchSceneByName(QString name); BoxItem* searchBlockItemById(int id); GroupItem* searchGroupItemById(int id); InterfaceItem* searchInterfaceItemById(int id); @@ -59,7 +61,7 @@ public slots: void removeBlock(AbstractBoxItem* item); void duplicateBlock(BoxItem* item); void duplicateInterface(InterfaceItem* item); - void addBlock(int idCategory, int idBlock); + void addBlock(int idCategory, int idBlock, int idScene); ConnectionItem *addConnection(InterfaceItem *input, InterfaceItem *output); void removeAllBlockConnections(AbstractBoxItem *block); void removeConnection(ConnectionItem *conn); @@ -84,6 +86,8 @@ private: QList groupList; GroupWidget* currentGroup; GroupWidget *topGroup; + + static int sceneCounter; }; #endif // __DISPATCHER_H__ diff --git a/GroupItem.cpp b/GroupItem.cpp index 04d7bca..bb26e53 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -36,7 +36,8 @@ GroupItem::GroupItem(BoxItem *_parentItem, setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); - updateGeometry(); + + updateGeometry(InterfaceMove); QPointF initPos = QPointF(0.0,0.0) - originPoint; setPos(initPos); cout << "total size of group: " << totalWidth << "," << totalHeight << endl; @@ -155,7 +156,7 @@ void GroupItem::updateMinimumSize() { } void GroupItem::updateShape() { - updateGeometry(); + updateGeometry(InterfaceMove); } bool GroupItem::updateGeometry(ChangeType type) { @@ -163,20 +164,29 @@ bool GroupItem::updateGeometry(ChangeType type) { QPointF oldOrigin = originPoint; QSize oldSize(totalWidth,totalHeight); - updateMinimumSize(); bool boxSizeChanged = false; + + // whatever the change, the minimum size may have changed + updateMinimumSize(); + + if (type == Resize) { + boxSizeChanged = true; + } + // if an internal block has moved, the actual box size may be inadequate if (boxWidth < minimumBoxWidth) { boxWidth = minimumBoxWidth; boxSizeChanged = true; } if (boxHeight < minimumBoxHeight) { boxHeight = minimumBoxHeight; - boxSizeChanged = true; + boxSizeChanged = true; } + if (boxSizeChanged) { updateInterfacesAndConnections(); } + // compute the max. width of interfaces' name for 4 orientations. int maxSouth = 0; int maxNorth = 0; @@ -221,7 +231,7 @@ bool GroupItem::updateGeometry(ChangeType type) { originPoint.setY(y); if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) { - //cout << "must change group item shape" << endl; + cout << "must change group item shape" << endl; prepareGeometryChange(); return true; } @@ -283,7 +293,7 @@ void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { cout << "abnormal case while resizing block" << endl; break; } - updateGeometry(); + updateGeometry(Resize); /* // recompute the geometry of the block updateGeometry(); @@ -302,16 +312,16 @@ void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { } else if(params->editState == Parameters::EditInterfaceMove) { prepareGeometryChange(); - deplaceInterface(event->pos()); + moveInterfaceTo(event->pos()); // recompute the geometry of the block - updateGeometry(); + updateGeometry(InterfaceMove); // update connection from/to the selected interface foreach(ConnectionItem *item, getScene()->getConnectionItems()){ if ((item->getFromInterfaceItem() == currentInterface) || (item->getToInterfaceItem() == currentInterface)) { - item->setPathes(); + item->setPath(); } } - update(); + //update(); } } diff --git a/GroupScene.cpp b/GroupScene.cpp index 7ba8c9d..daf6bf1 100644 --- a/GroupScene.cpp +++ b/GroupScene.cpp @@ -84,11 +84,12 @@ QList GroupScene::getGroupAndBlocks() { return lst; } -void GroupScene::createBlockItem(AbstractBlock *block) { +BoxItem *GroupScene::createBlockItem(AbstractBlock *block) { BoxItem* blockItem = new BoxItem(block,dispatcher,params,groupItem); blockItem->setZValue(1); addBlockItem(blockItem); + return blockItem; } void GroupScene::addBlockItem(BoxItem* item) { @@ -179,7 +180,7 @@ void GroupScene::unselecteInterfaces() { void GroupScene::updateConnectionItemsShape() { foreach(ConnectionItem* conn, connectionItems){ - conn->setPathes(); + conn->setPath(); } } diff --git a/GroupScene.h b/GroupScene.h index 8561482..3078305 100644 --- a/GroupScene.h +++ b/GroupScene.h @@ -68,7 +68,7 @@ public: // others - void createBlockItem(AbstractBlock* block); + BoxItem* createBlockItem(AbstractBlock* block); void addBlockItem(BoxItem* item); void removeBlockItem(BoxItem* item); void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2); diff --git a/GroupWidget.cpp b/GroupWidget.cpp index 1446a13..043561e 100644 --- a/GroupWidget.cpp +++ b/GroupWidget.cpp @@ -223,11 +223,14 @@ void GroupWidget::updateBlockButton() { void GroupWidget::slotNewEmptyGroup() { // creating the GroupBlock in graph model - GroupBlock* groupBlock = params->addGroupBlock(); - // creating the BlockItem in the inner scene - BoxItem* block = new BoxItem(groupBlock, dispatcher, params, scene->getGroupItem()); - - GroupWidget* child = dispatcher->createChildScene(this,block); + GroupBlock* parent = AB_TO_GRP(scene->getGroupItem()->getRefBlock()); + cout << "new group : parent = "<< qPrintable(parent->getName()) << endl; + GroupBlock* groupBlock = params->getGraph()->createChildBlock(parent); + cout << "new group : child = "<< qPrintable(groupBlock->getName()) << ", child of " << qPrintable(groupBlock->getParent()->getName()) << endl; + // creating the BlockItem in the scene + BoxItem* newItem = scene->createBlockItem(groupBlock); + + GroupWidget* child = dispatcher->createChildScene(this,newItem); child->show(); } diff --git a/MainWindow.cpp b/MainWindow.cpp index 01c23c1..1f8c1c0 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -60,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { // creating block library library = new BlockLibraryWidget(dispatcher,params); - isCurrentProject = false; + params->isCurrentProject = false; QLabel* labDefault = new QLabel("BLAST: BLock ASsembler Tool"); stackedWidget = new QStackedWidget; @@ -270,6 +270,7 @@ void MainWindow::slotLoadProject(){ GroupWidget* topGroup = dispatcher->loadProject(absoluteFilename); if (topGroup != NULL) { addTopGroup(topGroup); + library->updateComboScene(); } else { QMessageBox msgBox; @@ -289,7 +290,7 @@ void MainWindow::slotNewProject(){ enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ); GroupWidget* topGroup = dispatcher->createTopScene(); addTopGroup(topGroup); - + library->updateComboScene(); } void MainWindow::slotCloseProject(){ @@ -302,7 +303,7 @@ void MainWindow::slotCloseProject(){ dispatcher->closeCurrentProject(); - isCurrentProject = false; + params->isCurrentProject = false; params->unsaveModif = false; absoluteFilename = QString(); @@ -323,7 +324,7 @@ void MainWindow::slotSaveProject(){ } void MainWindow::slotSaveAsProject(){ - if(isCurrentProject){ + if(params->isCurrentProject){ QFileDialog dial(0, "Select a file", "save/"); dial.setDefaultSuffix(".xml"); dial.setAcceptMode(QFileDialog::AcceptSave); @@ -357,7 +358,7 @@ void MainWindow::removeTopGroup() { } void MainWindow::closeEvent(QCloseEvent *event){ - if(isCurrentProject){ + if(params->isCurrentProject){ QMessageBox msgBox; msgBox.setText("The project has been modified."); msgBox.setInformativeText("Do you want to save your changes?"); diff --git a/MainWindow.h b/MainWindow.h index ee51e4c..28feaff 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -72,7 +72,6 @@ private: Parameters *params; BlockLibraryWidget *library; - bool isCurrentProject; QString absoluteFilename; QString checkNewVersion; diff --git a/Makefile.in b/Makefile.in index e18672c..0801e93 100644 --- a/Makefile.in +++ b/Makefile.in @@ -176,10 +176,10 @@ $(BUILDPATH)/%.o : %.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< moc_%.cpp : %.h - moc -qt=$(QTVER) $(DEFINES) $(INCPATH) $< -o $@ + /usr/bin/moc -qt=$(QTVER) $(DEFINES) $(INCPATH) -o $@ $< rcc_%.cpp : %.qrc - rcc -qt=$(QTVER) $< -o $@ -name $* + /usr/bin/rcc -qt=$(QTVER) $< -o $@ -name $* ### DEPENDENCIES OF EACH SOURCE FILE (auto-added by configure) ### diff --git a/Parameters.h b/Parameters.h index 8393a79..69887a9 100644 --- a/Parameters.h +++ b/Parameters.h @@ -104,6 +104,7 @@ public : /*************************************************** attributes that are specific for the current project ****************************************************/ + bool isCurrentProject; // true if a projet is currently open int sceneMode; // takes values from MODE_XXX CursorState cursorState; EditState editState; // takes values from EDIT_STATE_XXX diff --git a/blast.creator.user b/blast.creator.user index 9b8a007..868e2d3 100755 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -65,7 +65,7 @@ 0 0 - /home/sdomas/Projet/Blast/code/v0.2 + /home/sdomas/Projet/Blast/code/blast diff --git a/object-files.txt b/object-files.txt index 841a369..806c346 100644 --- a/object-files.txt +++ b/object-files.txt @@ -30,7 +30,6 @@ COMMON-OBJ = $(BUILDPATH)/AbstractBlock.o \ $(BUILDPATH)/MainWindow.o \ $(BUILDPATH)/moc_MainWindow.o \ $(BUILDPATH)/ArithmeticEvaluator.o \ - $(BUILDPATH)/moc_ArithmeticEvaluator.o \ $(BUILDPATH)/BlockWidget.o \ $(BUILDPATH)/moc_BlockWidget.o \ $(BUILDPATH)/GroupWidget.o \