Salome HOME
85c4c938d5aa0e6dfd69a2b768debcfd44f74bff
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPoint2D.h
1 // File:        ModuleBase_WidgetPoint2D.h
2 // Created:     25 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef ModuleBase_WidgetPoint2D_H
6 #define ModuleBase_WidgetPoint2D_H
7
8 #include <ModuleBase.h>
9 #include "ModuleBase_ModelWidget.h"
10
11 #include <QObject>
12
13 class ModelAPI_Feature;
14
15 class QGroupBox;
16 class QDoubleSpinBox;
17
18 /**\class ModuleBase_WidgetPoint2D
19  * \ingroup GUI
20  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
21  */
22 class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_ModelWidget
23 {
24   Q_OBJECT
25 public:
26   /// Constructor
27   /// \theParent the parent object
28   /// \theTitle the group box title
29   /// \theFeatureAttributeID the identifier of the feature attribute
30   ModuleBase_WidgetPoint2D(QWidget* theParent, QString theTitle,
31                            const std::string& theFeatureAttributeID);
32   /// Destructor
33   virtual ~ModuleBase_WidgetPoint2D();
34
35   /// Saves the internal parameters to the given feature
36   /// \param theFeature a model feature to be changed
37   virtual bool storeValue(FeaturePtr theFeature) const;
38
39   virtual bool restoreValue(FeaturePtr theFeature);
40
41   /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
42   /// \param theAttribute name
43   virtual bool canFocusTo(const std::string& theAttributeName);
44
45   /// Set focus to the current widget if it corresponds to the given attribute
46   virtual void focusTo();
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   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
57
58 private:
59   std::string myFeatureAttributeID; ///< the identifier of the feature attribute
60   QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
61   QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
62   QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
63 };
64
65 #endif