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 <GeomAPI_AISObject.h>
16 #include <ModelAPI_Object.h>
18 #include <SelectMgr_ListOfFilter.hxx>
23 class ModuleBase_IWorkshop;
24 class ModuleBase_ISelection;
25 class ModuleBase_WidgetSelectorStore;
26 class ModelAPI_Validator;
27 class Config_WidgetAPI;
28 class Handle_SelectMgr_EntityOwner;
32 * Implementation of widget with validators and filters processing.
34 class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidget
39 /// \param theParent the parent object
40 /// \param theWorkshop a reference to workshop
41 /// \param theData the widget configuation. The attribute of the model widget is obtained from
42 ModuleBase_WidgetValidated(QWidget* theParent,
43 ModuleBase_IWorkshop* theWorkshop,
44 const Config_WidgetAPI* theData);
45 virtual ~ModuleBase_WidgetValidated();
47 /// Checks all widget validator if the owner is valid
48 /// \param theValue a selected presentation in the view
49 /// \return a boolean value
50 bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
52 //! Returns data object by AIS
53 ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
55 //! Clear all validated cash in the widget
56 void clearValidatedCash();
59 /// Checks whether all active viewer filters validate the presentation
60 /// \param thePrs a selected presentation in the view
61 /// \return a boolean value
62 bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
64 /// Creates a backup of the current values of the attribute
65 /// It should be realized in the specific widget because of different
66 /// parameters of the current attribute
67 virtual void storeAttributeValue();
69 /// Creates a backup of the current values of the attribute
70 /// It should be realized in the specific widget because of different
71 /// parameters of the current attribute
72 /// \param theValid a boolean flag, if restore happens for valid parameters
73 virtual void restoreAttributeValue(const bool theValid);
75 /// Checks the widget validity. By default, it returns true.
76 /// \param thePrs a selected presentation in the view
77 /// \return a boolean value
78 virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
80 /// Fills the attribute with the value of the selected owner
81 /// \param thePrs a selected owner
82 virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
84 /// Returns a list of selected presentations in the viewer and object browser
85 /// The presentations from the object browser are filtered by the AIS context filters
86 /// \return a list of presentations
87 QList<ModuleBase_ViewerPrs> getFilteredSelected();
89 /// It obtains selection filters from the workshop and activates them in the active viewer
90 /// \param toActivate a flag about activation or deactivation the filters
91 /// \return true if the selection filter of the widget is activated in viewer context
92 bool activateFilters(const bool toActivate);
94 /// Block the model flush of update and intialization of attribute
95 /// \param theToBlock flag whether the model is blocked or unblocked
96 /// \param isActive out value if model is blocked, in value if model is unblocked
97 /// to be used to restore flush state when unblocked
98 /// \param isAttributeSetInitializedBlocked out value if model is blocked
99 /// in value if model is unblocked to be used to restore previous state when unblocked
100 virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived,
101 bool& isAttributeSetInitializedBlocked);
104 /// Checks the current attibute in all attribute validators
105 // \return true if all validators return that the attribute is valid
106 bool isValidAttribute() const;
108 /// Returns true if the workshop validator filter has been already activated
109 /// \return boolean value
110 bool isFilterActivated() const;
112 /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored
113 /// \param theValue a viewer presentation
114 /// \param theValid a valid state
115 bool getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid);
117 /// Store the validity state of the presentation in an internal map
118 /// \param theValue a viewer presentation
119 /// \param theValid a valid state
120 void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid);
122 /// Applies AIS context filters to the parameter list. The not approved presentations are
123 /// removed from the parameters.
124 /// \param theValues a list of presentations.
125 void filterPresentations(QList<ModuleBase_ViewerPrs>& theValues);
127 /// Remove subshapes of compsolids if whole compsolid is present.
128 /// \param theValues a list of presentations.
129 void filterCompSolids(QList<ModuleBase_ViewerPrs>& theValues);
132 /// Reference to workshop
133 ModuleBase_IWorkshop* myWorkshop;
134 /// The widget is in validation mode: store is performed, restore is not
138 ObjectPtr myPresentedObject; /// back up of the filtered object
139 QList<ModuleBase_ViewerPrs> myValidPrs; /// cash of valid selection presentations
140 QList<ModuleBase_ViewerPrs> myInvalidPrs; /// cash of invalid selection presentations
142 /// store to backup parameters of the model
143 ModuleBase_WidgetSelectorStore* myAttributeStore;
146 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */