1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetValidated.h
4 // Created: 12 Mar 2015
5 // Author: Natalia ERMOLAEVA
8 #ifndef MODULEBASE_WIDGETVALIDATED_H_
9 #define MODULEBASE_WIDGETVALIDATED_H_
11 #include <ModuleBase.h>
12 #include <ModuleBase_ModelWidget.h>
14 #include <GeomAPI_Shape.h>
15 #include <ModelAPI_Object.h>
17 #include <SelectMgr_ListOfFilter.hxx>
22 class ModuleBase_IWorkshop;
23 class ModuleBase_ISelection;
24 class ModelAPI_Validator;
25 class Config_WidgetAPI;
26 class Handle_SelectMgr_EntityOwner;
30 * Implementation of widget with validators and filters processing.
32 class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidget
37 /// \param theParent the parent object
38 /// \param theData the widget configuation. The attribute of the model widget is obtained from
39 /// \param theParentId is Id of a parent of the current attribute
40 ModuleBase_WidgetValidated(QWidget* theParent,
41 ModuleBase_IWorkshop* theWorkshop,
42 const Config_WidgetAPI* theData,
43 const std::string& theParentId);
44 virtual ~ModuleBase_WidgetValidated();
46 /// Checks whether all active viewer filters validate the presentation
47 /// \param theWorkshop an active workshop
48 /// \param theValue a selected presentation in the view
49 /// \return a boolean value
50 bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
52 /// Checks all widget validator if the owner is valid
53 /// \param theValue a selected presentation in the view
54 /// \return a boolean value
55 bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
57 /// Set the given wrapped value to the current widget
58 /// This value should be processed in the widget according to the needs
59 /// The method is called by the current operation to process the operation preselection.
60 /// It is redefined to check the value validity and if it is, fill the attribute with by value
61 /// \param theValues the wrapped selection values
62 virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
63 const bool theToValidate);
65 /// Creates a backup of the current values of the attribute
66 /// It should be realized in the specific widget because of different
67 /// parameters of the current attribute
68 virtual void storeAttributeValue() = 0;
70 /// Creates a backup of the current values of the attribute
71 /// It should be realized in the specific widget because of different
72 /// parameters of the current attribute
73 /// \param theValid a boolean flag, if restore happens for valid parameters
74 virtual void restoreAttributeValue(const bool theValid) = 0;
76 /// Checks the widget validity. By default, it returns true.
77 /// \param theValue a selected presentation in the view
78 /// \return a boolean value
79 virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
81 /// Fills the attribute with the value of the selected owner
82 /// \param theOwner a selected owner
83 virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
85 /// Checks the current attibute in all attribute validators
86 // \return true if all validators return that the attribute is valid
87 bool isValidAttribute() const;
89 /// It obtains selection filters from the workshop and activates them in the active viewer
90 /// \param theWorkshop an active workshop
91 /// \param toActivate a flag about activation or deactivation the filters
92 virtual void activateFilters(const bool toActivate);
94 /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored
95 /// \param theValue a viewer presentation
96 /// \param theValid a valid state
97 bool getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid);
99 /// Store the validity state of the presentation in an internal map
100 /// \param theValue a viewer presentation
101 /// \param theValid a valid state
102 void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid);
104 // Removes all presentations from internal maps.
105 void clearValidState();
108 ModuleBase_IWorkshop* myWorkshop; /// Reference to workshop
111 QList<ModuleBase_ViewerPrs> myValidPrs;
112 QList<ModuleBase_ViewerPrs> myInvalidPrs;
113 bool isValidateBlocked;
116 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */