Assembly: Fix "deactivated by activating a App::Part, assembly stay in edit"
Fix "Activating a body in a part in an assembly deactivates the assembly and activate the part" Fix "A manually deactivated assembly is still restoring later"
This commit is contained in:
@@ -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 {
|
||||
@@ -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.
|
||||
Base::Console().warning("setEdit\n");
|
||||
getDocument()->setEditRestore(true);
|
||||
autoCollapseOnDeactivation = false;
|
||||
|
||||
@@ -290,7 +292,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 +312,13 @@ bool ViewProviderAssembly::setEdit(int mode)
|
||||
UpdateSolverInformation();
|
||||
});
|
||||
|
||||
connectActivatedVP = getDocument()->signalActivatedVP.connect(std::bind(
|
||||
&ViewProviderAssembly::slotActivatedVP,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
));
|
||||
|
||||
assembly->solve();
|
||||
|
||||
return true;
|
||||
@@ -334,13 +343,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 +360,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 +429,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)
|
||||
|
||||
Reference in New Issue
Block a user