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>
17 class ModuleBase_IViewWindow;
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:
25 * <point2ddistance id="CircleRadius"
26 * first_point="CircleCenter"
31 * icon=":icons/radius.png"
32 * tooltip="Set radius">
33 * <validator id="GeomValidators_Positive"/>
37 class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
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);
48 virtual ~PartSet_WidgetPoint2dDistance();
50 /// Fills the widget with default values
53 /// The methiod called when widget is deactivated
54 virtual void deactivate();
57 XGUI_Workshop* workshop() const { return myWorkshop; }
60 /// \param theWork a pointer to workshop
61 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
63 /// \returns the sketch instance
64 CompositeFeaturePtr sketch() const { return mySketch; }
66 /// Set sketch instance
67 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
70 /// Process of mouse move
71 /// \param theWnd a pointer to a window
72 /// \param theEvent a mouse event
73 void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
76 /// Process of mouse release
77 /// \param theWnd a pointer to a window
78 /// \param theEvent a mouse event
79 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
82 /// The methiod called when widget is activated
83 virtual void activateCustom();
85 /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
86 void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
89 /// Process values changed event
90 void onValuesChanged();
93 XGUI_Workshop* myWorkshop;
94 std::string myFirstPntName;
96 CompositeFeaturePtr mySketch;