Salome HOME
Support of open/save and undo/redo for filters feature
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_Selection.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef FILTERSPLUGIN_SELECTION_H_
21 #define FILTERSPLUGIN_SELECTION_H_
22
23 #include "FiltersPlugin.h"
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Filter.h>
26
27 /**\class FiltersPlugin_Selection
28 * \ingroup DataModel
29 * \brief An interface for working with filters in the feature. A filters feature must inherit it
30 *       in order to allow management of filters in the feature data structure.
31 */
32 class FiltersPlugin_Selection : public ModelAPI_FiltersFeature
33 {
34 public:
35   /// Extrusion kind
36   inline static const std::string& ID() {
37     static const std::string MY_GROUP_ID("FiltersSelection");
38     return MY_GROUP_ID;
39   }
40
41   /// Returns the kind of a feature
42   FILTERS_EXPORT virtual const std::string& getKind() {
43     return ID();
44   }
45
46   /// This feature does not displayed in the data tree
47   virtual bool isInHistory() {
48     return false;
49   }
50
51   /// Computes a selection?
52   FILTERS_EXPORT virtual void execute() {}
53
54   /// Feature is created in the plugin manager
55   FiltersPlugin_Selection() {}
56
57   /// This method initializes all filters on open of document
58   FILTERS_EXPORT virtual void initAttributes() override;
59
60   // methods related to the filters management
61
62   /// Adds a filter to the feature. Also initializes arguments of this filter.
63   FILTERS_EXPORT virtual void addFilter(const std::string theFilterID) override;
64
65   /// Removes an existing filter from the feature.
66   FILTERS_EXPORT virtual void removeFilter(const std::string theFilterID) override;
67
68   /// Returns the list of existing filters in the feature.
69   FILTERS_EXPORT virtual std::list<std::string> filters() const override;
70
71   /// Stores the reversed flag for the filter.
72   FILTERS_EXPORT virtual void setReversed
73   (const std::string theFilterID, const bool theReversed) override;
74
75   /// Returns the reversed flag value for the filter.
76   FILTERS_EXPORT virtual bool isReversed(const std::string theFilterID) override;
77
78   /// Returns the ordered list of attributes related to the filter.
79   FILTERS_EXPORT virtual std::list<AttributePtr>
80     filterArgs(const std::string theFilterID) const override;
81
82   /// Sets the attribute (not-persistent field) that contains this filters feature.
83   /// The filter feature may make synchronization by this method call.
84   FILTERS_EXPORT virtual void setAttribute(const AttributePtr& theAttr) override;
85
86   /// Returns the attribute (not-persistent field) that contains this filters feature.
87   FILTERS_EXPORT virtual const AttributePtr& baseAttribute() const override;
88
89 protected:
90
91   AttributePtr myBase; ///< the attribute related to this filter
92 };
93
94 #endif