From: vsv Date: Thu, 22 May 2014 05:44:15 +0000 (+0400) Subject: Delete feature command in pop-up X-Git-Tag: V_0.2~29^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=008184e7d2593cbfd407f53194a21c2abb023bf3;p=modules%2Fshaper.git Delete feature command in pop-up --- diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 60d6e9f83..461b2dab5 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -31,6 +31,9 @@ void XGUI_ContextMenuMgr::createActions() aAction = new QAction(QIcon(":pictures/assembly.png"), tr("Deactivate"), this); addAction("DEACTIVATE_PART_CMD", aAction); + + aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this); + addAction("DELETE_CMD", aAction); } void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction) @@ -95,6 +98,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const } else { aActions.append(action("EDIT_CMD")); } + aActions.append(action("DELETE_CMD")); // Process Root object (document) } else { // If feature is 0 the it means that selected root object (document) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9cef8d9b6..8504e1531 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -119,6 +119,7 @@ void XGUI_Workshop::startApplication() Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED); aLoop->registerListener(this, aFeatureUpdatedId); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); activateModule(); if (myMainWindow) { @@ -211,12 +212,19 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); FeaturePtr aFeature = aUpdMsg->feature(); if (aFeature->getKind() == "Part") { - //The created part will be created in Object Browser later and we have to activate that - // only when it created everywere + //The created part will be created in Object Browser later and we have to activate it + // only when it is created everywere QTimer::singleShot(50, this, SLOT(activateLastPart())); } } + // Process deletion of a part + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) { + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + if (aMgr->currentDocument() == aMgr->rootDocument()) + activatePart(FeaturePtr()); // Activate PartSet + } + //Update property panel on corresponding message. If there is no current operation (no //property panel), or received message has different feature to the current - do nothing. static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED); @@ -727,7 +735,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) activatePart(aFeatures.first()); else if (theId == "DEACTIVATE_PART_CMD") activatePart(FeaturePtr()); - + else if (theId == "DELETE_CMD") + deleteFeatures(aFeatures); } //************************************************************** @@ -745,3 +754,18 @@ void XGUI_Workshop::activateLastPart() FeaturePtr aLastPart = aDoc->feature(PARTS_GROUP, aDoc->size(PARTS_GROUP) - 1, true); activatePart(aLastPart); } + +//************************************************************** +void XGUI_Workshop::deleteFeatures(QFeatureList theList) +{ + QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() : myMainWindow; + QMessageBox::StandardButton aRes = QMessageBox::warning(aDesktop, tr("Delete features"), + tr("Seleted features will be deleted. Continue?"), + QMessageBox::No | QMessageBox::Yes, QMessageBox::No); + if (aRes == QMessageBox::Yes) { + foreach (FeaturePtr aFeature, theList) { + DocumentPtr aDoc = aFeature->data()->docRef("PartDocument")->value(); + aDoc->removeFeature(aFeature); + } + } +} \ No newline at end of file diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 04920e9ea..21ee4a87b 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -98,9 +98,15 @@ public: //! Returns icon name according to feature Id static QString featureIcon(const std::string& theId); + //! Activates or deactivates a part + //! If PartPtr is Null pointer then PartSet will be activated + void activatePart(FeaturePtr theFeature); + + void deleteFeatures(QFeatureList theList); signals: void salomeViewerSelection(); + void errorOccurred(const QString&); public slots: void updateCommandStatus(); @@ -121,14 +127,6 @@ public slots: void onFeatureTriggered(); void changeCurrentDocument(FeaturePtr thePart); -signals: - void errorOccurred(const QString&); - -public slots: - //! Activates or deactivates a part - //! If PartPtr is Null pointer then PartSet will be activated - void activatePart(FeaturePtr theFeature); - void activateLastPart(); protected: diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 30d9ba286..ab0bcf2af 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -54,5 +54,6 @@ pictures/edit.png pictures/assembly.png pictures/activate.png + pictures/delete.png diff --git a/src/XGUI/pictures/delete.png b/src/XGUI/pictures/delete.png new file mode 100644 index 000000000..6c6452718 Binary files /dev/null and b/src/XGUI/pictures/delete.png differ