SHAPER 9.16.0
ModelHighAPI_Selection.h
1// Copyright (C) 2014-2026 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 SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
21#define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
22
23//--------------------------------------------------------------------------------------
24#include "ModelHighAPI.h"
25
26#include <list>
27#include <memory>
28#include <string>
29#include <utility>
30//--------------------------------------------------------------------------------------
31class GeomAPI_Pnt;
32class GeomAPI_Shape;
36class ModelAPI_Result;
37//--------------------------------------------------------------------------------------
38typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >
39 ResultSubShapePair;
40typedef std::pair<std::string, std::wstring> TypeSubShapeNamePair;
41typedef std::pair<std::string, std::shared_ptr<GeomAPI_Pnt> > TypeInnerPointPair;
42typedef std::pair<std::string, std::pair<std::wstring, int> > TypeWeakNamingPair;
43//--------------------------------------------------------------------------------------
49{
50public:
51 enum VariantType {
52 VT_Empty,
53 VT_ResultSubShapePair,
54 VT_TypeSubShapeNamePair,
55 VT_TypeInnerPointPair,
56 VT_WeakNamingPair,
57 VT_Filtering
58 };
59
60public:
62 MODELHIGHAPI_EXPORT
64
66 MODELHIGHAPI_EXPORT
67 ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
68 const std::shared_ptr<GeomAPI_Shape>& theSubShape =
69 std::shared_ptr<GeomAPI_Shape>());
71 MODELHIGHAPI_EXPORT
72 ModelHighAPI_Selection(const std::string& theType,
73 const std::wstring& theSubShapeName);
74
76 MODELHIGHAPI_EXPORT
77 ModelHighAPI_Selection(const std::string& theType,
78 const std::shared_ptr<GeomAPI_Pnt>& theSubShapeInnerPoint);
79
81 MODELHIGHAPI_EXPORT
82 ModelHighAPI_Selection(const std::string& theType,
83 const std::list<double>& theSubShapeInnerPoint);
84
85
87 MODELHIGHAPI_EXPORT
88 ModelHighAPI_Selection(const std::string& theType,
89 const std::wstring& theContextName, const int theIndex);
90
92 MODELHIGHAPI_EXPORT
94
96 MODELHIGHAPI_EXPORT virtual
97 void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
98
100 MODELHIGHAPI_EXPORT virtual
101 void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute, const bool theIsIgnoreGroups = false) const;
102
104 MODELHIGHAPI_EXPORT
105 virtual VariantType variantType() const;
106
108 MODELHIGHAPI_EXPORT
109 virtual ResultSubShapePair resultSubShapePair() const;
110
112 MODELHIGHAPI_EXPORT
113 virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
114
116 MODELHIGHAPI_EXPORT
117 virtual TypeInnerPointPair typeInnerPointPair() const;
118
120 MODELHIGHAPI_EXPORT
121 virtual TypeWeakNamingPair typeWeakNamingPair() const;
122
124 MODELHIGHAPI_EXPORT
125 virtual std::string shapeType() const;
126
128 MODELHIGHAPI_EXPORT
129 void setName(const std::wstring& theName);
130
132 MODELHIGHAPI_EXPORT
133 std::wstring name() const;
134
136 MODELHIGHAPI_EXPORT
137 void setColor(int theRed = 0, int theGreen = 0, int theBlue = 0, bool random = false);
138
140 MODELHIGHAPI_EXPORT
141 void setSubShapeColor(const ModelHighAPI_Selection& theShape,
142 int theRed, int theGreen, int theBlue);
143
145 MODELHIGHAPI_EXPORT
146 std::list<int> getSubShapeColor(const ModelHighAPI_Selection& theShape);
147
149 MODELHIGHAPI_EXPORT
150 void setDeflection(double theValue);
151
153 MODELHIGHAPI_EXPORT
154 void setTransparency(double theValue);
155
157 MODELHIGHAPI_EXPORT
158 int numberOfSubs() const;
159
161 MODELHIGHAPI_EXPORT
162 ModelHighAPI_Selection subResult(int theIndex) const;
163
164private:
166 MODELHIGHAPI_EXPORT
167 std::wstring changePartName(const ModelHighAPI_Selection& theShape, const std::wstring& theName);
168
169protected:
170 VariantType myVariantType;
171 ResultSubShapePair myResultSubShapePair;
172 TypeSubShapeNamePair myTypeSubShapeNamePair;
173 TypeInnerPointPair myTypeInnerPointPair;
174 TypeWeakNamingPair myWeakNamingPair;
175 std::shared_ptr<ModelAPI_FiltersFeature> myFilterFeature;
176};
177
178//--------------------------------------------------------------------------------------
179//--------------------------------------------------------------------------------------
180#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
Attribute that contains list of references to the sub-shapes with possibility to manage them.
Definition: ModelAPI_AttributeSelectionList.h:37
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: ModelAPI_AttributeSelection.h:35
An interface for working with filters in the feature.
Definition: ModelAPI_FiltersFeature.h:33
The result of a feature.
Definition: ModelAPI_Result.h:37
Class for filling ModelAPI_AttributeSelection.
Definition: ModelHighAPI_Selection.h:49
void setName(const std::wstring &theName)
Shortcut for result()->data()->setName()
Definition: ModelHighAPI_Selection.cpp:193
int numberOfSubs() const
Returns the number of sub-elements.
Definition: ModelHighAPI_Selection.cpp:335
ModelHighAPI_Selection subResult(int theIndex) const
Returns the sub-result by zero-base index.
Definition: ModelHighAPI_Selection.cpp:347
virtual VariantType variantType() const
Definition: ModelHighAPI_Selection.cpp:147
std::wstring name() const
Shortcut for result()->data()->name()
Definition: ModelHighAPI_Selection.cpp:204
virtual ~ModelHighAPI_Selection()
Destructor.
Definition: ModelHighAPI_Selection.cpp:83
void setSubShapeColor(const ModelHighAPI_Selection &theShape, int theRed, int theGreen, int theBlue)
Change subShape' color.
Definition: ModelHighAPI_Selection.cpp:238
virtual TypeInnerPointPair typeInnerPointPair() const
Definition: ModelHighAPI_Selection.cpp:165
std::list< int > getSubShapeColor(const ModelHighAPI_Selection &theShape)
Get subShape' color.
Definition: ModelHighAPI_Selection.cpp:269
virtual TypeSubShapeNamePair typeSubShapeNamePair() const
Definition: ModelHighAPI_Selection.cpp:159
virtual std::string shapeType() const
Definition: ModelHighAPI_Selection.cpp:177
virtual void fillAttribute(const std::shared_ptr< ModelAPI_AttributeSelection > &theAttribute) const
Fill attribute values.
Definition: ModelHighAPI_Selection.cpp:88
virtual ResultSubShapePair resultSubShapePair() const
Definition: ModelHighAPI_Selection.cpp:153
virtual void appendToList(const std::shared_ptr< ModelAPI_AttributeSelectionList > &theAttribute, const bool theIsIgnoreGroups=false) const
Append to list attribute.
Definition: ModelHighAPI_Selection.cpp:118
void setDeflection(double theValue)
Change result's deflection.
Definition: ModelHighAPI_Selection.cpp:311
void setColor(int theRed=0, int theGreen=0, int theBlue=0, bool random=false)
Change result's color.
Definition: ModelHighAPI_Selection.cpp:214
void setTransparency(double theValue)
Change result's transparency.
Definition: ModelHighAPI_Selection.cpp:323
virtual TypeWeakNamingPair typeWeakNamingPair() const
Definition: ModelHighAPI_Selection.cpp:171
ModelHighAPI_Selection()
Default constructor with empty selection.
Definition: ModelHighAPI_Selection.cpp:35