From 86abf074c0f507d2199ae9868643b77d178f63cd Mon Sep 17 00:00:00 2001 From: bgbsww Date: Sat, 11 May 2024 22:13:15 -0400 Subject: [PATCH] Toponaming: bring in missing code fragments in PartDesign --- src/Mod/PartDesign/App/Feature.cpp | 25 ++++++++++++++++++- src/Mod/PartDesign/App/Feature.h | 1 + src/Mod/PartDesign/App/FeatureSketchBased.cpp | 14 ++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 5730f3e547..45d53c5faf 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -32,7 +32,8 @@ # include #endif -#include "App/DocumentObject.h" +#include +#include #include #include #include "App/OriginFeature.h" @@ -115,6 +116,28 @@ TopoShape Feature::getSolid(const TopoShape& shape) return shape; } +void Feature::onChanged(const App::Property *prop) +{ + if (!this->isRestoring() + && this->getDocument() + && !this->getDocument()->isPerformingTransaction()) { + if (prop == &Visibility || prop == &BaseFeature) { + auto body = Body::findBodyOf(this); + if (body) { + if (prop == &BaseFeature && BaseFeature.getValue()) { + int idx = -1; + body->Group.find(this->getNameInDocument(), &idx); + int baseidx = -1; + body->Group.find(BaseFeature.getValue()->getNameInDocument(), &idx); + if (idx >= 0 && baseidx >= 0 && baseidx+1 != idx) + body->insertObject(BaseFeature.getValue(), this); + } + } + } + } + Part::Feature::onChanged(prop); +} + int Feature::countSolids(const TopoDS_Shape& shape, TopAbs_ShapeEnum type) { int result = 0; diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index 8147024f49..05f860a0e6 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -84,6 +84,7 @@ public: return "PartDesignGui::ViewProvider"; } + void onChanged(const App::Property* prop) override; App::DocumentObject *getSubObject(const char *subname, PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const override; diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 964f9fe014..197ddfe9f4 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -101,7 +101,11 @@ void ProfileBased::positionByPrevious() else { //no base. Use either Sketch support's placement, or sketch's placement itself. Part::Part2DObject* sketch = getVerifiedSketch(); +#ifdef FC_USE_TNP_FIX + App::DocumentObject* support = sketch->Support.getValue(); +#else App::DocumentObject* support = sketch->AttachmentSupport.getValue(); +#endif if (support && support->isDerivedFrom(App::GeoFeature::getClassTypeId())) { this->Placement.setValue(static_cast(support)->Placement.getValue()); } @@ -575,8 +579,13 @@ TopoShape ProfileBased::getTopoShapeSupportFace() const shape = getTopoShapeVerifiedFace(); } else if (sketch->MapMode.getValue() == Attacher::mmFlatFace +#ifdef FC_USE_TNP_FIX + && sketch->Support.getValue()) { + const auto& Support = sketch->Support; +#else && sketch->AttachmentSupport.getValue()) { const auto& Support = sketch->AttachmentSupport; +#endif App::DocumentObject* ref = Support.getValue(); shape = Part::Feature::getTopoShape( ref, @@ -631,8 +640,11 @@ Part::Feature* ProfileBased::getBaseObject(bool silent) const //due to former test we know we have a 2d object Part::Part2DObject* sketch = getVerifiedSketch(silent); const char* err = nullptr; - +#ifdef FC_USE_TNP_FIX + App::DocumentObject* spt = sketch->Support.getValue(); +#else App::DocumentObject* spt = sketch->AttachmentSupport.getValue(); +#endif if (spt) { if (spt->isDerivedFrom(Part::Feature::getClassTypeId())) { rv = static_cast(spt);