From 720b4a2807cfe75d04ac18ef67e15bfa5d3bfe98 Mon Sep 17 00:00:00 2001 From: jriegel Date: Fri, 5 Apr 2013 15:44:29 +0200 Subject: [PATCH] Add active Analysis logic --- src/Mod/Fem/Gui/AppFemGuiPy.cpp | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/Mod/Fem/Gui/AppFemGuiPy.cpp b/src/Mod/Fem/Gui/AppFemGuiPy.cpp index d5ce3f616..5b1a9c91a 100755 --- a/src/Mod/Fem/Gui/AppFemGuiPy.cpp +++ b/src/Mod/Fem/Gui/AppFemGuiPy.cpp @@ -26,6 +26,71 @@ # include #endif +#include +#include +#include +#include +#include + +#include + + +// pointer to the active Analysis object +Fem::FemAnalysis *ActiveAnalysis =0; +Gui::Document *ActiveGuiDoc =0; +App::Document *ActiveAppDoc =0; +Gui::ViewProviderDocumentObject *ActiveVp =0; + + +/* module functions */ +static PyObject * setActiveAnalysis(PyObject *self, PyObject *args) +{ + if(ActiveAnalysis){ + // 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::Blue,false); + break; + } + + ActiveAnalysis = 0; + ActiveGuiDoc =0; + ActiveAppDoc =0; + ActiveVp =0; + } + + PyObject *object=0; + if (PyArg_ParseTuple(args,"|O!",&(App::DocumentObjectPy::Type), &object)&& object) { + App::DocumentObject* obj = static_cast(object)->getDocumentObjectPtr(); + if(!obj || !obj->getTypeId().isDerivedFrom(Fem::FemAnalysis::getClassTypeId()) ){ + PyErr_SetString(PyExc_Exception, "Active Analysis object have to be of type Fem::FemAnalysis!"); + return 0; + } + + // get the gui document of the Assembly Item + ActiveAnalysis = static_cast(obj); + ActiveAppDoc = ActiveAnalysis->getDocument(); + ActiveGuiDoc = Gui::Application::Instance->getDocument(ActiveAppDoc); + ActiveVp = dynamic_cast (ActiveGuiDoc->getViewProvider(ActiveAnalysis)) ; + ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,true); + } + + Py_Return; +} + +/* module functions */ +static PyObject * getActiveAnalysis(PyObject *self, PyObject *args) +{ + if(ActiveAnalysis){ + + return ActiveAnalysis->getPyObject(); + } + + + Py_Return; +} + /* registration table */