1 // Name : ModelHighAPI_Selection.cpp
5 // 06/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Selection.h"
10 #include <ModelAPI_AttributeSelection.h>
11 #include <ModelAPI_AttributeSelectionList.h>
12 //--------------------------------------------------------------------------------------
14 //--------------------------------------------------------------------------------------
15 ModelHighAPI_Selection::ModelHighAPI_Selection()
16 : myVariantType(VT_Empty)
20 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
21 const std::shared_ptr<GeomAPI_Shape>& theSubShape)
22 : myVariantType(VT_ResultSubShapePair)
23 , myResultSubShapePair(theContext, theSubShape)
27 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
28 const std::string& theSubShapeName)
29 : myVariantType(VT_TypeSubShapeNamePair)
30 , myTypeSubShapeNamePair(theType, theSubShapeName)
34 ModelHighAPI_Selection::~ModelHighAPI_Selection()
38 //--------------------------------------------------------------------------------------
39 void ModelHighAPI_Selection::fillAttribute(
40 const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
42 switch(myVariantType) {
43 case VT_Empty: return;
44 case VT_ResultSubShapePair: theAttribute->setValue(myResultSubShapePair.first, myResultSubShapePair.second); return;
45 case VT_TypeSubShapeNamePair: theAttribute->selectSubShape(myTypeSubShapeNamePair.first, myTypeSubShapeNamePair.second); return;
49 //--------------------------------------------------------------------------------------
50 void ModelHighAPI_Selection::appendToList(
51 const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const
53 switch(myVariantType) {
54 case VT_Empty: return;
55 case VT_ResultSubShapePair: theAttribute->append(myResultSubShapePair.first, myResultSubShapePair.second); return;
56 case VT_TypeSubShapeNamePair:
57 // Note: the reverse order (first - type, second - sub-shape name)
58 theAttribute->append(myTypeSubShapeNamePair.second, myTypeSubShapeNamePair.first);
63 //==================================================================================================
64 ModelHighAPI_Selection::VariantType ModelHighAPI_Selection::variantType() const
69 //==================================================================================================
70 ResultSubShapePair ModelHighAPI_Selection::resultSubShapePair() const
72 return myResultSubShapePair;
75 //==================================================================================================
76 TypeSubShapeNamePair ModelHighAPI_Selection::typeSubShapeNamePair() const
78 return myTypeSubShapeNamePair;
81 //==================================================================================================
82 std::string ModelHighAPI_Selection::shapeType() const
84 switch(myVariantType) {
85 case VT_ResultSubShapePair:
86 return myResultSubShapePair.second.get() ? myResultSubShapePair.second->shapeTypeStr() :
87 myResultSubShapePair.first->shape()->shapeTypeStr();
88 case VT_TypeSubShapeNamePair: return myTypeSubShapeNamePair.first;