Salome HOME
Preselection using in operations: setSelection of widget returns a modified list...
[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 ModuleBase_ISelection;
22 class ModelAPI_Validator;
23 class Config_WidgetAPI;
24 class Handle_SelectMgr_EntityOwner;
25
26 /**
27 * \ingroup GUI
28 * Implementation of widget with validators and filters processing.
29 */
30 class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidget
31 {
32   Q_OBJECT
33  public:
34   /// Constructor
35   /// \param theParent the parent object
36   /// \param theData the widget configuation. The attribute of the model widget is obtained from
37   /// \param theParentId is Id of a parent of the current attribute
38   ModuleBase_WidgetValidated(QWidget* theParent,
39                              const Config_WidgetAPI* theData,
40                              const std::string& theParentId);
41   virtual ~ModuleBase_WidgetValidated();
42
43   /// Checks all widget validator if the owner is valid
44   /// \param theValue a selected presentation in the view
45   /// \return a boolean value
46   bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
47
48   /// Set the given wrapped value to the current widget
49   /// This value should be processed in the widget according to the needs
50   /// The method is called by the current operation to process the operation preselection.
51   /// It is redefined to check the value validity and if it is, fill the attribute with by value
52   /// \param theValues the wrapped selection values
53   virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues);
54
55 protected:
56   /// Creates a backup of the current values of the attribute
57   /// It should be realized in the specific widget because of different
58   /// parameters of the current attribute
59   virtual void storeAttributeValue() = 0;
60
61   /// Creates a backup of the current values of the attribute
62   /// It should be realized in the specific widget because of different
63   /// parameters of the current attribute
64   /// \param theValid a boolean flag, if restore happens for valid parameters
65   virtual void restoreAttributeValue(const bool theValid) = 0;
66
67   /// Checks the widget validity. By default, it returns true.
68   /// \param theValue a selected presentation in the view
69   /// \return a boolean value
70   virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
71
72   /// Fills the attribute with the value of the selected owner
73   /// \param theOwner a selected owner
74   virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
75
76   /// Checks the current attibute in all attribute validators
77   // \return true if all validators return that the attribute is valid
78   bool isValidAttribute() const;
79
80   /// It obtains selection filters from the workshop and activates them in the active viewer
81   /// \param theWorkshop an active workshop
82   /// \param toActivate a flag about activation or deactivation the filters
83   virtual void activateFilters(ModuleBase_IWorkshop* theWorkshop, const bool toActivate) const;
84
85   /// Puts additional validators to the given list
86   /// \param theValidators a list of validators
87   /// \param theArguments a list of validators arguments
88   virtual void customValidators(std::list<ModelAPI_Validator*>& theValidators,
89                                 std::list<std::list<std::string> >& theArguments) const;
90 };
91
92 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */