1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
21 #define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
23 //--------------------------------------------------------------------------------------
24 #include "ModelHighAPI.h"
30 //--------------------------------------------------------------------------------------
33 class ModelAPI_AttributeSelection;
34 class ModelAPI_AttributeSelectionList;
35 class ModelAPI_FiltersFeature;
36 class ModelAPI_Result;
37 //--------------------------------------------------------------------------------------
38 typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >
40 typedef std::pair<std::string, std::string> TypeSubShapeNamePair;
41 typedef std::pair<std::string, std::shared_ptr<GeomAPI_Pnt> > TypeInnerPointPair;
42 typedef std::pair<std::string, std::pair<std::string, int> > TypeWeakNamingPair;
43 //--------------------------------------------------------------------------------------
44 /**\class ModelHighAPI_Selection
46 * \brief Class for filling ModelAPI_AttributeSelection
48 class ModelHighAPI_Selection
53 VT_ResultSubShapePair,
54 VT_TypeSubShapeNamePair,
55 VT_TypeInnerPointPair,
61 /// Default constructor with empty selection.
63 ModelHighAPI_Selection();
65 /// Constructor for result and sub-shape
67 ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
68 const std::shared_ptr<GeomAPI_Shape>& theSubShape =
69 std::shared_ptr<GeomAPI_Shape>());
70 /// Constructor for sub-shape by the textual Name
72 ModelHighAPI_Selection(const std::string& theType,
73 const std::string& theSubShapeName);
75 /// Constructor for sub-shape by inner point coordinates
77 ModelHighAPI_Selection(const std::string& theType,
78 const std::shared_ptr<GeomAPI_Pnt>& theSubShapeInnerPoint);
80 /// Constructor for sub-shape by inner point coordinates given by a tuple
82 ModelHighAPI_Selection(const std::string& theType,
83 const std::list<double>& theSubShapeInnerPoint);
86 /// Constructor for sub-shape by weak naming identifier
88 ModelHighAPI_Selection(const std::string& theType,
89 const std::string& theContextName, const int theIndex);
93 virtual ~ModelHighAPI_Selection();
95 /// Fill attribute values
96 MODELHIGHAPI_EXPORT virtual
97 void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
99 /// Append to list attribute
100 MODELHIGHAPI_EXPORT virtual
101 void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
103 /// \return variant type.
105 virtual VariantType variantType() const;
107 /// \return pair of result and sub-shape.
109 virtual ResultSubShapePair resultSubShapePair() const;
111 /// \return pair of sub-shape type and name.
113 virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
115 /// \return pair of sub-shape type and inner point to identify sub-shape.
117 virtual TypeInnerPointPair typeInnerPointPair() const;
119 /// \return pair of sub-shape type and pair of context name and sub-shape index.
121 virtual TypeWeakNamingPair typeWeakNamingPair() const;
123 /// \return shape type.
125 virtual std::string shapeType() const;
127 /// Shortcut for result()->data()->setName()
129 void setName(const std::string& theName);
131 /// Shortcut for result()->data()->name()
133 std::string name() const;
135 /// Change result's color
137 void setColor(int theRed, int theGreen, int theBlue);
139 /// Change result's deflection
141 void setDeflection(double theValue);
143 /// Change result's transparency
145 void setTransparency(double theValue);
147 /// Returns the number of sub-elements.
149 int numberOfSubs() const;
151 /// Returns the sub-result by zero-base index.
153 ModelHighAPI_Selection subResult(int theIndex) const;
156 VariantType myVariantType;
157 ResultSubShapePair myResultSubShapePair;
158 TypeSubShapeNamePair myTypeSubShapeNamePair;
159 TypeInnerPointPair myTypeInnerPointPair;
160 TypeWeakNamingPair myWeakNamingPair;
161 std::shared_ptr<ModelAPI_FiltersFeature> myFilterFeature;
164 //--------------------------------------------------------------------------------------
165 //--------------------------------------------------------------------------------------
166 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */