Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidated.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetValidated.h
4 // Created:     12 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7
8 #ifndef MODULEBASE_WIDGETVALIDATED_H_
9 #define MODULEBASE_WIDGETVALIDATED_H_
10
11 #include <ModuleBase.h>
12 #include <ModuleBase_ModelWidget.h>
13
14 #include <GeomAPI_Shape.h>
15 #include <ModelAPI_Object.h>
16
17 #include <SelectMgr_ListOfFilter.hxx>
18
19 class QWidget;
20 class ModuleBase_IWorkshop;
21 class Config_WidgetAPI;
22 class Handle_SelectMgr_EntityOwner;
23
24 /**
25 * \ingroup GUI
26 * Implementation of widget with validators and filters processing.
27 */
28 class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidget
29 {
30   Q_OBJECT
31  public:
32   /// Constructor
33   /// \param theParent the parent object
34   /// \param theData the widget configuation. The attribute of the model widget is obtained from
35   /// \param theParentId is Id of a parent of the current attribute
36   ModuleBase_WidgetValidated(QWidget* theParent,
37                              const Config_WidgetAPI* theData,
38                              const std::string& theParentId);
39   virtual ~ModuleBase_WidgetValidated();
40
41   /// Checks all widget validator if the owner is valid
42   /// \param theOwner a selected owner in the view
43   /// \return a boolean value
44   bool isValid(const Handle_SelectMgr_EntityOwner& theOwner);
45
46   /// Set the given wrapped value to the current widget
47   /// This value should be processed in the widget according to the needs
48   /// The method is called by the current operation to process the operation preselection.
49   /// It is redefined to check the value validity and if it is, fill the attribute with by value
50   /// \param theValue the wrapped widget value
51   virtual bool setSelection(ModuleBase_ViewerPrs theValue);
52
53 protected:
54   /// Creates a backup of the current values of the attribute
55   /// It should be realized in the specific widget because of different
56   /// parameters of the current attribute
57   /// \param isBackup a boolean flag, if true, store values from the attribute
58   /// to backup, otherwise set the backed up values to the attribute
59   virtual void backupAttributeValue(const bool isBackup) = 0;
60
61   /// Fills the attribute with the value of the selected owner
62   /// \param theOwner a selected owner
63   virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner) = 0;
64
65   /// Checks the current attibute in all attribute validators
66   // \return true if all validators return that the attribute is valid
67   bool isValidAttribute() const;
68
69   /// It obtains selection filters from the workshop and activates them in the active viewer
70   /// \param theWorkshop an active workshop
71   /// \param toActivate a flag about activation or deactivation the filters
72   virtual void activateFilters(ModuleBase_IWorkshop* theWorkshop, const bool toActivate) const;
73 };
74
75 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */