Salome HOME
Update code documentation
[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 /**
21 * \ingroup Module
22 * Implementation of model widget for widget which provides input of a distance between two points
23 * In XML file can be defined as following:
24 * \code
25 * <point2ddistance id="CircleRadius" 
26 *   first_point="CircleCenter" 
27 *   label="Radius:" 
28 *   min="0" 
29 *   step="1.0" 
30 *   default="0" 
31 *   icon=":icons/radius.png" 
32 *   tooltip="Set radius">
33 *   <validator id="GeomValidators_Positive"/>
34 * </point2ddistance>
35 * \endcode
36 */ 
37 class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
38 {
39 Q_OBJECT
40  public:
41   /// Constructor
42   /// \param theParent the parent object
43   /// \param theData the widget configuation. The attribute of the model widget is obtained from
44   /// \param theParentId is Id of a parent of the current attribute
45   PartSet_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData,
46                                    const std::string& theParentId);
47
48   virtual ~PartSet_WidgetPoint2dDistance();
49
50   /// The methiod called when widget is activated
51   virtual void activate();
52
53   /// The methiod called when widget is deactivated
54   virtual void deactivate();
55
56   /// Returns workshop
57   XGUI_Workshop* workshop() const { return myWorkshop; }
58
59   /// Set workshop
60   /// \param theWork a pointer to workshop
61   void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
62
63   /// \returns the sketch instance
64   CompositeFeaturePtr sketch() const { return mySketch; }
65
66   /// Set sketch instance
67   void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
68
69  protected slots:
70    /// Process of mouse release
71    /// \param theWnd a pointer to a window
72    /// \param theEvent a mouse event
73   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
74
75    /// Process of mouse move
76    /// \param theWnd a pointer to a window
77    /// \param theEvent a mouse event
78   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
79
80 protected:
81   /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
82   void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
83
84 private slots:
85   /// Process values changed event
86   void onValuesChanged();
87
88  private:
89   XGUI_Workshop* myWorkshop;
90   std::string myFirstPntName;
91
92   CompositeFeaturePtr mySketch;
93 };
94
95 #endif