1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeSelection.h
5 // Author: Mikhail PONIKAROV
7 #ifndef ModelAPI_AttributeSelection_H_
8 #define ModelAPI_AttributeSelection_H_
10 #include "ModelAPI_Attribute.h"
11 #include <ModelAPI_Result.h>
15 /**\class ModelAPI_AttributeSelection
17 * \brief Attribute that contains reference to the sub-shape of some result, the selected shape.
20 class ModelAPI_AttributeSelection : public ModelAPI_Attribute
23 /// Type of the center of the circular of elliptical edge
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
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;
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;
47 /// Reset temporary stored values
48 virtual void removeTemporaryValues() = 0;
50 /// Returns the selected subshape
51 virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
53 /// Returns the context of the selection (the whole shape owner)
54 virtual ResultPtr context() = 0;
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;
60 /// Returns the type of this class of attributes
61 static std::string typeId()
66 /// Returns the type of this class of attributes, not static method
67 MODELAPI_EXPORT virtual std::string attributeType();
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;
73 /// Returns an id of the selection
76 /// Defines an id of the selection
77 virtual void setId(int theID) = 0;
79 /// Selects sub-shape by the textual Name
80 virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0;
82 /// Returns true if recompute of selection become impossible
83 virtual bool isInvalid() = 0;
85 /// To virtually destroy the fields of successors
86 MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
89 /// Objects are created for features automatically
90 MODELAPI_EXPORT ModelAPI_AttributeSelection();
93 //! Pointer on double attribute
94 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;