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 Custom widget. An abstract class to be redefined to fill with some GUI controls
33 class PARTSET_EXPORT PartSet_WidgetPoint2D : public ModuleBase_ModelWidget
38 /// \theParent the parent object
39 /// \theParent the parent object
40 /// \theData the widget configuation. The attribute of the model widget is obtained from
41 PartSet_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData,
42 const std::string& theParentId);
44 virtual ~PartSet_WidgetPoint2D();
46 /// Set the given wrapped value to the current widget
47 /// This value should be processed in the widget according to the needs
48 /// \param theValue the wrapped widget value
49 virtual bool setSelection(ModuleBase_ViewerPrs theValue);
51 /// Saves the internal parameters to the given feature
52 /// \param theObject a model feature to be changed
53 virtual bool storeValue() const;
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 activated
68 virtual void activate();
70 /// The methiod called when widget is deactivated
71 virtual void deactivate();
73 XGUI_Workshop* workshop() const { return myWorkshop; }
75 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
77 /// \returns the sketch instance
78 CompositeFeaturePtr sketch() const { return mySketch; }
79 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
81 /// Fill the widget values by given point
82 /// \param thePoint the point
83 void setPoint(double theX, double theY);
85 /// Returns coordinate X currently defined in the control
88 /// Returns coordinate Y currently defined in the control
92 /// Signal about selection of an existing vertex from an object
93 /// \param theObject - the selected object
94 /// \param theShape - the selected shape
95 void vertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
98 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
99 void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
102 void onValuesChanged();
105 bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
106 double& theX, double& theY) const;
108 XGUI_Workshop* myWorkshop;
110 QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
111 ModuleBase_DoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
112 ModuleBase_DoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
114 //std::string myOptionParam; /// Parameter name which has to be taken from previous feature
116 CompositeFeaturePtr mySketch;