]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_AttributeSelection.h
Salome HOME
Ability to select centers of circles and ellipses, not existing in the context shape.
[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 GeomAPI_Edge;
14
15 /**\class ModelAPI_AttributeSelection
16  * \ingroup DataModel
17  * \brief Attribute that contains reference to the sub-shape of some result, the selected shape.
18  */
19
20 class ModelAPI_AttributeSelection : public ModelAPI_Attribute
21 {
22  public:
23    /// Type of the center of the circular of elliptical edge
24    enum CenterType {
25      NOT_CENTER, ///< this is not a center
26      CIRCLE_CENTER, ///< center of the circle
27      ELLIPSE_FIRST_FOCUS, ///< first focus point of the ellipse
28      ELLIPSE_SECOND_FOCUS, ///< second focus point of the ellipse
29    };
30
31   /// Defines the result and its selected sub-shape
32   /// \param theContext object where the sub-shape was selected
33   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
34   /// \param theTemporarily if it is true, do not store and name the added in the data framework
35   ///           (used to remove immideately, without the following updates)
36   virtual void setValue(
37     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
38     const bool theTemporarily = false) = 0;
39
40   /// Same as SetValue, but it takes an edge (on circular or elliptical curve)
41   /// and stores the vertex of the central point (for ellipse the first or the second focus point)
42   virtual void setValueCenter(
43     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
44     const CenterType theCenterType,
45     const bool theTemporarily = false) = 0;
46
47   /// Reset temporary stored values
48   virtual void removeTemporaryValues() = 0;
49
50   /// Returns the selected subshape
51   virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
52
53   /// Returns the context of the selection (the whole shape owner)
54   virtual ResultPtr context() = 0;
55
56   /// Updates the underlied selection due to the changes in the referenced objects
57   /// \returns false if update is failed
58   virtual bool update() = 0;
59
60   /// Returns the type of this class of attributes
61   static std::string typeId()
62   {
63     return "Selection";
64   }
65
66   /// Returns the type of this class of attributes, not static method
67   MODELAPI_EXPORT virtual std::string attributeType();
68
69   /// Returns a textual string of the selection
70   /// \param theDefaultValue a value, which is used if the naming name can not be obtained
71   virtual std::string namingName(const std::string& theDefaultValue = "") = 0;
72
73   /// Returns an id of the selection
74   virtual int Id() = 0;
75
76   /// Defines an id of the selection
77   virtual void setId(int theID) = 0;
78
79   /// Selects sub-shape by the textual Name
80   virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0;
81
82   /// Returns true if recompute of selection become impossible
83   virtual bool isInvalid() = 0;
84
85   /// To virtually destroy the fields of successors
86   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
87
88  protected:
89   /// Objects are created for features automatically
90   MODELAPI_EXPORT ModelAPI_AttributeSelection();
91 };
92
93 //! Pointer on double attribute
94 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;
95
96 #endif