Salome HOME
Issue #1664: In the Sketcher, add the function Split a segment. Split feature impleme...
[modules/shaper.git] / src / Model / Model_AttributeRefList.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeRefList.h
4 // Created:     8 May 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_AttributeRefList_H_
8 #define Model_AttributeRefList_H_
9
10 #include "Model.h"
11 #include "ModelAPI_AttributeRefList.h"
12 #include "ModelAPI_Feature.h"
13 #include "Model_Document.h"
14
15 #include <TDataStd_ReferenceList.hxx>
16 #include <TDataStd_ExtStringList.hxx>
17
18 /**\class Model_AttributeRefList
19  * \ingroup DataModel
20  * \brief Attribute that contains list of references to features, may be located in different documents.
21  */
22
23 class Model_AttributeRefList : public ModelAPI_AttributeRefList
24 {
25   Handle_TDataStd_ReferenceList myRef;  ///< references to the features labels
26   /// pairs of doc ID and entries if reference is to external object, appends some in this list if
27   /// something in myRef is empty
28   Handle_TDataStd_ExtStringList myExtDocRef;
29  public:
30   /// Appends the feature to the end of a list
31   MODEL_EXPORT virtual void append(ObjectPtr theObject);
32
33   /// Erases the first meet of the feature in the list
34   MODEL_EXPORT virtual void remove(ObjectPtr theObject);
35
36   /// Returns number of features in the list
37   ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
38   MODEL_EXPORT virtual int size(const bool theWithEmpty = true) const;
39
40   /// Removes all references from the list
41   MODEL_EXPORT virtual void clear();
42
43   /// Returns the list of features
44   MODEL_EXPORT virtual std::list<ObjectPtr> list();
45
46   /// Returns true if the object is in list
47   MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
48
49   /// Returns the list of features
50   ///\param theIndex zero-based index in the list
51   ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
52   MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const;
53
54   /// Substitutes the feature by another one. Does nothing if such object is not found.
55   /// Does not support the external documents objects yet.
56   MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
57
58   /// Substitutes the object by another one and back. So, features will become exchanged in the list
59   /// Does not support the external documents objects yet.
60   MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
61
62   /// Removes the last element in the list.
63   /// Does not support the external documents objects yet.
64   MODEL_EXPORT virtual void removeLast();
65
66   /// Removes the elements from the list.
67   /// Does not support the external documents objects yet.
68   /// \param theIndices a list of indices of elements to be removed
69   MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
70
71   /// Returns true if attribute was  initialized by some value
72   MODEL_EXPORT virtual bool isInitialized();
73  protected:
74   /// Objects are created for features automatically
75   MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
76   /// Returns the object by iterators (theExtIter is iterated if necessary)
77   ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList& theLIter,
78     TDataStd_ListIteratorOfListOfExtendedString& theExtIter,
79     std::shared_ptr<Model_Document> theDoc) const;
80
81   friend class Model_Data;
82 };
83
84 #endif