X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Filter.h;h=4adeec43261d103ce4a0d486916ed2b1781f6145;hb=2e0f664e66dc2b46796df2953f52871b10799173;hp=e313d9f24299eb594aa21ffa695a195ec49bba7f;hpb=38f557fe5c90f6b272ddc70e22a06eacf0fb4b45;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Filter.h b/src/ModelAPI/ModelAPI_Filter.h index e313d9f24..4adeec432 100644 --- a/src/ModelAPI/ModelAPI_Filter.h +++ b/src/ModelAPI/ModelAPI_Filter.h @@ -20,40 +20,11 @@ #ifndef ModelAPI_Filter_H_ #define ModelAPI_Filter_H_ -#include "ModelAPI.h" -#include "ModelAPI_Attribute.h" -#include "ModelAPI_Feature.h" +#include "ModelAPI_FiltersArgs.h" +#include "ModelAPI_ResultBody.h" #include -#include -/// 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 myMap; - std::string myCurrentFilter; ///< ID of the filter that will take attributes now -public: - ModelAPI_FiltersArgs() {} - - /// Sets the current filter ID - void setFilter(const std::string& theFilterID) { - myCurrentFilter = theFilterID; - } - - /// 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) { - return myMap.find(myCurrentFilter + kFilterSeparator + theID)->second; - } - -}; /**\class ModelAPI_ViewFilter * \ingroup DataModel @@ -62,6 +33,8 @@ public: class ModelAPI_Filter { public: + virtual ~ModelAPI_Filter() {} + /// Returns name of the filter to represent it in GUI virtual const std::string& name() const = 0; @@ -71,78 +44,28 @@ public: /// This method should contain the filter logic. It returns true if the given shape /// is accepted by the filter. /// \param theShape the given shape - virtual bool isOk(const GeomShapePtr& theShape, const ModelAPI_FiltersArgs& theArgs) const = 0; + /// \param theResult parent result of the shape to be checked + /// \param theArgs arguments of the filter + virtual bool isOk(const GeomShapePtr& theShape, + const ResultPtr& theResult, + const ModelAPI_FiltersArgs& theArgs) const = 0; /// Returns XML string which represents GUI of the filter - /// By default it retrurns nothing (no GUI) + /// By default it returns nothing (no GUI) virtual std::string xmlRepresentation() const { return ""; } + /// Initializes arguments of a filter. If a filter has no arguments, this method may be + /// not redefined. + virtual void initAttributes(ModelAPI_FiltersArgs& theArguments) {} + + /// Returns XML string which represents GUI of the filter + /// by reading corresponding XML file. + MODELAPI_EXPORT virtual std::string xmlFromFile(const std::string& theConfigFile) const; + private: bool myIsReverse; }; typedef std::shared_ptr 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 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() {} -}; - -/**\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: - /// 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 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 filterArgs(const std::string theFilterID) const = 0; -}; - -typedef std::shared_ptr FiltersFeaturePtr; - #endif \ No newline at end of file