better active part and document tip handling
This commit is contained in:
parent
d435e15a97
commit
7f80e711f6
|
@ -2080,6 +2080,12 @@ void Document::remObject(const char* sName)
|
|||
// Before deleting we must nullify all dependant objects
|
||||
breakDependency(pos->second, true);
|
||||
|
||||
//and remove the tip if needed
|
||||
if(Tip.getValue() && strcmp(Tip.getValue()->getNameInDocument(), sName)==0) {
|
||||
Tip.setValue(nullptr);
|
||||
TipName.setValue("");
|
||||
}
|
||||
|
||||
// do no transactions if we do a rollback!
|
||||
if(!d->rollback){
|
||||
|
||||
|
@ -2123,6 +2129,12 @@ void Document::_remObject(DocumentObject* pcObject)
|
|||
|
||||
signalDeletedObject(*pcObject);
|
||||
|
||||
//remove the tip if needed
|
||||
if(Tip.getValue() == pcObject) {
|
||||
Tip.setValue(nullptr);
|
||||
TipName.setValue("");
|
||||
}
|
||||
|
||||
// do no transactions if we do a rollback!
|
||||
if(!d->rollback){
|
||||
// Transaction stuff
|
||||
|
|
|
@ -69,5 +69,6 @@ namespace Gui
|
|||
} //namespace Gui
|
||||
|
||||
static const char PDBODYKEY[] = "pdbody";
|
||||
static const char PARTKEY[] = "part";
|
||||
|
||||
#endif
|
||||
|
|
|
@ -170,17 +170,21 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
|||
bool ViewProviderPart::doubleClicked(void)
|
||||
{
|
||||
if(Workbench.getValue() != "")
|
||||
// assure the PartDesign workbench
|
||||
// assure the given workbench
|
||||
Gui::Command::assureWorkbench( Workbench.getValue() );
|
||||
|
||||
//make the part the active one
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PARTKEY, this->getObject()->getNameInDocument());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ViewProviderPart::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
//Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument(\"%s\").getObject(\"%s\").removeObjectsFromDocument()"
|
||||
// ,getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
if(getActiveView()->getActiveObject<App::Part*>(PARTKEY) == getObject())
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', None)", PARTKEY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ void CmdPartDesignPart::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().Tip = App.activeDocument().addObject('App::Part','%s')",PartName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr(PartName.c_str()).toStdString().c_str());
|
||||
PartDesignGui::Workbench::setUpPart(dynamic_cast<App::Part *>(getDocument()->getObject(PartName.c_str())));
|
||||
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PARTKEY, PartName.c_str());
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
@ -151,6 +152,8 @@ void CmdPartDesignBody::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().Tip = App.activeDocument().addObject('App::Part','%s')",PartName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr(PartName.c_str()).toStdString().c_str());
|
||||
PartDesignGui::Workbench::setUpPart(dynamic_cast<App::Part *>(getDocument()->getObject(PartName.c_str())));
|
||||
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PARTKEY, PartName.c_str());
|
||||
|
||||
} else {
|
||||
PartName = actPart->getNameInDocument();
|
||||
// add the Body feature itself, and make it active
|
||||
|
@ -159,6 +162,7 @@ void CmdPartDesignBody::activated(int iMsg)
|
|||
//doCommand(Doc,"App.activeDocument().%s.Tip = None",FeatName.c_str());
|
||||
addModule(Gui,"PartDesignGui"); // import the Gui module only once a session
|
||||
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, FeatName.c_str());
|
||||
|
||||
// Make the "Create sketch" prompt appear in the task panel
|
||||
doCommand(Gui,"Gui.Selection.clearSelection()");
|
||||
doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", FeatName.c_str());
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "Base/Console.h"
|
||||
#include <App/Part.h>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
|
@ -105,7 +106,12 @@ bool ViewProviderBody::doubleClicked(void)
|
|||
{
|
||||
// assure the PartDesign workbench
|
||||
Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
//Gui::Command::doCommand(Gui::Command::Gui,"PartDesignGui.setActiveBody(App.activeDocument().%s)",this->getObject()->getNameInDocument());
|
||||
|
||||
//and set correct active objects
|
||||
auto* part = PartDesignGui::getPartFor(getObject(), false);
|
||||
if(part!=Gui::Application::Instance->activeView()->getActiveObject<App::Part*>(PARTKEY))
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PARTKEY, part->getNameInDocument());
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, this->getObject()->getNameInDocument());
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user