Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / PartSet / PartSet_WidgetShapeSelector.cpp
index ead2a719aab71e133fe8ea75ac919d9eeca000c6..fb8a9df78fc57d065b234694a568541f4fa2a364 100755 (executable)
@@ -19,6 +19,8 @@
 //
 
 #include "PartSet_WidgetShapeSelector.h"
+
+#include "PartSet_CenterPrs.h"
 #include "PartSet_Module.h"
 #include "PartSet_SketcherMgr.h"
 
@@ -58,23 +60,27 @@ PartSet_WidgetShapeSelector::~PartSet_WidgetShapeSelector()
 }
 
 //********************************************************************
-bool PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate)
+void PartSet_WidgetShapeSelector::selectionFilters(QIntList& theModuleSelectionFilters,
+                                                   SelectMgr_ListOfFilter& theSelectionFilters)
 {
-  bool aHasSelectionFilter = ModuleBase_WidgetShapeSelector::activateSelectionAndFilters
-                                                                           (toActivate);
+  ModuleBase_WidgetShapeSelector::selectionFilters(theModuleSelectionFilters, theSelectionFilters);
+
   if (!myUseSketchPlane) {
-    XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(aWorkshop->module());
-    bool isUsePlaneFilterOnly = !toActivate;
-    aModule->sketchMgr()->activatePlaneFilter(isUsePlaneFilterOnly);
+    if (theModuleSelectionFilters.contains(SF_SketchPlaneFilter))
+      theModuleSelectionFilters.removeAll(SF_SketchPlaneFilter);
   }
-  return aHasSelectionFilter;
 }
 
 //********************************************************************
 bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
 {
-  bool aValid = ModuleBase_WidgetShapeSelector::isValidSelectionCustom(thePrs);
+  bool aValid = false;
+  if (thePrs.get() && thePrs->interactive().get() &&
+      thePrs->interactive()->IsKind(STANDARD_TYPE(PartSet_CenterPrs)))
+    aValid = true; // we should not check acceptSubShape for such presentation
+  else
+    aValid = ModuleBase_WidgetShapeSelector::isValidSelectionCustom(thePrs);
+
   if (aValid) {
     ObjectPtr anObject = myWorkshop->selection()->getResult(thePrs);
     aValid = myExternalObjectMgr->isValidObject(anObject);