Gui/PartDesign: fix setActiveObject() for Part and Body
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -146,8 +146,9 @@ bool ViewProviderBody::doubleClicked(void)
|
||||
auto activeDoc = Gui::Application::Instance->activeDocument();
|
||||
if(!activeDoc)
|
||||
activeDoc = getDocument();
|
||||
auto activeView = activeDoc->getActiveView();
|
||||
if(!activeView) return false;
|
||||
auto activeView = activeDoc->setActiveView(this);
|
||||
if(!activeView)
|
||||
return false;
|
||||
|
||||
if (activeView->isActiveObject(getObject(),PDBODYKEY)) {
|
||||
//active body double-clicked. Deactivate.
|
||||
@@ -160,7 +161,7 @@ bool ViewProviderBody::doubleClicked(void)
|
||||
|
||||
// and set correct active objects
|
||||
auto* part = App::Part::getPartOfObject ( getObject() );
|
||||
if ( part && part != getActiveView()->getActiveObject<App::Part*> ( PARTKEY ) ) {
|
||||
if ( part && part != activeView->getActiveObject<App::Part*> ( PARTKEY ) ) {
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.ActiveDocument.ActiveView.setActiveObject('%s',%s)",
|
||||
PARTKEY, Gui::Command::getObjectCmd(part).c_str());
|
||||
|
||||
Reference in New Issue
Block a user