]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Selection.h
Salome HOME
Issue #2358: Preserve state of folders on move in/out objects to a folder
[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_Shape;
32 class ModelAPI_AttributeSelection;
33 class ModelAPI_AttributeSelectionList;
34 class ModelAPI_Result;
35 //--------------------------------------------------------------------------------------
36 typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> >
37   ResultSubShapePair;
38 typedef std::pair<std::string, std::string> TypeSubShapeNamePair;
39 //--------------------------------------------------------------------------------------
40 /**\class ModelHighAPI_Selection
41  * \ingroup CPPHighAPI
42  * \brief Class for filling ModelAPI_AttributeSelection
43  */
44 class ModelHighAPI_Selection
45 {
46 public:
47   enum VariantType {
48     VT_Empty,
49     VT_ResultSubShapePair,
50     VT_TypeSubShapeNamePair
51   };
52
53 public:
54   /// Default constructor with empty selection.
55   MODELHIGHAPI_EXPORT
56   ModelHighAPI_Selection();
57
58   /// Constructor for result and sub-shape
59   MODELHIGHAPI_EXPORT
60   ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
61                          const std::shared_ptr<GeomAPI_Shape>& theSubShape =
62                          std::shared_ptr<GeomAPI_Shape>());
63   /// Constructor for sub-shape by the textual Name
64   MODELHIGHAPI_EXPORT
65   ModelHighAPI_Selection(const std::string& theType,
66                          const std::string& theSubShapeName);
67   /// Destructor
68   MODELHIGHAPI_EXPORT
69   virtual ~ModelHighAPI_Selection();
70
71   /// Fill attribute values
72   MODELHIGHAPI_EXPORT virtual
73     void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
74
75   /// Append to list attribute
76   MODELHIGHAPI_EXPORT virtual
77     void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
78
79   /// \return variant type.
80   MODELHIGHAPI_EXPORT
81   virtual VariantType variantType() const;
82
83   /// \return pair of result and sub-shape.
84   MODELHIGHAPI_EXPORT
85   virtual ResultSubShapePair resultSubShapePair() const;
86
87   /// \return pair of sub-shape type and name.
88   MODELHIGHAPI_EXPORT
89   virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
90
91   /// \return shape type.
92   MODELHIGHAPI_EXPORT
93   virtual std::string shapeType() const;
94
95   /// Shortcut for result()->data()->setName()
96   MODELHIGHAPI_EXPORT
97   void setName(const std::string& theName);
98
99   /// Shortcut for result()->data()->name()
100   MODELHIGHAPI_EXPORT
101   std::string name() const;
102
103   /// Change result's color
104   MODELHIGHAPI_EXPORT
105   void setColor(int theRed, int theGreen, int theBlue);
106
107   /// Change result's deflection
108   MODELHIGHAPI_EXPORT
109   void setDeflection(double theValue);
110
111   /// Change result's transparency
112   MODELHIGHAPI_EXPORT
113   void setTransparency(double theValue);
114
115   /// Returns the number of sub-elements.
116   MODELHIGHAPI_EXPORT
117   int numberOfSubs() const;
118
119   /// Returns the sub-result by zero-base index.
120   MODELHIGHAPI_EXPORT
121   ModelHighAPI_Selection subResult(int theIndex) const;
122
123 private:
124   VariantType myVariantType;
125   ResultSubShapePair myResultSubShapePair;
126   TypeSubShapeNamePair myTypeSubShapeNamePair;
127 };
128
129 //--------------------------------------------------------------------------------------
130 //--------------------------------------------------------------------------------------
131 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ */