X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetValidated.h;h=385f11a00f04e334e29fd048ebad38dc6765ae0e;hb=aebde79eb2410f5e7699ee44254173b442727df7;hp=0ac6657e7d302fe66846362903933581a8412ec6;hpb=87db694c19f51ae773e27f6b61770225d0b4727c;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 0ac6657e7..385f11a00 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D // File: ModuleBase_WidgetValidated.h // Created: 12 Mar 2015 @@ -12,10 +12,13 @@ #include #include +#include #include #include +#include + class QWidget; class ModuleBase_IWorkshop; class ModuleBase_ISelection; @@ -33,15 +36,22 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg public: /// Constructor /// \param theParent the parent object + /// \param theWorkshop a reference to workshop /// \param theData the widget configuation. The attribute of the model widget is obtained from /// \param theParentId is Id of a parent of the current attribute ModuleBase_WidgetValidated(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId); virtual ~ModuleBase_WidgetValidated(); + /// Checks whether all active viewer filters validate the presentation + /// \param thePrs a selected presentation in the view + /// \return a boolean value + bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs); + /// Checks all widget validator if the owner is valid - /// \param theOwner a selected owner in the view + /// \param theValue a selected presentation in the view /// \return a boolean value bool isValidSelection(const ModuleBase_ViewerPrs& theValue); @@ -50,51 +60,80 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg /// The method is called by the current operation to process the operation preselection. /// It is redefined to check the value validity and if it is, fill the attribute with by value /// \param theValues the wrapped selection values - /// \param thePosition an index in the list of values, the values should be get from the index - virtual bool setSelection(const QList& theValues, int& thePosition); + /// \param theToValidate a flag on validation of the values + virtual bool setSelection(QList& theValues, + const bool theToValidate); + + //! Returns data object by AIS + ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const; protected: /// 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 - virtual void storeAttributeValue() = 0; + virtual void storeAttributeValue(); /// 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 theValid a boolean flag, if restore happens for valid parameters - virtual void restoreAttributeValue(const bool theValid) = 0; + virtual void restoreAttributeValue(const bool theValid); + + /// Checks the widget validity. By default, it returns true. + /// \param thePrs a selected presentation in the view + /// \return a boolean value + virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// Fills the attribute with the value of the selected owner - /// \param theOwner a selected owner + /// \param thePrs a selected owner virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0; - virtual void removePresentations() {}; - /// Checks the current attibute in all attribute validators // \return true if all validators return that the attribute is valid bool isValidAttribute() const; + /// Returns true if the workshop validator filter has been already activated + /// \return boolean value + bool isFilterActivated() const; + + /// 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 ModuleBase_ViewerPrs& theValue, bool& theValid); + + /// Store the validity state of the presentation in an internal map + /// \param theValue a viewer presentation + /// \param theValid a valid state + void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid); + + /// Removes all presentations from internal maps. + void clearValidState(); + + /// Returns a list of selected presentations in the viewer and object browser + /// The presentations from the object browser are filtered by the AIS context filters + /// \return a list of presentations + QList getFilteredSelected(); + + /// Applies AIS context filters to the parameter list. The not approved presentations are + /// removed from the parameters. + /// \param theValues a list of presentations. + void filterPresentations(QList& theValues); + /// It obtains selection filters from the workshop and activates them in the active viewer - /// \param theWorkshop an active workshop /// \param toActivate a flag about activation or deactivation the filters - virtual void activateFilters(ModuleBase_IWorkshop* theWorkshop, const bool toActivate) const; - - /// Puts additional validators to the given list - /// \param theValidators a list of validators - /// \param theArguments a list of validators arguments - virtual void customValidators(std::list& theValidators, - std::list >& theArguments) const; - - /// Returns a list of selected presentations. Firstly it is obtained from the viewer, - /// if there are not selected objects in the viewer, it get the selection from the object browser. - /// If the browser has selected objects, the viewer prs objects are created with only object - /// field of the presentation initialized. The widget should accept the selection in the object - /// browser at the same way as in the viewer. - /// \param theSelection a selection, where the selected objects and presentations are found - /// \return a list of presentations - QList getSelectedEntitiesOrObjects(ModuleBase_ISelection* theSelection) const; + void activateFilters(const bool toActivate); + +protected: + /// Reference to workshop + ModuleBase_IWorkshop* myWorkshop; + + /// The widget is in validation mode: store is performed, restore is not + bool myIsInValidate; +private: + ObjectPtr myPresentedObject; /// back up of the filtered object + QList myValidPrs; + QList myInvalidPrs; }; #endif /* MODULEBASE_WIDGETVALIDATED_H_ */