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:
parent
23d905e869
commit
739509aadc
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
#include "ViewProviderBody.h"
|
||||
#include "ViewProvider.h"
|
||||
#include <Gui/MDIView.h>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
|
@ -130,20 +131,42 @@ void ViewProviderBody::setOverrideMode(const std::string& mode) {
|
|||
|
||||
bool ViewProviderBody::doubleClicked(void)
|
||||
{
|
||||
// assure the PartDesign workbench
|
||||
Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// and set correct active objects
|
||||
auto* part = App::Part::getPartOfObject ( getObject() );
|
||||
if ( part && part != getActiveView()->getActiveObject<App::Part*> ( PARTKEY ) ) {
|
||||
Gui::Command::doCommand ( Gui::Command::Gui,
|
||||
"Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
|
||||
PARTKEY, part->getNameInDocument() );
|
||||
//first, check if the body is already active.
|
||||
App::DocumentObject* activeBody = nullptr;
|
||||
Gui::MDIView* activeView = this->getActiveView();
|
||||
if ( activeView ) {
|
||||
activeBody = activeView->getActiveObject<App::DocumentObject*> (PDBODYKEY);
|
||||
}
|
||||
|
||||
Gui::Command::doCommand ( Gui::Command::Gui,
|
||||
"Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
|
||||
PDBODYKEY, this->getObject()->getNameInDocument() );
|
||||
if (activeBody == this->getObject()){
|
||||
//active body double-clicked. Deactivate.
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', None)",
|
||||
this->getObject()->getDocument()->getName(),
|
||||
PDBODYKEY);
|
||||
} else {
|
||||
|
||||
// assure the PartDesign workbench
|
||||
Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// and set correct active objects
|
||||
auto* part = App::Part::getPartOfObject ( getObject() );
|
||||
if ( part && part != getActiveView()->getActiveObject<App::Part*> ( PARTKEY ) ) {
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
|
||||
part->getDocument()->getName(),
|
||||
PARTKEY,
|
||||
part->getDocument()->getName(),
|
||||
part->getNameInDocument());
|
||||
}
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"Gui.getDocument('%s').ActiveView.setActiveObject('%s', App.getDocument('%s').getObject('%s'))",
|
||||
this->getObject()->getDocument()->getName(),
|
||||
PDBODYKEY,
|
||||
this->getObject()->getDocument()->getName(),
|
||||
this->getObject()->getNameInDocument());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user