]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Selection.h
Salome HOME
Dump with geometrical selection
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Selection.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
22 #define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
23
24 //--------------------------------------------------------------------------------------
25 #include "ModelHighAPI.h"
26
27 #include <memory>
28 #include <string>
29 #include <utility>
30 //--------------------------------------------------------------------------------------
31 class GeomAPI_Pnt;
32 class GeomAPI_Shape;
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> >
38   ResultSubShapePair;
39 typedef std::pair<std::string, std::string> TypeSubShapeNamePair;
40 typedef std::pair<std::string, std::shared_ptr<GeomAPI_Pnt> > TypeInnerPointPair;
41 //--------------------------------------------------------------------------------------
42 /**\class ModelHighAPI_Selection
43  * \ingroup CPPHighAPI
44  * \brief Class for filling ModelAPI_AttributeSelection
45  */
46 class ModelHighAPI_Selection
47 {
48 public:
49   enum VariantType {
50     VT_Empty,
51     VT_ResultSubShapePair,
52     VT_TypeSubShapeNamePair,
53     VT_TypeInnerPointPair
54   };
55
56 public:
57   /// Default constructor with empty selection.
58   MODELHIGHAPI_EXPORT
59   ModelHighAPI_Selection();
60
61   /// Constructor for result and sub-shape
62   MODELHIGHAPI_EXPORT
63   ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
64                          const std::shared_ptr<GeomAPI_Shape>& theSubShape =
65                          std::shared_ptr<GeomAPI_Shape>());
66   /// Constructor for sub-shape by the textual Name
67   MODELHIGHAPI_EXPORT
68   ModelHighAPI_Selection(const std::string& theType,
69                          const std::string& theSubShapeName);
70
71   /// Constructor for sub-shape by inner point coordinates
72   MODELHIGHAPI_EXPORT
73   ModelHighAPI_Selection(const std::string& theType,
74                          const std::shared_ptr<GeomAPI_Pnt>& theSubShapeInnerPoint);
75
76   /// Destructor
77   MODELHIGHAPI_EXPORT
78   virtual ~ModelHighAPI_Selection();
79
80   /// Fill attribute values
81   MODELHIGHAPI_EXPORT virtual
82     void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
83
84   /// Append to list attribute
85   MODELHIGHAPI_EXPORT virtual
86     void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
87
88   /// \return variant type.
89   MODELHIGHAPI_EXPORT
90   virtual VariantType variantType() const;
91
92   /// \return pair of result and sub-shape.
93   MODELHIGHAPI_EXPORT
94   virtual ResultSubShapePair resultSubShapePair() const;
95
96   /// \return pair of sub-shape type and name.
97   MODELHIGHAPI_EXPORT
98   virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
99
100   /// \return pair of sub-shape type and inner point to identify sub-shape.
101   MODELHIGHAPI_EXPORT
102   virtual TypeInnerPointPair typeInnerPointPair() const;
103
104   /// \return shape type.
105   MODELHIGHAPI_EXPORT
106   virtual std::string shapeType() const;
107
108   /// Shortcut for result()->data()->setName()
109   MODELHIGHAPI_EXPORT
110   void setName(const std::string& theName);
111
112   /// Shortcut for result()->data()->name()
113   MODELHIGHAPI_EXPORT
114   std::string name() const;
115
116   /// Change result's color
117   MODELHIGHAPI_EXPORT
118   void setColor(int theRed, int theGreen, int theBlue);
119
120   /// Change result's deflection
121   MODELHIGHAPI_EXPORT
122   void setDeflection(double theValue);
123
124   /// Change result's transparency
125   MODELHIGHAPI_EXPORT
126   void setTransparency(double theValue);
127
128   /// Returns the number of sub-elements.
129   MODELHIGHAPI_EXPORT
130   int numberOfSubs() const;
131
132   /// Returns the sub-result by zero-base index.
133   MODELHIGHAPI_EXPORT
134   ModelHighAPI_Selection subResult(int theIndex) const;
135
136 private:
137   VariantType myVariantType;
138   ResultSubShapePair myResultSubShapePair;
139   TypeSubShapeNamePair myTypeSubShapeNamePair;
140   TypeInnerPointPair myTypeInnerPointPair;
141 };
142
143 //--------------------------------------------------------------------------------------
144 //--------------------------------------------------------------------------------------
145 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */