1 // File: ModuleBase_WidgetPoint2D.h
2 // Created: 25 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef ModuleBase_WidgetPoint2D_H
6 #define ModuleBase_WidgetPoint2D_H
8 #include <ModuleBase.h>
9 #include "ModuleBase_ModelWidget.h"
13 class ModelAPI_Feature;
14 class ModuleBase_WidgetValue;
20 /**\class ModuleBase_WidgetPoint2D
22 * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
24 class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_ModelWidget
29 /// \theParent the parent object
30 /// \theParent the parent object
31 /// \theData the widget configuation. The attribute of the model widget is obtained from
32 ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
34 virtual ~ModuleBase_WidgetPoint2D();
36 /// Set the given wrapped value to the current widget
37 /// This value should be processed in the widget according to the needs
38 /// \param theValue the wrapped widget value
39 virtual bool setValue(ModuleBase_WidgetValue* theValue);
41 /// Saves the internal parameters to the given feature
42 /// \param theObject a model feature to be changed
43 virtual bool storeValue(ObjectPtr theObject) const;
45 virtual bool restoreValue(ObjectPtr theObject);
47 /// Returns the internal parent wiget control, that can be shown anywhere
48 /// \returns the widget
49 QWidget* getControl() const;
51 /// Returns list of widget controls
52 /// \return a control list
53 virtual QList<QWidget*> getControls() const;
55 /// Process key release envent on the widget spin box controls
56 /// \param theObject the object where the event happens
57 /// \param theEvent the processed event
58 virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
60 bool initFromPrevious(ObjectPtr theObject);
63 /// Signal about the point 2d set to the feature
64 /// \param the feature
65 /// \param the attribute of the feature
66 void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute);
69 /// Fill the widget values by given point
70 /// \param thePoint the point
71 void setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
74 QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
75 QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
76 QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
78 std::string myOptionParam; /// Parameter name which has to be taken from previous feature