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 storeValue() const;
57 virtual bool restoreValue();
59 /// Returns the internal parent wiget control, that can be shown anywhere
60 /// \returns the widget
61 QWidget* getControl() const;
63 /// Returns list of widget controls
64 /// \return a control list
65 virtual QList<QWidget*> getControls() const;
67 //bool initFromPrevious(ObjectPtr theObject);
69 /// The methiod called when widget is deactivated
70 virtual void deactivate();
73 XGUI_Workshop* workshop() const { return myWorkshop; }
76 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
78 /// \returns the sketch instance
79 CompositeFeaturePtr sketch() const { return mySketch; }
81 /// Set sketch instance
82 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
84 /// Fill the widget values by given point
85 /// \param theX the X coordinate
86 /// \param theY the Y coordinate
87 /// \returns True in case of success
88 bool setPoint(double theX, double theY);
90 /// Returns coordinate X currently defined in the control
93 /// Returns coordinate Y currently defined in the control
97 /// Signal about selection of an existing vertex from an object
98 void vertexSelected();
101 /// Process mouse release event
102 /// \param theWnd a view window
103 /// \param theEvent a mouse event
104 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
106 /// Process mouse move event
107 /// \param theWnd a view window
108 /// \param theEvent a mouse event
109 void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
112 /// The methiod called when widget is activated
113 virtual void activateCustom();
116 /// Process value changed event
117 void onValuesChanged();
120 /// Returns point 2d from selected vertex
121 /// \param theView a view window
122 /// \param theShape a vertex shape
123 /// \param theX an output value of X coordinate
124 /// \param theY an output value of Y coordinate
125 bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
126 double& theX, double& theY) const;
128 XGUI_Workshop* myWorkshop;
130 QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
131 ModuleBase_DoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
132 ModuleBase_DoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
134 //std::string myOptionParam; /// Parameter name which has to be taken from previous feature
136 CompositeFeaturePtr mySketch;