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})
return false;
}
-static std::string XMLRepresentation =
-"<filter id = \"BelongsTo\">"
-" <multi_selector id=\"BelongsTo__BelongsTo\""
-" label=\"Objects:\""
-" tooltip=\"Select objects to limit selection.\""
-" type_choice=\"objects\">"
-" </multi_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_BelongsTo::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-BelongsTo.xml");
}
void FiltersPlugin_BelongsTo::initAttributes(ModelAPI_FiltersArgs& theArguments)
return false;
}
-static std::string XMLRepresentation =
-"<filter id = \"OnGeometry\">"
-" <multi_selector id=\"OnGeometry__OnGeometry\""
-" label=\"Edges/faces:\""
-" tooltip=\"Select objects to limit selection.\""
-" type_choice=\"edges faces\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"edge,face\"/>"
-" </multi_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OnGeometry::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OnGeometry.xml");
}
void FiltersPlugin_OnGeometry::initAttributes(ModelAPI_FiltersArgs& theArguments)
return false;
}
-static std::string XMLRepresentation =
-"<filter id = \"OnLine\">"
-" <multi_selector id=\"OnLine__OnLine\""
-" label=\"Lines:\""
-" tooltip=\"Select vertices or segments.\""
-" type_choice=\"edges\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"line\"/>"
-" </multi_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OnLine::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OnLine.xml");
}
void FiltersPlugin_OnLine::initAttributes(ModelAPI_FiltersArgs& theArguments)
return false;
}
-static std::string XMLRepresentation =
-"<filter id = \"OnPlane\">"
-" <multi_selector id=\"OnPlane__OnPlane\""
-" label=\"Planes:\""
-" tooltip=\"Select planes or planar faces.\""
-" type_choice=\"faces\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"plane\"/>"
-" </multi_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OnPlane::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OnPlane.xml");
}
void FiltersPlugin_OnPlane::initAttributes(ModelAPI_FiltersArgs& theArguments)
return aVec->dot(aPlaneNorm->xyz()) > THE_TOLERANCE;
}
-static std::string XMLRepresentation =
-"<filter id = \"OnPlaneSide\">"
-" <shape_selector id=\"OnPlaneSide__OnPlaneSide\""
-" label=\"Plane:\""
-" tooltip=\"Select plane or planar face.\""
-" shape_types=\"faces\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"plane\"/>"
-" </shape_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OnPlaneSide::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OnPlaneSide.xml");
}
void FiltersPlugin_OnPlaneSide::initAttributes(ModelAPI_FiltersArgs& theArguments)
return myCachedShapes.find(theShape) != myCachedShapes.end();
}
-static std::string XMLRepresentation =
-"<filter id = \"OppositeToEdge\">"
-" <shape_selector id=\"OppositeToEdge__OppositeToEdge\""
-" label=\"Edge:\""
-" tooltip=\"Select edge.\""
-" shape_types=\"edges\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"line\"/>"
-" </shape_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OppositeToEdge::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OppositeToEdge.xml");
}
void FiltersPlugin_OppositeToEdge::initAttributes(ModelAPI_FiltersArgs& theArguments)
return isOK;
}
-static std::string XMLRepresentation =
-"<filter id = \"RelativeToSolid\">"
-" <shape_selector id=\"RelativeToSolid__Solid\""
-" label=\"Solid:\""
-" tooltip=\"Select a solid.\""
-" shape_types=\"solids\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"solid\"/>"
-" </shape_selector>"
-" <switch id=\"RelativeToSolid__Location\" label=\"Algorithm:\">"
-" <case id=\"in\" title=\"In\"/>"
-" <case id=\"out\" title=\"Out\"/>"
-" <case id=\"on\" title=\"On\"/>"
-" <case id=\"not_on\" title=\"Not On\"/>"
-" <case id=\"not_out\" title=\"In and On\"/>"
-" <case id=\"not_in\" title=\"On and Out\"/>"
-" </switch>"
-"</filter>";
-
-
std::string FiltersPlugin_RelativeToSolid::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-RelativeToSolid.xml");
}
void FiltersPlugin_RelativeToSolid::initAttributes(ModelAPI_FiltersArgs& theArguments)
--- /dev/null
+<filter id="BelongsTo">
+ <multi_selector id="BelongsTo__BelongsTo"
+ label="Objects:"
+ tooltip="Select objects to limit selection."
+ type_choice="objects">
+ </multi_selector>
+</filter>
--- /dev/null
+<filter id="OnGeometry">
+ <multi_selector id="OnGeometry__OnGeometry"
+ label="Edges/faces:"
+ tooltip="Select objects to limit selection."
+ type_choice="edges faces">
+ <validator id="GeomValidators_ShapeType" parameters="edge,face"/>
+ </multi_selector>
+</filter>
--- /dev/null
+<filter id="OnLine">
+ <multi_selector id="OnLine__OnLine"
+ label="Lines:"
+ tooltip="Select vertices or segments."
+ type_choice="edges">
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ </multi_selector>
+</filter>
--- /dev/null
+<filter id="OnPlane">
+ <multi_selector id="OnPlane__OnPlane"
+ label="Planes:"
+ tooltip="Select planes or planar faces."
+ type_choice="faces">
+ <validator id="GeomValidators_ShapeType" parameters="plane"/>
+ </multi_selector>
+</filter>
--- /dev/null
+<filter id="OnPlaneSide">
+ <shape_selector id="OnPlaneSide__OnPlaneSide"
+ label="Plane:"
+ tooltip="Select plane or planar face."
+ shape_types="faces">
+ <validator id="GeomValidators_ShapeType" parameters="plane"/>
+ </shape_selector>
+</filter>
--- /dev/null
+<filter id="OppositeToEdge">
+ <shape_selector id="OppositeToEdge__OppositeToEdge"
+ label="Edge:"
+ tooltip="Select edge."
+ shape_types="edges">
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ </shape_selector>
+</filter>
--- /dev/null
+<filter id="RelativeToSolid">
+ <shape_selector id="RelativeToSolid__Solid"
+ label="Solid:"
+ tooltip="Select a solid."
+ shape_types="solids">
+ <validator id="GeomValidators_ShapeType" parameters="solid"/>
+ </shape_selector>
+ <switch id="RelativeToSolid__Location" label="Algorithm:">
+ <case id="in" title="In"/>
+ <case id="out" title="Out"/>
+ <case id="on" title="On"/>
+ <case id="not_on" title="Not On"/>
+ <case id="not_out" title="In and On"/>
+ <case id="not_in" title="On and Out"/>
+ </switch>
+</filter>
ModelAPI_Expression.cpp
ModelAPI_Feature.cpp
ModelAPI_FeatureValidator.cpp
+ ModelAPI_Filter.cpp
ModelAPI_Folder.cpp
ModelAPI_IReentrant.cpp
ModelAPI_Object.cpp
--- /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 "ModelAPI_Filter.h"
+
+#include <Config_XMLReader.h>
+
+#include <fstream>
+
+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<char>(anInputFile),
+ std::istreambuf_iterator<char>());
+ }
+ return aXmlRepresentation;
+}
/// 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;
};