Salome HOME
Small fix to register selected name.
[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   virtual void setValue(
23     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape) = 0;
24
25   /// Returns the selected subshape
26   virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
27
28   /// Returns the context of the selection (the whole shape owner)
29   virtual ResultPtr context() = 0;
30
31   /// Updates the underlied selection due to the changes in the referenced objects
32   /// \returns false if update is failed
33   virtual bool update() = 0;
34
35   /// Returns the type of this class of attributes
36   static std::string type()
37   {
38     return "Selection";
39   }
40
41   /// Returns the type of this class of attributes, not static method
42   virtual std::string attributeType()
43   {
44     return type();
45   }
46
47   /// Builds name of the SubShape 
48   virtual std::string buildSubShapeName(std::shared_ptr<GeomAPI_Shape> theSubShape, 
49                                             const ResultPtr& theContext) = 0;
50
51   /// Selects sub-shape by Name
52   //virtual selectSubShape(const std::string& theSubShapeName, const std::string& theContextShapeName)
53   /// To virtually destroy the fields of successors
54   virtual ~ModelAPI_AttributeSelection()
55   {
56   }
57
58  protected:
59   /// Objects are created for features automatically
60   MODELAPI_EXPORT ModelAPI_AttributeSelection()
61   {
62   }
63 };
64
65 //! Pointer on double attribute
66 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;
67
68 #endif