]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Delete feature command in pop-up
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 22 May 2014 05:44:15 +0000 (09:44 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 22 May 2014 05:44:15 +0000 (09:44 +0400)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/delete.png [new file with mode: 0644]

index 60d6e9f8392ecb04d1ddb1c74adce731dfd13c0c..461b2dab58195409ae5e75c4bcf1372925cfa58e 100644 (file)
@@ -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)
index 9cef8d9b65604fb68665360173b89538c28e5834..8504e153177b2c6a40890ef8c50fe3344712619f 100644 (file)
@@ -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<const Model_FeatureUpdatedMessage*>(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
index 04920e9ea7e342745647b9a5844f5b580319d596..21ee4a87b6cd86f755b56630bcc2a7c42b231648 100644 (file)
@@ -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:
index 30d9ba286de752a09b080113369f1d8334bb21a8..ab0bcf2afc799bd6ec8b84b5c4e0857df0504547 100644 (file)
@@ -54,5 +54,6 @@
      <file>pictures/edit.png</file>
      <file>pictures/assembly.png</file>
      <file>pictures/activate.png</file>
+     <file>pictures/delete.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/delete.png b/src/XGUI/pictures/delete.png
new file mode 100644 (file)
index 0000000..6c64527
Binary files /dev/null and b/src/XGUI/pictures/delete.png differ