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(const std::shared_ptr<ModelAPI_Result>& theContext,
16 const std::shared_ptr<GeomAPI_Shape>& theSubShape)
17 : myValue(ResultSubShapePair(theContext, theSubShape))
21 ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
22 const std::string& theSubShapeName)
23 : myValue(TypeSubShapeNamePair(theType, theSubShapeName))
27 ModelHighAPI_Selection::~ModelHighAPI_Selection()
31 //--------------------------------------------------------------------------------------
32 struct fill_visitor : boost::static_visitor<void>
34 mutable std::shared_ptr<ModelAPI_AttributeSelection> myAttribute;
36 fill_visitor(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
37 : myAttribute(theAttribute) {}
39 void operator()(const ResultSubShapePair & thePair) const { myAttribute->setValue(thePair.first, thePair.second); }
40 void operator()(const TypeSubShapeNamePair & thePair) const { myAttribute->selectSubShape(thePair.first, thePair.second); }
43 void ModelHighAPI_Selection::fillAttribute(
44 const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
46 boost::apply_visitor(fill_visitor(theAttribute), myValue);
49 //--------------------------------------------------------------------------------------
50 struct append_visitor : boost::static_visitor<void>
52 mutable std::shared_ptr<ModelAPI_AttributeSelectionList> myAttribute;
54 append_visitor(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
55 : myAttribute(theAttribute) {}
57 void operator()(const ResultSubShapePair & thePair) const { myAttribute->append(thePair.first, thePair.second); }
58 void operator()(const TypeSubShapeNamePair & thePair) const {
59 // Note: the reverse order (first - type, second - sub-shape name)
60 myAttribute->append(thePair.second, thePair.first);
64 void ModelHighAPI_Selection::appendToList(
65 const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const
67 boost::apply_visitor(append_visitor(theAttribute), myValue);