Merge pull request #27107 from PaddleStroke/asm_3patches

Assembly: Fix Assembly activation issues.
This commit is contained in:
sliptonic
2026-01-26 10:51:28 -06:00
committed by GitHub
9 changed files with 64 additions and 15 deletions

View File

@@ -143,7 +143,7 @@ void ViewProviderAssembly::setupContextMenu(QMenu* menu, QObject* receiver, cons
QAction* act = menu->addAction(QObject::tr("Active object"));
act->setCheckable(true);
act->setChecked(isActivePart());
act->setChecked(isActivePart(ASSEMBLYKEY));
func->trigger(act, [this]() { this->doubleClicked(); });
ViewProviderDragger::setupContextMenu(menu, receiver, member); // NOLINT
@@ -153,6 +153,7 @@ bool ViewProviderAssembly::doubleClicked()
{
if (isInEditMode()) {
autoCollapseOnDeactivation = true;
getDocument()->setEditRestore(false);
getDocument()->resetEdit();
}
else {
@@ -290,7 +291,7 @@ bool ViewProviderAssembly::setEdit(int mode)
"Gui.getDocument(appDoc).ActiveView.setActiveObject('%s', "
"appDoc.getObject('%s'))",
this->getObject()->getDocument()->getName(),
PARTKEY,
ASSEMBLYKEY,
this->getObject()->getNameInDocument()
);
@@ -310,6 +311,15 @@ bool ViewProviderAssembly::setEdit(int mode)
UpdateSolverInformation();
});
connectActivatedVP = getDocument()->signalActivatedViewProvider.connect(
std::bind(
&ViewProviderAssembly::slotActivatedVP,
this,
std::placeholders::_1,
std::placeholders::_2
)
);
assembly->solve();
return true;
@@ -334,13 +344,15 @@ void ViewProviderAssembly::unsetEdit(int mode)
}
// Set the part as not 'Activated' ie not bold in the tree.
Gui::Command::doCommand(
Gui::Command::Gui,
"appDoc = App.getDocument('%s')\n"
"Gui.getDocument(appDoc).ActiveView.setActiveObject('%s', None)",
this->getObject()->getDocument()->getName(),
PARTKEY
);
if (isActivePart(ASSEMBLYKEY)) {
Gui::Command::doCommand(
Gui::Command::Gui,
"appDoc = App.getDocument('%s')\n"
"Gui.getDocument(appDoc).ActiveView.setActiveObject('%s', None)",
this->getObject()->getDocument()->getName(),
ASSEMBLYKEY
);
}
Gui::TaskView::TaskView* taskView = Gui::Control().taskPanel();
if (taskView) {
@@ -349,12 +361,26 @@ void ViewProviderAssembly::unsetEdit(int mode)
}
connectSolverUpdate.disconnect();
connectActivatedVP.disconnect();
return;
}
ViewProviderPart::unsetEdit(mode);
}
void ViewProviderAssembly::slotActivatedVP(const Gui::ViewProviderDocumentObject* vp, const char* name)
{
if (name && strcmp(name, ASSEMBLYKEY) == 0) {
// If the new active VP is NOT this assembly (meaning we lost activation or it was cleared)
if (vp != this && isInEditMode()) {
autoCollapseOnDeactivation = true;
getDocument()->setEditRestore(false);
getDocument()->resetEdit();
}
}
}
void ViewProviderAssembly::setDragger()
{
// Create the dragger coin object
@@ -404,7 +430,7 @@ App::DocumentObject* ViewProviderAssembly::getActivePart() const
if (!activeView) {
return nullptr;
}
return activeView->getActiveObject<App::DocumentObject*>(PARTKEY);
return activeView->getActiveObject<App::DocumentObject*>(ASSEMBLYKEY);
}
bool ViewProviderAssembly::keyPressed(bool pressed, int key)