]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Selection.h
Salome HOME
52b9b40507d353641166c721ad8a7b333ce5d544
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Selection.h
1 // Copyright (C) 2014-2019  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 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 //--------------------------------------------------------------------------------------
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 typedef std::pair<std::string, std::pair<std::string, int> > TypeWeakNamingPair;
42 //--------------------------------------------------------------------------------------
43 /**\class ModelHighAPI_Selection
44  * \ingroup CPPHighAPI
45  * \brief Class for filling ModelAPI_AttributeSelection
46  */
47 class ModelHighAPI_Selection
48 {
49 public:
50   enum VariantType {
51     VT_Empty,
52     VT_ResultSubShapePair,
53     VT_TypeSubShapeNamePair,
54     VT_TypeInnerPointPair,
55     VT_WeakNamingPair
56   };
57
58 public:
59   /// Default constructor with empty selection.
60   MODELHIGHAPI_EXPORT
61   ModelHighAPI_Selection();
62
63   /// Constructor for result and sub-shape
64   MODELHIGHAPI_EXPORT
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
69   MODELHIGHAPI_EXPORT
70   ModelHighAPI_Selection(const std::string& theType,
71                          const std::string& theSubShapeName);
72
73   /// Constructor for sub-shape by inner point coordinates
74   MODELHIGHAPI_EXPORT
75   ModelHighAPI_Selection(const std::string& theType,
76                          const std::shared_ptr<GeomAPI_Pnt>& theSubShapeInnerPoint);
77
78   /// Constructor for sub-shape by inner point coordinates given by a tuple
79   MODELHIGHAPI_EXPORT
80   ModelHighAPI_Selection(const std::string& theType,
81                          const std::list<double>& theSubShapeInnerPoint);
82
83
84   /// Constructor for sub-shape by weak naming identifier
85   MODELHIGHAPI_EXPORT
86     ModelHighAPI_Selection(const std::string& theType,
87       const std::string& theContextName, const int theIndex);
88
89   /// Destructor
90   MODELHIGHAPI_EXPORT
91   virtual ~ModelHighAPI_Selection();
92
93   /// Fill attribute values
94   MODELHIGHAPI_EXPORT virtual
95     void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
96
97   /// Append to list attribute
98   MODELHIGHAPI_EXPORT virtual
99     void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
100
101   /// \return variant type.
102   MODELHIGHAPI_EXPORT
103   virtual VariantType variantType() const;
104
105   /// \return pair of result and sub-shape.
106   MODELHIGHAPI_EXPORT
107   virtual ResultSubShapePair resultSubShapePair() const;
108
109   /// \return pair of sub-shape type and name.
110   MODELHIGHAPI_EXPORT
111   virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
112
113   /// \return pair of sub-shape type and inner point to identify sub-shape.
114   MODELHIGHAPI_EXPORT
115   virtual TypeInnerPointPair typeInnerPointPair() const;
116
117   /// \return pair of sub-shape type and pair of context name and sub-shape index.
118   MODELHIGHAPI_EXPORT
119     virtual TypeWeakNamingPair typeWeakNamingPair() const;
120
121   /// \return shape type.
122   MODELHIGHAPI_EXPORT
123   virtual std::string shapeType() const;
124
125   /// Shortcut for result()->data()->setName()
126   MODELHIGHAPI_EXPORT
127   void setName(const std::string& theName);
128
129   /// Shortcut for result()->data()->name()
130   MODELHIGHAPI_EXPORT
131   std::string name() const;
132
133   /// Change result's color
134   MODELHIGHAPI_EXPORT
135   void setColor(int theRed, int theGreen, int theBlue);
136
137   /// Change result's deflection
138   MODELHIGHAPI_EXPORT
139   void setDeflection(double theValue);
140
141   /// Change result's transparency
142   MODELHIGHAPI_EXPORT
143   void setTransparency(double theValue);
144
145   /// Returns the number of sub-elements.
146   MODELHIGHAPI_EXPORT
147   int numberOfSubs() const;
148
149   /// Returns the sub-result by zero-base index.
150   MODELHIGHAPI_EXPORT
151   ModelHighAPI_Selection subResult(int theIndex) const;
152
153 private:
154   VariantType myVariantType;
155   ResultSubShapePair myResultSubShapePair;
156   TypeSubShapeNamePair myTypeSubShapeNamePair;
157   TypeInnerPointPair myTypeInnerPointPair;
158   TypeWeakNamingPair myWeakNamingPair;
159 };
160
161 //--------------------------------------------------------------------------------------
162 //--------------------------------------------------------------------------------------
163 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */