Salome HOME
61b1979a0b2c1643f126059a716fe8b556948649
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeSelection.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_AttributeSelection.h
4 // Created:     2 Oct 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ModelAPI_AttributeSelection_H_
8 #define ModelAPI_AttributeSelection_H_
9
10 #include "ModelAPI_Attribute.h"
11 #include <ModelAPI_Result.h>
12
13 /**\class ModelAPI_AttributeSelection
14  * \ingroup DataModel
15  * \brief Attribute that contains reference to the sub-shape of some result, the selected shape.
16  */
17
18 class ModelAPI_AttributeSelection : public ModelAPI_Attribute
19 {
20  public:
21   /// Defines the result and its selected sub-shape
22   /// \param theContext object where the sub-shape was selected
23   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
24   /// \param theTemporarily if it is true, do not store and name the added in the data framework
25   ///           (used to remove immideately, without the following updates)
26   virtual void setValue(
27     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
28     const bool theTemporarily = false) = 0;
29
30   /// Returns the selected subshape
31   virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
32
33   /// Returns the context of the selection (the whole shape owner)
34   virtual ResultPtr context() = 0;
35
36   /// Updates the underlied selection due to the changes in the referenced objects
37   /// \returns false if update is failed
38   virtual bool update() = 0;
39
40   /// Returns the type of this class of attributes
41   static std::string typeId()
42   {
43     return "Selection";
44   }
45
46   /// Returns the type of this class of attributes, not static method
47   MODELAPI_EXPORT virtual std::string attributeType();
48
49   /// Returns a textual string of the selection
50   /// \param theDefaultValue a value, which is used if the naming name can not be obtained
51   virtual std::string namingName(const std::string& theDefaultValue = "") = 0;
52   
53   /// Returns an id of the selection
54   virtual int Id() = 0;
55
56
57   /// Selects sub-shape by the textual Name
58   virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0;
59
60   /// Returns true if recompute of selection become impossible
61   virtual bool isInvalid() = 0;
62
63   /// To virtually destroy the fields of successors
64   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
65
66  protected:
67   /// Objects are created for features automatically
68   MODELAPI_EXPORT ModelAPI_AttributeSelection();
69 };
70
71 //! Pointer on double attribute
72 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;
73
74 #endif