Salome HOME
Divide init method of sketch operation on initFeature and initSelection.
[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 class GeomAPI_Pnt2d;
15
16 class QGroupBox;
17 class QDoubleSpinBox;
18
19 /**\class ModuleBase_WidgetPoint2D
20  * \ingroup GUI
21  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
22  */
23 class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_ModelWidget
24 {
25   Q_OBJECT
26 public:
27   /// Constructor
28   /// \theParent the parent object
29   /// \theParent the parent object
30   /// \theData the widget configuation. The attribute of the model widget is obtained from
31   ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData);
32   /// Destructor
33   virtual ~ModuleBase_WidgetPoint2D();
34
35   /// Fill the widget values by given point
36   /// \param thePoint the point
37   void setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
38
39   /// Saves the internal parameters to the given feature
40   /// \param theFeature a model feature to be changed
41   virtual bool storeValue(FeaturePtr theFeature) const;
42
43   virtual bool restoreValue(FeaturePtr theFeature);
44
45   /// Returns the internal parent wiget control, that can be shown anywhere
46   /// \returns the widget
47   QWidget* getControl() const;
48
49   /// Returns list of widget controls
50   /// \return a control list
51   virtual QList<QWidget*> getControls() const;
52
53   /// Process key release envent on the widget spin box controls
54   /// \param theObject the object where the event happens
55   /// \param theEvent the processed event
56   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
57
58   bool initFromPrevious(FeaturePtr theFeature);
59
60 signals:
61   /// Signal about the point 2d set to the feature
62   /// \param the feature
63   /// \param the attribute of the feature
64   void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
65
66 private:
67   QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
68   QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
69   QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
70
71   std::string myOptionParam; /// Parameter name which has to be taken from previous feature
72 };
73
74 #endif