PartDesign: deactivate a container on double-click if already active

Before, it was impossible to deactivate a container (Part, Body) via gui
(or it wasn't obvious).
This commit is contained in:
DeepSOIC
2016-05-20 15:41:03 +03:00
parent f873a24b84
commit 218c81b7cc
2 changed files with 60 additions and 15 deletions

View File

@@ -36,6 +36,8 @@
#include "Command.h"
#include "ViewProviderPart.h"
#include "Application.h"
#include "MDIView.h"
using namespace Gui;
@@ -65,9 +67,29 @@ void ViewProviderPart::onChanged(const App::Property* prop) {
bool ViewProviderPart::doubleClicked(void)
{
//make the part the active one
Gui::Command::doCommand(Gui::Command::Gui,
"Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
PARTKEY, this->getObject()->getNameInDocument());
//first, check if the part is already active.
App::DocumentObject* activePart = nullptr;
MDIView* activeView = this->getActiveView();
if ( activeView ) {
activePart = activeView->getActiveObject<App::DocumentObject*> (PARTKEY);
}
if (activePart == this->getObject()){
//active part double-clicked. Deactivate.
Gui::Command::doCommand(Gui::Command::Gui,
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', None)",
this->getObject()->getDocument()->getName(),
PARTKEY);
} else {
//set new active part
Gui::Command::doCommand(Gui::Command::Gui,
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
this->getObject()->getDocument()->getName(),
PARTKEY,
this->getObject()->getDocument()->getName(),
this->getObject()->getNameInDocument());
}
return true;
}