Salome HOME
Move representations of filters to separate XML files.
authorazv <azv@opencascade.com>
Thu, 4 Jul 2019 13:46:23 +0000 (16:46 +0300)
committerazv <azv@opencascade.com>
Thu, 4 Jul 2019 13:46:23 +0000 (16:46 +0300)
18 files changed:
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp
src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp
src/FiltersPlugin/FiltersPlugin_OnLine.cpp
src/FiltersPlugin/FiltersPlugin_OnPlane.cpp
src/FiltersPlugin/FiltersPlugin_OnPlaneSide.cpp
src/FiltersPlugin/FiltersPlugin_OppositeToEdge.cpp
src/FiltersPlugin/FiltersPlugin_RelativeToSolid.cpp
src/FiltersPlugin/filter-BelongsTo.xml [new file with mode: 0644]
src/FiltersPlugin/filter-OnGeometry.xml [new file with mode: 0644]
src/FiltersPlugin/filter-OnLine.xml [new file with mode: 0644]
src/FiltersPlugin/filter-OnPlane.xml [new file with mode: 0644]
src/FiltersPlugin/filter-OnPlaneSide.xml [new file with mode: 0644]
src/FiltersPlugin/filter-OppositeToEdge.xml [new file with mode: 0644]
src/FiltersPlugin/filter-RelativeToSolid.xml [new file with mode: 0644]
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Filter.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_Filter.h

index 75ebaf3ef5dfa1229ce4fb41c6152f153bb12313..bc9646cee8db95d21b15c9ebdfba62a1ee234c66 100644 (file)
@@ -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})
index 6a1553acedb9a7a4997630b09bc60be439d2de0c..9c7010b2d1204cb245e93ddefb45299d9114ebe4 100644 (file)
@@ -43,19 +43,9 @@ bool FiltersPlugin_BelongsTo::isOk(const GeomShapePtr& theShape, const ResultPtr
   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)
index 44d9ff4017a9dd984409b1a8931a63d7e1dc1e92..c7fa73d32aa2516a475566fe54ffa27a892928af 100644 (file)
@@ -43,20 +43,9 @@ bool FiltersPlugin_OnGeometry::isOk(const GeomShapePtr& theShape, const ResultPt
   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)
index d2e4384320237f5a635ad7d221fe6b2bfb27b53d..29dc5b4611386ad41ec49b0a679bc26e20b4b2e8 100644 (file)
@@ -79,20 +79,9 @@ bool FiltersPlugin_OnLine::isOk(const GeomShapePtr& theShape, const ResultPtr&,
   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)
index f7b4a07a660cd0e0120291eb7562fe7125b77326..b9f6329560cf737813e4d96767aeacf886133400 100644 (file)
@@ -108,20 +108,9 @@ bool FiltersPlugin_OnPlane::isOk(const GeomShapePtr& theShape, const ResultPtr&,
   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)
index 1d77e6b742e1d879536414db15d6ee7f951e93fc..54f8c93918e219d94d18e583a697b238d3c59b75 100644 (file)
@@ -55,20 +55,9 @@ bool FiltersPlugin_OnPlaneSide::isOk(const GeomShapePtr& theShape, const ResultP
   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)
index b2cc86a6c85e17f649f7cec75aa6425ccfc14dbd..6e0e0d8a3ee2e4dd93886964f990dd0123c5de1d 100644 (file)
@@ -143,20 +143,9 @@ bool FiltersPlugin_OppositeToEdge::isOk(const GeomShapePtr& theShape, const Resu
   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)
index df1559485e3b9ebf9b3995d2ba23995967bf8719..3a0a76cd4fada9af9e74acade21d1ede801e6409 100644 (file)
@@ -72,28 +72,9 @@ bool FiltersPlugin_RelativeToSolid::isOk(const GeomShapePtr& theShape, const Res
   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)
diff --git a/src/FiltersPlugin/filter-BelongsTo.xml b/src/FiltersPlugin/filter-BelongsTo.xml
new file mode 100644 (file)
index 0000000..217645b
--- /dev/null
@@ -0,0 +1,7 @@
+<filter id="BelongsTo">
+  <multi_selector id="BelongsTo__BelongsTo"
+                  label="Objects:"
+                  tooltip="Select objects to limit selection."
+                  type_choice="objects">
+  </multi_selector>
+</filter>
diff --git a/src/FiltersPlugin/filter-OnGeometry.xml b/src/FiltersPlugin/filter-OnGeometry.xml
new file mode 100644 (file)
index 0000000..cd44c7e
--- /dev/null
@@ -0,0 +1,8 @@
+<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>
diff --git a/src/FiltersPlugin/filter-OnLine.xml b/src/FiltersPlugin/filter-OnLine.xml
new file mode 100644 (file)
index 0000000..8f8f527
--- /dev/null
@@ -0,0 +1,8 @@
+<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>
diff --git a/src/FiltersPlugin/filter-OnPlane.xml b/src/FiltersPlugin/filter-OnPlane.xml
new file mode 100644 (file)
index 0000000..fa65cc0
--- /dev/null
@@ -0,0 +1,8 @@
+<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>
diff --git a/src/FiltersPlugin/filter-OnPlaneSide.xml b/src/FiltersPlugin/filter-OnPlaneSide.xml
new file mode 100644 (file)
index 0000000..263b560
--- /dev/null
@@ -0,0 +1,8 @@
+<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>
diff --git a/src/FiltersPlugin/filter-OppositeToEdge.xml b/src/FiltersPlugin/filter-OppositeToEdge.xml
new file mode 100644 (file)
index 0000000..6e2e817
--- /dev/null
@@ -0,0 +1,8 @@
+<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>
diff --git a/src/FiltersPlugin/filter-RelativeToSolid.xml b/src/FiltersPlugin/filter-RelativeToSolid.xml
new file mode 100644 (file)
index 0000000..9dd453c
--- /dev/null
@@ -0,0 +1,16 @@
+<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>
index 2884d106bc44780e86c3df0d461b5732ed3472db..f031c68d15c7a4954292867b48a01905be77e27f 100644 (file)
@@ -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 (file)
index 0000000..dac32e7
--- /dev/null
@@ -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 <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;
+}
index 0469801fe5fbb3fd9b8d85a7ad2d2a4b88ebd6fb..05b85f6b60a033ddc5bce267afd02294b1901f4b 100644 (file)
@@ -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;
 };