Salome HOME
Update documentation
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index a38f41b65a24baa598eafd38c2526b9f120fbaae..09b8ef5d58c71373cb2e8b60fdbcd7e0b8e8c851 100644 (file)
@@ -7,6 +7,7 @@
 #include <PartSet_WidgetPoint2d.h>
 #include <PartSet_WidgetPoint2dDistance.h>
 #include <PartSet_WidgetShapeSelector.h>
+#include <PartSet_WidgetMultiSelector.h>
 #include <PartSet_WidgetEditor.h>
 #include "PartSet_SketcherMgr.h"
 #include "PartSet_MenuMgr.h"
@@ -456,7 +457,13 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aShapeSelectorWgt;
-  } if (theType == WDG_DOUBLEVALUE_EDITOR) {
+  } if (theType == "sketch_multi_selector") {
+    PartSet_WidgetMultiSelector* aShapeSelectorWgt =
+      new PartSet_WidgetMultiSelector(theParent, workshop(), theWidgetApi, theParentId);
+    aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+    aWgt = aShapeSelectorWgt;
+  }
+  if (theType == WDG_DOUBLEVALUE_EDITOR) {
     aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
   } 
   return aWgt;
@@ -485,6 +492,20 @@ bool PartSet_Module::deleteObjects()
   if (aSelectedObj.count() == 0)
     return false;
 
+  // avoid delete of the objects, which are not belong to the current sketch
+  // in order to do not delete results of other sketches
+  QObjectPtrList aSketchObjects;
+  QObjectPtrList::const_iterator anIt = aSelectedObj.begin(), aLast = aSelectedObj.end();
+  for ( ; anIt != aLast; anIt++) {
+    ObjectPtr anObject = *anIt;
+    if (mySketchMgr->isObjectOfSketch(anObject))
+      aSketchObjects.append(anObject);
+  }
+  // if the selection contains only local selected presentations from other sketches,
+  // the Delete operation should not be done at all
+  if (aSketchObjects.size() == 0)
+    return true;
+
   // the active nested sketch operation should be aborted unconditionally
   if (isNestedOp)
     anOperation->abort();
@@ -499,7 +520,7 @@ bool PartSet_Module::deleteObjects()
   // when sketch operation is active
   std::set<FeaturePtr> anIgnoredFeatures;
   anIgnoredFeatures.insert(mySketchMgr->activeSketch());
-  aWorkshop->deleteFeatures(aSelectedObj, anIgnoredFeatures);
+  aWorkshop->deleteFeatures(aSketchObjects, anIgnoredFeatures);
   
   // 5. stop operation
   aWorkshop->displayer()->updateViewer();