Gui/PartDesign: fix setActiveObject() for Part and Body

This commit is contained in:
Zheng, Lei
2019-08-24 10:20:46 +08:00
committed by wmayer
parent 778ccc2692
commit 432c9ae15b
2 changed files with 14 additions and 13 deletions

View File

@@ -86,24 +86,24 @@ bool ViewProviderPart::doubleClicked(void)
//first, check if the part is already active.
App::DocumentObject* activePart = nullptr;
MDIView* activeView = this->getActiveView();
if ( activeView ) {
activePart = activeView->getActiveObject<App::DocumentObject*> (PARTKEY);
}
auto activeDoc = Gui::Application::Instance->activeDocument();
if(!activeDoc)
activeDoc = getDocument();
auto activeView = activeDoc->setActiveView(this);
if(!activeView)
return false;
activePart = activeView->getActiveObject<App::DocumentObject*> (PARTKEY);
if (activePart == this->getObject()){
//active part double-clicked. Deactivate.
Gui::Command::doCommand(Gui::Command::Gui,
"Gui.activateView('Gui::View3DInventor', True)\n"
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', None)",
this->getObject()->getDocument()->getName(),
"Gui.ActiveDocument.ActiveView.setActiveObject('%s', None)",
PARTKEY);
} else {
//set new active part
Gui::Command::doCommand(Gui::Command::Gui,
"Gui.activateView('Gui::View3DInventor', True)\n"
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
this->getObject()->getDocument()->getName(),
"Gui.ActiveDocument.ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
PARTKEY,
this->getObject()->getDocument()->getName(),
this->getObject()->getNameInDocument());