X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetValidator.h;h=bfefaadcb4a22049bd9de0d9b9f87242db912032;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=db9719b807f4d3351301edee79b6920eeb5cffee;hpb=49d5a27258260087aad5e7ca30d6863e08a186d1;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetValidator.h b/src/ModuleBase/ModuleBase_WidgetValidator.h old mode 100755 new mode 100644 index db9719b80..bfefaadcb --- a/src/ModuleBase/ModuleBase_WidgetValidator.h +++ b/src/ModuleBase/ModuleBase_WidgetValidator.h @@ -1,21 +1,40 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetValidator.h -// Created: 12 Mar 2015 -// Author: Natalia ERMOLAEVA - +// Copyright (C) 2014-2024 CEA, EDF +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #ifndef ModuleBase_WidgetValidator_H_ #define ModuleBase_WidgetValidator_H_ -#include +#include "ModuleBase.h" + +#include "ModuleBase_Definitions.h" + +#include #include #include +class ModelAPI_Attribute; + class ModuleBase_ModelWidget; class ModuleBase_IWorkshop; class ModuleBase_ViewerPrs; +class ModuleBase_WidgetSelectorStore; /** * \ingroup GUI @@ -31,6 +50,20 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator ModuleBase_IWorkshop* theWorkshop); virtual ~ModuleBase_WidgetValidator(); + /// Fills given container with selection modes if the widget has it + /// \param [out] theModuleSelectionModes module additional modes, -1 means all default modes + /// \param theModes [out] a container of modes + virtual void selectionModes(int& /*theModuleSelectionModes*/, QIntList& /*theModes*/) {} + + /// Appends into container of workshop selection filters + /// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes + /// \param [out] selection filters + virtual void selectionFilters(QIntList& theModuleSelectionFilters, + SelectMgr_ListOfFilter& theSelectionFilters); + + /// 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 @@ -39,20 +72,35 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator /// \return a boolean value virtual bool isValidSelection(const std::shared_ptr& theValue); - /// It obtains selection filters from the workshop and activates them in the active viewer - /// \param toActivate a flag about activation or deactivation the filters - /// \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& 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& 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& theAttribute) const; + + //! Clear all validated cash in the widget + void clearValidatedCash(); private: /// Returns true if the workshop validator filter has been already activated /// \return boolean value bool isFilterActivated() const; - //! Clear all validated cash in the widget - void clearValidatedCash(); - - /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored + /// Gets the validity state of the presentation in an internal map. + /// Returns true if the valid state of value is stored /// \param theValue a viewer presentation /// \param theValid a valid state bool getValidState(const std::shared_ptr& theValue, bool& theValid); @@ -63,12 +111,17 @@ private: void storeValidState(const std::shared_ptr& 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> myValidPrs; - QList> myValidPrs; ///< cash of valid selection presentations - QList> myInvalidPrs; ///< cash of invalid selection presentations + /// cash of invalid selection presentations + QList> myInvalidPrs; }; #endif /* ModuleBase_WidgetValidator_H_ */