diff --git a/src/Gui/ActiveObjectList.h b/src/Gui/ActiveObjectList.h index d145e9f2a..8ef0baa01 100644 --- a/src/Gui/ActiveObjectList.h +++ b/src/Gui/ActiveObjectList.h @@ -66,4 +66,6 @@ namespace Gui } //namespace Gui -#endif \ No newline at end of file +static const char PDBODYKEY[] = "pdbody"; + +#endif diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index a21bca2b8..9922a34b2 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -123,7 +123,7 @@ void CmdPartDesignBody::activated(int iMsg) //doCommand(Doc,"App.activeDocument().%s.Model = []",FeatName.c_str()); //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('Body',App.activeDocument().%s)", 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 doCommand(Gui,"Gui.Selection.clearSelection()"); doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", FeatName.c_str()); @@ -174,8 +174,8 @@ void CmdPartDesignMoveTip::activated(int iMsg) // Switch to other body pcActiveBody = static_cast(Part::BodyBase::findBodyOf(selFeature)); if (pcActiveBody != NULL) - Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('Body',App.activeDocument().%s)", - pcActiveBody->getNameInDocument()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s',App.activeDocument().%s)", + PDBODYKEY, pcActiveBody->getNameInDocument()); else return; } @@ -244,8 +244,8 @@ void CmdPartDesignDuplicateSelection::activated(int iMsg) // Switch to other body pcActiveBody = static_cast(Part::BodyBase::findBodyOf(selFeature)); if (pcActiveBody != NULL) - Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('Body',App.activeDocument().%s)", - pcActiveBody->getNameInDocument()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", + PDBODYKEY, pcActiveBody->getNameInDocument()); else return; } @@ -1868,7 +1868,7 @@ void CmdPartDesignBoolean::activated(int iMsg) openCommand("Create Boolean"); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); // Make sure we are working on the selected body if (body != activeBody) { Gui::Selection().clearSelection(); diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index 702474121..34029cac7 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -51,7 +51,7 @@ using namespace Gui; bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName) { - PartDesign::Body* ActivePartObject = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* ActivePartObject = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); App::Part* activePart = Gui::Application::Instance->activeView()->getActiveObject("Part"); // Don't allow selection in other document diff --git a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp index b2a2eca1b..d95282d43 100644 --- a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp @@ -435,7 +435,7 @@ void TaskDatumParameters::onCheckFlip(bool on) void TaskDatumParameters::onButtonRef(const bool pressed, const int idx) { // Note: Even if there is no solid, App::Plane and Part::Datum can still be selected - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); App::DocumentObject* solid = activeBody->getPrevSolidFeature(); if (pressed) { @@ -507,7 +507,7 @@ void TaskDatumParameters::onRefName(const QString& text, const int idx) if (obj == NULL) return; std::string subElement; - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { // everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree) @@ -715,7 +715,7 @@ bool TaskDlgDatumParameters::accept() Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle()); //Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Checked = %i",name.c_str(),parameter->getCheckBox1()?1:0); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); App::DocumentObject* solid = activeBody->getPrevSolidFeature(); if (solid != NULL) { QString buf = QString::fromAscii("["); @@ -749,7 +749,7 @@ bool TaskDlgDatumParameters::reject() Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); // Body housekeeping if (activeBody != NULL) { // Make the new Tip and the previous solid feature visible again diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 43dda43fa..4721a4a4c 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -240,7 +240,7 @@ bool TaskDlgDressUpParameters::reject() Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); // Body housekeeping - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (activeBody != NULL) { // Make the new Tip and the previous solid feature visible again App::DocumentObject* tip = activeBody->Tip.getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index c32aa8a33..026903e4a 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -91,7 +91,7 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar) { // Note: Even if there is no solid, App::Plane and Part::Datum can still be selected - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); App::DocumentObject* prevSolid = activeBody->getPrevSolidFeature(vp->getObject(), false); App::DocumentObject* curSolid = activeBody->getPrevSolidFeature(); @@ -136,7 +136,7 @@ const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text) if (obj == NULL) return QByteArray(); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { // everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree) return QByteArray(); @@ -245,7 +245,7 @@ bool TaskDlgSketchBasedParameters::reject() } // Body housekeeping - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (activeBody != NULL) { // Make the new Tip and the previous solid feature visible again App::DocumentObject* tip = activeBody->Tip.getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index 85c15b5ff..ad6e3f877 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -340,7 +340,7 @@ bool TaskDlgTransformedParameters::reject() Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); // Body housekeeping - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (activeBody != NULL) { // Make the new Tip and the previous solid feature visible again App::DocumentObject* tip = activeBody->Tip.getValue(); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 6b76d3a37..955723919 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -52,7 +52,7 @@ ViewProvider::~ViewProvider() bool ViewProvider::doubleClicked(void) { - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (activeBody != NULL) { // Drop into insert mode so that the user doesn't see all the geometry that comes later in the tree // Also, this way the user won't be tempted to use future geometry as external references for the sketch @@ -85,7 +85,7 @@ void ViewProvider::unsetEdit(int ModNum) if (ModNum == ViewProvider::Default) { // when pressing ESC make sure to close the dialog - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); Gui::Control().closeDialog(); if ((activeBody != NULL) && (oldTip != NULL)) { Gui::Selection().clearSelection(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index b23e609a6..6160fece6 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -105,7 +105,7 @@ 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()); - Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('Body',App.activeDocument().%s)",this->getObject()->getNameInDocument()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, this->getObject()->getNameInDocument()); return true; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index 31dc56a92..c0e5f5e0a 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -276,7 +276,7 @@ bool ViewProviderDatum::doubleClicked(void) std::string Msg("Edit "); Msg += this->pcObject->Label.getValue(); Gui::Command::openCommand(Msg.c_str()); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (activeBody != NULL) { // Drop into insert mode so that the user doesn't see all the geometry that comes later in the tree // Also, this way the user won't be tempted to use future geometry as external references for the sketch @@ -301,7 +301,7 @@ void ViewProviderDatum::unsetEdit(int ModNum) if (ModNum == ViewProvider::Default) { // when pressing ESC make sure to close the dialog Gui::Control().closeDialog(); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if ((activeBody != NULL) && (oldTip != NULL)) { Gui::Selection().clearSelection(); diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 6b9a620aa..edfaa0d77 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -75,7 +75,7 @@ namespace PartDesignGui { PartDesign::Body *getBody(void) { - PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (!activeBody){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"), @@ -118,7 +118,7 @@ PartDesign::Body *Workbench::setUpPart(const App::Part *part) Gui::Command::addModule(Gui::Command::Doc, "PartDesign"); Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().addObject('PartDesign::Body','%s')", BodyName.c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", part->getNameInDocument()); - Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('Body',App.activeDocument().%s)", BodyName.c_str()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, BodyName.c_str()); return NULL; } @@ -184,7 +184,7 @@ void Workbench::_doMigration(const App::Document* doc) // Always create at least the first body, even if the document is empty // This adds both the base planes and the body Gui::Command::runCommand(Gui::Command::Doc, "FreeCADGui.runCommand('PartDesign_Body')"); - PartDesign::Body *activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + PartDesign::Body *activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); assert(activeBody); @@ -192,7 +192,7 @@ void Workbench::_doMigration(const App::Document* doc) for (std::vector::iterator r = roots.begin(); r != roots.end(); r++) { if (r != roots.begin()) { Gui::Command::runCommand(Gui::Command::Doc, "FreeCADGui.runCommand('PartDesign_Body')"); - activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); } std::set inList; @@ -355,7 +355,7 @@ void Workbench::_switchToDocument(const App::Document* doc) Gui::Command::doCommand(Gui::Command::Doc, "PartDesignGui.setUpPart(App.activeDocument().%s)", PartName.c_str()); Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('Part',App.activeDocument().%s)", PartName.c_str()); - activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); // body have to be created assert(activeBody); @@ -363,13 +363,13 @@ void Workbench::_switchToDocument(const App::Document* doc) } else { // empty document with no tip, so do migration _doMigration(doc); - activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); assert(activeBody); } } else { - activeBody = Gui::Application::Instance->activeView()->getActiveObject("Body"); + activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); assert(activeBody); activePart = Gui::Application::Instance->activeView()->getActiveObject("Part"); assert(activePart);