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