Salome HOME
Remove dependency on boost
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Selection.cpp
1 // Name   : ModelHighAPI_Selection.cpp
2 // Purpose: 
3 //
4 // History:
5 // 06/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Selection.h"
9
10 #include <ModelAPI_AttributeSelection.h>
11 #include <ModelAPI_AttributeSelectionList.h>
12 //--------------------------------------------------------------------------------------
13
14 //--------------------------------------------------------------------------------------
15 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
16                                                const std::shared_ptr<GeomAPI_Shape>& theSubShape)
17 : myVariantType(VT_ResultSubShapePair)
18 , myResultSubShapePair(theContext, theSubShape)
19 {
20 }
21
22 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
23                                                const std::string& theSubShapeName)
24 : myVariantType(VT_TypeSubShapeNamePair)
25 , myTypeSubShapeNamePair(theType, theSubShapeName)
26 {
27 }
28
29 ModelHighAPI_Selection::~ModelHighAPI_Selection()
30 {
31 }
32
33 //--------------------------------------------------------------------------------------
34 void ModelHighAPI_Selection::fillAttribute(
35     const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
36 {
37   switch(myVariantType) {
38     case VT_ResultSubShapePair: theAttribute->setValue(myResultSubShapePair.first, myResultSubShapePair.second); return;
39     case VT_TypeSubShapeNamePair: theAttribute->selectSubShape(myTypeSubShapeNamePair.first, myTypeSubShapeNamePair.second); return;
40   }
41 }
42
43 //--------------------------------------------------------------------------------------
44 void ModelHighAPI_Selection::appendToList(
45     const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const
46 {
47   switch(myVariantType) {
48     case VT_ResultSubShapePair: theAttribute->append(myResultSubShapePair.first, myResultSubShapePair.second); return;
49     case VT_TypeSubShapeNamePair:
50       // Note: the reverse order (first - type, second - sub-shape name)
51       theAttribute->append(myTypeSubShapeNamePair.second, myTypeSubShapeNamePair.first);
52       return;
53   }
54 }