Salome HOME
Issue #1278 In the sketch the creation line is not functional when I check the box...
[modules/shaper.git] / src / ModuleBase / ModuleBase_FilterValidated.cpp
index a6336d3533360bdf3c7c3f7e345ca44a297a4dfe..08314d734cc3cf2793e3e601ac6a9a53d891551d 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
-// File:        ModuleBase_FilterValidated.h
+// File:        ModuleBase_FilterValidated.cpp
 // Created:     17 Mar 2015
 // Author:      Natalia ERMOLAEVA
 
@@ -9,20 +9,34 @@
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ISelection.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_WidgetValidated.h>
+#include <ModuleBase_ViewerPrs.h>
 
 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
 
 Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
+  bool aValid = true;
   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
-  ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+  if (anOperation) {
+    ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+    ModuleBase_ModelWidget* aCurrentWidget = aPanel->preselectionWidget();
+    if (!aCurrentWidget)
+      aCurrentWidget = myWorkshop->module()->activeWidget();
+    ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
+                                                                           (aCurrentWidget);
+    ModuleBase_ViewerPrs aPrs;
+    myWorkshop->selection()->fillPresentation(aPrs, theOwner);
 
-  ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
-  ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
-                                                                          (anActiveWidget);
-  return !aWidgetValidated || aWidgetValidated->isValid(theOwner);
+    aValid = !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
+  }
+
+#ifdef DEBUG_FILTERS
+  qDebug(QString("ModuleBase_FilterValidated::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }