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 /// The methiod called when widget is deactivated
51 virtual void deactivate();
54 XGUI_Workshop* workshop() const { return myWorkshop; }
57 /// \param theWork a pointer to workshop
58 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
60 /// \returns the sketch instance
61 CompositeFeaturePtr sketch() const { return mySketch; }
63 /// Set sketch instance
64 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
67 /// Process of mouse release
68 /// \param theWnd a pointer to a window
69 /// \param theEvent a mouse event
70 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
72 /// Process of mouse move
73 /// \param theWnd a pointer to a window
74 /// \param theEvent a mouse event
75 void onMouseMove(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);
85 /// Process values changed event
86 void onValuesChanged();
89 XGUI_Workshop* myWorkshop;
90 std::string myFirstPntName;
92 CompositeFeaturePtr mySketch;