Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPoint2D.h
index a973ef693bf4951c8d4d8ed21b09f6227ac2f77c..29d65a7b23288511f351566c41cdd561c0f26b5f 100644 (file)
@@ -6,45 +6,72 @@
 #define ModuleBase_WidgetPoint2D_H
 
 #include <ModuleBase.h>
-#include "ModuleBase_WidgetCustom.h"
+#include "ModuleBase_ModelWidget.h"
 
 #include <QObject>
 
 class ModelAPI_Feature;
+class ModuleBase_WidgetValue;
+class GeomAPI_Pnt2d;
 
 class QGroupBox;
-class QDoubleSpinBox;
+class ModuleBase_DoubleSpinBox;
 
 /**\class ModuleBase_WidgetPoint2D
  * \ingroup GUI
  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
  */
-class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_WidgetCustom
+class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_ModelWidget
 {
-  Q_OBJECT
-public:
+Q_OBJECT
+ public:
   /// Constructor
   /// \theParent the parent object
-  /// \theTitle the group box title
-  /// \theFeatureAttributeID the identifier of the feature attribute
-  ModuleBase_WidgetPoint2D(QWidget* theParent, QString theTitle,
-                           const std::string& theFeatureAttributeID);
+  /// \theParent the parent object
+  /// \theData the widget configuation. The attribute of the model widget is obtained from
+  ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData,
+                           const std::string& theParentId);
   /// Destructor
   virtual ~ModuleBase_WidgetPoint2D();
 
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// \param theValue the wrapped widget value
+  virtual bool setValue(ModuleBase_WidgetValue* theValue);
+
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual void store(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue() const;
+
+  virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
   QWidget* getControl() const;
 
-private:
-  std::string myFeatureAttributeID; ///< the identifier of the feature attribute
-  QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
-  QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
-  QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  bool initFromPrevious(ObjectPtr theObject);
+
+signals:
+  /// Signal about the point 2d set to the feature
+  /// \param the feature
+  /// \param the attribute of the feature
+  void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute);
+
+ protected:
+  /// Fill the widget values by given point
+  /// \param thePoint the point
+  void setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
+
+ private:
+  QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets
+  ModuleBase_DoubleSpinBox* myXSpin;  ///< the spin box for the X coordinate
+  ModuleBase_DoubleSpinBox* myYSpin;  ///< the spin box for the Y coordinate
+
+  std::string myOptionParam;  /// Parameter name which has to be taken from previous feature
 };
 
 #endif