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