From: azv Date: Fri, 21 Jun 2019 08:38:50 +0000 (+0300) Subject: Implement dumping filters to Python X-Git-Tag: VEDF2019Lot4~101^2~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86f8397a0cc86e83d5f963aaadffb3d765fc836a;p=modules%2Fshaper.git Implement dumping filters to Python --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 80fba2970..f03e21f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,7 @@ ADD_SUBDIRECTORY (src/PrimitivesAPI) ADD_SUBDIRECTORY (src/SketchAPI) ADD_SUBDIRECTORY (src/GDMLAPI) ADD_SUBDIRECTORY (src/ConnectorAPI) +ADD_SUBDIRECTORY (src/FiltersAPI) # Tests ADD_SUBDIRECTORY (test.API/SHAPER) diff --git a/src/FiltersAPI/CMakeLists.txt b/src/FiltersAPI/CMakeLists.txt new file mode 100644 index 000000000..f0ff3da60 --- /dev/null +++ b/src/FiltersAPI/CMakeLists.txt @@ -0,0 +1,91 @@ +# 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(Common) + +SET(PROJECT_HEADERS + FiltersAPI.h + FiltersAPI_Feature.h + FiltersAPI_Filter.h + FiltersAPI_Selection.h +) + +SET(PROJECT_SOURCES + FiltersAPI_Feature.cpp + FiltersAPI_Filter.cpp + FiltersAPI_Selection.cpp +) + +SET(PROJECT_LIBRARIES + ModelAPI + ModelHighAPI +) + +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/Events + ${PROJECT_SOURCE_DIR}/src/GeomAPI + ${PROJECT_SOURCE_DIR}/src/GeomDataAPI + ${PROJECT_SOURCE_DIR}/src/ModelAPI + ${PROJECT_SOURCE_DIR}/src/ModelHighAPI +) + +# Plugin headers dependency +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/FiltersPlugin +) + +ADD_DEFINITIONS(-DFILTERSAPI_EXPORTS) +ADD_LIBRARY(FiltersAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(FiltersAPI ${PROJECT_LIBRARIES}) + +# SWIG wrapper + +INCLUDE(PythonAPI) + +SET_SOURCE_FILES_PROPERTIES(FiltersAPI.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(FiltersAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow") + +SET(SWIG_LINK_LIBRARIES + FiltersAPI + ModelHighAPI + ModelAPI + ${PYTHON_LIBRARIES} +) +SET(CMAKE_SWIG_FLAGS -threads -w325,321,302,362,322,383,403) + +SET(SWIG_MODULE_FiltersAPI_EXTRA_DEPS ${SWIG_MODULE_FiltersAPI_EXTRA_DEPS} + ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i + doxyhelp.i + ${PROJECT_HEADERS} +) + +IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0") + SWIG_ADD_LIBRARY(FiltersAPI LANGUAGE python SOURCES FiltersAPI.i ${PROJECT_HEADERS}) +ELSE() + SWIG_ADD_MODULE(FiltersAPI python FiltersAPI.i ${PROJECT_HEADERS}) +ENDIF() +SWIG_LINK_LIBRARIES(FiltersAPI ${SWIG_LINK_LIBRARIES}) + +IF(WIN32) + SET_TARGET_PROPERTIES(_FiltersAPI PROPERTIES DEBUG_OUTPUT_NAME _FiltersAPI_d) +ENDIF(WIN32) + +INSTALL(TARGETS _FiltersAPI DESTINATION ${SHAPER_INSTALL_SWIG}) +INSTALL(TARGETS FiltersAPI DESTINATION ${SHAPER_INSTALL_BIN}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/FiltersAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) diff --git a/src/FiltersAPI/FiltersAPI.h b/src/FiltersAPI/FiltersAPI.h new file mode 100644 index 000000000..509588b0c --- /dev/null +++ b/src/FiltersAPI/FiltersAPI.h @@ -0,0 +1,37 @@ +// 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 FILTERSAPI_H +#define FILTERSAPI_H + +#if defined FILTERSAPI_EXPORTS +#if defined WIN32 +#define FILTERSAPI_EXPORT __declspec( dllexport ) +#else +#define FILTERSAPI_EXPORT +#endif +#else +#if defined WIN32 +#define FILTERSAPI_EXPORT __declspec( dllimport ) +#else +#define FILTERSAPI_EXPORT +#endif +#endif + +#endif diff --git a/src/FiltersAPI/FiltersAPI.i b/src/FiltersAPI/FiltersAPI.i new file mode 100644 index 000000000..6249bfe4a --- /dev/null +++ b/src/FiltersAPI/FiltersAPI.i @@ -0,0 +1,57 @@ +// 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 +// + +/* FiltersAPI.i */ + +%module FiltersAPI + +%{ + #include "FiltersAPI_swig.h" + + // fix for SWIG v2.0.4 + #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) +%} + +%include "doxyhelp.i" + +// import other modules +%import "ModelHighAPI.i" + +// to avoid error on this +#define FILTERSAPI_EXPORT + +// standard definitions +%include "typemaps.i" +%include "std_list.i" +%include "std_shared_ptr.i" + +// shared pointers +%shared_ptr(FiltersAPI_Feature) +%shared_ptr(FiltersAPI_Filter) + +// std::list -> [] +%template(FilterList) std::list >; + +// function with named parameters +%feature("kwargs") addFilter; + +// all supported interfaces +%include "FiltersAPI_Feature.h" +%include "FiltersAPI_Filter.h" +%include "FiltersAPI_Selection.h" diff --git a/src/FiltersAPI/FiltersAPI_Feature.cpp b/src/FiltersAPI/FiltersAPI_Feature.cpp new file mode 100644 index 000000000..9829d9b87 --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_Feature.cpp @@ -0,0 +1,65 @@ +// 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 "FiltersAPI_Feature.h" + +#include + +#include + +FiltersAPI_Feature::FiltersAPI_Feature( + const std::shared_ptr & theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +FiltersAPI_Feature::~FiltersAPI_Feature() +{ +} + +void FiltersAPI_Feature::setFilters(const std::list& theFilters) +{ + FiltersFeaturePtr aBase = std::dynamic_pointer_cast(feature()); + for (std::list::const_iterator anIt = theFilters.begin(); + anIt != theFilters.end(); ++anIt) { + aBase->addFilter((*anIt)->name()); + aBase->setReversed((*anIt)->name(), (*anIt)->isReversed()); + } +} + +void FiltersAPI_Feature::dump(ModelHighAPI_Dumper& theDumper) const +{ + FiltersFeaturePtr aBase = std::dynamic_pointer_cast(feature()); + if (!aBase) + return; + + const std::string& aDocName = theDumper.name(aBase->document()); + theDumper << "model.filters(" << aDocName << ", ["; + + std::list aFilters = aBase->filters(); + for (std::list::iterator aFIt = aFilters.begin(); aFIt != aFilters.end(); ++aFIt) { + FiltersAPI_Filter aFilter(*aFIt, aBase->filterArgs(*aFIt)); + if (aFIt != aFilters.begin()) + theDumper << ", "; + aFilter.dump(theDumper); + } + + theDumper << "])"; +} diff --git a/src/FiltersAPI/FiltersAPI_Feature.h b/src/FiltersAPI/FiltersAPI_Feature.h new file mode 100644 index 000000000..2864001e5 --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_Feature.h @@ -0,0 +1,61 @@ +// 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 FILTERSAPI_FEATURE_H_ +#define FILTERSAPI_FEATURE_H_ + +#include "FiltersAPI.h" +#include "FiltersAPI_Filter.h" + +#include +#include + +#include + +class ModelAPI_Feature; + +/**\class FiltersAPI_Feature + * \ingroup CPPHighAPI + * \brief Interface for the list of filters + */ +class FiltersAPI_Feature : public ModelHighAPI_Interface +{ +public: + /// Constructor without values + FILTERSAPI_EXPORT + explicit FiltersAPI_Feature(const std::shared_ptr & theFeature); + + /// Destructor + FILTERSAPI_EXPORT + virtual ~FiltersAPI_Feature(); + + INTERFACE_0(FiltersPlugin_Selection::ID()) + + /// assign list of filters + FILTERSAPI_EXPORT + void setFilters(const std::list& theFilters); + + /// Dump wrapped feature + FILTERSAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +typedef std::shared_ptr FiltersPtr; + +#endif diff --git a/src/FiltersAPI/FiltersAPI_Filter.cpp b/src/FiltersAPI/FiltersAPI_Filter.cpp new file mode 100644 index 000000000..668a89f7b --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_Filter.cpp @@ -0,0 +1,81 @@ +// 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 "FiltersAPI_Filter.h" + +#include +#include +#include + +#include + +FiltersAPI_Filter::FiltersAPI_Filter( + const std::string& theName, + const bool theRevertFilter, + const std::list& theArguments) + : myName(theName), myReversed(theRevertFilter), myFilterArguments(theArguments) +{ +} + +FiltersAPI_Filter::FiltersAPI_Filter(const std::string& theName, + const std::list& theArguments) + : myName(theName) +{ + for (std::list::const_iterator anArgIt = theArguments.begin(); + anArgIt != theArguments.end(); ++anArgIt) { + AttributeBooleanPtr aBoolAttr = + std::dynamic_pointer_cast(*anArgIt); + if (aBoolAttr) + myReversed = aBoolAttr->value(); + else { + AttributeSelectionListPtr aSelList = + std::dynamic_pointer_cast(*anArgIt); + if (aSelList) { + int aSize = aSelList->size(); + for (int i = 0; i < aSize; ++i) { + AttributeSelectionPtr aSelection = aSelList->value(i); + myFilterArguments.push_back( + ModelHighAPI_Selection(aSelection->context(), aSelection->value())); + } + } + } + } +} + +FiltersAPI_Filter::~FiltersAPI_Filter() +{ +} + +void FiltersAPI_Filter::dump(ModelHighAPI_Dumper& theDumper) const +{ + theDumper << "model.addFilter(name = \"" << myName << "\""; + if (myReversed) + theDumper << ", exclude = " << myReversed; + if (!myFilterArguments.empty()) + theDumper << ", args = []"; + theDumper << ")"; +} + +// ================================================================================================ +FilterAPIPtr addFilter(const std::string& name, + const bool exclude, + const std::list& args) +{ + return FilterAPIPtr(new FiltersAPI_Filter(name, exclude, args)); +} diff --git a/src/FiltersAPI/FiltersAPI_Filter.h b/src/FiltersAPI/FiltersAPI_Filter.h new file mode 100644 index 000000000..7621b819b --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_Filter.h @@ -0,0 +1,73 @@ +// 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 FILTERSAPI_FILTER_H_ +#define FILTERSAPI_FILTER_H_ + +#include "FiltersAPI.h" + +#include +#include + +class ModelAPI_Attribute; + +/**\class FiltersAPI_Filter + * \ingroup CPPHighAPI + * \brief Interface for the Filter + */ +class FiltersAPI_Filter +{ +public: + FILTERSAPI_EXPORT + FiltersAPI_Filter( + const std::string& theName, + const bool theRevertFilter = false, + const std::list& theArguments = std::list()); + + // Internal constructor based on filter arguments + FILTERSAPI_EXPORT + FiltersAPI_Filter(const std::string& theName, + const std::list >& theArguments); + + /// Destructor + FILTERSAPI_EXPORT + virtual ~FiltersAPI_Filter(); + + const std::string& name() const { return myName; } + bool isReversed() const { return myReversed; } + + /// Dump wrapped feature + FILTERSAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; + +private: + std::string myName; + bool myReversed; + std::list myFilterArguments; +}; + +typedef std::shared_ptr FilterAPIPtr; + +/// Create list of filters +FILTERSAPI_EXPORT FilterAPIPtr +addFilter(const std::string& name = std::string(), + const bool exclude = false, + const std::list& args = std::list()); + +#endif diff --git a/src/FiltersAPI/FiltersAPI_Selection.cpp b/src/FiltersAPI/FiltersAPI_Selection.cpp new file mode 100644 index 000000000..93a4444d9 --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_Selection.cpp @@ -0,0 +1,40 @@ +// 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 "FiltersAPI_Selection.h" + +FiltersAPI_Selection::FiltersAPI_Selection(const FiltersPtr & theFeature) +{ + myVariantType = VT_Filtering; + myFilterFeature = std::dynamic_pointer_cast(theFeature->feature()); +} + +FiltersAPI_Selection::~FiltersAPI_Selection() +{ +} + +// ================================================================================================ +FiltersAPI_Selection filters(const std::shared_ptr& thePart, + const std::list& theFilters) +{ + FeaturePtr aFeature = thePart->addFeature(FiltersPlugin_Selection::ID()); + FiltersPtr aFiltersFeature(new FiltersAPI_Feature(aFeature)); + aFiltersFeature->setFilters(theFilters); + return FiltersAPI_Selection(aFiltersFeature); +} diff --git a/src/FiltersAPI/FiltersAPI_Selection.h b/src/FiltersAPI/FiltersAPI_Selection.h new file mode 100644 index 000000000..10e9b4560 --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_Selection.h @@ -0,0 +1,50 @@ +// 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 FILTERSAPI_SELECTION_H_ +#define FILTERSAPI_SELECTION_H_ + +#include "FiltersAPI.h" +#include "FiltersAPI_Feature.h" + +#include + + +/**\class FiltersAPI_Selection + * \ingroup CPPHighAPI + * \brief Interface for the selection of filters + */ +class FiltersAPI_Selection : public ModelHighAPI_Selection +{ +public: + /// Constructor without values + FILTERSAPI_EXPORT + explicit FiltersAPI_Selection(const FiltersPtr& theFeature); + + /// Destructor + FILTERSAPI_EXPORT + virtual ~FiltersAPI_Selection(); +}; + +/// Create list of filters +FILTERSAPI_EXPORT +FiltersAPI_Selection filters(const std::shared_ptr& thePart, + const std::list& theFilters); + +#endif diff --git a/src/FiltersAPI/FiltersAPI_swig.h b/src/FiltersAPI/FiltersAPI_swig.h new file mode 100644 index 000000000..2681f4801 --- /dev/null +++ b/src/FiltersAPI/FiltersAPI_swig.h @@ -0,0 +1,30 @@ +// 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 FiltersAPI_swig_H_ +#define FiltersAPI_swig_H_ + + #include + + #include "FiltersAPI.h" + #include "FiltersAPI_Feature.h" + #include "FiltersAPI_Filter.h" + #include "FiltersAPI_Selection.h" + +#endif // FiltersAPI_swig_H_ diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 39b3cbe75..80a7440f2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1340,6 +1341,13 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( *this << anAttribute; } + // check selection list is obtained by filters + FiltersFeaturePtr aFilters = theAttrSelList->filters(); + if (aFilters) { + *myDumpStorage << ", "; + dumpFeature(aFilters, true); + } + *myDumpStorage << "]"; } else { // obtain name of list (the feature may contain several selection lists) diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index cb74050bc..30f92c222 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -133,6 +133,9 @@ void ModelHighAPI_Selection::appendToList( theAttribute->append( myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); return; + case VT_Filtering: + theAttribute->setFilters(myFilterFeature); + return; } } diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.h b/src/ModelHighAPI/ModelHighAPI_Selection.h index 52b9b4050..3ef133dd9 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.h +++ b/src/ModelHighAPI/ModelHighAPI_Selection.h @@ -32,6 +32,7 @@ class GeomAPI_Pnt; class GeomAPI_Shape; class ModelAPI_AttributeSelection; class ModelAPI_AttributeSelectionList; +class ModelAPI_FiltersFeature; class ModelAPI_Result; //-------------------------------------------------------------------------------------- typedef std::pair, std::shared_ptr > @@ -52,7 +53,8 @@ public: VT_ResultSubShapePair, VT_TypeSubShapeNamePair, VT_TypeInnerPointPair, - VT_WeakNamingPair + VT_WeakNamingPair, + VT_Filtering }; public: @@ -150,12 +152,13 @@ public: MODELHIGHAPI_EXPORT ModelHighAPI_Selection subResult(int theIndex) const; -private: +protected: VariantType myVariantType; ResultSubShapePair myResultSubShapePair; TypeSubShapeNamePair myTypeSubShapeNamePair; TypeInnerPointPair myTypeInnerPointPair; TypeWeakNamingPair myWeakNamingPair; + std::shared_ptr myFilterFeature; }; //-------------------------------------------------------------------------------------- diff --git a/src/PythonAPI/model/__init__.py b/src/PythonAPI/model/__init__.py index 08f3d8650..8bdbd49a8 100644 --- a/src/PythonAPI/model/__init__.py +++ b/src/PythonAPI/model/__init__.py @@ -37,6 +37,7 @@ from .connection import * from .construction import * from .exchange import * from .features import * +from .filters import * from .collection import * from .parameter import * from .partset import * diff --git a/src/PythonAPI/model/filters/__init__.py b/src/PythonAPI/model/filters/__init__.py new file mode 100644 index 000000000..054620430 --- /dev/null +++ b/src/PythonAPI/model/filters/__init__.py @@ -0,0 +1,22 @@ +# Copyright (C) 2015-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 +# +"""Package for Filters plugin for the Parametric Geometry API of the Modeler. +""" + +from FiltersAPI import filters, addFilter