Salome HOME
Issue #2024: Redesign of circle and arc of circle (validate preselected object)
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidator.h
index ee8d6151b38719e917aa6a37787bbdf80ad10fdc..d159fdad9274673067bfc1b2a09c07aaf9052cae 100755 (executable)
 #include <QList>
 #include <memory>
 
+class ModelAPI_Attribute;
+
 class ModuleBase_ModelWidget;
 class ModuleBase_IWorkshop;
 class ModuleBase_ViewerPrs;
+class ModuleBase_WidgetSelectorStore;
 
 /**
 * \ingroup GUI
@@ -31,6 +34,9 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator
                              ModuleBase_IWorkshop* theWorkshop);
   virtual ~ModuleBase_WidgetValidator();
 
+  /// Returns true if the validation is activated
+  bool isInValidate() const { return myIsInValidate; }
+
   /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
   /// next, the attribute's validating. It trying on the give selection to current attribute by
   /// setting the value inside and calling validators. After this, the previous attribute value is
@@ -44,6 +50,25 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator
   /// \return true if the selection filter of the widget is activated in viewer context
   bool activateFilters(const bool toActivate);
 
+    /// Creates a backup of the current values of the attribute
+  /// It should be realized in the specific widget because of different
+  /// parameters of the current attribute
+  /// \param theAttribute an attribute to be stored
+  virtual void storeAttributeValue(const std::shared_ptr<ModelAPI_Attribute>& theAttribute);
+
+  /// Creates a backup of the current values of the attribute
+  /// It should be realized in the specific widget because of different
+  /// parameters of the current attribute
+  /// \param theAttribute an attribute to be restored
+  /// \param theValid a boolean flag, if restore happens for valid parameters
+  virtual void restoreAttributeValue(const std::shared_ptr<ModelAPI_Attribute>& theAttribute,
+                                     const bool theValid);
+
+  /// Checks the current attibute in all attribute validators
+  /// \param theAttribute an attribute to be validated
+  /// \return true if all validators return that the attribute is valid
+  bool isValidAttribute(const std::shared_ptr<ModelAPI_Attribute>& theAttribute) const;
+
 private:
   /// Returns true if the workshop validator filter has been already activated
   /// \return boolean value
@@ -64,9 +89,11 @@ private:
   void storeValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, const bool theValid);
 
 protected:
+  bool myIsInValidate; ///< cashed if the value is processed in validation
   /// Reference to workshop
   ModuleBase_ModelWidget* myModelWidget; ///< the current widget to be validated
   ModuleBase_IWorkshop* myWorkshop; ///< the active workshop
+  ModuleBase_WidgetSelectorStore* myAttributeStore; //< store/restore attribute values
 
   /// cash of valid selection presentations
   QList<std::shared_ptr<ModuleBase_ViewerPrs>> myValidPrs;