]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetValidator.h
Salome HOME
942e9bc931153aa0744e1b8f0b4b4e29c03e9ea1
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidator.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetValidator.h
4 // Created:     12 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7
8 #ifndef ModuleBase_WidgetValidator_H_
9 #define ModuleBase_WidgetValidator_H_
10
11 #include <ModuleBase.h>
12
13 #include <memory>
14
15 class ModuleBase_ModelWidget;
16 class ModuleBase_IWorkshop;
17 class ModuleBase_ViewerPrs;
18
19 /**
20 * \ingroup GUI
21 * Implementation of widget with validators and filters processing.
22 */
23 class MODULEBASE_EXPORT ModuleBase_WidgetValidator
24 {
25  public:
26   /// Constructor
27   /// \param theModelWidget the model widget to be validated
28   /// \param theWorkshop the current workshop
29   ModuleBase_WidgetValidator(ModuleBase_ModelWidget* theModelWidget,
30                              ModuleBase_IWorkshop* theWorkshop);
31   virtual ~ModuleBase_WidgetValidator();
32
33   /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
34   /// next, the attribute's validating. It trying on the give selection to current attribute by
35   /// setting the value inside and calling validators. After this, the previous attribute value is
36   /// restored.The valid/invalid value is cashed.
37   /// \param theValue a selected presentation in the view
38   /// \return a boolean value
39   virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
40
41   /// It obtains selection filters from the workshop and activates them in the active viewer
42   /// \param toActivate a flag about activation or deactivation the filters
43   /// \return true if the selection filter of the widget is activated in viewer context
44   bool activateFilters(const bool toActivate);
45
46 private:
47   /// Returns true if the workshop validator filter has been already activated
48   /// \return boolean value
49   bool isFilterActivated() const;
50
51 protected:
52   /// Reference to workshop
53   ModuleBase_ModelWidget* myModelWidget; ///< the current widget to be validated
54   ModuleBase_IWorkshop* myWorkshop; ///< the active workshop
55 };
56
57 #endif /* ModuleBase_WidgetValidator_H_ */