Salome HOME
69e6461ea75b3038667c4743ee9d75c0f2f00dd6
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2d.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetPoint2d.h
4 // Created:     25 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef PartSet_WidgetPoint2D_H
8 #define PartSet_WidgetPoint2D_H
9
10 #include "PartSet.h"
11 #include <ModelAPI_CompositeFeature.h>
12 #include <ModuleBase_ModelWidget.h>
13
14 #include <QObject>
15
16 #include <TopoDS_Shape.hxx>
17 #include <V3d_View.hxx>
18
19 class ModelAPI_Feature;
20 class ModuleBase_IWorkshop;
21 class ModuleBase_DoubleSpinBox;
22 class ModuleBase_IViewWindow;
23 class GeomAPI_Pnt2d;
24 class XGUI_Workshop;
25
26 class QGroupBox;
27 class QMouseEvent;
28
29 /**\class PartSet_WidgetPoint2D
30  * \ingroup GUI
31  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
32  */
33 class PARTSET_EXPORT PartSet_WidgetPoint2D : public ModuleBase_ModelWidget
34 {
35 Q_OBJECT
36  public:
37   /// Constructor
38   /// \theParent the parent object
39   /// \theParent the parent object
40   /// \theData the widget configuation. The attribute of the model widget is obtained from
41   PartSet_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, 
42                         const std::string& theParentId);
43   /// Destructor
44   virtual ~PartSet_WidgetPoint2D();
45
46   /// Set the given wrapped value to the current widget
47   /// This value should be processed in the widget according to the needs
48   /// \param theValue the wrapped widget value
49   virtual bool setSelection(ModuleBase_ViewerPrs theValue);
50
51   /// Saves the internal parameters to the given feature
52   /// \param theObject a model feature to be changed
53   virtual bool storeValue() const;
54
55   virtual bool restoreValue();
56
57   /// Returns the internal parent wiget control, that can be shown anywhere
58   /// \returns the widget
59   QWidget* getControl() const;
60
61   /// Returns list of widget controls
62   /// \return a control list
63   virtual QList<QWidget*> getControls() const;
64
65   //bool initFromPrevious(ObjectPtr theObject);
66
67   /// The methiod called when widget is activated
68   virtual void activate();
69
70   /// The methiod called when widget is deactivated
71   virtual void deactivate();
72
73   XGUI_Workshop* workshop() const { return myWorkshop; }
74
75   void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
76
77   /// \returns the sketch instance
78   CompositeFeaturePtr sketch() const { return mySketch; }
79   void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
80
81   /// Fill the widget values by given point
82   /// \param thePoint the point
83   void setPoint(double theX, double theY);
84
85   /// Returns coordinate X currently defined in the control
86   double x() const;
87
88   /// Returns coordinate Y currently defined in the control
89   double y() const;
90
91 signals:
92   /// Signal about selection of an existing vertex from an object
93   /// \param theObject - the selected object
94   /// \param theShape - the selected shape
95   void vertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
96
97 protected slots:
98   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
99   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
100
101 private slots:
102   void onValuesChanged();
103
104  private:
105    bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape, 
106                    double& theX, double& theY) const;
107
108   XGUI_Workshop* myWorkshop;
109
110   QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets
111   ModuleBase_DoubleSpinBox* myXSpin;  ///< the spin box for the X coordinate
112   ModuleBase_DoubleSpinBox* myYSpin;  ///< the spin box for the Y coordinate
113
114   //std::string myOptionParam;  /// Parameter name which has to be taken from previous feature
115
116   CompositeFeaturePtr mySketch;
117 };
118
119 #endif