]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Adaptation to new data structure
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 15 Jul 2014 13:59:20 +0000 (17:59 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 15 Jul 2014 13:59:20 +0000 (17:59 +0400)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index d7dcfce78ad8b04ea0c56d449391c2cfeaf5e8d2..21fc9672b7617e33b05e9496e34f5f650de76c51 100644 (file)
@@ -123,9 +123,13 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
             aMenu->addAction(action("HIDE_CMD"));
           else
             aMenu->addAction(action("SHOW_CMD"));
+        } else {
+          FeaturePtr aResult = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+          if (aResult) {
+            aMenu->addAction(action("DELETE_CMD"));
+          }
         }
       }
-      aMenu->addAction(action("DELETE_CMD"));
       aMenu->addSeparator();
 
     // Process Root object (document)
index 436803e09bfdc9fa1809d87a9cd17d454ba8e6c8..a94804532d134af3ed4d9c6f55f618348a8c222f 100644 (file)
@@ -133,6 +133,7 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
   activateModule();
   if (myMainWindow) {
@@ -233,12 +234,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
     const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
     onFeatureCreatedMsg(aUpdMsg);
+    return;
   }
 
   // Redisplay feature
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
     const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
     onFeatureRedisplayMsg(aUpdMsg);
+    return;
   }
 
   //Update property panel on corresponding message. If there is no current operation (no
@@ -247,6 +250,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     const Model_ObjectUpdatedMessage* anUpdateMsg =
         dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
     onFeatureUpdatedMsg(anUpdateMsg);
+    return;
+  }
+
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
+    const Model_ObjectDeletedMessage* aDelMsg =
+        dynamic_cast<const Model_ObjectDeletedMessage*>(theMessage);
+    onObjectDeletedMsg(aDelMsg);
+    return;
   }
 
   //An operation passed by message. Start it, process and commit.
@@ -296,7 +307,8 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM
   std::set<ObjectPtr>::const_iterator aIt;
   bool isDisplayed = false;
   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
-    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(*aIt);
+    ObjectPtr aObj = (*aIt);
+    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
     if (aRes) {
       isDisplayed = myDisplayer->redisplay(aRes, false);
     }
@@ -332,6 +344,12 @@ void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg
     QTimer::singleShot(50, this, SLOT(activateLastPart()));
   }
 }
+
+//******************************************************
+void XGUI_Workshop::onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg)
+{
+  //std::set<ObjectPtr> aFeatures = theMsg->objects();
+}
  
 //******************************************************
 void XGUI_Workshop::onOperationStarted()
@@ -917,7 +935,7 @@ void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
                                                           tr("Seleted features will be deleted. Continue?"), 
                                                           QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
   // ToDo: definbe deleting method
-  /*  if (aRes == QMessageBox::Yes) {
+  if (aRes == QMessageBox::Yes) {
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     aMgr->rootDocument()->startOperation();
     foreach (ObjectPtr aObj, theList) {
@@ -927,14 +945,16 @@ void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
         if (aDoc == aMgr->currentDocument()) {
           aDoc->close();
         }
-        aMgr->rootDocument()->removeFeature(aPart->owner());
+        //aMgr->rootDocument()->removeFeature(aPart->owner());
       } else {
-        aObj->document()->removeFeature(aObj);
+        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+        if (aFeature)
+          aObj->document()->removeFeature(aFeature);
       }
     }
     myDisplayer->updateViewer();
     aMgr->rootDocument()->finishOperation();
-  }*/
+  }
 }
 
 //**************************************************************
index 1b85fbc0c417f318e6563492203f5742d7441808..681afb312cd09e406e457296cc012309e05e0ea3 100644 (file)
@@ -39,6 +39,7 @@ class QWidget;
 class QDockWidget;
 
 class Model_ObjectUpdatedMessage;
+class Model_ObjectDeletedMessage;
 class QAction;
 
 /**\class XGUI_Workshop
@@ -156,6 +157,7 @@ protected:
   void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg);
   void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg);
   void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg);
+  void onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg);
 
   QList<QAction*> getModuleCommands() const;