Salome HOME
Improve multi-selector control to provide items multi-selection and "Delete" context...
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeSelectionList.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_AttributeSelectionList.h
4 // Created:     22 Oct 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ModelAPI_AttributeSelectionList_H_
8 #define ModelAPI_AttributeSelectionList_H_
9
10 #include "ModelAPI_AttributeSelection.h"
11 #include <ModelAPI_Result.h>
12
13 /**\class ModelAPI_AttributeSelectionList
14  * \ingroup DataModel
15  * \brief Attribute that contains list of references to the sub-shapes with
16  * possibility to manage them.
17  */
18
19 class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
20 {
21  public:
22   /// Adds the new reference to the end of the list
23   /// \param theContext object where the sub-shape was selected
24   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
25   /// \param theTemporarily if it is true, do not store and name the added in the data framework
26   ///           (used to remove immediately, without the following updates)
27   virtual void append(const ResultPtr& theContext,
28                       const GeomShapePtr& theSubShape,
29                       const bool theTemporarily = false) = 0;
30
31   /// Adds the new reference to the end of the list by the naming name of the selected shape
32   /// The type of shape is taken from the current selection type if the given is empty
33   virtual void append(const std::string theNamingName, const std::string& theType = "") = 0;
34
35   /// Removes the last element in the list
36   virtual void removeLast() = 0;
37
38   /// Removes the elements from the list.
39   /// \param theIndices a list of indices of elements to be removed
40   virtual void remove(const std::set<int>& theIndices) = 0;
41
42   /// Returns the number of selection attributes in the list
43   virtual int size() = 0;
44
45   /// The type of all elements selection
46   /// \returns the index of the enumeration of the type of shape
47   virtual const std::string selectionType() const = 0;
48
49   /// Sets the type of all elements selection
50   /// \param theType the index of the enumeration of the type of shape
51   virtual void setSelectionType(const std::string& theType) = 0;
52
53   /// Returns the attribute selection by the index (zero based)
54   virtual std::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex) = 0;
55
56   /// Returns all attributes
57   virtual void clear() = 0;
58
59   /// Returns the type of this class of attributes
60   static std::string typeId()
61   {
62     return "SelectionList";
63   }
64
65   /// Returns the type of this class of attributes, not static method
66   MODELAPI_EXPORT virtual std::string attributeType();
67
68   /// To virtually destroy the fields of successors
69   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelectionList();
70
71  protected:
72   /// Objects are created for features automatically
73   MODELAPI_EXPORT ModelAPI_AttributeSelectionList();
74 };
75
76 //! Pointer on double attribute
77 typedef std::shared_ptr<ModelAPI_AttributeSelectionList> AttributeSelectionListPtr;
78
79 #endif