Salome HOME
Separate classes related to Filters in Model/ModelAPI
authorazv <azv@opencascade.com>
Wed, 19 Jun 2019 13:30:26 +0000 (16:30 +0300)
committerazv <azv@opencascade.com>
Fri, 21 Jun 2019 09:56:44 +0000 (12:56 +0300)
16 files changed:
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/FiltersPlugin_Plugin.cpp
src/FiltersPlugin/FiltersPlugin_Selection.cpp
src/FiltersPlugin/FiltersPlugin_Selection.h
src/Model/CMakeLists.txt
src/Model/Model_Filter.cpp [deleted file]
src/Model/Model_Filter.h [deleted file]
src/Model/Model_FiltersFactory.cpp [new file with mode: 0644]
src/Model/Model_FiltersFactory.h [new file with mode: 0644]
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Filter.h
src/ModelAPI/ModelAPI_FiltersArgs.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_FiltersFactory.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_FiltersFeature.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp
src/ModuleBase/ModuleBase_WidgetSelectionFilter.h

index 9cb138019cc8bd89d5a5dbbf6b25010ae9710120..a764abe5e432f0e64520e8106f4c56d18f77eda1 100644 (file)
@@ -25,8 +25,8 @@ SET(PROJECT_HEADERS
     FiltersPlugin_Selection.h
     FiltersPlugin_HorizontalFace.h
     FiltersPlugin_VerticalFace.h
-       FiltersPlugin_BelongsTo.h
-       FiltersPlugin_OnPlane.h
+    FiltersPlugin_BelongsTo.h
+    FiltersPlugin_OnPlane.h
 )
 
 SET(PROJECT_SOURCES
@@ -34,8 +34,8 @@ 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
index 92ff9b1a1676735a7c0dedaeb846baae1cbb1c5c..6f0b9886c0c78726d70f453af037d4a599b3dc47 100644 (file)
@@ -25,7 +25,7 @@
 #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();
index 2a98fc4ffa6d5cc49997e6e0627876bb37aeab54..fde5dda2903d91fc21f514193a4e61054edbb096 100644 (file)
 
 #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("");
index a9e62517f9f1a9c6daee5ead18e5a491defc2627..8fe3850a72d2eab2d200d6c6469a19c640ec7b23 100644 (file)
@@ -21,8 +21,7 @@
 #define FILTERSPLUGIN_SELECTION_H_
 
 #include "FiltersPlugin.h"
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Filter.h>
+#include <ModelAPI_FiltersFeature.h>
 
 /**\class FiltersPlugin_Selection
 * \ingroup DataModel
index cd1dcb5d1d534b10e5ec729d656e938c82ee9d69..554b8c03a56b0d03c8040699d627ca1f5043565b 100644 (file)
@@ -41,20 +41,20 @@ SET(PROJECT_HEADERS
     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
@@ -78,20 +78,20 @@ 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
diff --git a/src/Model/Model_Filter.cpp b/src/Model/Model_Filter.cpp
deleted file mode 100644 (file)
index 549bed4..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// 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
-}
diff --git a/src/Model/Model_Filter.h b/src/Model/Model_Filter.h
deleted file mode 100644 (file)
index 2ccec58..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// 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
diff --git a/src/Model/Model_FiltersFactory.cpp b/src/Model/Model_FiltersFactory.cpp
new file mode 100644 (file)
index 0000000..f0a7c92
--- /dev/null
@@ -0,0 +1,126 @@
+// 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
+}
diff --git a/src/Model/Model_FiltersFactory.h b/src/Model/Model_FiltersFactory.h
new file mode 100644 (file)
index 0000000..3672516
--- /dev/null
@@ -0,0 +1,67 @@
+// 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
index 58249a22192e844bd8a5ffe50c9e218d4a244ac1..2884d106bc44780e86c3df0d461b5732ed3472db 100644 (file)
@@ -45,11 +45,16 @@ SET(PROJECT_HEADERS
     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
@@ -64,8 +69,6 @@ SET(PROJECT_HEADERS
     ModelAPI_Session.h
     ModelAPI_Tools.h
     ModelAPI_Validator.h
-    ModelAPI_Entity.h
-       ModelAPI_Filter.h
 )
 
 SET(PROJECT_SOURCES
@@ -85,6 +88,7 @@ SET(PROJECT_SOURCES
     ModelAPI_AttributeString.cpp
     ModelAPI_AttributeStringArray.cpp
     ModelAPI_AttributeTables.cpp
+    ModelAPI_AttributeValidator.cpp
     ModelAPI_BodyBuilder.cpp
     ModelAPI_CompositeFeature.cpp
     ModelAPI_Data.cpp
@@ -107,7 +111,6 @@ SET(PROJECT_SOURCES
     ModelAPI_ResultParameter.cpp
     ModelAPI_Session.cpp
     ModelAPI_Tools.cpp
-    ModelAPI_AttributeValidator.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 08bb82d1e03d23082cf16950049c4cb0c2482195..0e5d5b9dfa232f831cbef219ee8f4b769688884b 100644 (file)
 #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
@@ -138,37 +57,4 @@ private:
 
 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
diff --git a/src/ModelAPI/ModelAPI_FiltersArgs.h b/src/ModelAPI/ModelAPI_FiltersArgs.h
new file mode 100644 (file)
index 0000000..0140fdf
--- /dev/null
@@ -0,0 +1,67 @@
+// 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
diff --git a/src/ModelAPI/ModelAPI_FiltersFactory.h b/src/ModelAPI/ModelAPI_FiltersFactory.h
new file mode 100644 (file)
index 0000000..bc24d0d
--- /dev/null
@@ -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 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
diff --git a/src/ModelAPI/ModelAPI_FiltersFeature.h b/src/ModelAPI/ModelAPI_FiltersFeature.h
new file mode 100644 (file)
index 0000000..b479099
--- /dev/null
@@ -0,0 +1,63 @@
+// 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
index 54e99f1d2aa3ff4dac8fcae1f761504e0e17eb2b..1ddaaac2a2848116f2cf25e1ac2d2d91ac7ba27e 100644 (file)
@@ -32,6 +32,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_FiltersFactory.h>
 #include <ModelAPI_ResultBody.h>
 #include <GeomAPI_ShapeExplorer.h>
 
index 45b6ec6b64147275e2a62b720c1eacb8bc650614..3c76e55dc237149755ed3349739e1b29a583e1e1 100644 (file)
@@ -24,7 +24,7 @@
 #include "ModuleBase_ModelWidget.h"
 #include "ModuleBase_ViewerPrs.h"
 
-#include <ModelAPI_Filter.h>
+#include <ModelAPI_FiltersFeature.h>
 
 #include <SelectMgr_IndexedMapOfOwner.hxx>
 #include <AIS_Shape.hxx>