Salome HOME
Update of the unit-test for checking the issue #2892
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeSelectionList.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 ModelAPI_AttributeSelectionList_H_
21 #define ModelAPI_AttributeSelectionList_H_
22
23 #include "ModelAPI_AttributeSelection.h"
24 #include <ModelAPI_Result.h>
25
26 class GeomAPI_Pnt;
27 class GeomAPI_Shape;
28
29 /**\class ModelAPI_AttributeSelectionList
30  * \ingroup DataModel
31  * \brief Attribute that contains list of references to the sub-shapes with
32  * possibility to manage them.
33  */
34
35 class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
36 {
37  public:
38   /// Adds the new reference to the end of the list
39   /// \param theContext object where the sub-shape was selected
40   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
41   /// \param theTemporarily if it is true, do not store and name the added in the data framework
42   ///           (used to remove immediately, without the following updates)
43   virtual void append(const ObjectPtr& theContext,
44                       const std::shared_ptr<GeomAPI_Shape>& theSubShape,
45                       const bool theTemporarily = false) = 0;
46
47   /// Adds the new reference to the end of the list by the naming name of the selected shape
48   /// The type of shape is taken from the current selection type if the given is empty
49   virtual void append(const std::string& theNamingName, const std::string& theType = "") = 0;
50
51   /// Adds the new reference to the end of the list by inner point on the selected shape
52   virtual void append(const std::shared_ptr<GeomAPI_Pnt>& thePoint,
53                       const std::string& theType) = 0;
54
55   /// Adds the new reference to the end of the list by weak naming index
56   virtual void append(const std::string& theType, const std::string& theContextName,
57                       const int theIndex) = 0;
58
59   /// Reset temporary stored values
60   virtual void removeTemporaryValues() = 0;
61
62   /// Removes the last element in the list
63   virtual void removeLast() = 0;
64
65   /// Removes the elements from the list.
66   /// \param theIndices a list of indices of elements to be removed
67   virtual void remove(const std::set<int>& theIndices) = 0;
68
69   /// Returns the number of selection attributes in the list
70   virtual int size() = 0;
71
72   /// Returns true if the object with the shape are in list
73   /// \param theContext object where the sub-shape was selected
74   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
75   /// \param theTemporarily if it is true, it checks also the temporary added item
76   /// \returns true if the pair is found in the attribute
77   virtual bool isInList(
78     const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
79     const bool theTemporarily = false) = 0;
80
81   /// The type of all elements selection
82   /// \returns the index of the enumeration of the type of shape
83   virtual const std::string selectionType() const = 0;
84
85   /// Sets the type of all elements selection
86   /// \param theType the index of the enumeration of the type of shape
87   virtual void setSelectionType(const std::string& theType) = 0;
88
89   /// Returns the attribute selection by the index (zero based)
90   virtual std::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex) = 0;
91
92   /// Removes all attributes of the list.
93   virtual void clear() = 0;
94
95   /// Starts or stops cashing of the values in the attribute (the cash may become invalid
96   /// on modification of the attribute or sub-elements, so the cash must be enabled only
97   /// during non-modification operations with this attribute)
98   virtual void cashValues(const bool theEnabled) = 0;
99
100   virtual void setGeometricalSelection(const bool theIsGeometricalSelection) = 0;
101
102   /// Returns true if is geometrical selection.
103   virtual bool isGeometricalSelection() const = 0;
104
105   /// Returns the type of this class of attributes
106   static std::string typeId()
107   {
108     return "SelectionList";
109   }
110
111   /// Returns the type of this class of attributes, not static method
112   MODELAPI_EXPORT virtual std::string attributeType();
113
114   /// To virtually destroy the fields of successors
115   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelectionList();
116
117  protected:
118   /// Objects are created for features automatically
119   MODELAPI_EXPORT ModelAPI_AttributeSelectionList();
120 };
121
122 //! Pointer on double attribute
123 typedef std::shared_ptr<ModelAPI_AttributeSelectionList> AttributeSelectionListPtr;
124
125 #endif