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