1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetPoint2d.h
4 // Created: 25 Apr 2014
5 // Author: Natalia ERMOLAEVA
7 #ifndef PartSet_WidgetPoint2D_H
8 #define PartSet_WidgetPoint2D_H
11 #include <ModelAPI_CompositeFeature.h>
12 #include <ModuleBase_ModelWidget.h>
16 #include <TopoDS_Shape.hxx>
17 #include <V3d_View.hxx>
19 class ModelAPI_Feature;
20 class ModuleBase_IWorkshop;
21 class ModuleBase_DoubleSpinBox;
22 class ModuleBase_IViewWindow;
29 /**\class PartSet_WidgetPoint2D
31 * \brief Implementation of model widget to provide widget to input point 2d
32 * In XML can be defined as folloung:
34 * <sketch-2dpoint_selector id="CircleCenter" title="Center" tooltip="Center coordinates"/>
37 class PARTSET_EXPORT PartSet_WidgetPoint2D : public ModuleBase_ModelWidget
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_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData,
46 const std::string& theParentId);
48 virtual ~PartSet_WidgetPoint2D();
50 /// Fills the widget with default values
53 /// Set the given wrapped value to the current widget
54 /// This value should be processed in the widget according to the needs
55 /// \param theValue the wrapped widget value
56 virtual bool setSelection(ModuleBase_ViewerPrs theValue);
58 virtual bool restoreValue();
60 /// Returns list of widget controls
61 /// \return a control list
62 virtual QList<QWidget*> getControls() const;
64 //bool initFromPrevious(ObjectPtr theObject);
66 /// The methiod called when widget is deactivated
67 virtual void deactivate();
70 XGUI_Workshop* workshop() const { return myWorkshop; }
73 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
75 /// \returns the sketch instance
76 CompositeFeaturePtr sketch() const { return mySketch; }
78 /// Set sketch instance
79 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
81 /// Fill the widget values by given point
82 /// \param theX the X coordinate
83 /// \param theY the Y coordinate
84 /// \returns True in case of success
85 bool setPoint(double theX, double theY);
87 /// Returns coordinate X currently defined in the control
90 /// Returns coordinate Y currently defined in the control
94 /// Signal about selection of an existing vertex from an object
95 void vertexSelected();
98 /// Process mouse move event
99 /// \param theWnd a view window
100 /// \param theEvent a mouse event
101 void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
104 /// Process mouse release event
105 /// \param theWnd a view window
106 /// \param theEvent a mouse event
107 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
110 /// Saves the internal parameters to the given feature
111 /// \return True in success
112 virtual bool storeValueCustom() const;
114 /// The methiod called when widget is activated
115 virtual void activateCustom();
118 /// Process value changed event
119 void onValuesChanged();
122 /// Returns point 2d from selected vertex
123 /// \param theView a view window
124 /// \param theShape a vertex shape
125 /// \param theX an output value of X coordinate
126 /// \param theY an output value of Y coordinate
127 bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
128 double& theX, double& theY) const;
130 XGUI_Workshop* myWorkshop;
132 QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
133 ModuleBase_DoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
134 ModuleBase_DoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
136 //std::string myOptionParam; /// Parameter name which has to be taken from previous feature
138 CompositeFeaturePtr mySketch;