Salome HOME
#1821 Axis by two plains: problem in selection update
[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   /// Reset temporary stored values
31   virtual void removeTemporaryValues() = 0;
32
33   /// Returns the selected subshape
34   virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
35
36   /// Returns the context of the selection (the whole shape owner)
37   virtual ResultPtr context() = 0;
38
39   /// Updates the underlied selection due to the changes in the referenced objects
40   /// \returns false if update is failed
41   virtual bool update() = 0;
42
43   /// Returns the type of this class of attributes
44   static std::string typeId()
45   {
46     return "Selection";
47   }
48
49   /// Returns the type of this class of attributes, not static method
50   MODELAPI_EXPORT virtual std::string attributeType();
51
52   /// Returns a textual string of the selection
53   /// \param theDefaultValue a value, which is used if the naming name can not be obtained
54   virtual std::string namingName(const std::string& theDefaultValue = "") = 0;
55
56   /// Returns an id of the selection
57   virtual int Id() = 0;
58
59   /// Defines an id of the selection
60   virtual void setId(int theID) = 0;
61
62   /// Selects sub-shape by the textual Name
63   virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0;
64
65   /// Returns true if recompute of selection become impossible
66   virtual bool isInvalid() = 0;
67
68   /// To virtually destroy the fields of successors
69   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
70
71  protected:
72   /// Objects are created for features automatically
73   MODELAPI_EXPORT ModelAPI_AttributeSelection();
74 };
75
76 //! Pointer on double attribute
77 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;
78
79 #endif