From d6c40727f761ee11c6f0106532c2253a8342b2f5 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Fri, 23 Jan 2026 16:01:06 +0100 Subject: [PATCH] Assembly: prevent assembly collapse when editing sketch. (#26956) * Gui: View provider: isAutoCollapseOnDeactivation * Update ViewProvider.h * Update ActiveObjectList.cpp * Update ViewProviderAssembly.cpp * Update ActiveObjectList.cpp --- src/Gui/ActiveObjectList.cpp | 2 +- src/Gui/ViewProvider.h | 6 ++++++ src/Mod/Assembly/Gui/ViewProviderAssembly.cpp | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Gui/ActiveObjectList.cpp b/src/Gui/ActiveObjectList.cpp index 612e0a0aff..6d27c0f22c 100644 --- a/src/Gui/ActiveObjectList.cpp +++ b/src/Gui/ActiveObjectList.cpp @@ -73,7 +73,7 @@ void ActiveObjectList::setHighlight(const ObjectInfo& info, HighlightMode mode, return; } - if (TreeParams::getTreeActiveAutoExpand()) { + if (TreeParams::getTreeActiveAutoExpand() && (enable || vp->isAutoCollapseOnDeactivation())) { vp->getDocument()->signalExpandObject( *vp, enable ? TreeItemMode::ExpandPath : TreeItemMode::CollapseItem, diff --git a/src/Gui/ViewProvider.h b/src/Gui/ViewProvider.h index 1adc5e8b70..4f13d15edb 100644 --- a/src/Gui/ViewProvider.h +++ b/src/Gui/ViewProvider.h @@ -445,6 +445,11 @@ public: { return true; } + /** Tell if the tree item should be auto collapsed*/ + bool isAutoCollapseOnDeactivation() const + { + return autoCollapseOnDeactivation; + } /** @name Signals of the view provider */ //@{ @@ -707,6 +712,7 @@ protected: /// The root separator for annotations SoSeparator* pcAnnotation {nullptr}; ViewProviderPy* pyViewObject {nullptr}; + bool autoCollapseOnDeactivation {true}; std::string overrideMode; std::bitset<32> StatusBits; /// whether visibility can toggled diff --git a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp index 5029c1296a..5056ad9201 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp @@ -152,6 +152,7 @@ void ViewProviderAssembly::setupContextMenu(QMenu* menu, QObject* receiver, cons bool ViewProviderAssembly::doubleClicked() { if (isInEditMode()) { + autoCollapseOnDeactivation = true; getDocument()->resetEdit(); } else { @@ -280,6 +281,7 @@ bool ViewProviderAssembly::setEdit(int mode) if (mode == ViewProvider::Default) { // Ask that this edit mode be restored. For example if it is quit to edit a sketch. getDocument()->setEditRestore(true); + autoCollapseOnDeactivation = false; // Set the part as 'Activated' ie bold in the tree. Gui::Command::doCommand(