Salome HOME
Define abstract module class
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFeatureOrAttribute.h
1 // File:        ModuleBase_WidgetFeatureOrAttribute.h
2 // Created:     25 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef ModuleBase_WidgetFeatureOrAttribute_H
6 #define ModuleBase_WidgetFeatureOrAttribute_H
7
8 #include <ModuleBase.h>
9 #include "ModuleBase_WidgetFeature.h"
10
11 #include <QObject>
12
13 class ModuleBase_WidgetValue;
14 class ModelAPI_Attribute;
15
16 /**\class ModuleBase_WidgetFeatureOrAttribute
17  * \ingroup GUI
18  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
19  */
20 class MODULEBASE_EXPORT ModuleBase_WidgetFeatureOrAttribute : public ModuleBase_WidgetFeature
21 {
22 Q_OBJECT
23  public:
24   /// Constructor
25   /// \theParent the parent object
26   /// \theParent the parent object
27   /// \theData the widget configuation. The attribute of the model widget is obtained from
28   ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData,
29                                       const std::string& theParentId);
30   /// Destructor
31   virtual ~ModuleBase_WidgetFeatureOrAttribute();
32
33   /// Set the given wrapped value to the current widget
34   /// This value should be processed in the widget according to the needs
35   /// \param theValue the wrapped widget value
36   virtual bool setValue(ModuleBase_WidgetValue* theValue);
37
38   /// Saves the internal parameters to the given feature
39   /// \param theFeature a model feature to be changed
40   virtual bool storeValue() const;
41
42   virtual bool restoreValue();
43   /// Defines if it is supposed that the widget should interact with the viewer.
44   virtual bool isViewerSelector() { return true; }
45
46  protected:
47   /// Set the attribute
48   /// \param theAttribute value
49   /// \return the boolean result of the attribute set
50   bool setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute, bool theSendEvent =
51                         true);
52
53  protected:
54   boost::shared_ptr<ModelAPI_Attribute> myAttribute;  /// < the attribute
55 };
56
57 #endif