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