1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
22 #define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
24 //--------------------------------------------------------------------------------------
25 #include "ModelHighAPI.h"
30 //--------------------------------------------------------------------------------------
33 class ModelAPI_AttributeSelection;
34 class ModelAPI_AttributeSelectionList;
35 class ModelAPI_Result;
36 //--------------------------------------------------------------------------------------
37 typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >
39 typedef std::pair<std::string, std::string> TypeSubShapeNamePair;
40 typedef std::pair<std::string, std::shared_ptr<GeomAPI_Pnt> > TypeInnerPointPair;
41 typedef std::pair<std::string, std::pair<std::string, int> > TypeWeakNamingPair;
42 //--------------------------------------------------------------------------------------
43 /**\class ModelHighAPI_Selection
45 * \brief Class for filling ModelAPI_AttributeSelection
47 class ModelHighAPI_Selection
52 VT_ResultSubShapePair,
53 VT_TypeSubShapeNamePair,
54 VT_TypeInnerPointPair,
59 /// Default constructor with empty selection.
61 ModelHighAPI_Selection();
63 /// Constructor for result and sub-shape
65 ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
66 const std::shared_ptr<GeomAPI_Shape>& theSubShape =
67 std::shared_ptr<GeomAPI_Shape>());
68 /// Constructor for sub-shape by the textual Name
70 ModelHighAPI_Selection(const std::string& theType,
71 const std::string& theSubShapeName);
73 /// Constructor for sub-shape by inner point coordinates
75 ModelHighAPI_Selection(const std::string& theType,
76 const std::shared_ptr<GeomAPI_Pnt>& theSubShapeInnerPoint);
79 /// Constructor for sub-shape by weak naming identifier
81 ModelHighAPI_Selection(const std::string& theType,
82 const std::string& theContextName, const int theIndex);
86 virtual ~ModelHighAPI_Selection();
88 /// Fill attribute values
89 MODELHIGHAPI_EXPORT virtual
90 void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
92 /// Append to list attribute
93 MODELHIGHAPI_EXPORT virtual
94 void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
96 /// \return variant type.
98 virtual VariantType variantType() const;
100 /// \return pair of result and sub-shape.
102 virtual ResultSubShapePair resultSubShapePair() const;
104 /// \return pair of sub-shape type and name.
106 virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
108 /// \return pair of sub-shape type and inner point to identify sub-shape.
110 virtual TypeInnerPointPair typeInnerPointPair() const;
112 /// \return shape type.
114 virtual std::string shapeType() const;
116 /// Shortcut for result()->data()->setName()
118 void setName(const std::string& theName);
120 /// Shortcut for result()->data()->name()
122 std::string name() const;
124 /// Change result's color
126 void setColor(int theRed, int theGreen, int theBlue);
128 /// Change result's deflection
130 void setDeflection(double theValue);
132 /// Change result's transparency
134 void setTransparency(double theValue);
136 /// Returns the number of sub-elements.
138 int numberOfSubs() const;
140 /// Returns the sub-result by zero-base index.
142 ModelHighAPI_Selection subResult(int theIndex) const;
145 VariantType myVariantType;
146 ResultSubShapePair myResultSubShapePair;
147 TypeSubShapeNamePair myTypeSubShapeNamePair;
148 TypeInnerPointPair myTypeInnerPointPair;
149 TypeWeakNamingPair myWeakNamingPair;
152 //--------------------------------------------------------------------------------------
153 //--------------------------------------------------------------------------------------
154 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */