From 657bcef7985ed1cc11726fd1fea791c9ccfb6e79 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 15 Jun 2019 15:43:29 +0200 Subject: [PATCH] use ShapeBinder to create a copy from Origin feature --- src/Mod/PartDesign/App/ShapeBinder.h | 2 +- src/Mod/PartDesign/Gui/TaskFeaturePick.cpp | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Mod/PartDesign/App/ShapeBinder.h b/src/Mod/PartDesign/App/ShapeBinder.h index 89484ad1fa..2ef74fa63e 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.h +++ b/src/Mod/PartDesign/App/ShapeBinder.h @@ -52,6 +52,7 @@ public: App::PropertyBool TraceSupport; static void getFilteredReferences(App::PropertyLinkSubList* prop, App::GeoFeature*& object, std::vector< std::string >& subobjects); + static Part::TopoShape buildShapeFromReferences(App::GeoFeature* obj, std::vector< std::string > subs); const char* getViewProviderName(void) const { return "PartDesignGui::ViewProviderShapeBinder"; @@ -65,7 +66,6 @@ protected: private: void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop); virtual void onSettingDocument(); - static Part::TopoShape buildShapeFromReferences(App::GeoFeature* obj, std::vector< std::string > subs); typedef boost::signals2::connection Connection; Connection connectDocumentChangedObject; diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 008f9075c9..f195b3e4ed 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -406,9 +406,25 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st else shapeProp = &static_cast(copy)->Shape; } + else if(obj->isDerivedFrom(App::Plane::getClassTypeId()) || + obj->isDerivedFrom(App::Line::getClassTypeId())) { - if(independent && shapeProp) { - if(entity.empty()) + copy = App::GetApplication().getActiveDocument()->addObject("PartDesign::ShapeBinder", name.c_str()); + + if (!independent) { + static_cast(copy)->Support.setValue(obj, entity.c_str()); + } + else { + App::GeoFeature* geo = static_cast(obj); + std::vector subvalues; + subvalues.push_back(entity); + Part::TopoShape shape = PartDesign::ShapeBinder::buildShapeFromReferences(geo, subvalues); + static_cast(copy)->Shape.setValue(shape); + } + } + + if (independent && shapeProp) { + if (entity.empty()) shapeProp->setValue(static_cast(obj)->Shape.getValue()); else shapeProp->setValue(static_cast(obj)->Shape.getShape().getSubShape(entity.c_str()));