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 /// Set the given wrapped value to the current widget
51 /// This value should be processed in the widget according to the needs
52 /// \param theValue the wrapped widget value
53 virtual bool setSelection(ModuleBase_ViewerPrs theValue);
55 virtual bool restoreValue();
57 /// Returns the internal parent wiget control, that can be shown anywhere
58 /// \returns the widget
59 QWidget* getControl() const;
61 /// Returns list of widget controls
62 /// \return a control list
63 virtual QList<QWidget*> getControls() const;
65 //bool initFromPrevious(ObjectPtr theObject);
67 /// The methiod called when widget is deactivated
68 virtual void deactivate();
71 XGUI_Workshop* workshop() const { return myWorkshop; }
74 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
76 /// \returns the sketch instance
77 CompositeFeaturePtr sketch() const { return mySketch; }
79 /// Set sketch instance
80 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
82 /// Fill the widget values by given point
83 /// \param theX the X coordinate
84 /// \param theY the Y coordinate
85 /// \returns True in case of success
86 bool setPoint(double theX, double theY);
88 /// Returns coordinate X currently defined in the control
91 /// Returns coordinate Y currently defined in the control
95 /// Signal about selection of an existing vertex from an object
96 void vertexSelected();
99 /// Process mouse release event
100 /// \param theWnd a view window
101 /// \param theEvent a mouse event
102 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
104 /// Process mouse move event
105 /// \param theWnd a view window
106 /// \param theEvent a mouse event
107 void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
110 /// Saves the internal parameters to the given feature
111 /// \return True in success
112 virtual bool storeValue() 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;