1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeSelectionList.h
4 // Created: 22 Oct 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef ModelAPI_AttributeSelectionList_H_
8 #define ModelAPI_AttributeSelectionList_H_
10 #include "ModelAPI_AttributeSelection.h"
11 #include <ModelAPI_Result.h>
13 /**\class ModelAPI_AttributeSelectionList
15 * \brief Attribute that contains list of references to the sub-shapes with
16 * possibility to manage them.
19 class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
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;
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;
35 /// Reset temporary stored values
36 virtual void removeTemporaryValues() = 0;
38 /// Removes the last element in the list
39 virtual void removeLast() = 0;
41 /// Removes the elements from the list.
42 /// \param theIndices a list of indices of elements to be removed
43 virtual void remove(const std::set<int>& theIndices) = 0;
45 /// Returns the number of selection attributes in the list
46 virtual int size() = 0;
48 /// Returns true if the object with the shape are in list
49 /// \param theContext object where the sub-shape was selected
50 /// \param theSubShape selected sub-shape (if null, the whole context is selected)
51 /// \param theTemporarily if it is true, it checks also the temporary added item
52 /// \returns true if the pair is found in the attirbute
53 virtual bool isInList(
54 const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
55 const bool theTemporarily = false) = 0;
57 /// The type of all elements selection
58 /// \returns the index of the enumeration of the type of shape
59 virtual const std::string selectionType() const = 0;
61 /// Sets the type of all elements selection
62 /// \param theType the index of the enumeration of the type of shape
63 virtual void setSelectionType(const std::string& theType) = 0;
65 /// Returns the attribute selection by the index (zero based)
66 virtual std::shared_ptr<ModelAPI_AttributeSelection> value(const int theIndex) = 0;
68 /// Returns all attributes
69 virtual void clear() = 0;
71 /// Starts or stops cashing of the values in the attribute (the cash may become invalid
72 /// on modification of the attribute or sub-elements, so the cash must be enabled only
73 /// during non-modification operations with this attribute)
74 virtual void cashValues(const bool theEnabled) = 0;
76 /// Returns the type of this class of attributes
77 static std::string typeId()
79 return "SelectionList";
82 /// Returns the type of this class of attributes, not static method
83 MODELAPI_EXPORT virtual std::string attributeType();
85 /// To virtually destroy the fields of successors
86 MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelectionList();
89 /// Objects are created for features automatically
90 MODELAPI_EXPORT ModelAPI_AttributeSelectionList();
93 //! Pointer on double attribute
94 typedef std::shared_ptr<ModelAPI_AttributeSelectionList> AttributeSelectionListPtr;