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;
24 class ModuleBase_IWorkshop;
25 class PartSet_LockApplyMgr;
30 /**\class PartSet_WidgetPoint2D
32 * \brief Implementation of model widget to provide widget to input point 2d
33 * In XML can be defined as folloung:
35 * <sketch-2dpoint_selector id="CircleCenter" title="Center" tooltip="Center coordinates"/>
38 class PARTSET_EXPORT PartSet_WidgetPoint2D : public ModuleBase_ModelWidget
43 /// \param theParent the parent object
44 /// \param theWorkshop a current workshop
45 /// \param theData the widget configuation. The attribute of the model widget is obtained from
46 /// \param theParentId is Id of a parent of the current attribute
47 PartSet_WidgetPoint2D(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
48 const Config_WidgetAPI* theData,
49 const std::string& theParentId);
51 virtual ~PartSet_WidgetPoint2D();
53 /// Fills the widget with default values
56 /// Set the given wrapped value to the current widget
57 /// This value should be processed in the widget according to the needs
58 /// \param theValues the wrapped widget values
59 virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
60 const bool theToValidate);
62 /// Returns list of widget controls
63 /// \return a control list
64 virtual QList<QWidget*> getControls() const;
66 //bool initFromPrevious(ObjectPtr theObject);
68 /// The methiod called when widget is deactivated
69 virtual void deactivate();
71 /// \returns the sketch instance
72 CompositeFeaturePtr sketch() const { return mySketch; }
74 /// Set sketch instance
75 void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
77 /// Fill the widget values by given point
78 /// \param theX the X coordinate
79 /// \param theY the Y coordinate
80 /// \returns True in case of success
81 bool setPoint(double theX, double theY);
83 /// Returns coordinate X currently defined in the control
86 /// Returns coordinate Y currently defined in the control
90 /// Signal about selection of an existing vertex from an object
91 void vertexSelected();
94 /// Process mouse move event
95 /// \param theWnd a view window
96 /// \param theEvent a mouse event
97 void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
100 /// Process mouse release event
101 /// \param theWnd a view window
102 /// \param theEvent a mouse event
103 void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
106 /// Saves the internal parameters to the given feature
107 /// \return True in success
108 virtual bool storeValueCustom() const;
110 virtual bool restoreValueCustom();
112 /// The methiod called when widget is activated
113 virtual void activateCustom();
115 /// Returns true if the feature contains Point2D attribute with the same coordinates
116 /// The attribute of the widget is not processed.
117 /// \param theX the X coordinate
118 /// \param theY the Y coordinate
119 /// \return boolean result
120 bool isFeatureContainsPoint(const FeaturePtr& theFeature, double theX, double theY);
123 /// Process value changed event
124 void onValuesChanged();
127 /// Returns point 2d from selected vertex
128 /// \param theView a view window
129 /// \param theShape a vertex shape
130 /// \param theX an output value of X coordinate
131 /// \param theY an output value of Y coordinate
132 bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
133 double& theX, double& theY) const;
135 /// Create a coincidence constraint between the attribute and the parameter object
136 /// \theObject a result object
137 void setConstraintWith(const ObjectPtr& theObject);
139 ModuleBase_IWorkshop* myWorkshop;
140 PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
142 QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
143 ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
144 ModuleBase_ParamSpinBox* myYSpin; ///< the spin box for the Y coordinate
146 //std::string myOptionParam; /// Parameter name which has to be taken from previous feature
148 CompositeFeaturePtr mySketch;