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