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 38dc9a3f506b5acd1b9fe6828e8d964430861adb..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
 
@@ -19,19 +19,24 @@ 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();
-  if (!anOperation)
-    return true;
-
-  ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
-  ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
-  if (!anActiveWidget)
-    anActiveWidget = aPanel->preselectionWidget();
-  ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
-                                                                         (anActiveWidget);
-  ModuleBase_ViewerPrs aPrs;
-  myWorkshop->selection()->fillPresentation(aPrs, theOwner);
-
-  return !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
+  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);
+
+    aValid = !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
+  }
+
+#ifdef DEBUG_FILTERS
+  qDebug(QString("ModuleBase_FilterValidated::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }