From 105c3363b8c4b1c01db525f69f12d9e064e3cccd Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 21 Mar 2024 10:04:42 -0400 Subject: [PATCH] Toponaming/Part: Move missed attacher code into place --- src/Mod/Part/App/AttachEnginePyImp.cpp | 15 ++++++++++----- src/Mod/Part/App/AttachExtension.cpp | 9 ++++++--- src/Mod/Part/App/Attacher.cpp | 17 ++++++++++------- src/Mod/Part/App/Attacher.h | 1 - src/Mod/PartDesign/Gui/Command.cpp | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/Mod/Part/App/AttachEnginePyImp.cpp b/src/Mod/Part/App/AttachEnginePyImp.cpp index f79f4113354e..d7b27b0297d0 100644 --- a/src/Mod/Part/App/AttachEnginePyImp.cpp +++ b/src/Mod/Part/App/AttachEnginePyImp.cpp @@ -131,8 +131,12 @@ Py::Object AttachEnginePy::getReferences() const { try { AttachEngine &attacher = *(this->getAttachEnginePtr()); - AttachEngine::verifyReferencesAreSafe(attacher.references); - return Py::Object(attacher.references.getPyObject(),true); + Py::List ret; + int i=0; + for(auto obj : attacher.getRefObjects()) + ret.append(Py::TupleN(Py::asObject(obj->getPyObject()), + Py::String(attacher.subnames[i++]))); + return ret; } ATTACHERPY_STDCATCH_ATTR; } @@ -140,7 +144,9 @@ void AttachEnginePy::setReferences(Py::Object arg) { try { AttachEngine &attacher = *(this->getAttachEnginePtr()); - attacher.references.setPyObject(arg.ptr()); + App::PropertyLinkSubList references; + references.setPyObject(arg.ptr()); + attacher.setReferences(references); } ATTACHERPY_STDCATCH_ATTR; } @@ -542,8 +548,7 @@ PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args) } Part::AttachExtension* feat = dobj->getExtensionByType(); const AttachEngine &attacher = *(this->getAttachEnginePtr()); - AttachEngine::verifyReferencesAreSafe(attacher.references); - feat->AttachmentSupport.Paste(attacher.references); + feat->AttachmentSupport.setValues(attacher.getRefObjects(),attacher.getSubValues()); feat->MapMode.setValue(attacher.mapMode); feat->MapReversed.setValue(attacher.mapReverse); feat->MapPathParameter.setValue(attacher.attachParameter); diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index 5c3c1f43ed66..530fc748ad2c 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -119,7 +119,10 @@ bool AttachExtension::positionBySupport() try { if (_attacher->mapMode == mmDeactivated) return false; - getPlacement().setValue(_attacher->calculateAttachedPlacement(getPlacement().getValue())); + bool subChanged = false; + getPlacement().setValue(_attacher->calculateAttachedPlacement(getPlacement().getValue(), &subChanged)); + if(subChanged) + AttachmentSupport.setValues(AttachmentSupport.getValues(),_attacher->getSubValues()); _active = 1; return true; } catch (ExceptionCancel&) { @@ -193,7 +196,7 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) // MapPathParameter is only used if there is a reference to one edge and not edge + vertex bool hasOneRef = false; - if (_attacher && _attacher->references.getSubValues().size() == 1) { + if (_attacher && _attacher->subnames.size() == 1) { hasOneRef = true; } @@ -257,7 +260,7 @@ void AttachExtension::onExtendedDocumentRestored() // MapPathParameter is only used if there is a reference to one edge and not edge + vertex bool hasOneRef = false; - if (_attacher && _attacher->references.getSubValues().size() == 1) { + if (_attacher && _attacher->subnames.size() == 1) { hasOneRef = true; } diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index d0ccc757fe8e..0b61bd708ee6 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -245,13 +245,16 @@ void AttachEngine::setUp(const App::PropertyLinkSubList &references, void AttachEngine::setUp(const AttachEngine &another) { - setUp(another.references, - another.mapMode, - another.mapReverse, - another.attachParameter, - another.surfU, - another.surfV, - another.attachmentOffset); + this->docName = another.docName; + this->objNames = another.objNames; + this->subnames = another.subnames; + this->shadowSubs = another.shadowSubs; + this->mapMode = another.mapMode; + this->mapReverse = another.mapReverse; + this->attachParameter = another.attachParameter; + this->surfU = another.surfU; + this->surfV = another.surfV; + this->attachmentOffset = another.attachmentOffset; } Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis, diff --git a/src/Mod/Part/App/Attacher.h b/src/Mod/Part/App/Attacher.h index b2f6c04ff0b1..da086becbd76 100644 --- a/src/Mod/Part/App/Attacher.h +++ b/src/Mod/Part/App/Attacher.h @@ -376,7 +376,6 @@ class PartExport AttachEngine : public Base::BaseClass public: //members - App::PropertyLinkSubList references; std::string docName; std::vector objNames; std::vector subnames; diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 76774871f816..c85ae15533db 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -129,7 +129,7 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name) //test if current selection fits a mode. if (support.getSize() > 0) { Part::AttachExtension* pcDatum = Feat->getExtensionByType(); - pcDatum->attacher().references.Paste(support); + pcDatum->attacher().setReferences(support); SuggestResult sugr; pcDatum->attacher().suggestMapModes(sugr); if (sugr.message == Attacher::SuggestResult::srOK) {