]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetPoint2dDistance.h
Salome HOME
5db72e573fbfcff1f6f1b8d6c6332698b912a3a8
[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   /// Fills the widget with default values
54   //virtual void reset();
55
56   /// The methiod called when widget is deactivated
57   virtual void deactivate();
58
59   /// \returns the sketch instance
60   CompositeFeaturePtr sketch() const { return mySketch; }
61
62   /// Set sketch instance
63   void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
64
65 public slots:
66    /// Process of mouse move
67    /// \param theWnd a pointer to a window
68    /// \param theEvent a mouse event
69   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
70
71   protected slots:
72    /// Process of mouse release
73    /// \param theWnd a pointer to a window
74    /// \param theEvent a mouse event
75   void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
76
77 protected:
78   /// The methiod called when widget is activated
79   virtual void activateCustom();
80
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   /// Compute the distance between points
85   /// \param theFirstPnt a point value of the out point attribute
86   /// \param theCurrentPnt a point of the current widget
87   /// \return a double value
88   virtual double computeValue(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPnt,
89                               const std::shared_ptr<GeomAPI_Pnt2d>& theCurrentPnt);
90
91 private slots:
92   /// Process values changed event
93   void onValuesChanged();
94
95 protected:
96   ModuleBase_IWorkshop* myWorkshop;
97   PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
98
99   std::string myFirstPntName;
100   CompositeFeaturePtr mySketch;
101 };
102
103 #endif