Salome HOME
Update documentation
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index 60ab634a785d3722796b414c8cbc176039bd2249..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"
 #include <ModuleBase_IPropertyPanel.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_FilterFactory.h>
-#include <ModuleBase_FilterLinearEdge.h>
-#include <ModuleBase_FilterFace.h>
-#include <ModuleBase_FilterMulti.h>
-#include <ModuleBase_FilterCustom.h>
-#include <ModuleBase_FilterNoConsructionSubShapes.h>
 #include <GeomValidators_Edge.h>
 #include <GeomValidators_EdgeOrVertex.h>
 #include <GeomValidators_Face.h>
 #include <GeomValidators_ConstructionComposite.h>
 
-#include <PartSet_FilterSketchEntity.h>
 
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
@@ -163,15 +158,6 @@ void PartSet_Module::registerFilters()
   //Registering of selection filters
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
   ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
-
-  //aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
-  //aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
-  //aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
-  //Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
-  //aFactory->registerFilter("NoConstructionSubShapesFilter",
-  //          new ModuleBase_FilterCustom(aSelectFilter));
-  //Handle(SelectMgr_Filter) aSelectFilter = new PartSet_FilterSketchEntity(workshop());
-  //aFactory->registerFilter("SketchEntityFilter", new ModuleBase_FilterCustom(aSelectFilter));
 }
 
 void PartSet_Module::registerProperties()
@@ -471,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;
@@ -500,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();
@@ -514,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();