Salome HOME
Issue #653 - Double and triple click edges -- Fix Debian dynamic_pointer_cast problem...
[modules/shaper.git] / src / ModuleBase / ModuleBase_FilterValidated.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_FilterValidated.cpp
4 // Created:     17 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #include "ModuleBase_FilterValidated.h"
8 #include "ModuleBase_IWorkshop.h"
9
10 #include <ModuleBase_IModule.h>
11 #include <ModuleBase_IPropertyPanel.h>
12 #include <ModuleBase_ISelection.h>
13 #include <ModuleBase_Operation.h>
14 #include <ModuleBase_WidgetValidated.h>
15 #include <ModuleBase_ViewerPrs.h>
16
17 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter);
18 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
19
20 Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
21 {
22   bool aValid = true;
23   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
24   if (anOperation) {
25     ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
26     ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
27     if (!anActiveWidget)
28       anActiveWidget = aPanel->preselectionWidget();
29     ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
30                                                                            (anActiveWidget);
31     ModuleBase_ViewerPrs aPrs;
32     myWorkshop->selection()->fillPresentation(aPrs, theOwner);
33
34     aValid = !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
35   }
36
37 #ifdef DEBUG_FILTERS
38   qDebug(QString("ModuleBase_FilterValidated::IsOk = %1").arg(aValid).toStdString().c_str());
39 #endif
40   return aValid;
41 }
42