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"
31 //--------------------------------------------------------------------------------------
34 class ModelAPI_AttributeSelection;
35 class ModelAPI_AttributeSelectionList;
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,
60 /// Default constructor with empty selection.
62 ModelHighAPI_Selection();
64 /// Constructor for result and sub-shape
66 ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
67 const std::shared_ptr<GeomAPI_Shape>& theSubShape =
68 std::shared_ptr<GeomAPI_Shape>());
69 /// Constructor for sub-shape by the textual Name
71 ModelHighAPI_Selection(const std::string& theType,
72 const std::string& theSubShapeName);
74 /// Constructor for sub-shape by inner point coordinates
76 ModelHighAPI_Selection(const std::string& theType,
77 const std::shared_ptr<GeomAPI_Pnt>& theSubShapeInnerPoint);
79 /// Constructor for sub-shape by inner point coordinates given by a tuple
81 ModelHighAPI_Selection(const std::string& theType,
82 const std::list<double>& theSubShapeInnerPoint);
85 /// Constructor for sub-shape by weak naming identifier
87 ModelHighAPI_Selection(const std::string& theType,
88 const std::string& theContextName, const int theIndex);
92 virtual ~ModelHighAPI_Selection();
94 /// Fill attribute values
95 MODELHIGHAPI_EXPORT virtual
96 void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
98 /// Append to list attribute
99 MODELHIGHAPI_EXPORT virtual
100 void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
102 /// \return variant type.
104 virtual VariantType variantType() const;
106 /// \return pair of result and sub-shape.
108 virtual ResultSubShapePair resultSubShapePair() const;
110 /// \return pair of sub-shape type and name.
112 virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
114 /// \return pair of sub-shape type and inner point to identify sub-shape.
116 virtual TypeInnerPointPair typeInnerPointPair() const;
118 /// \return shape type.
120 virtual std::string shapeType() const;
122 /// Shortcut for result()->data()->setName()
124 void setName(const std::string& theName);
126 /// Shortcut for result()->data()->name()
128 std::string name() const;
130 /// Change result's color
132 void setColor(int theRed, int theGreen, int theBlue);
134 /// Change result's deflection
136 void setDeflection(double theValue);
138 /// Change result's transparency
140 void setTransparency(double theValue);
142 /// Returns the number of sub-elements.
144 int numberOfSubs() const;
146 /// Returns the sub-result by zero-base index.
148 ModelHighAPI_Selection subResult(int theIndex) const;
151 VariantType myVariantType;
152 ResultSubShapePair myResultSubShapePair;
153 TypeSubShapeNamePair myTypeSubShapeNamePair;
154 TypeInnerPointPair myTypeInnerPointPair;
155 TypeWeakNamingPair myWeakNamingPair;
158 //--------------------------------------------------------------------------------------
159 //--------------------------------------------------------------------------------------
160 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */