]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetPoint2dDistance.h
Salome HOME
84d962a06982de936d8ec59b1b8bef002602ac5a
[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 GeomAPI_Pnt2d;
14 class XGUI_Workshop;
15 class ModuleBase_IViewWindow;
16 class QMouseEvent;
17
18 class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
19 {
20 Q_OBJECT
21  public:
22   /// Constructor
23   /// \theParent the parent object
24   /// \theData the widget configuation. The attribute of the model widget is obtained from
25   PartSet_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData,
26                                    const std::string& theParentId);
27
28   virtual ~PartSet_WidgetPoint2dDistance();
29
30   /// The methiod called when widget is activated
31   virtual void activate();
32
33   /// The methiod called when widget is deactivated
34   virtual void deactivate();
35
36   /// Set the given wrapped value to the current widget
37   /// This value should be processed in the widget according to the needs
38   /// \param theValue the wrapped widget value
39   //virtual bool setValue(ModuleBase_WidgetValue* theValue);
40
41   XGUI_Workshop* workshop() const { return myWorkshop; }
42
43   void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
44
45   /// \returns the sketch instance
46   CompositeFeaturePtr sketch() const { return mySketch; }
47   void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
48
49  protected slots:
50   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
51   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
52
53 protected:
54   /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
55   void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
56
57  private:
58   XGUI_Workshop* myWorkshop;
59   std::string myFirstPntName;
60
61   CompositeFeaturePtr mySketch;
62 };
63
64 #endif