Salome HOME
9320fb6965e2f3fb8adc6ec2f8174bbae352c271
[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,
33                            const std::string& theParentId);
34   /// Destructor
35   virtual ~ModuleBase_WidgetFeature();
36
37   /// Set the given wrapped value to the current widget
38   /// This value should be processed in the widget according to the needs
39   /// \param theValue the wrapped widget value
40   virtual bool setValue(ModuleBase_WidgetValue* theValue);
41
42   /// Saves the internal parameters to the given feature
43   /// \param theFeature a model feature to be changed
44   virtual bool storeValue() const;
45
46   virtual bool restoreValue();
47
48   /// Returns the internal parent wiget control, that can be shown anywhere
49   /// \returns the widget
50   QWidget* getControl() const;
51
52   /// Returns list of widget controls
53   /// \return a control list
54   virtual QList<QWidget*> getControls() const;
55
56  protected:
57   /// Fill the widget values by given point
58   /// \param thePoint the point
59   /// \return the boolean result of the feature set
60   bool setObject(const ObjectPtr& theObject, bool theSendEvent = true);
61
62   /// Returns current widget feature
63   /// \return the feature
64   const ObjectPtr object() const
65   {
66     return myObject;
67   }
68
69   /// Returns the widget editor
70   /// \return the editor
71   QLineEdit* editor() const
72   {
73     return myEditor;
74   }
75
76   /// Returns the possible feature kinds
77   /// \return the list of kinds
78   const QStringList& featureKinds() const
79   {
80     return myObjectKinds;
81   }
82
83   ObjectPtr myObject;  ///< the current widget feature
84   QStringList myObjectKinds;  ///< the kinds of possible features
85
86   QWidget* myContainer;  /// the parent top control
87   QLabel* myLabel;  /// the editor information label
88   QLineEdit* myEditor;  ///< the feature editor to visualize the feature name
89 };
90
91 #endif