1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetPoint2dDistance.h
4 // Created: 23 June 2014
5 // Author: Vitaly Smetannikov
7 #ifndef PartSet_WidgetPoint2dDistance_H
8 #define PartSet_WidgetPoint2dDistance_H
11 #include <ModuleBase_WidgetDoubleValue.h>
13 #include <ModelAPI_CompositeFeature.h>
15 class PartSet_LockApplyMgr;
17 class ModuleBase_IWorkshop;
18 class ModuleBase_IViewWindow;
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:
26 * <point2ddistance id="CircleRadius"
27 * first_point="CircleCenter"
32 * icon=":icons/radius.png"
33 * tooltip="Set radius">
34 * <validator id="GeomValidators_Positive"/>
38 class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
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);
51 virtual ~PartSet_WidgetPoint2dDistance();
53 /// The methiod called when widget is deactivated
54 virtual void deactivate();
56 /// \returns the sketch instance
57 CompositeFeaturePtr sketch() const { return mySketch; }
59 /// Set sketch instance
60 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
62 /// Returns true if the event is processed.
63 virtual bool processEnter();
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);
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);
78 /// The methiod called when widget is activated
79 virtual void activateCustom();
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);
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);
92 /// Process values changed event
93 void onValuesChanged();
96 /// A reference to workshop
97 ModuleBase_IWorkshop* myWorkshop;
99 /// A manager to lock/unlock Apply button in PP
100 PartSet_LockApplyMgr* myLockApplyMgr;
102 /// A name of the first point
103 std::string myFirstPntName;
105 /// Reference to sketch
106 CompositeFeaturePtr mySketch;