Salome HOME
Update behavior of calculation of Multi-Rotation constraint
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSelector.cpp
index dcfb86bec31f814fce42413e07561fbfa6a4fd5b..e2233ab7c96229ed3866d3d88f9117bd93a94184 100755 (executable)
@@ -1,6 +1,6 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
-// File:        ModuleBase_WidgetSelector.h
+// File:        ModuleBase_WidgetSelector.cpp
 // Created:     19 June 2015
 // Author:      Natalia ERMOLAEVA
 
 
 #include <ModelAPI_ResultConstruction.h>
 
+#include <TopoDS_Iterator.hxx>
+
 ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
                                                      ModuleBase_IWorkshop* theWorkshop,
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId)
- : ModuleBase_WidgetValidated(theParent, theData, theParentId),
-   myWorkshop(theWorkshop)
+ : ModuleBase_WidgetValidated(theParent, theWorkshop, theData, theParentId)
 {
 }
 
@@ -46,10 +47,9 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 {
   clearAttribute();
 
-  QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected(
-                                                              ModuleBase_ISelection::AllControls);
-  bool isDone = setSelection(aSelected);
+  QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
 
+  bool isDone = setSelection(aSelected, false);
   emit valuesChanged();
   // the updateObject method should be called to flush the updated sigal. The workshop listens it,
   // calls validators for the feature and, as a result, updates the Apply button state.
@@ -59,8 +59,6 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
     updateFocus();
 }
 
-#include <TopoDS_Iterator.hxx>
-
 //********************************************************************
 bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
                                                const ResultPtr& theResult) const
@@ -138,13 +136,10 @@ void ModuleBase_WidgetSelector::activateCustom()
   // Restore selection in the viewer by the attribute selection list
   myWorkshop->setSelected(getAttributeSelection());
 
-  activateFilters(myWorkshop, true);
+  activateFilters(true);
 }
 
 //********************************************************************
-#include <ModuleBase_IViewer.h>
-#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
-#include <StdSelect_BRepOwner.hxx>
 bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
 {
   GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
@@ -157,30 +152,6 @@ bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPr
     FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aResult);
     aValid = aSelectedFeature != myFeature;
   }
-  
-  // selection happens in the Object browser.
-  // it creates a selection owner and check whether the viewer filters process it
-  if (thePrs.owner().IsNull() && thePrs.object().get()) {
-    ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-    if (aResult.get())
-      aShape = aResult->shape();
-
-    const TopoDS_Shape aTDShape = aShape->impl<TopoDS_Shape>();
-
-    Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
-    Handle(StdSelect_BRepOwner) aShapeOwner = new StdSelect_BRepOwner(aTDShape, anIO);
-
-    const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters();
-    SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
-    for (; anIt.More() && aValid; anIt.Next()) {
-      Handle(SelectMgr_Filter) aFilter = anIt.Value();
-      if (aFilter == myWorkshop->validatorFilter())
-        continue;
-
-      aValid = aFilter->IsOk(aShapeOwner);
-    }
-    aShapeOwner.Nullify();
-  }
   return aValid;
 }
 
@@ -200,5 +171,6 @@ void ModuleBase_WidgetSelector::deactivate()
 {
   disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
   activateSelection(false);
-  activateFilters(myWorkshop, false);
+  activateFilters(false);
 }
+