FiltersPlugin_Selection.h
FiltersPlugin_HorizontalFace.h
FiltersPlugin_VerticalFace.h
- FiltersPlugin_BelongsTo.h
- FiltersPlugin_OnPlane.h
+ FiltersPlugin_BelongsTo.h
+ FiltersPlugin_OnPlane.h
)
SET(PROJECT_SOURCES
FiltersPlugin_Selection.cpp
FiltersPlugin_HorizontalFace.cpp
FiltersPlugin_VerticalFace.cpp
- FiltersPlugin_BelongsTo.cpp
- FiltersPlugin_OnPlane.cpp
+ FiltersPlugin_BelongsTo.cpp
+ FiltersPlugin_OnPlane.cpp
)
SET(PROJECT_LIBRARIES
#include "FiltersPlugin_OnPlane.h"
#include <ModelAPI_Session.h>
-#include <ModelAPI_Filter.h>
+#include <ModelAPI_FiltersFactory.h>
// the only created instance of this plugin
static FiltersPlugin_Plugin* MY_VIEWFILTERS_INSTANCE = new FiltersPlugin_Plugin();
#include "FiltersPlugin_Selection.h"
-#include <ModelAPI_Session.h>
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_FiltersFactory.h>
+#include <ModelAPI_Session.h>
// identifier of the reverse flag of a filter
static const std::string kReverseAttrID("");
#define FILTERSPLUGIN_SELECTION_H_
#include "FiltersPlugin.h"
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Filter.h>
+#include <ModelAPI_FiltersFeature.h>
/**\class FiltersPlugin_Selection
* \ingroup DataModel
Model_AttributeSelection.h
Model_AttributeSelectionList.h
Model_AttributeTables.h
+ Model_AttributeValidator.h
Model_BodyBuilder.h
Model_Events.h
Model_Expression.h
- Model_Update.h
- Model_Validator.h
+ Model_FeatureValidator.h
+ Model_FiltersFactory.h
Model_ResultBody.h
Model_ResultConstruction.h
Model_ResultPart.h
Model_ResultField.h
Model_ResultGroup.h
Model_ResultParameter.h
- Model_FeatureValidator.h
- Model_AttributeValidator.h
- Model_Filter.h
+ Model_Update.h
+ Model_Validator.h
)
SET(PROJECT_SOURCES
Model_AttributeSelection.cpp
Model_AttributeSelectionList.cpp
Model_AttributeTables.cpp
+ Model_AttributeValidator.cpp
Model_BodyBuilder.cpp
Model_Events.cpp
Model_Expression.cpp
- Model_Update.cpp
- Model_Validator.cpp
+ Model_FeatureValidator.cpp
+ Model_FiltersFactory.cpp
Model_ResultBody.cpp
Model_ResultConstruction.cpp
Model_ResultPart.cpp
Model_ResultField.cpp
Model_ResultGroup.cpp
Model_ResultParameter.cpp
- Model_FeatureValidator.cpp
- Model_AttributeValidator.cpp
- Model_Filter.cpp
+ Model_Update.cpp
+ Model_Validator.cpp
)
SET(PROJECT_LIBRARIES
+++ /dev/null
-// 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
-//
-
-#include "Model_Filter.h"
-
-#include "ModelAPI_AttributeBoolean.h"
-#include "ModelAPI_AttributeSelectionList.h"
-#include <Events_InfoMessage.h>
-
-
-void Model_FiltersFactory::registerFilter(const std::string& theID, ModelAPI_Filter* theFilter)
-{
- if (myFilters.find(theID) != myFilters.end()) {
- Events_InfoMessage("Model_FiltersFactory", "Filter %1 is already registered").arg(theID).send();
- }
- else {
- myFilters[theID] = FilterPtr(theFilter);
- }
-}
-
-struct FilterArgs {
- FilterPtr myFilter;
- bool myReverse;
- std::string myFilterID;
-};
-
-bool Model_FiltersFactory::isValid(FeaturePtr theFiltersFeature, GeomShapePtr theShape)
-{
- // check that the shape type corresponds to the attribute list type
- AttributePtr aBase =
- std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theFiltersFeature)->baseAttribute();
- if (aBase.get()) {
- std::shared_ptr<ModelAPI_AttributeSelectionList> aList =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aBase);
- std::string aStrType = aList->selectionType();
- GeomAPI_Shape::ShapeType aType = GeomAPI_Shape::shapeTypeByStr(aStrType);
- if (theShape->shapeType() != aType)
- return false;
- }
- // prepare all filters args
- ModelAPI_FiltersArgs anArgs;
- std::list<FilterArgs> aFilters; /// all filters and the reverse values
-
- std::list<std::string> aGroups;
- theFiltersFeature->data()->allGroups(aGroups);
- for(std::list<std::string>::iterator aGIter = aGroups.begin(); aGIter != aGroups.end(); aGIter++)
- {
- if (myFilters.find(*aGIter) == myFilters.end())
- continue;
- std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs;
- theFiltersFeature->data()->attributesOfGroup(*aGIter, anAttrs);
- std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttrIter = anAttrs.begin();
- for(; anAttrIter != anAttrs.end(); anAttrIter++) {
- std::string anArgID = (*anAttrIter)->id().substr((*aGIter).length() + 2);
- if (anArgID.empty()) { // reverse flag
- std::shared_ptr<ModelAPI_AttributeBoolean> aReverse =
- std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(*anAttrIter);
- FilterArgs aFArgs = { myFilters[*aGIter] , aReverse->value() , *aGIter };
- aFilters.push_back(aFArgs);
-
- } else {
- anArgs.add(*anAttrIter);
- }
- }
- }
-
- // iterate filters and check shape for validity for all of them
- std::list<FilterArgs>::iterator aFilter = aFilters.begin();
- for(; aFilter != aFilters.end(); aFilter++) {
- anArgs.setFilter(aFilter->myFilterID);
- bool aResult = aFilter->myFilter->isOk(theShape, anArgs);
- if (aFilter->myReverse)
- aResult = !aResult;
- if (!aResult) // one filter is failed => exit immediately
- return false;
- }
- // all filters are passed
- return true;
-}
-
-/// Returns list of filters for the given shape type
-/// \param theType a shape type
-std::list<FilterPtr> Model_FiltersFactory::filters(GeomAPI_Shape::ShapeType theType)
-{
- std::list<FilterPtr> aResult;
- std::map<std::string, FilterPtr>::const_iterator anIt;
- std::list<int> aTypes;
- std::list<int>::const_iterator aTIt;
- for (anIt = myFilters.cbegin(); anIt != myFilters.cend(); anIt++) {
- if (anIt->second->isSupported(theType))
- aResult.push_back(anIt->second);
- }
- return aResult;
-}
-
-FilterPtr Model_FiltersFactory::filter(std::string theID)
-{
- std::map<std::string, FilterPtr>::iterator aFound = myFilters.find(theID);
- return aFound == myFilters.end() ? FilterPtr() : aFound->second;
-}
-
-std::string Model_FiltersFactory::id(FilterPtr theFilter)
-{
- std::map<std::string, FilterPtr>::iterator anIter = myFilters.begin();
- for(; anIter != myFilters.end(); anIter++) {
- if (anIter->second == theFilter)
- return anIter->first;
- }
- return ""; // unknown case
-}
+++ /dev/null
-// 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 Model_Filter_H_
-#define Model_Filter_H_
-
-#include "Model.h"
-
-#include <ModelAPI_Filter.h>
-
-#include <map>
-
-
-/**\class Model_ValidatorsFactory
-* \ingroup DataModel
-* \brief Manages registering of filters
-*/
-class Model_FiltersFactory : public ModelAPI_FiltersFactory
-{
-public:
- /// Register an instance of a filter
- /// \param theID unique identifier of the filter, not necessary equal to the name of filter
- /// \param theFilter the filter's instance
- virtual void registerFilter(const std::string& theID, ModelAPI_Filter* theFilter);
-
- /// Returns true if all filters of the Filters feature are ok for the Shape (taking into account
- /// the Reversed states).
- /// \param theFiltersFeature feature that contains all information about the filters
- /// \param theShape the checked shape
- virtual bool isValid(FeaturePtr theFiltersFeature, GeomShapePtr theShape);
-
- /// Returns the filters that support the given shape type
- virtual std::list<FilterPtr> filters(GeomAPI_Shape::ShapeType theType);
-
- /// Returns a filter by ID
- virtual FilterPtr filter(std::string theID);
-
- /// Returns a filter ID by the filter pointer
- virtual std::string id(FilterPtr theFilter);
-
-protected:
- /// Get instance from Session
- Model_FiltersFactory() {}
-
-private:
- std::map<std::string, FilterPtr> myFilters; ///< map from ID to registered filters
-
- friend class Model_Session;
-};
-
-#endif
\ No newline at end of file
--- /dev/null
+// 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
+//
+
+#include "Model_FiltersFactory.h"
+
+#include "ModelAPI_AttributeBoolean.h"
+#include "ModelAPI_AttributeSelectionList.h"
+#include <Events_InfoMessage.h>
+
+
+void Model_FiltersFactory::registerFilter(const std::string& theID, ModelAPI_Filter* theFilter)
+{
+ if (myFilters.find(theID) != myFilters.end()) {
+ Events_InfoMessage("Model_FiltersFactory", "Filter %1 is already registered").arg(theID).send();
+ }
+ else {
+ myFilters[theID] = FilterPtr(theFilter);
+ }
+}
+
+struct FilterArgs {
+ FilterPtr myFilter;
+ bool myReverse;
+ std::string myFilterID;
+};
+
+bool Model_FiltersFactory::isValid(FeaturePtr theFiltersFeature, GeomShapePtr theShape)
+{
+ // check that the shape type corresponds to the attribute list type
+ AttributePtr aBase =
+ std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theFiltersFeature)->baseAttribute();
+ if (aBase.get()) {
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aBase);
+ std::string aStrType = aList->selectionType();
+ GeomAPI_Shape::ShapeType aType = GeomAPI_Shape::shapeTypeByStr(aStrType);
+ if (theShape->shapeType() != aType)
+ return false;
+ }
+ // prepare all filters args
+ ModelAPI_FiltersArgs anArgs;
+ std::list<FilterArgs> aFilters; /// all filters and the reverse values
+
+ std::list<std::string> aGroups;
+ theFiltersFeature->data()->allGroups(aGroups);
+ for(std::list<std::string>::iterator aGIter = aGroups.begin(); aGIter != aGroups.end(); aGIter++)
+ {
+ if (myFilters.find(*aGIter) == myFilters.end())
+ continue;
+ std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs;
+ theFiltersFeature->data()->attributesOfGroup(*aGIter, anAttrs);
+ std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttrIter = anAttrs.begin();
+ for(; anAttrIter != anAttrs.end(); anAttrIter++) {
+ std::string anArgID = (*anAttrIter)->id().substr((*aGIter).length() + 2);
+ if (anArgID.empty()) { // reverse flag
+ std::shared_ptr<ModelAPI_AttributeBoolean> aReverse =
+ std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(*anAttrIter);
+ FilterArgs aFArgs = { myFilters[*aGIter] , aReverse->value() , *aGIter };
+ aFilters.push_back(aFArgs);
+
+ } else {
+ anArgs.add(*anAttrIter);
+ }
+ }
+ }
+
+ // iterate filters and check shape for validity for all of them
+ std::list<FilterArgs>::iterator aFilter = aFilters.begin();
+ for(; aFilter != aFilters.end(); aFilter++) {
+ anArgs.setFilter(aFilter->myFilterID);
+ bool aResult = aFilter->myFilter->isOk(theShape, anArgs);
+ if (aFilter->myReverse)
+ aResult = !aResult;
+ if (!aResult) // one filter is failed => exit immediately
+ return false;
+ }
+ // all filters are passed
+ return true;
+}
+
+/// Returns list of filters for the given shape type
+/// \param theType a shape type
+std::list<FilterPtr> Model_FiltersFactory::filters(GeomAPI_Shape::ShapeType theType)
+{
+ std::list<FilterPtr> aResult;
+ std::map<std::string, FilterPtr>::const_iterator anIt;
+ std::list<int> aTypes;
+ std::list<int>::const_iterator aTIt;
+ for (anIt = myFilters.cbegin(); anIt != myFilters.cend(); anIt++) {
+ if (anIt->second->isSupported(theType))
+ aResult.push_back(anIt->second);
+ }
+ return aResult;
+}
+
+FilterPtr Model_FiltersFactory::filter(std::string theID)
+{
+ std::map<std::string, FilterPtr>::iterator aFound = myFilters.find(theID);
+ return aFound == myFilters.end() ? FilterPtr() : aFound->second;
+}
+
+std::string Model_FiltersFactory::id(FilterPtr theFilter)
+{
+ std::map<std::string, FilterPtr>::iterator anIter = myFilters.begin();
+ for(; anIter != myFilters.end(); anIter++) {
+ if (anIter->second == theFilter)
+ return anIter->first;
+ }
+ return ""; // unknown case
+}
--- /dev/null
+// 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 Model_FiltersFactory_H_
+#define Model_FiltersFactory_H_
+
+#include "Model.h"
+
+#include <ModelAPI_FiltersFactory.h>
+
+#include <map>
+
+
+/**\class Model_FiltersFactory
+* \ingroup DataModel
+* \brief Manages registering of filters
+*/
+class Model_FiltersFactory : public ModelAPI_FiltersFactory
+{
+public:
+ /// Register an instance of a filter
+ /// \param theID unique identifier of the filter, not necessary equal to the name of filter
+ /// \param theFilter the filter's instance
+ virtual void registerFilter(const std::string& theID, ModelAPI_Filter* theFilter);
+
+ /// Returns true if all filters of the Filters feature are ok for the Shape (taking into account
+ /// the Reversed states).
+ /// \param theFiltersFeature feature that contains all information about the filters
+ /// \param theShape the checked shape
+ virtual bool isValid(FeaturePtr theFiltersFeature, GeomShapePtr theShape);
+
+ /// Returns the filters that support the given shape type
+ virtual std::list<FilterPtr> filters(GeomAPI_Shape::ShapeType theType);
+
+ /// Returns a filter by ID
+ virtual FilterPtr filter(std::string theID);
+
+ /// Returns a filter ID by the filter pointer
+ virtual std::string id(FilterPtr theFilter);
+
+protected:
+ /// Get instance from Session
+ Model_FiltersFactory() {}
+
+private:
+ std::map<std::string, FilterPtr> myFilters; ///< map from ID to registered filters
+
+ friend class Model_Session;
+};
+
+#endif
\ No newline at end of file
ModelAPI_CompositeFeature.h
ModelAPI_Data.h
ModelAPI_Document.h
+ ModelAPI_Entity.h
ModelAPI_EventReentrantMessage.h
ModelAPI_Events.h
ModelAPI_Expression.h
ModelAPI_Feature.h
ModelAPI_FeatureValidator.h
+ ModelAPI_Filter.h
+ ModelAPI_FiltersArgs.h
+ ModelAPI_FiltersFactory.h
+ ModelAPI_FiltersFeature.h
ModelAPI_Folder.h
ModelAPI_IReentrant.h
ModelAPI_Object.h
ModelAPI_Session.h
ModelAPI_Tools.h
ModelAPI_Validator.h
- ModelAPI_Entity.h
- ModelAPI_Filter.h
)
SET(PROJECT_SOURCES
ModelAPI_AttributeString.cpp
ModelAPI_AttributeStringArray.cpp
ModelAPI_AttributeTables.cpp
+ ModelAPI_AttributeValidator.cpp
ModelAPI_BodyBuilder.cpp
ModelAPI_CompositeFeature.cpp
ModelAPI_Data.cpp
ModelAPI_ResultParameter.cpp
ModelAPI_Session.cpp
ModelAPI_Tools.cpp
- ModelAPI_AttributeValidator.cpp
)
SET(PROJECT_LIBRARIES
#ifndef ModelAPI_Filter_H_
#define ModelAPI_Filter_H_
-#include "ModelAPI.h"
-#include "ModelAPI_Attribute.h"
-#include "ModelAPI_Feature.h"
-
-#include "ModelAPI_Data.h"
+#include "ModelAPI_FiltersArgs.h"
#include <GeomAPI_Shape.h>
-#include <map>
-
-/// separator between the filter name and the filter attribute ID
-static const std::string kFilterSeparator = "__";
-
-/**\class ModelAPI_FiltersFeature
-* \ingroup DataModel
-* \brief An interface for working with filters in the feature. A filters feature must inherit it
-* in order to allow management of filters in the feature data structure.
-*/
-class ModelAPI_FiltersFeature: public ModelAPI_Feature
-{
-public:
- /// Adds a filter to the feature. Also initializes arguments of this filter.
- virtual void addFilter(const std::string theFilterID) = 0;
-
- /// Removes an existing filter from the feature.
- virtual void removeFilter(const std::string theFilterID) = 0;
-
- /// Returns the list of existing filters in the feature.
- virtual std::list<std::string> filters() const = 0;
- /// Stores the reversed flag for the filter.
- virtual void setReversed(const std::string theFilterID, const bool theReversed) = 0;
-
- /// Returns the reversed flag value for the filter.
- virtual bool isReversed(const std::string theFilterID) = 0;
-
- /// Returns the ordered list of attributes related to the filter.
- virtual std::list<AttributePtr> filterArgs(const std::string theFilterID) const = 0;
-
- /// Sets the attribute (not-persistent field) that contains this filters feature.
- /// The filter feature may make synchronization by this method call.
- virtual void setAttribute(const AttributePtr& theAttr) = 0;
-
- /// Returns the attribute (not-persistent field) that contains this filters feature.
- virtual const AttributePtr& baseAttribute() const = 0;
-};
-
-typedef std::shared_ptr<ModelAPI_FiltersFeature> FiltersFeaturePtr;
-
-
-/// definition of arguments of filters: id of the argument to attributes
-class ModelAPI_FiltersArgs {
- /// a map from the FilterID+AttributeID -> attribute
- std::map<std::string, AttributePtr> 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<ModelAPI_Attribute> 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;
- }
-};
/**\class ModelAPI_ViewFilter
* \ingroup DataModel
typedef std::shared_ptr<ModelAPI_Filter> FilterPtr;
-
-/**\class ModelAPI_FiltersFactory
-* \ingroup DataModel
-* \brief Manages registering of filters
-*/
-class ModelAPI_FiltersFactory
-{
-public:
- /// Register an instance of a filter
- /// \param theID unique identifier of the filter, not necessary equal to the name of filter
- /// \param theFilter the filter's instance
- virtual void registerFilter(const std::string& theID, ModelAPI_Filter* theFilter) = 0;
-
- /// Returns true if all filters of the Filters feature are ok for the Shape (taking into account
- /// the Reversed states).
- /// \param theFiltersFeature feature that contains all information about the filters
- /// \param theShape the checked shape
- virtual bool isValid(FeaturePtr theFiltersFeature, GeomShapePtr theShape) = 0;
-
- /// Returns the filters that support the given shape type
- virtual std::list<FilterPtr> filters(GeomAPI_Shape::ShapeType theType) = 0;
-
- /// Returns a filter by ID
- virtual FilterPtr filter(std::string theID) = 0;
-
- /// Returns a filter ID by the filter pointer
- virtual std::string id(FilterPtr theFilter) = 0;
-
-protected:
- /// Get instance from Session
- ModelAPI_FiltersFactory() {}
-};
-
#endif
\ No newline at end of file
--- /dev/null
+// 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 <map>
+
+/// 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<std::string, AttributePtr> 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<ModelAPI_Attribute> 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
--- /dev/null
+// 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_FiltersFactory_H_
+#define ModelAPI_FiltersFactory_H_
+
+#include "ModelAPI_Feature.h"
+#include "ModelAPI_Filter.h"
+
+#include <GeomAPI_Shape.h>
+
+
+/**\class ModelAPI_FiltersFactory
+* \ingroup DataModel
+* \brief Manages registering of filters
+*/
+class ModelAPI_FiltersFactory
+{
+public:
+ /// Register an instance of a filter
+ /// \param theID unique identifier of the filter, not necessary equal to the name of filter
+ /// \param theFilter the filter's instance
+ virtual void registerFilter(const std::string& theID, ModelAPI_Filter* theFilter) = 0;
+
+ /// Returns true if all filters of the Filters feature are ok for the Shape (taking into account
+ /// the Reversed states).
+ /// \param theFiltersFeature feature that contains all information about the filters
+ /// \param theShape the checked shape
+ virtual bool isValid(FeaturePtr theFiltersFeature, GeomShapePtr theShape) = 0;
+
+ /// Returns the filters that support the given shape type
+ virtual std::list<FilterPtr> filters(GeomAPI_Shape::ShapeType theType) = 0;
+
+ /// Returns a filter by ID
+ virtual FilterPtr filter(std::string theID) = 0;
+
+ /// Returns a filter ID by the filter pointer
+ virtual std::string id(FilterPtr theFilter) = 0;
+
+protected:
+ /// Get instance from Session
+ ModelAPI_FiltersFactory() {}
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// 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_FiltersFeature_H_
+#define ModelAPI_FiltersFeature_H_
+
+#include "ModelAPI_Attribute.h"
+#include "ModelAPI_Feature.h"
+
+
+/**\class ModelAPI_FiltersFeature
+* \ingroup DataModel
+* \brief An interface for working with filters in the feature. A filters feature must inherit it
+* in order to allow management of filters in the feature data structure.
+*/
+class ModelAPI_FiltersFeature: public ModelAPI_Feature
+{
+public:
+ /// Adds a filter to the feature. Also initializes arguments of this filter.
+ virtual void addFilter(const std::string theFilterID) = 0;
+
+ /// Removes an existing filter from the feature.
+ virtual void removeFilter(const std::string theFilterID) = 0;
+
+ /// Returns the list of existing filters in the feature.
+ virtual std::list<std::string> filters() const = 0;
+
+ /// Stores the reversed flag for the filter.
+ virtual void setReversed(const std::string theFilterID, const bool theReversed) = 0;
+
+ /// Returns the reversed flag value for the filter.
+ virtual bool isReversed(const std::string theFilterID) = 0;
+
+ /// Returns the ordered list of attributes related to the filter.
+ virtual std::list<AttributePtr> filterArgs(const std::string theFilterID) const = 0;
+
+ /// Sets the attribute (not-persistent field) that contains this filters feature.
+ /// The filter feature may make synchronization by this method call.
+ virtual void setAttribute(const AttributePtr& theAttr) = 0;
+
+ /// Returns the attribute (not-persistent field) that contains this filters feature.
+ virtual const AttributePtr& baseAttribute() const = 0;
+};
+
+typedef std::shared_ptr<ModelAPI_FiltersFeature> FiltersFeaturePtr;
+
+#endif
\ No newline at end of file
#include <ModelAPI_Session.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_FiltersFactory.h>
#include <ModelAPI_ResultBody.h>
#include <GeomAPI_ShapeExplorer.h>
#include "ModuleBase_ModelWidget.h"
#include "ModuleBase_ViewerPrs.h"
-#include <ModelAPI_Filter.h>
+#include <ModelAPI_FiltersFeature.h>
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <AIS_Shape.hxx>