Salome HOME
Merge branch 'Dev_0.6' of newgeom:newgeom into Dev_0.6
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2dDistance.h
1 // File:        PartSet_WidgetPoint2dDistance.h
2 // Created:     23 June 2014
3 // Author:      Vitaly Smetannikov
4
5 #ifndef PartSet_WidgetPoint2dDistance_H
6 #define PartSet_WidgetPoint2dDistance_H
7
8 #include "PartSet.h"
9 #include <ModuleBase_WidgetDoubleValue.h>
10
11 #include <ModelAPI_CompositeFeature.h>
12
13 //class ModuleBase_WidgetValue;
14 class GeomAPI_Pnt2d;
15 class XGUI_Workshop;
16 class ModuleBase_IViewWindow;
17 class QMouseEvent;
18
19 class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
20 {
21 Q_OBJECT
22  public:
23   /// Constructor
24   /// \theParent the parent object
25   /// \theData the widget configuation. The attribute of the model widget is obtained from
26   PartSet_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData,
27                                    const std::string& theParentId);
28
29   virtual ~PartSet_WidgetPoint2dDistance();
30
31   /// The methiod called when widget is activated
32   virtual void activate();
33
34   /// The methiod called when widget is deactivated
35   virtual void deactivate();
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   XGUI_Workshop* workshop() const { return myWorkshop; }
43
44   void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
45
46   /// \returns the sketch instance
47   CompositeFeaturePtr sketch() const { return mySketch; }
48   void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
49
50  protected slots:
51   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
52   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
53
54 protected:
55   /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
56   void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
57
58  private:
59   XGUI_Workshop* myWorkshop;
60   std::string myFirstPntName;
61
62   CompositeFeaturePtr mySketch;
63 };
64
65 #endif