better active part and document tip handling
This commit is contained in:
parent
d435e15a97
commit
7f80e711f6
|
@ -2079,6 +2079,12 @@ void Document::remObject(const char* sName)
|
||||||
|
|
||||||
// Before deleting we must nullify all dependant objects
|
// Before deleting we must nullify all dependant objects
|
||||||
breakDependency(pos->second, true);
|
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!
|
// do no transactions if we do a rollback!
|
||||||
if(!d->rollback){
|
if(!d->rollback){
|
||||||
|
@ -2122,6 +2128,12 @@ void Document::_remObject(DocumentObject* pcObject)
|
||||||
d->activeObject = 0;
|
d->activeObject = 0;
|
||||||
|
|
||||||
signalDeletedObject(*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!
|
// do no transactions if we do a rollback!
|
||||||
if(!d->rollback){
|
if(!d->rollback){
|
||||||
|
|
|
@ -69,5 +69,6 @@ namespace Gui
|
||||||
} //namespace Gui
|
} //namespace Gui
|
||||||
|
|
||||||
static const char PDBODYKEY[] = "pdbody";
|
static const char PDBODYKEY[] = "pdbody";
|
||||||
|
static const char PARTKEY[] = "part";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -170,17 +170,21 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
||||||
bool ViewProviderPart::doubleClicked(void)
|
bool ViewProviderPart::doubleClicked(void)
|
||||||
{
|
{
|
||||||
if(Workbench.getValue() != "")
|
if(Workbench.getValue() != "")
|
||||||
// assure the PartDesign workbench
|
// assure the given workbench
|
||||||
Gui::Command::assureWorkbench( Workbench.getValue() );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ViewProviderPart::onDelete(const std::vector<std::string> &)
|
bool ViewProviderPart::onDelete(const std::vector<std::string> &)
|
||||||
{
|
{
|
||||||
//Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument(\"%s\").getObject(\"%s\").removeObjectsFromDocument()"
|
if(getActiveView()->getActiveObject<App::Part*>(PARTKEY) == getObject())
|
||||||
// ,getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', None)", PARTKEY);
|
||||||
|
|
||||||
return true;
|
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().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());
|
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())));
|
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();
|
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().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());
|
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())));
|
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 {
|
} else {
|
||||||
PartName = actPart->getNameInDocument();
|
PartName = actPart->getNameInDocument();
|
||||||
// add the Body feature itself, and make it active
|
// 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());
|
//doCommand(Doc,"App.activeDocument().%s.Tip = None",FeatName.c_str());
|
||||||
addModule(Gui,"PartDesignGui"); // import the Gui module only once a session
|
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());
|
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
|
// Make the "Create sketch" prompt appear in the task panel
|
||||||
doCommand(Gui,"Gui.Selection.clearSelection()");
|
doCommand(Gui,"Gui.Selection.clearSelection()");
|
||||||
doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", FeatName.c_str());
|
doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", FeatName.c_str());
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Base/Console.h"
|
#include "Base/Console.h"
|
||||||
|
#include <App/Part.h>
|
||||||
|
|
||||||
using namespace PartDesignGui;
|
using namespace PartDesignGui;
|
||||||
|
|
||||||
|
@ -105,8 +106,13 @@ bool ViewProviderBody::doubleClicked(void)
|
||||||
{
|
{
|
||||||
// assure the PartDesign workbench
|
// assure the PartDesign workbench
|
||||||
Gui::Command::assureWorkbench("PartDesignWorkbench");
|
Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||||
//Gui::Command::doCommand(Gui::Command::Gui,"PartDesignGui.setActiveBody(App.activeDocument().%s)",this->getObject()->getNameInDocument());
|
|
||||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user