SHAPER  9.12.0
ModelAPI_AttributeSelection.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef ModelAPI_AttributeSelection_H_
21 #define ModelAPI_AttributeSelection_H_
22 
23 #include "ModelAPI_Attribute.h"
24 #include <ModelAPI_Result.h>
25 
26 class GeomAPI_Edge;
27 class GeomAPI_Pnt;
28 
35 {
36  public:
38  enum CenterType {
43  };
44 
51  virtual bool setValue(
52  const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
53  const bool theTemporarily = false) = 0;
54 
57  virtual void setValueCenter(
58  const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
59  const CenterType theCenterType,
60  const bool theTemporarily = false) = 0;
61 
63  virtual void selectValue(
64  const std::shared_ptr<ModelAPI_AttributeSelection>& theSource) = 0;
65 
67  virtual void removeTemporaryValues() = 0;
68 
70  virtual std::shared_ptr<GeomAPI_Shape> value() = 0;
71 
73  virtual ResultPtr context() = 0;
74 
76  virtual std::shared_ptr<ModelAPI_Feature> contextFeature() = 0;
78  virtual std::shared_ptr<ModelAPI_Object> contextObject() = 0;
79 
82  virtual bool update() = 0;
83 
85  static std::string typeId()
86  {
87  return "Selection";
88  }
89 
91  MODELAPI_EXPORT virtual std::string attributeType();
92 
95  virtual std::wstring namingName(const std::wstring& theDefaultValue = L"") = 0;
96 
98  virtual void setId(int theID) = 0;
99 
101  virtual void selectSubShape(const std::string& theType, const std::wstring& theSubShapeName) = 0;
102 
104  virtual void selectSubShape(const std::string& theType,
105  const std::shared_ptr<GeomAPI_Pnt>& thePoint) = 0;
106 
108  virtual void selectSubShape(const std::string& theType,
109  const std::wstring& theContextName, const int theIndex) = 0;
110 
112  virtual bool isInvalid() = 0;
113 
115  virtual bool isGeometricalSelection() const = 0;
116 
118  MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
119 
121  MODELAPI_EXPORT virtual std::wstring contextName(const ResultPtr& theContext) const = 0;
122 
124  MODELAPI_EXPORT virtual void combineGeometrical() = 0;
125 
129  MODELAPI_EXPORT virtual void updateInHistory(bool& theRemove) = 0;
130 
131  protected:
133  MODELAPI_EXPORT ModelAPI_AttributeSelection();
134 };
135 
137 typedef std::shared_ptr<ModelAPI_AttributeSelection> AttributeSelectionPtr;
138 
139 #endif
Interface to the edge object.
Definition: GeomAPI_Edge.h:38
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: ModelAPI_AttributeSelection.h:35
virtual std::shared_ptr< GeomAPI_Shape > value()=0
Returns the selected subshape.
virtual void selectSubShape(const std::string &theType, const std::wstring &theContextName, const int theIndex)=0
Selects sub-shape by weak naming index.
virtual void removeTemporaryValues()=0
Reset temporary stored values.
virtual bool update()=0
Updates the selection due to the changes in the referenced objects.
virtual void setValueCenter(const ObjectPtr &theContext, const std::shared_ptr< GeomAPI_Edge > &theEdge, const CenterType theCenterType, const bool theTemporarily=false)=0
Same as SetValue, but it takes an edge (on circular or elliptic curve) and stores the vertex of the c...
virtual std::string attributeType()
Returns the type of this class of attributes, not static method.
Definition: ModelAPI_AttributeSelection.cpp:23
CenterType
Type of the center of the circular of elliptic edge.
Definition: ModelAPI_AttributeSelection.h:38
@ NOT_CENTER
this is not a center
Definition: ModelAPI_AttributeSelection.h:39
@ CIRCLE_CENTER
center of the circle
Definition: ModelAPI_AttributeSelection.h:40
@ ELLIPSE_SECOND_FOCUS
second focus point of the ellipse
Definition: ModelAPI_AttributeSelection.h:42
@ ELLIPSE_FIRST_FOCUS
first focus point of the ellipse
Definition: ModelAPI_AttributeSelection.h:41
virtual std::shared_ptr< ModelAPI_Feature > contextFeature()=0
Returns the context of the selection if the whole feature was selected.
virtual void combineGeometrical()=0
Makes the current local selection becomes all sub-shapes with same base geometry.
virtual void setId(int theID)=0
Defines an id of the selection.
ModelAPI_AttributeSelection()
Objects are created for features automatically.
Definition: ModelAPI_AttributeSelection.cpp:32
static std::string typeId()
Returns the type of this class of attributes.
Definition: ModelAPI_AttributeSelection.h:85
virtual ResultPtr context()=0
Returns the context of the selection (the whole shape owner)
virtual void updateInHistory(bool &theRemove)=0
Updates the arguments of selection if something was affected by creation or reorder of features upper...
virtual bool setValue(const ObjectPtr &theContext, const std::shared_ptr< GeomAPI_Shape > &theSubShape, const bool theTemporarily=false)=0
Defines the result and its selected sub-shape.
virtual std::wstring namingName(const std::wstring &theDefaultValue=L"")=0
Returns a textual string of the selection.
virtual void selectSubShape(const std::string &theType, const std::wstring &theSubShapeName)=0
Selects sub-shape by the textual Name.
virtual ~ModelAPI_AttributeSelection()
To virtually destroy the fields of successors.
Definition: ModelAPI_AttributeSelection.cpp:28
virtual std::wstring contextName(const ResultPtr &theContext) const =0
Returns the name by context. Adds the part name if the context is located in other document.
virtual bool isGeometricalSelection() const =0
Returns true if is geometrical selection.
virtual void selectValue(const std::shared_ptr< ModelAPI_AttributeSelection > &theSource)=0
Makes this selection attribute selects the same as in theSource selection.
virtual void selectSubShape(const std::string &theType, const std::shared_ptr< GeomAPI_Pnt > &thePoint)=0
Selects sub-shape by its inner point.
virtual bool isInvalid()=0
Returns true if recompute of selection become impossible.
virtual std::shared_ptr< ModelAPI_Object > contextObject()=0
Returns the context of the selection : result or feature.
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34