1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef ModelAPI_FiltersArgs_H_
21 #define ModelAPI_FiltersArgs_H_
23 #include "ModelAPI_FiltersFeature.h"
27 /// separator between the filter name and the filter attribute ID
28 static const std::string kFilterSeparator = "__";
30 /// definition of arguments of filters: id of the argument to attributes
31 class ModelAPI_FiltersArgs {
32 /// a map from the FilterID+AttributeID -> attribute
33 std::map<std::string, AttributePtr> myMap;
34 std::string myCurrentFilter; ///< ID of the filter that will take attributes now
35 FiltersFeaturePtr myFeature; ///< the feature is stored to minimize initAttribute interface
37 ModelAPI_FiltersArgs() {}
39 /// Sets the current filter ID
40 void setFilter(const std::string& theFilterID) {
41 myCurrentFilter = theFilterID;
44 /// Sets the current feature
45 void setFeature(const FiltersFeaturePtr theFeature) {
46 myFeature = theFeature;
49 /// Appends an argument of a filter
50 void add(AttributePtr theAttribute) {
51 myMap[theAttribute->id()] = theAttribute;
54 /// returns the argument of the current filter by the argument id
55 AttributePtr argument(const std::string& theID) const {
56 return myMap.find(myCurrentFilter + kFilterSeparator + theID)->second;
58 /// adds an attribute of the filter
59 std::shared_ptr<ModelAPI_Attribute> initAttribute(
60 const std::string& theID, const std::string theAttrType) {
61 AttributePtr aR = myFeature->data()->addFloatingAttribute(theID, theAttrType, myCurrentFilter);
62 aR->setIsArgument(false); // to avoid parametric update