Salome HOME
81720edabf1400a45892d4f0e3b5c821fa225a1c
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFeature.h
1 // File:        ModuleBase_WidgetFeature.h
2 // Created:     25 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef ModuleBase_WidgetFeature_H
6 #define ModuleBase_WidgetFeature_H
7
8 #include <ModuleBase.h>
9 #include "ModuleBase_ModelWidget.h"
10
11 #include <QObject>
12 #include <QStringList>
13
14 class ModuleBase_WidgetValue;
15 class ModelAPI_Feature;
16 class QWidget;
17 class QLabel;
18 class QLineEdit;
19
20 /**\class ModuleBase_WidgetFeature
21  * \ingroup GUI
22  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
23  */
24 class MODULEBASE_EXPORT ModuleBase_WidgetFeature : public ModuleBase_ModelWidget
25 {
26   Q_OBJECT
27 public:
28   /// Constructor
29   /// \theParent the parent object
30   /// \theParent the parent object
31   /// \theData the widget configuation. The attribute of the model widget is obtained from
32   ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
33   /// Destructor
34   virtual ~ModuleBase_WidgetFeature();
35
36   /// Set the given wrapped value to the current widget
37   /// This value should be processed in the widget according to the needs
38   /// \param theValue the wrapped widget value
39   virtual bool setValue(ModuleBase_WidgetValue* theValue);
40
41   /// Saves the internal parameters to the given feature
42   /// \param theFeature a model feature to be changed
43   virtual bool storeValue(ObjectPtr theObject) const;
44
45   virtual bool restoreValue(ObjectPtr theObject);
46
47   /// Returns the internal parent wiget control, that can be shown anywhere
48   /// \returns the widget
49   QWidget* getControl() const;
50
51   /// Returns list of widget controls
52   /// \return a control list
53   virtual QList<QWidget*> getControls() const;
54
55 protected:
56   /// Fill the widget values by given point
57   /// \param thePoint the point
58   /// \return the boolean result of the feature set
59   bool setObject(const ObjectPtr& theObject, bool theSendEvent = true);
60
61   /// Returns current widget feature
62   /// \return the feature
63   const ObjectPtr object() const { return myObject; }
64
65   /// Returns the widget editor
66   /// \return the editor
67   QLineEdit* editor() const { return myEditor; }
68
69   /// Returns the possible feature kinds
70   /// \return the list of kinds
71   const QStringList& featureKinds() const { return myObjectKinds; }
72
73   ObjectPtr myObject; ///< the current widget feature
74   QStringList myObjectKinds; ///< the kinds of possible features
75
76   QWidget*   myContainer; /// the parent top control
77   QLabel*    myLabel; /// the editor information label
78   QLineEdit* myEditor; ///< the feature editor to visualize the feature name
79 };
80
81 #endif