From 10c8ba7e9bcff4c4686b4d228d5252ad310b5a73 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Fri, 5 Apr 2013 20:06:23 +0430 Subject: [PATCH] Moved ActivePartObject etc. to PartDesignGui namespace and added extern declaration to Workbench.h as suggested by logari81 --- src/Mod/Assembly/App/AppAssemblyPy.cpp | 30 ++++++++++++++------------ src/Mod/PartDesign/Gui/Command.cpp | 7 +++--- src/Mod/PartDesign/Gui/Workbench.cpp | 6 ++---- src/Mod/PartDesign/Gui/Workbench.h | 14 ++++++++++++ 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/Mod/Assembly/App/AppAssemblyPy.cpp b/src/Mod/Assembly/App/AppAssemblyPy.cpp index e048646e9..7c0997d49 100644 --- a/src/Mod/Assembly/App/AppAssemblyPy.cpp +++ b/src/Mod/Assembly/App/AppAssemblyPy.cpp @@ -36,30 +36,32 @@ #include +namespace PartDesignGui { + // pointer to the active assembly object PartDesign::Body *ActivePartObject =0; Gui::Document *ActiveGuiDoc =0; App::Document *ActiveAppDoc =0; Gui::ViewProviderDocumentObject *ActiveVp =0; - +} static PyObject * setActivePart(PyObject *self, PyObject *args) { - if(ActivePartObject){ + if(PartDesignGui::ActivePartObject){ // check if the document not already closed std::vector docs = App::GetApplication().getDocuments(); for(std::vector::const_iterator it=docs.begin();it!=docs.end();++it) - if(*it == ActiveAppDoc){ - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,false); + if(*it == PartDesignGui::ActiveAppDoc){ + PartDesignGui::ActiveGuiDoc->signalHighlightObject(*PartDesignGui::ActiveVp,Gui::Underlined,false); break; } - ActivePartObject->IsActive.setValue(false); - ActivePartObject = 0; - ActiveGuiDoc =0; - ActiveAppDoc =0; - ActiveVp =0; + PartDesignGui::ActivePartObject->IsActive.setValue(false); + PartDesignGui::ActivePartObject = 0; + PartDesignGui::ActiveGuiDoc =0; + PartDesignGui::ActiveAppDoc =0; + PartDesignGui::ActiveVp =0; } PyObject *object=0; @@ -69,11 +71,11 @@ static PyObject * setActivePart(PyObject *self, PyObject *args) assert(Item); Item->IsActive.setValue(true); - ActivePartObject = Item; - ActiveAppDoc = Item->getDocument(); - ActiveGuiDoc = Gui::Application::Instance->getDocument(ActiveAppDoc); - ActiveVp = dynamic_cast (ActiveGuiDoc->getViewProvider(Item)) ; - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined,true); + PartDesignGui::ActivePartObject = Item; + PartDesignGui::ActiveAppDoc = Item->getDocument(); + PartDesignGui::ActiveGuiDoc = Gui::Application::Instance->getDocument(PartDesignGui::ActiveAppDoc); + PartDesignGui::ActiveVp = dynamic_cast (PartDesignGui::ActiveGuiDoc->getViewProvider(Item)) ; + PartDesignGui::ActiveGuiDoc->signalHighlightObject(*PartDesignGui::ActiveVp,Gui::Underlined,true); } diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 473e6effc..dff0d12b7 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -59,11 +59,10 @@ #include #include "FeaturePickDialog.h" +#include "Workbench.h" using namespace std; -extern PartDesign::Body *ActivePartObject; - //=========================================================================== // Helper for Body @@ -71,7 +70,7 @@ extern PartDesign::Body *ActivePartObject; PartDesign::Body *getBody(void) { - if(!ActivePartObject){ + if(!PartDesignGui::ActivePartObject){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"), QObject::tr("In order to use PartDesign you need an active Body object in the document. " "Please make one active or create one. If you have a legacy document " @@ -79,7 +78,7 @@ PartDesign::Body *getBody(void) "PartDesign to put them into a Body." )); } - return ActivePartObject; + return PartDesignGui::ActivePartObject; } diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 85c547e32..e98ba841f 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -47,8 +47,6 @@ using namespace PartDesignGui; qApp->translate("Gui::TaskView::TaskWatcherCommands", "Create Geometry"); #endif -extern PartDesign::Body *ActivePartObject; - /// @namespace PartDesignGui @class Workbench TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench) @@ -208,8 +206,8 @@ void Workbench::deactivated() removeTaskWatcher(); // remember the body for later activation // TODO: Remove this if the IsActive Property of Body works OK - if(ActivePartObject) - oldActive = ActivePartObject->getNameInDocument(); + if(PartDesignGui::ActivePartObject) + oldActive = PartDesignGui::ActivePartObject->getNameInDocument(); else oldActive = ""; // reset the active Body diff --git a/src/Mod/PartDesign/Gui/Workbench.h b/src/Mod/PartDesign/Gui/Workbench.h index f7cc4b97a..dea16e27d 100644 --- a/src/Mod/PartDesign/Gui/Workbench.h +++ b/src/Mod/PartDesign/Gui/Workbench.h @@ -29,11 +29,25 @@ namespace Gui { class MenuItem; +class Document; +class ViewProviderDocumentObject; + +} + +namespace PartDesign { + +class Body; } namespace PartDesignGui { +// pointer to the active assembly object +extern PartDesign::Body *ActivePartObject; +extern Gui::Document *ActiveGuiDoc; +extern App::Document *ActiveAppDoc; +extern Gui::ViewProviderDocumentObject *ActiveVp; + /** * @author Werner Mayer */