SHAPER 9.16.0
ModuleBase_WidgetValidator.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef ModuleBase_WidgetValidator_H_
21#define ModuleBase_WidgetValidator_H_
22
23#include "ModuleBase.h"
24
25#include "ModuleBase_Definitions.h"
26
27#include <SelectMgr_ListOfFilter.hxx>
28
29#include <QList>
30#include <memory>
31
33
38
43class MODULEBASE_EXPORT ModuleBase_WidgetValidator
44{
45 public:
50 ModuleBase_IWorkshop* theWorkshop);
52
56 virtual void selectionModes(int& /*theModuleSelectionModes*/, QIntList& /*theModes*/) {}
57
61 virtual void selectionFilters(QIntList& theModuleSelectionFilters,
62 SelectMgr_ListOfFilter& theSelectionFilters);
63
65 bool isInValidate() const { return myIsInValidate; }
66
73 virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
74
79 virtual void storeAttributeValue(const std::shared_ptr<ModelAPI_Attribute>& theAttribute);
80
86 virtual void restoreAttributeValue(const std::shared_ptr<ModelAPI_Attribute>& theAttribute,
87 const bool theValid);
88
92 bool isValidAttribute(const std::shared_ptr<ModelAPI_Attribute>& theAttribute) const;
93
95 void clearValidatedCash();
96
97private:
100 bool isFilterActivated() const;
101
106 bool getValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, bool& theValid);
107
111 void storeValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, const bool theValid);
112
113protected:
119
121 QList<std::shared_ptr<ModuleBase_ViewerPrs>> myValidPrs;
122
124 QList<std::shared_ptr<ModuleBase_ViewerPrs>> myInvalidPrs;
125};
126
127#endif /* ModuleBase_WidgetValidator_H_ */
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
Presentation.
Definition: ModuleBase_ViewerPrs.h:37
Provides for an attribute backup of values.
Definition: ModuleBase_WidgetSelectorStore.h:37
Implementation of widget with validators and filters processing.
Definition: ModuleBase_WidgetValidator.h:44
bool isInValidate() const
Returns true if the validation is activated.
Definition: ModuleBase_WidgetValidator.h:65
QList< std::shared_ptr< ModuleBase_ViewerPrs > > myValidPrs
cash of valid selection presentations
Definition: ModuleBase_WidgetValidator.h:121
ModuleBase_ModelWidget * myModelWidget
Reference to workshop.
Definition: ModuleBase_WidgetValidator.h:116
bool myIsInValidate
cashed if the value is processed in validation
Definition: ModuleBase_WidgetValidator.h:114
virtual void selectionModes(int &, QIntList &)
Fills given container with selection modes if the widget has it.
Definition: ModuleBase_WidgetValidator.h:56
ModuleBase_WidgetSelectorStore * myAttributeStore
store/restore attribute values
Definition: ModuleBase_WidgetValidator.h:118
QList< std::shared_ptr< ModuleBase_ViewerPrs > > myInvalidPrs
cash of invalid selection presentations
Definition: ModuleBase_WidgetValidator.h:124
ModuleBase_IWorkshop * myWorkshop
the active workshop
Definition: ModuleBase_WidgetValidator.h:117