From: dbv Date: Thu, 11 Aug 2016 14:34:40 +0000 (+0300) Subject: Issue #1648: Dump Python in the High Level Parameterized Geometry API X-Git-Tag: V_2.5.0~137^2~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b519afb1eed5da2e6dd09519543cb81b7fca020a;p=modules%2Fshaper.git Issue #1648: Dump Python in the High Level Parameterized Geometry API Dump for FeaturesAPI_Group --- diff --git a/src/FeaturesAPI/FeaturesAPI_Group.cpp b/src/FeaturesAPI/FeaturesAPI_Group.cpp index 274fe8e40..d12e73f45 100644 --- a/src/FeaturesAPI/FeaturesAPI_Group.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Group.cpp @@ -6,6 +6,7 @@ #include "FeaturesAPI_Group.h" +#include #include #include #include @@ -41,6 +42,17 @@ void FeaturesAPI_Group::setGroupList(const std::list& th execute(); } +//================================================================================================== +void FeaturesAPI_Group::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + AttributeSelectionListPtr anAttrList = aBase->selectionList(FeaturesPlugin_Group::LIST_ID()); + + theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList << ")" << std::endl; +} + //================================================================================================== GroupPtr addGroup(const std::shared_ptr& thePart, const std::list& theGroupList) diff --git a/src/FeaturesAPI/FeaturesAPI_Group.h b/src/FeaturesAPI/FeaturesAPI_Group.h index 68239201b..fece502f2 100644 --- a/src/FeaturesAPI/FeaturesAPI_Group.h +++ b/src/FeaturesAPI/FeaturesAPI_Group.h @@ -14,6 +14,7 @@ #include #include +class ModelHighAPI_Dumper; class ModelHighAPI_Selection; /// \class FeaturesAPI_Group @@ -41,6 +42,10 @@ public: /// Set main objects. FEATURESAPI_EXPORT void setGroupList(const std::list& theGroupList); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; }; /// Pointer on Group object. diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index 69915b1b3..075bd5f7b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -39,13 +39,9 @@ void FeaturesPlugin_Boolean::initAttributes() AttributeSelectionListPtr aSelection = std::dynamic_pointer_cast(data()->addAttribute( FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - // extrusion works with faces always - aSelection->setSelectionType("SOLID"); aSelection = std::dynamic_pointer_cast(data()->addAttribute( FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - // extrusion works with faces always - aSelection->setSelectionType("SOLID"); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index 43b25be20..496abeb0a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -34,8 +34,6 @@ void FeaturesPlugin_Placement::initAttributes() AttributeSelectionListPtr aSelection = std::dynamic_pointer_cast(data()->addAttribute( OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - // extrusion works with faces always - aSelection->setSelectionType("SOLID"); data()->addAttribute(START_SHAPE_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(END_SHAPE_ID(), ModelAPI_AttributeSelection::typeId()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 3d3076ab5..91ab7c7b0 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -25,8 +25,6 @@ void FeaturesPlugin_Rotation::initAttributes() AttributeSelectionListPtr aSelection = std::dynamic_pointer_cast(data()->addAttribute( FeaturesPlugin_Rotation::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - // revolution works with faces always - aSelection->setSelectionType("SOLID"); data()->addAttribute(FeaturesPlugin_Rotation::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(FeaturesPlugin_Rotation::ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index c3931387c..e33527784 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -27,8 +27,6 @@ void FeaturesPlugin_Translation::initAttributes() AttributeSelectionListPtr aSelection = std::dynamic_pointer_cast(data()->addAttribute( FeaturesPlugin_Translation::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - // revolution works with faces always - aSelection->setSelectionType("SOLID"); data()->addAttribute(FeaturesPlugin_Translation::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(FeaturesPlugin_Translation::DISTANCE_ID(), ModelAPI_AttributeDouble::typeId()); diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index c2540b8f5..0c4e764f5 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -77,3 +77,14 @@ TypeSubShapeNamePair ModelHighAPI_Selection::typeSubShapeNamePair() const { return myTypeSubShapeNamePair; } + +//================================================================================================== +std::string ModelHighAPI_Selection::shapeType() const +{ + switch(myVariantType) { + case VT_ResultSubShapePair: return myResultSubShapePair.second->shapeTypeStr(); + case VT_TypeSubShapeNamePair: return myTypeSubShapeNamePair.first; + } + + return "SHAPE"; +} diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.h b/src/ModelHighAPI/ModelHighAPI_Selection.h index e559228b6..2e1507ff1 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.h +++ b/src/ModelHighAPI/ModelHighAPI_Selection.h @@ -72,6 +72,10 @@ public: MODELHIGHAPI_EXPORT virtual TypeSubShapeNamePair typeSubShapeNamePair() const; + /// \return shape type. + MODELHIGHAPI_EXPORT + virtual std::string shapeType() const; + private: VariantType myVariantType; ResultSubShapePair myResultSubShapePair; diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 7931f0dca..8923fd6e1 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -173,6 +173,13 @@ void fillAttribute(const std::list & theValue, const std::shared_ptr & theAttribute) { theAttribute->clear(); + + if(!theValue.empty()) { + std::string aSelectionType; + const ModelHighAPI_Selection& aSelection = theValue.front(); + theAttribute->setSelectionType(aSelection.shapeType()); + } + for (auto it = theValue.begin(); it != theValue.end(); ++it) it->appendToList(theAttribute); }