From 7d8793b0eca98467fffc16a5acf8e8022a15f77e Mon Sep 17 00:00:00 2001 From: abn Date: Thu, 16 Oct 2014 11:50:56 +0200 Subject: [PATCH] Various fixes for PVViewer: * better insulation of PVViewer and PARAVIS: resources are now in GUI * fixed cyclic dependencies * fixed translation --- src/PVViewer/CMakeLists.txt | 3 + src/PVViewer/PVViewer_EngineWrapper.cxx | 13 +- src/PVViewer/PVViewer_EngineWrapper.h | 1 + src/PVViewer/PVViewer_GUIElements.cxx | 4 +- src/PVViewer/PVViewer_ViewManager.cxx | 15 +- src/PVViewer/resources/CMakeLists.txt | 29 +++ src/PVViewer/resources/ParaViewFilters.xml | 215 +++++++++++++++++++++ src/PVViewer/resources/ParaViewReaders.xml | 78 ++++++++ src/PVViewer/resources/ParaViewSources.xml | 29 +++ src/PVViewer/resources/ParaViewWriters.xml | 28 +++ src/PyInterp/PyInterp_Utils.cxx | 11 ++ src/PyInterp/PyInterp_Utils.h | 5 +- src/SALOME_PYQT/SalomePyQt/CMakeLists.txt | 1 - src/Session/SALOME_Session_Server.cxx | 14 +- 14 files changed, 428 insertions(+), 18 deletions(-) create mode 100644 src/PVViewer/resources/CMakeLists.txt create mode 100755 src/PVViewer/resources/ParaViewFilters.xml create mode 100755 src/PVViewer/resources/ParaViewReaders.xml create mode 100755 src/PVViewer/resources/ParaViewSources.xml create mode 100755 src/PVViewer/resources/ParaViewWriters.xml diff --git a/src/PVViewer/CMakeLists.txt b/src/PVViewer/CMakeLists.txt index ac492e4cc..8a43e577c 100644 --- a/src/PVViewer/CMakeLists.txt +++ b/src/PVViewer/CMakeLists.txt @@ -19,6 +19,9 @@ INCLUDE(UseQt4Ext) +# Install ParaView filters, etc ... +ADD_SUBDIRECTORY(resources) + # --- options --- INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS} diff --git a/src/PVViewer/PVViewer_EngineWrapper.cxx b/src/PVViewer/PVViewer_EngineWrapper.cxx index 1f1eeee73..e94214adc 100644 --- a/src/PVViewer/PVViewer_EngineWrapper.cxx +++ b/src/PVViewer/PVViewer_EngineWrapper.cxx @@ -141,7 +141,6 @@ void PVViewer_EngineWrapper::SetGUIConnected(bool isConnected) std::string PVViewer_EngineWrapper::FindOrStartPVServer(int port) { PyLockWrapper lock; - PyObjWrapper obj(PyObject_CallMethod(paravisEngine, (char*)("FindOrStartPVServer"), (char *)"i", port ) ); if (!obj) @@ -153,3 +152,15 @@ std::string PVViewer_EngineWrapper::FindOrStartPVServer(int port) return std::string(s); } + +void PVViewer_EngineWrapper::PutPythonTraceStringToEngine(const char * str) +{ + PyLockWrapper lock; + PyObjWrapper obj(PyObject_CallMethod(paravisEngine, (char*)("PutPythonTraceStringToEngine"), + (char *)"s", str) ); + if (!obj) + { + PyErr_Print(); + throw SALOME_Exception("Unable to invoke PARAVIS engine!"); + } +} diff --git a/src/PVViewer/PVViewer_EngineWrapper.h b/src/PVViewer/PVViewer_EngineWrapper.h index 8f78d685a..a14993c04 100644 --- a/src/PVViewer/PVViewer_EngineWrapper.h +++ b/src/PVViewer/PVViewer_EngineWrapper.h @@ -47,6 +47,7 @@ public: bool GetGUIConnected(); void SetGUIConnected(bool isConnected); std::string FindOrStartPVServer(int port); + void PutPythonTraceStringToEngine(const char *); private: PVViewer_EngineWrapper(); diff --git a/src/PVViewer/PVViewer_GUIElements.cxx b/src/PVViewer/PVViewer_GUIElements.cxx index 70b4751fe..ff139e682 100644 --- a/src/PVViewer/PVViewer_GUIElements.cxx +++ b/src/PVViewer/PVViewer_GUIElements.cxx @@ -35,8 +35,8 @@ PVViewer_GUIElements::PVViewer_GUIElements(SUIT_Desktop* desk) : propertiesPanel(0), pipelineBrowserWidget(0), sourcesMenu(0) { -// propertiesPanel = new pqPropertiesPanel(desk); -// propertiesPanel->hide(); + propertiesPanel = new pqPropertiesPanel(desk); + propertiesPanel->hide(); pipelineBrowserWidget = new pqPipelineBrowserWidget(desk); pipelineBrowserWidget->hide(); diff --git a/src/PVViewer/PVViewer_ViewManager.cxx b/src/PVViewer/PVViewer_ViewManager.cxx index 82aba0ac4..a167c9acf 100644 --- a/src/PVViewer/PVViewer_ViewManager.cxx +++ b/src/PVViewer/PVViewer_ViewManager.cxx @@ -65,7 +65,7 @@ PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* des : SUIT_ViewManager( study, desk, new PVViewer_Viewer() ), desktop(desk) { - MESSAGE("PARAVIS - view manager created ...") + MESSAGE("PVViewer - view manager created ...") setTitle( tr( "PARAVIEW_VIEW_TITLE" ) ); // Initialize minimal paraview stuff (if not already done) ParaviewInitApp(desk, logWindow); @@ -89,7 +89,7 @@ bool PVViewer_ViewManager::ParaviewInitApp(SUIT_Desktop * aDesktop, LogWindow * // Obtain command-line arguments int argc = 0; char** argv = 0; - QString aOptions = getenv("PARAVIS_OPTIONS"); + QString aOptions = getenv("PARAVIEW_OPTIONS"); QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts); argv = new char*[aOptList.size() + 1]; QStringList args = QApplication::arguments(); @@ -140,7 +140,7 @@ void PVViewer_ViewManager::ParaviewLoadConfigurations() if (!ConfigLoaded) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - QString aPath = resMgr->stringValue("resources", "PARAVIS", QString()); + QString aPath = resMgr->stringValue("resources", "PVViewer", QString()); if (!aPath.isNull()) { MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml"); MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml"); @@ -204,7 +204,7 @@ bool PVViewer_ViewManager::ConnectToExternalPVServer(SUIT_Desktop* aDesktop) std::stringstream msg; // Try to connect to the external PVServer - gives priority to an externally specified URL: - QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL"); + QString serverUrlEnv = getenv("PARAVIEW_PVSERVER_URL"); std::string serverUrl; if (!serverUrlEnv.isEmpty()) serverUrl = serverUrlEnv.toStdString(); @@ -235,13 +235,6 @@ bool PVViewer_ViewManager::ConnectToExternalPVServer(SUIT_Desktop* aDesktop) return true; } -//void PVViewer_ViewManager::onPVViewCreated(SUIT_ViewWindow* w) -//{ -// PVViewer_ViewWindow * w2 = dynamic_cast(w); -// Q_ASSERT(w2 != NULL); -// connect(w2, SIGNAL(applyRequest()), ParaviewBehaviors, SLOT(onEmulateApply())); -//} - void PVViewer_ViewManager::onEmulateApply() { PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desktop); diff --git a/src/PVViewer/resources/CMakeLists.txt b/src/PVViewer/resources/CMakeLists.txt new file mode 100644 index 000000000..16d3b4f24 --- /dev/null +++ b/src/PVViewer/resources/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (C) 2010-2014 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(dist_salomeres_DATA + ParaViewFilters.xml + ParaViewReaders.xml + ParaViewSources.xml + ParaViewWriters.xml + ) + +FOREACH(f ${dist_salomeres_DATA}) + INSTALL(FILES ${f} DESTINATION ${SALOME_GUI_INSTALL_RES_DATA}) +ENDFOREACH(f ${dist_salomeres_DATA}) diff --git a/src/PVViewer/resources/ParaViewFilters.xml b/src/PVViewer/resources/ParaViewFilters.xml new file mode 100755 index 000000000..22eb6da66 --- /dev/null +++ b/src/PVViewer/resources/ParaViewFilters.xml @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PVViewer/resources/ParaViewReaders.xml b/src/PVViewer/resources/ParaViewReaders.xml new file mode 100755 index 000000000..dd88e53a0 --- /dev/null +++ b/src/PVViewer/resources/ParaViewReaders.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PVViewer/resources/ParaViewSources.xml b/src/PVViewer/resources/ParaViewSources.xml new file mode 100755 index 000000000..b8b3cf8cb --- /dev/null +++ b/src/PVViewer/resources/ParaViewSources.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PVViewer/resources/ParaViewWriters.xml b/src/PVViewer/resources/ParaViewWriters.xml new file mode 100755 index 000000000..db7fd3e1c --- /dev/null +++ b/src/PVViewer/resources/ParaViewWriters.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PyInterp/PyInterp_Utils.cxx b/src/PyInterp/PyInterp_Utils.cxx index 4fa3bc2ae..b9ec47780 100644 --- a/src/PyInterp/PyInterp_Utils.cxx +++ b/src/PyInterp/PyInterp_Utils.cxx @@ -24,6 +24,8 @@ #include "PyInterp_Utils.h" +#include + /*! \class PyLockWrapper \brief Python GIL wrapper. @@ -35,6 +37,8 @@ PyLockWrapper::PyLockWrapper() { _gil_state = PyGILState_Ensure(); + // Save current thread state for later comparison + _state = PyGILState_GetThisThreadState(); } /*! @@ -42,6 +46,13 @@ PyLockWrapper::PyLockWrapper() */ PyLockWrapper::~PyLockWrapper() { + PyThreadState * _currState = PyGILState_GetThisThreadState(); + if (_currState != _state) + { + std::cout << "!!!!!!!!! PyLockWrapper inconsistency - now entering infinite loop for debugging\n"; + while(1); + } + PyGILState_Release(_gil_state); } diff --git a/src/PyInterp/PyInterp_Utils.h b/src/PyInterp/PyInterp_Utils.h index c9866bab1..090ca1fc2 100644 --- a/src/PyInterp/PyInterp_Utils.h +++ b/src/PyInterp/PyInterp_Utils.h @@ -37,12 +37,15 @@ */ class PYINTERP_EXPORT PyLockWrapper { - PyGILState_STATE _gil_state; + public: PyLockWrapper(); ~PyLockWrapper(); private: + PyGILState_STATE _gil_state; + PyThreadState * _state; + // "Rule of 3" - Forbid usage of copy operator and copy-constructor PyLockWrapper(const PyLockWrapper & another); const PyLockWrapper & operator=(const PyLockWrapper & another); diff --git a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt index 0b25339bb..4246ca76b 100755 --- a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt +++ b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt @@ -76,7 +76,6 @@ SET(_link_LIBRARIES ${OPENGL_LIBRARIES} ${QWT_LIBRARY} SalomePyQtGUILight - SalomeApp ) # --- headers --- diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 4d34b5e58..c8b52cf4f 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -68,6 +68,8 @@ #include CORBA_SERVER_HEADER(SALOME_Session) #include CORBA_SERVER_HEADER(SALOMEDS) +#include + #include #include #include @@ -647,20 +649,28 @@ int main( int argc, char **argv ) //PyRun_SimpleString("orb.destroy()"); // Destroy the ORB: - MESSAGE("Explicitely destroying the ORB (hoping to kill omniORB threads ...)"); + sleep(2); + //std::cout << "@@@@@ Explicitely destroying the ORB (hoping to kill omniORB threads ...)\n"; ORB_INIT * init = SINGLETON_::Instance(); if (init) init->explicit_destroy(); + //std::cout << "@@@@@ ORB destroyed\n"; // After ORB destruction if(Py_IsInitialized()) { PyGILState_Ensure(); + //std::cout << "@@@@@ About to PyFinalize\n"; Py_Finalize(); + //std::cout << "@@@@@ DONE PyFinalize\n"; } if ( shutdownAll ) - killOmniNames(); + { + //std::cout << "@@@@@ About to kill omni\n"; + killOmniNames(); + //std::cout << "@@@@@ DONE kill omni\n"; + } MESSAGE( "Salome_Session_Server:endofserver" ); return result; -- 2.39.2