From d4230889a1c3107f165746d0e73fc276444a4396 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 4 Jul 2019 16:46:23 +0300 Subject: [PATCH] Move representations of filters to separate XML files. --- src/FiltersPlugin/CMakeLists.txt | 7 ++++ src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp | 12 +------ .../FiltersPlugin_OnGeometry.cpp | 13 +------ src/FiltersPlugin/FiltersPlugin_OnLine.cpp | 13 +------ src/FiltersPlugin/FiltersPlugin_OnPlane.cpp | 13 +------ .../FiltersPlugin_OnPlaneSide.cpp | 13 +------ .../FiltersPlugin_OppositeToEdge.cpp | 13 +------ .../FiltersPlugin_RelativeToSolid.cpp | 21 +---------- src/FiltersPlugin/filter-BelongsTo.xml | 7 ++++ src/FiltersPlugin/filter-OnGeometry.xml | 8 +++++ src/FiltersPlugin/filter-OnLine.xml | 8 +++++ src/FiltersPlugin/filter-OnPlane.xml | 8 +++++ src/FiltersPlugin/filter-OnPlaneSide.xml | 8 +++++ src/FiltersPlugin/filter-OppositeToEdge.xml | 8 +++++ src/FiltersPlugin/filter-RelativeToSolid.xml | 16 +++++++++ src/ModelAPI/CMakeLists.txt | 1 + src/ModelAPI/ModelAPI_Filter.cpp | 36 +++++++++++++++++++ src/ModelAPI/ModelAPI_Filter.h | 5 +++ 18 files changed, 119 insertions(+), 91 deletions(-) create mode 100644 src/FiltersPlugin/filter-BelongsTo.xml create mode 100644 src/FiltersPlugin/filter-OnGeometry.xml create mode 100644 src/FiltersPlugin/filter-OnLine.xml create mode 100644 src/FiltersPlugin/filter-OnPlane.xml create mode 100644 src/FiltersPlugin/filter-OnPlaneSide.xml create mode 100644 src/FiltersPlugin/filter-OppositeToEdge.xml create mode 100644 src/FiltersPlugin/filter-RelativeToSolid.xml create mode 100644 src/ModelAPI/ModelAPI_Filter.cpp diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index 75ebaf3ef..bc9646cee 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -61,6 +61,13 @@ SET(PROJECT_LIBRARIES SET(XML_RESOURCES plugin-Filters.xml + filter-BelongsTo.xml + filter-OnGeometry.xml + filter-OnLine.xml + filter-OnPlane.xml + filter-OnPlaneSide.xml + filter-OppositeToEdge.xml + filter-RelativeToSolid.xml ) ADD_DEFINITIONS(-DFILTERS_EXPORTS ${OpenCASCADE_DEFINITIONS}) diff --git a/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp b/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp index 6a1553ace..9c7010b2d 100644 --- a/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp +++ b/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp @@ -43,19 +43,9 @@ bool FiltersPlugin_BelongsTo::isOk(const GeomShapePtr& theShape, const ResultPtr return false; } -static std::string XMLRepresentation = -"" -" " -" " -""; - - std::string FiltersPlugin_BelongsTo::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-BelongsTo.xml"); } void FiltersPlugin_BelongsTo::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp b/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp index 44d9ff401..c7fa73d32 100644 --- a/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp +++ b/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp @@ -43,20 +43,9 @@ bool FiltersPlugin_OnGeometry::isOk(const GeomShapePtr& theShape, const ResultPt return false; } -static std::string XMLRepresentation = -"" -" " -" " -" " -""; - - std::string FiltersPlugin_OnGeometry::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-OnGeometry.xml"); } void FiltersPlugin_OnGeometry::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/FiltersPlugin_OnLine.cpp b/src/FiltersPlugin/FiltersPlugin_OnLine.cpp index d2e438432..29dc5b461 100644 --- a/src/FiltersPlugin/FiltersPlugin_OnLine.cpp +++ b/src/FiltersPlugin/FiltersPlugin_OnLine.cpp @@ -79,20 +79,9 @@ bool FiltersPlugin_OnLine::isOk(const GeomShapePtr& theShape, const ResultPtr&, return false; } -static std::string XMLRepresentation = -"" -" " -" " -" " -""; - - std::string FiltersPlugin_OnLine::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-OnLine.xml"); } void FiltersPlugin_OnLine::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/FiltersPlugin_OnPlane.cpp b/src/FiltersPlugin/FiltersPlugin_OnPlane.cpp index f7b4a07a6..b9f632956 100644 --- a/src/FiltersPlugin/FiltersPlugin_OnPlane.cpp +++ b/src/FiltersPlugin/FiltersPlugin_OnPlane.cpp @@ -108,20 +108,9 @@ bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape, const ResultPtr&, return false; } -static std::string XMLRepresentation = -"" -" " -" " -" " -""; - - std::string FiltersPlugin_OnPlane::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-OnPlane.xml"); } void FiltersPlugin_OnPlane::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/FiltersPlugin_OnPlaneSide.cpp b/src/FiltersPlugin/FiltersPlugin_OnPlaneSide.cpp index 1d77e6b74..54f8c9391 100644 --- a/src/FiltersPlugin/FiltersPlugin_OnPlaneSide.cpp +++ b/src/FiltersPlugin/FiltersPlugin_OnPlaneSide.cpp @@ -55,20 +55,9 @@ bool FiltersPlugin_OnPlaneSide::isOk(const GeomShapePtr& theShape, const ResultP return aVec->dot(aPlaneNorm->xyz()) > THE_TOLERANCE; } -static std::string XMLRepresentation = -"" -" " -" " -" " -""; - - std::string FiltersPlugin_OnPlaneSide::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-OnPlaneSide.xml"); } void FiltersPlugin_OnPlaneSide::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/FiltersPlugin_OppositeToEdge.cpp b/src/FiltersPlugin/FiltersPlugin_OppositeToEdge.cpp index b2cc86a6c..6e0e0d8a3 100644 --- a/src/FiltersPlugin/FiltersPlugin_OppositeToEdge.cpp +++ b/src/FiltersPlugin/FiltersPlugin_OppositeToEdge.cpp @@ -143,20 +143,9 @@ bool FiltersPlugin_OppositeToEdge::isOk(const GeomShapePtr& theShape, const Resu return myCachedShapes.find(theShape) != myCachedShapes.end(); } -static std::string XMLRepresentation = -"" -" " -" " -" " -""; - - std::string FiltersPlugin_OppositeToEdge::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-OppositeToEdge.xml"); } void FiltersPlugin_OppositeToEdge::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp b/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp index df1559485..3a0a76cd4 100644 --- a/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp +++ b/src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp @@ -72,28 +72,9 @@ bool FiltersPlugin_RelativeToSolid::isOk(const GeomShapePtr& theShape, const Res return isOK; } -static std::string XMLRepresentation = -"" -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -""; - - std::string FiltersPlugin_RelativeToSolid::xmlRepresentation() const { - return XMLRepresentation; + return xmlFromFile("filter-RelativeToSolid.xml"); } void FiltersPlugin_RelativeToSolid::initAttributes(ModelAPI_FiltersArgs& theArguments) diff --git a/src/FiltersPlugin/filter-BelongsTo.xml b/src/FiltersPlugin/filter-BelongsTo.xml new file mode 100644 index 000000000..217645b3a --- /dev/null +++ b/src/FiltersPlugin/filter-BelongsTo.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/FiltersPlugin/filter-OnGeometry.xml b/src/FiltersPlugin/filter-OnGeometry.xml new file mode 100644 index 000000000..cd44c7ee2 --- /dev/null +++ b/src/FiltersPlugin/filter-OnGeometry.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/FiltersPlugin/filter-OnLine.xml b/src/FiltersPlugin/filter-OnLine.xml new file mode 100644 index 000000000..8f8f52702 --- /dev/null +++ b/src/FiltersPlugin/filter-OnLine.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/FiltersPlugin/filter-OnPlane.xml b/src/FiltersPlugin/filter-OnPlane.xml new file mode 100644 index 000000000..fa65cc0a4 --- /dev/null +++ b/src/FiltersPlugin/filter-OnPlane.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/FiltersPlugin/filter-OnPlaneSide.xml b/src/FiltersPlugin/filter-OnPlaneSide.xml new file mode 100644 index 000000000..263b56041 --- /dev/null +++ b/src/FiltersPlugin/filter-OnPlaneSide.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/FiltersPlugin/filter-OppositeToEdge.xml b/src/FiltersPlugin/filter-OppositeToEdge.xml new file mode 100644 index 000000000..6e2e817e6 --- /dev/null +++ b/src/FiltersPlugin/filter-OppositeToEdge.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/FiltersPlugin/filter-RelativeToSolid.xml b/src/FiltersPlugin/filter-RelativeToSolid.xml new file mode 100644 index 000000000..9dd453c5e --- /dev/null +++ b/src/FiltersPlugin/filter-RelativeToSolid.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 2884d106b..f031c68d1 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -98,6 +98,7 @@ SET(PROJECT_SOURCES ModelAPI_Expression.cpp ModelAPI_Feature.cpp ModelAPI_FeatureValidator.cpp + ModelAPI_Filter.cpp ModelAPI_Folder.cpp ModelAPI_IReentrant.cpp ModelAPI_Object.cpp diff --git a/src/ModelAPI/ModelAPI_Filter.cpp b/src/ModelAPI/ModelAPI_Filter.cpp new file mode 100644 index 000000000..dac32e784 --- /dev/null +++ b/src/ModelAPI/ModelAPI_Filter.cpp @@ -0,0 +1,36 @@ +// 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 "ModelAPI_Filter.h" + +#include + +#include + +std::string ModelAPI_Filter::xmlFromFile(const std::string& theConfigFile) const +{ + std::string aXmlRepresentation; + std::string aFullPath = Config_XMLReader::findConfigFile(theConfigFile); + if (!aFullPath.empty()) { + std::ifstream anInputFile(aFullPath); + aXmlRepresentation.assign(std::istreambuf_iterator(anInputFile), + std::istreambuf_iterator()); + } + return aXmlRepresentation; +} diff --git a/src/ModelAPI/ModelAPI_Filter.h b/src/ModelAPI/ModelAPI_Filter.h index 0469801fe..05b85f6b6 100644 --- a/src/ModelAPI/ModelAPI_Filter.h +++ b/src/ModelAPI/ModelAPI_Filter.h @@ -56,6 +56,11 @@ public: /// not redefined. virtual void initAttributes(ModelAPI_FiltersArgs& theArguments) {} +protected: + /// Returns XML string which represents GUI of the filter + /// by reading corresponding XML file. + MODELAPI_EXPORT std::string xmlFromFile(const std::string& theConfigFile) const; + private: bool myIsReverse; }; -- 2.39.2