X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_FiltersArgs.h;fp=src%2FModelAPI%2FModelAPI_FiltersArgs.h;h=0140fdf707da7578b5c8bc1acdc5329c1d41cac0;hb=bae2c0f9a9f1c1adbaa371b938feb25ccdfd61ac;hp=0000000000000000000000000000000000000000;hpb=68ff61fcb1317c61adf8ed9f9bb664177fe88538;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_FiltersArgs.h b/src/ModelAPI/ModelAPI_FiltersArgs.h new file mode 100644 index 000000000..0140fdf70 --- /dev/null +++ b/src/ModelAPI/ModelAPI_FiltersArgs.h @@ -0,0 +1,67 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// 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 ModelAPI_FiltersArgs_H_ +#define ModelAPI_FiltersArgs_H_ + +#include "ModelAPI_FiltersFeature.h" + +#include + +/// separator between the filter name and the filter attribute ID +static const std::string kFilterSeparator = "__"; + +/// definition of arguments of filters: id of the argument to attributes +class ModelAPI_FiltersArgs { + /// a map from the FilterID+AttributeID -> attribute + std::map myMap; + std::string myCurrentFilter; ///< ID of the filter that will take attributes now + FiltersFeaturePtr myFeature; ///< the feature is stored to minimize initAttribute interface +public: + ModelAPI_FiltersArgs() {} + + /// Sets the current filter ID + void setFilter(const std::string& theFilterID) { + myCurrentFilter = theFilterID; + } + + /// Sets the current feature + void setFeature(const FiltersFeaturePtr theFeature) { + myFeature = theFeature; + } + + /// Appends an argument of a filter + void add(AttributePtr theAttribute) { + myMap[theAttribute->id()] = theAttribute; + } + + /// returns the argument of the current filter by the argument id + AttributePtr argument(const std::string& theID) const { + return myMap.find(myCurrentFilter + kFilterSeparator + theID)->second; + } + /// adds an attribute of the filter + std::shared_ptr initAttribute( + const std::string& theID, const std::string theAttrType) { + AttributePtr aR = myFeature->data()->addFloatingAttribute(theID, theAttrType, myCurrentFilter); + aR->setIsArgument(false); // to avoid parametric update + return aR; + } +}; + +#endif \ No newline at end of file