From b519afb1eed5da2e6dd09519543cb81b7fca020a Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 11 Aug 2016 17:34:40 +0300 Subject: [PATCH] Issue #1648: Dump Python in the High Level Parameterized Geometry API Dump for FeaturesAPI_Group --- src/FeaturesAPI/FeaturesAPI_Group.cpp | 12 ++++++++++++ src/FeaturesAPI/FeaturesAPI_Group.h | 5 +++++ src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp | 4 ---- src/FeaturesPlugin/FeaturesPlugin_Placement.cpp | 2 -- src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp | 2 -- src/FeaturesPlugin/FeaturesPlugin_Translation.cpp | 2 -- src/ModelHighAPI/ModelHighAPI_Selection.cpp | 11 +++++++++++ src/ModelHighAPI/ModelHighAPI_Selection.h | 4 ++++ src/ModelHighAPI/ModelHighAPI_Tools.cpp | 7 +++++++ 9 files changed, 39 insertions(+), 10 deletions(-) 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); } -- 2.39.2