Salome HOME
d28798dda638f5dac20896b926f8428cd937dc91
[modules/shaper.git] / src / Model / Model_AttributeSelectionList.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeSelectionList.h
4 // Created:     22 Oct 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_AttributeSelectionList_H_
8 #define Model_AttributeSelectionList_H_
9
10 #include "Model.h"
11 #include "Model_AttributeSelection.h"
12 #include <ModelAPI_AttributeSelectionList.h>
13 #include <TDataStd_Integer.hxx>
14 #include <TDataStd_Comment.hxx>
15 #include <vector>
16
17 /**\class Model_AttributeSelectionList
18  * \ingroup DataModel
19  * \brief Attribute that contains list of references to the sub-shapes with
20  * possibility to manage them.
21  */
22
23 class Model_AttributeSelectionList : public ModelAPI_AttributeSelectionList
24 {
25   Handle(TDataStd_Integer) mySize;  ///< Contains size of this list
26   Handle(TDataStd_Comment) mySelectionType;  ///< Contains current type name (same as selection attribute)
27   std::shared_ptr<Model_AttributeSelection> myTmpAttr; ///< temporary attribute (the last one)
28 public:
29   /// Adds the new reference to the end of the list
30   /// \param theContext object where the sub-shape was selected
31   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
32   /// \param theTemporarily if it is true, do not store and name the added in the data framework
33   ///           (used to remove immideately, without the following updates)
34   MODEL_EXPORT virtual void append(
35     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
36     const bool theTemporarily = false);
37
38   /// Adds the new reference to the end of the list by the naming name of the selected shape
39   /// The type of shape is taken from the current selection type if the given is empty
40   MODEL_EXPORT virtual void append(const std::string theNamingName, const std::string& theType="");
41
42   /// Removes the last element in the list
43   MODEL_EXPORT virtual void removeLast();
44
45   /// Removes the elements from the list.
46   /// \param theIndices a list of indices of elements to be removed
47   MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
48
49   /// Returns the number ofselection attributes in the list
50   MODEL_EXPORT virtual int size();
51
52   /// Returns true if the object with the shape are in list
53   /// \param theContext object where the sub-shape was selected
54   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
55   /// \returns true if the pair is found in the attirbute
56   MODEL_EXPORT virtual bool isInList(
57     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
58     const bool theTemporarily = false);
59
60   /// The type of all elements selection
61   /// \returns the index of the OCCT enumeration of the type of shape
62   MODEL_EXPORT virtual const std::string selectionType() const;
63
64   /// Sets the type of all elements selection
65   /// \param theType the index of the OCCT enumeration of the type of shape
66   MODEL_EXPORT virtual void setSelectionType(const std::string& theType);
67
68   /// Returns the attribute selection by the index (zero based)
69   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex);
70
71   /// Returns all attributes
72   MODEL_EXPORT virtual void clear();
73
74   /// Returns true if attribute was  initialized by some value
75   MODEL_EXPORT virtual bool isInitialized();
76
77 protected:
78   /// Objects are created for features automatically
79   MODEL_EXPORT Model_AttributeSelectionList(TDF_Label& theLabel);
80
81   friend class Model_Data;
82 };
83
84 #endif