]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Fri, 16 May 2014 05:26:54 +0000 (09:26 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 16 May 2014 05:26:54 +0000 (09:26 +0400)
Displayer method to remove deleted features from the displayer map.
onUndo() - perform abortOperation if the document method isOperation() returns true.

src/PartSet/PartSet_Listener.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp

index 9615dac4cf175d81bc72b4c88c2c6e8c570f0be5..0deb7fb74359fd6823902a7b9e3571abcf687b9b 100644 (file)
@@ -50,6 +50,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
 
     std::string aGroup = aDelMsg->group();
     if (aDelMsg->group().compare("Sketch") == 0) { // Update only Sketch group
+      //myModule->workshop()->displayer()->EraseDeletedFeatures();
       myModule->updateCurrentPreview(aGroup);
     }
   }
index ee3f8c8612dd9fa32e01d082f6864b51be5c561c..734666d8973d51e2112f0e4317ba4e7cdfe6cea9 100644 (file)
@@ -17,7 +17,6 @@ const double PLANE_SIZE = 200;
 SketchPlugin_Line::SketchPlugin_Line()
   : SketchPlugin_Feature()
 {
-  setSketch(0);
 }
 
 void SketchPlugin_Line::initAttributes()
index 2613adae6bbc9ab20b77f31e8b3f5e49b7bb6e75..a01a311291b73009ab8556a5441caf7aa0e83f06 100644 (file)
@@ -161,6 +161,34 @@ void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
     ic->UpdateCurrentViewer();
 }
 
+void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer)
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+
+  FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
+                                  aFLast = myFeature2AISObjectMap.end();
+  std::list<boost::shared_ptr<ModelAPI_Feature>> aRemoved;
+  for (; aFIt != aFLast; aFIt++)
+  {
+    boost::shared_ptr<ModelAPI_Feature> aFeature = (*aFIt).first;
+    if (!aFeature) {
+      Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
+      if (!anAIS.IsNull()) {
+        aContext->Erase(anAIS, false);
+        aRemoved.push_back(aFeature);
+      }
+    }
+  }
+  std::list<boost::shared_ptr<ModelAPI_Feature>>::const_iterator anIt = aRemoved.begin(),
+                                                                 aLast = aRemoved.end();
+  for (; anIt != aLast; anIt++) {
+    myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt));
+  }
+
+  if (isUpdateViewer)
+    aContext->UpdateCurrentViewer();
+}
+
 void XGUI_Displayer::CloseLocalContexts(const bool isUpdateViewer)
 {
   closeAllContexts(true);
index a8bfbe2f35d0d2364befa48b2b01163bf6deb4ea..c03157885da2ed2e51c5720b07e774aef2371fc0 100644 (file)
@@ -85,6 +85,10 @@ public:
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void EraseAll(const bool isUpdateViewer = true);
 
+  /// Erase AIS interactive objects, which has an empty feature in the internal map
+  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+  void EraseDeletedFeatures(const bool isUpdateViewer = true);
+
   /// Deactivates selection of sub-shapes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void CloseLocalContexts(const bool isUpdateViewer = true);
index 20f4e47c7bc6e25184a512f58fdd12f54bfc6543..9b391a44e4a37ceff33e15b60cc10e4ebea39641 100644 (file)
@@ -473,9 +473,8 @@ void XGUI_Workshop::onUndo()
   objectBrowser()->setCurrentIndex(QModelIndex());
   boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
   boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
-  //if (!operationMgr()->abortOperation())
-  //  return;
-  operationMgr()->abortOperation();
+  if (aDoc->isOperation())
+    operationMgr()->abortOperation();
   aDoc->undo();
   updateCommandStatus();
 }