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_ParamSpinBox;
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(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
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);
109 // Set lock validating in the operation manager. Set apply is disabled
110 void onLockValidating();
112 // Set unlock validating in the operation manager. Call method to update the apply state.
113 void onUnlockValidating();
116 /// Saves the internal parameters to the given feature
117 /// \return True in success
118 virtual bool storeValueCustom() const;
120 /// The methiod called when widget is activated
121 virtual void activateCustom();
124 /// Process value changed event
125 void onValuesChanged();
128 /// Returns point 2d from selected vertex
129 /// \param theView a view window
130 /// \param theShape a vertex shape
131 /// \param theX an output value of X coordinate
132 /// \param theY an output value of Y coordinate
133 bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
134 double& theX, double& theY) const;
136 XGUI_Workshop* myWorkshop;
138 QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
139 ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
140 ModuleBase_ParamSpinBox* myYSpin; ///< the spin box for the Y coordinate
142 //std::string myOptionParam; /// Parameter name which has to be taken from previous feature
144 CompositeFeaturePtr mySketch;