1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetValidator.h
4 // Created: 12 Mar 2015
5 // Author: Natalia ERMOLAEVA
8 #ifndef ModuleBase_WidgetValidator_H_
9 #define ModuleBase_WidgetValidator_H_
11 #include <ModuleBase.h>
16 class ModuleBase_ModelWidget;
17 class ModuleBase_IWorkshop;
18 class ModuleBase_ViewerPrs;
22 * Implementation of widget with validators and filters processing.
24 class MODULEBASE_EXPORT ModuleBase_WidgetValidator
28 /// \param theModelWidget the model widget to be validated
29 /// \param theWorkshop the current workshop
30 ModuleBase_WidgetValidator(ModuleBase_ModelWidget* theModelWidget,
31 ModuleBase_IWorkshop* theWorkshop);
32 virtual ~ModuleBase_WidgetValidator();
34 /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
35 /// next, the attribute's validating. It trying on the give selection to current attribute by
36 /// setting the value inside and calling validators. After this, the previous attribute value is
37 /// restored.The valid/invalid value is cashed.
38 /// \param theValue a selected presentation in the view
39 /// \return a boolean value
40 virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
42 /// It obtains selection filters from the workshop and activates them in the active viewer
43 /// \param toActivate a flag about activation or deactivation the filters
44 /// \return true if the selection filter of the widget is activated in viewer context
45 bool activateFilters(const bool toActivate);
48 /// Returns true if the workshop validator filter has been already activated
49 /// \return boolean value
50 bool isFilterActivated() const;
52 //! Clear all validated cash in the widget
53 void clearValidatedCash();
55 /// Gets the validity state of the presentation in an internal map.
56 /// Returns true if the valid state of value is stored
57 /// \param theValue a viewer presentation
58 /// \param theValid a valid state
59 bool getValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, bool& theValid);
61 /// Store the validity state of the presentation in an internal map
62 /// \param theValue a viewer presentation
63 /// \param theValid a valid state
64 void storeValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, const bool theValid);
67 /// Reference to workshop
68 ModuleBase_ModelWidget* myModelWidget; ///< the current widget to be validated
69 ModuleBase_IWorkshop* myWorkshop; ///< the active workshop
71 /// cash of valid selection presentations
72 QList<std::shared_ptr<ModuleBase_ViewerPrs>> myValidPrs;
74 /// cash of invalid selection presentations
75 QList<std::shared_ptr<ModuleBase_ViewerPrs>> myInvalidPrs;
78 #endif /* ModuleBase_WidgetValidator_H_ */