From fefd312d1e3275214b2cfb49168f3e1a3d918d09 Mon Sep 17 00:00:00 2001 From: mpa Date: Thu, 11 Jun 2015 15:22:55 +0300 Subject: [PATCH] CMake improvement: editing of SALOME_GUI_MODE() macro, checking of optional dependencies in code. --- CMakeLists.txt | 4 +- adm_local/cmake_files/FindSalomeGUI.cmake | 61 ++++++++------- src/CMakeLists.txt | 4 +- src/LightApp/CMakeLists.txt | 2 +- src/OCCViewer/CMakeLists.txt | 14 +++- src/OCCViewer/OCCViewer_ViewWindow.cxx | 6 +- src/PVViewer/CMakeLists.txt | 38 +++++----- src/PVViewer/PVViewer_Behaviors.h | 3 - src/PVViewer/PVViewer_EngineWrapper.cxx | 87 +++++----------------- src/PVViewer/PVViewer_EngineWrapper.h | 24 ++---- src/PVViewer/PVViewer_LogWindowAdapter.cxx | 11 --- src/PVViewer/PVViewer_ViewManager.cxx | 4 - src/PVViewer/PVViewer_ViewModel.cxx | 1 - src/PyInterp/CMakeLists.txt | 1 - src/PyInterp/PyInterp_Utils.cxx | 58 --------------- src/PyInterp/PyInterp_Utils.h | 38 +++++++++- src/SVTK/CMakeLists.txt | 15 +++- src/SVTK/SVTK_ViewWindow.cxx | 6 +- src/SalomeApp/SalomeApp_Application.cxx | 2 + 19 files changed, 150 insertions(+), 229 deletions(-) delete mode 100644 src/PyInterp/PyInterp_Utils.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bab82439..a0fbbaade 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,7 +277,7 @@ INCLUDE(CMakePackageConfigHelpers) # List of targets in this project we want to make visible to the rest of the world. # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets - caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils + caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser QDS qtx SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData ImageComposer ) @@ -291,7 +291,7 @@ ENDIF(SALOME_USE_SALOMEOBJECT) # GL specific targets: IF(SALOME_USE_GLVIEWER) LIST(APPEND _${PROJECT_NAME}_exposed_targets - GLViewer) + OpenGLUtils GLViewer) ENDIF(SALOME_USE_GLVIEWER) # VTK specific targets: diff --git a/adm_local/cmake_files/FindSalomeGUI.cmake b/adm_local/cmake_files/FindSalomeGUI.cmake index 0f2419e2b..59a621a88 100644 --- a/adm_local/cmake_files/FindSalomeGUI.cmake +++ b/adm_local/cmake_files/FindSalomeGUI.cmake @@ -51,46 +51,51 @@ MACRO(SALOME_GUI_WITH_CORBA) ENDIF() ENDMACRO(SALOME_GUI_WITH_CORBA) -#---------------------------------------------------------------------------- -# FULL_GUI is a macro useful for determining whether a GUI module -# builded in full mode -#---------------------------------------------------------------------------- -MACRO(FULL_GUI) - SET(_options) - LIST(APPEND _options SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_VTKVIEWER - SALOME_USE_PLOT2DVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_QXGRAPHVIEWER - SALOME_USE_SALOMEOBJECT SALOME_USE_PYCONSOLE) - SALOME_GUI_MODE(${_options}) -ENDMACRO(FULL_GUI) #---------------------------------------------------------------------------- # SALOME_GUI_MODE is a macro useful for determining whether a GUI module # builded in particular mode #---------------------------------------------------------------------------- ######################################################################### -# FULL_GUI() +# SALOME_GUI_MODE() # -# USAGE: FULL_GUI(_options) +# USAGE: SALOME_GUI_MODE(_options) # # ARGUMENTS: # _options [input] List - The list of CMake options given to SALOME GUI # -MACRO(SALOME_GUI_MODE _options) - MESSAGE(STATUS "Checking status of GUI options ${_options}") - SET(_message) - FOREACH(_option ${_options}) - IF(NOT ${_option}) - LIST(APPEND _message ${_option}) +# Notes: +# The arguments list can include "OPTIONAL" keywords: +# * All arguments preceded by "OPTIONAL" keyword are mandatory for current module. +# If GUI module was compiled without this functionality, further installation +# of the current module becomes impossible. +# * All arguments following "OPTIONAL" keyword are optional for current module, which +# uses this functionality, but can be installed without it. +# +MACRO(SALOME_GUI_MODE) + MESSAGE(STATUS "") + MESSAGE(STATUS " Checking status of GUI options") + MESSAGE(STATUS " ==================================== ") + MESSAGE(STATUS "") + SET(_message) + SET(_length 25) + SET(_is_optional OFF) + FOREACH(_option ${ARGN}) + IF(${_option} STREQUAL "OPTIONAL") + SET(_is_optional ON) + MESSAGE(STATUS " Optional:") + ELSE() + SALOME_JUSTIFY_STRING(${_option} ${_length} _option_name) + MESSAGE(STATUS " * ${_option_name} -> ${${_option}}") + IF(NOT ${_option} AND NOT ${_is_optional}) + LIST(APPEND _message ${_option}) + ENDIF() ENDIF() ENDFOREACH() + MESSAGE(STATUS "") + IF(_message) - SET(_message "We absolutely need a Salome GUI module in full mode.\nThe following options should be set to ON when building GUI module:\n${_message}\n") - IF(_corba_message) - MESSAGE(FATAL_ERROR "${_corba_message}\n${_message}") - ELSE() - MESSAGE(FATAL_ERROR "${_message}") - ENDIF() - ELSEIF(_corba_message) - MESSAGE(FATAL_ERROR "${_corba_message}") - ENDIF() + SET(_message "We absolutely need a Salome GUI module in special mode. The following options should be set to ON when building GUI module: \n${_message}\n") + MESSAGE(FATAL_ERROR "${_message}") + ENDIF() ENDMACRO(SALOME_GUI_MODE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3d3f8aab..b1baf4576 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,7 +22,7 @@ ## SET(SUBDIRS_COMMON CASCatch Qtx HelpBrowser Style DDS QDS ObjBrowser SUIT SUITApp STD CAF - CAM LogWindow Prs Event OpenGLUtils ViewerData ViewerTools ImageComposer GUI_PY + CAM LogWindow Prs Event ViewerData ViewerTools ImageComposer GUI_PY ) ## @@ -36,7 +36,7 @@ ENDIF(SALOME_USE_SALOMEOBJECT) # GL viewer ## IF(SALOME_USE_GLVIEWER) - SET(SUBDIRS_GLVIEWER GLViewer) + SET(SUBDIRS_GLVIEWER OpenGLUtils GLViewer) ENDIF(SALOME_USE_GLVIEWER) ## diff --git a/src/LightApp/CMakeLists.txt b/src/LightApp/CMakeLists.txt index c295aa78f..9b39c65e8 100755 --- a/src/LightApp/CMakeLists.txt +++ b/src/LightApp/CMakeLists.txt @@ -101,7 +101,7 @@ SET(_link_LIBRARIES ${CAS_KERNEL} ${QT_LIBRARIES} ${HDF5_LIBRARIES} - CASCatch qtx suit std SalomeStyle SalomePrs CAM LogWindow ObjBrowser + CASCatch qtx suit std SalomeStyle SalomePrs CAM LogWindow ObjBrowser Event ${KERNEL_SalomeHDFPersist} ${KERNEL_SALOMELocalTrace} ) IF(SALOME_USE_SALOMEOBJECT) diff --git a/src/OCCViewer/CMakeLists.txt b/src/OCCViewer/CMakeLists.txt index e3282c54c..17f5c45a8 100755 --- a/src/OCCViewer/CMakeLists.txt +++ b/src/OCCViewer/CMakeLists.txt @@ -32,11 +32,15 @@ INCLUDE_DIRECTORIES( ${PTHREAD_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/src/CASCatch ${PROJECT_SOURCE_DIR}/src/Qtx - ${PROJECT_SOURCE_DIR}/src/OpenGLUtils ${PROJECT_SOURCE_DIR}/src/SUIT ${PROJECT_SOURCE_DIR}/src/ViewerData ${PROJECT_SOURCE_DIR}/src/ViewerTools ) +IF(SALOME_USE_GLVIEWER) + INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/OpenGLUtils + ) +ENDIF() # additional preprocessor / compiler flags ADD_DEFINITIONS(${QT_DEFINITIONS} ${CAS_DEFINITIONS} ${OGL_DEFINITIONS}) @@ -45,9 +49,15 @@ ADD_DEFINITIONS(${QT_DEFINITIONS} ${CAS_DEFINITIONS} ${OGL_DEFINITIONS}) SET(_link_LIBRARIES ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ${CAS_KERNEL} ${CAS_VIEWER} ${CAS_TKGeomAlgo} ${CAS_TKTopAlgo} ${CAS_TKG2d} ${CAS_TKOpenGl} - CASCatch qtx suit OpenGLUtils ViewerTools ViewerData + CASCatch qtx suit ViewerTools ViewerData ) +IF(SALOME_USE_GLVIEWER) + LIST(APPEND _link_LIBRARIES + OpenGLUtils + ) +ENDIF() + # --- headers --- # header files / to be processed by moc diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index c7d66be64..08f89e269 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -49,7 +49,9 @@ #include #include -#include +#ifndef DISABLE_GLVIEWER + #include +#endif #include #include @@ -2000,6 +2002,7 @@ QImage OCCViewer_ViewWindow::dumpView() view->Redraw(); // In order to reactivate GL context //view->Update(); +#ifndef DISABLE_GLVIEWER OpenGLUtils_FrameBuffer aFrameBuffer; if( aFrameBuffer.init( aWidth, aHeight ) ) { @@ -2032,6 +2035,7 @@ QImage OCCViewer_ViewWindow::dumpView() glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data); +#endif */ Image_PixMap aPix; diff --git a/src/PVViewer/CMakeLists.txt b/src/PVViewer/CMakeLists.txt index 04b265cf0..e67c3c4be 100644 --- a/src/PVViewer/CMakeLists.txt +++ b/src/PVViewer/CMakeLists.txt @@ -24,32 +24,28 @@ ADD_SUBDIRECTORY(resources) # --- options --- -INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS} - ${QT_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/SUIT - ${CMAKE_SOURCE_DIR}/src/CAM - ${CMAKE_SOURCE_DIR}/src/STD - ${CMAKE_SOURCE_DIR}/src/Qtx - ${CMAKE_SOURCE_DIR}/src/Event - ${CMAKE_SOURCE_DIR}/src/PyInterp - ${CMAKE_SOURCE_DIR}/src/PyConsole - ${CMAKE_SOURCE_DIR}/src/LogWindow - ) - -SET(_PARAVIEW_APP_COMPO_LIB - pqApplicationComponents +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/SUIT + ${PROJECT_SOURCE_DIR}/src/STD + ${PROJECT_SOURCE_DIR}/src/Qtx + ${PROJECT_SOURCE_DIR}/src/Event + ${PROJECT_SOURCE_DIR}/src/PyInterp + ${CMAKE_SOURCE_DIR}/src/LogWindow ) -ADD_DEFINITIONS(${KERNEL_DEFINITIONS}) -ADD_DEFINITIONS(${OMNIORB_DEFINITIONS} ${PYTHON_DEFINITIONS}) +ADD_DEFINITIONS( + ${KERNEL_DEFINITIONS} + ${PYTHON_DEFINITIONS} + ) SET(_link_LIBRARIES - ${KERNEL_LDFLAGS} ${KERNEL_SALOMELocalTrace} ${KERNEL_OpUtil} - ${GUI_LDFLAGS} suit Event PyInterp - ${_PARAVIEW_APP_COMPO_LIB} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + suit + Event + pqApplicationComponents vtkRenderingFreeTypeOpenGL -) + ) # --- headers --- diff --git a/src/PVViewer/PVViewer_Behaviors.h b/src/PVViewer/PVViewer_Behaviors.h index 4b166ab21..8adc8dc28 100644 --- a/src/PVViewer/PVViewer_Behaviors.h +++ b/src/PVViewer/PVViewer_Behaviors.h @@ -47,9 +47,6 @@ public: virtual ~PVViewer_Behaviors() {} -//public slots: -// void onEmulateApply(); - private: static int BehaviorLoadingLevel; }; diff --git a/src/PVViewer/PVViewer_EngineWrapper.cxx b/src/PVViewer/PVViewer_EngineWrapper.cxx index 7ec6271da..e9c8abd8b 100644 --- a/src/PVViewer/PVViewer_EngineWrapper.cxx +++ b/src/PVViewer/PVViewer_EngineWrapper.cxx @@ -21,8 +21,14 @@ #include "PVViewer_EngineWrapper.h" #include -//#include #include +#include + +class PVViewer_EngineWrapper::Private +{ +public: + PyObjWrapper pvserverEngine; +}; PVViewer_EngineWrapper * PVViewer_EngineWrapper::instance = NULL; @@ -33,69 +39,9 @@ PVViewer_EngineWrapper * PVViewer_EngineWrapper::GetInstance() return instance; } -//static SalomeApp_Application* getApplication() -//{ -// if ( SUIT_Session::session() ) -// return dynamic_cast( SUIT_Session::session()->activeApplication() ); -// return 0; -//} -// -//PVViewer_EngineWrapper::PVViewer_EngineWrapper() -//// : pvserverEngine(NULL) -//{ -// _component = getApplication()->lcc()->FindOrLoad_Component( "FactoryServer", "PARAVIS" ); -//} -// -//bool PVViewer_EngineWrapper::GetGUIConnected() -//{ -// CORBA::Request_var req = _component->_request("GetGUIConnected"); -// req->set_return_type(CORBA::_tc_boolean); -// req->invoke(); -// CORBA::Exception *exc =req->env()->exception(); -// if( exc ) -// throw SALOME_Exception("Unable to invoke PARAVIS engine!"); -// CORBA::Any & ret = req->return_value(); -// CORBA::Boolean bo; -// -// if (ret >>= bo) -// return bool(bo); -// else -// throw SALOME_Exception("Unable to convert engine result!"); -//} -// -//void PVViewer_EngineWrapper::SetGUIConnected(bool isConnected) -//{ -// CORBA::Request_var req = _component->_request("SetGUIConnected"); -// CORBA::Boolean arg = isConnected; -// req->add_in_arg() <<= arg; -// req->set_return_type(CORBA::_tc_void); -// req->invoke(); -// CORBA::Exception *exc =req->env()->exception(); -// if( exc ) -// throw SALOME_Exception("Unable to invoke PARAVIS engine!"); -//} -// -//std::string PVViewer_EngineWrapper::FindOrStartPVServer(int port) -//{ -// CORBA::Request_var req = _component->_request("FindOrStartPVServer"); -// CORBA::Long arg = port; -// req->add_in_arg() <<= arg; -// req->set_return_type(CORBA::_tc_string); -// req->invoke(); -// CORBA::Exception *exc =req->env()->exception(); -// if( exc ) -// throw SALOME_Exception("Unable to invoke PARAVIS engine!"); -// -// const char* ret; -// if(req->return_value() >>= ret) -// return std::string(ret); -// else -// throw SALOME_Exception("Unable to convert engine result!"); -//} - -PVViewer_EngineWrapper::PVViewer_EngineWrapper() : - pvserverEngine(NULL) +PVViewer_EngineWrapper::PVViewer_EngineWrapper() { + myData = new Private; PyLockWrapper lock; const char* code = "import PVSERVER_utils as pa;__enginePVSERVER=pa.getEngine()"; int ret = PyRun_SimpleString(const_cast(code)); @@ -107,15 +53,18 @@ PVViewer_EngineWrapper::PVViewer_EngineWrapper() : PyObject* main_module = PyImport_AddModule((char*)"__main__"); PyObject* global_dict = PyModule_GetDict(main_module); PyObjWrapper tmp(PyDict_GetItemString(global_dict, "__enginePVSERVER")); - pvserverEngine = tmp; + myData->pvserverEngine = tmp; } - +PVViewer_EngineWrapper::~PVViewer_EngineWrapper() +{ + delete myData; +} bool PVViewer_EngineWrapper::GetGUIConnected() { PyLockWrapper lock; - PyObjWrapper obj(PyObject_CallMethod(pvserverEngine, (char*)("GetGUIConnected"), NULL)); + PyObjWrapper obj(PyObject_CallMethod(myData->pvserverEngine, (char*)("GetGUIConnected"), NULL)); if (!obj) { PyErr_Print(); @@ -128,7 +77,7 @@ void PVViewer_EngineWrapper::SetGUIConnected(bool isConnected) { PyLockWrapper lock; - PyObjWrapper obj(PyObject_CallMethod(pvserverEngine, (char*)("SetGUIConnected"), + PyObjWrapper obj(PyObject_CallMethod(myData->pvserverEngine, (char*)("SetGUIConnected"), (char *)"i", (int)isConnected ) ); if (!obj) { @@ -140,7 +89,7 @@ void PVViewer_EngineWrapper::SetGUIConnected(bool isConnected) std::string PVViewer_EngineWrapper::FindOrStartPVServer(int port) { PyLockWrapper lock; - PyObjWrapper obj(PyObject_CallMethod(pvserverEngine, (char*)("FindOrStartPVServer"), + PyObjWrapper obj(PyObject_CallMethod(myData->pvserverEngine, (char*)("FindOrStartPVServer"), (char *)"i", port ) ); if (!obj) { @@ -155,7 +104,7 @@ std::string PVViewer_EngineWrapper::FindOrStartPVServer(int port) void PVViewer_EngineWrapper::PutPythonTraceStringToEngine(const char * str) { PyLockWrapper lock; - PyObjWrapper obj(PyObject_CallMethod(pvserverEngine, (char*)("PutPythonTraceStringToEngine"), + PyObjWrapper obj(PyObject_CallMethod(myData->pvserverEngine, (char*)("PutPythonTraceStringToEngine"), (char *)"s", str) ); if (!obj) { diff --git a/src/PVViewer/PVViewer_EngineWrapper.h b/src/PVViewer/PVViewer_EngineWrapper.h index 358163430..6ce74f2fd 100644 --- a/src/PVViewer/PVViewer_EngineWrapper.h +++ b/src/PVViewer/PVViewer_EngineWrapper.h @@ -23,42 +23,30 @@ #include "PVViewer.h" -#include #include -//#include -//#include -//#include -//#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) -//#include CORBA_SERVER_HEADER(SALOMEDS) - - /*! * Class facilitating the access to the PARAVIS engine without having to link * to it. Documentation of the method is found in the PARAVIS module (in the idl directory). - * - * (Two implementations are provided: one with CORBA dynamic invokation from C++, one using - * Python - see commented elements in the .cxx file) */ class PVVIEWER_EXPORT PVViewer_EngineWrapper { + class Private; public: //! Returns the unique instance of the engine. - static PVViewer_EngineWrapper * GetInstance(); + static PVViewer_EngineWrapper* GetInstance(); bool GetGUIConnected(); void SetGUIConnected(bool isConnected); std::string FindOrStartPVServer(int port); - void PutPythonTraceStringToEngine(const char *); + void PutPythonTraceStringToEngine(const char*); private: PVViewer_EngineWrapper(); - virtual ~PVViewer_EngineWrapper() {} - - static PVViewer_EngineWrapper * instance; - //Engines::EngineComponent_var _component; + virtual ~PVViewer_EngineWrapper(); - PyObjWrapper pvserverEngine; + static PVViewer_EngineWrapper* instance; + Private* myData; }; #endif /* PVVIEWERENGINEWRAPPER_H_ */ diff --git a/src/PVViewer/PVViewer_LogWindowAdapter.cxx b/src/PVViewer/PVViewer_LogWindowAdapter.cxx index fc3801103..ac4fa9c4a 100644 --- a/src/PVViewer/PVViewer_LogWindowAdapter.cxx +++ b/src/PVViewer/PVViewer_LogWindowAdapter.cxx @@ -28,8 +28,6 @@ vtkStandardNewMacro(PVViewer_LogWindowAdapter); - - /*! * Put the message in the log window. */ @@ -86,15 +84,6 @@ const unsigned int PVViewer_LogWindowAdapter::getGenericWarningCount() return this->GenericWarningCount; } -//LogWindow* PVViewer_LogWindowAdapter::getLogWindow() -//{ -// LogWindow* wnd = 0; -// LightApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); -// if ( anApp ) -// wnd = anApp->logWindow(); -// return wnd; -//} - void PVViewer_LogWindowAdapter::DisplayText(const char* text) { ++this->TextCount; diff --git a/src/PVViewer/PVViewer_ViewManager.cxx b/src/PVViewer/PVViewer_ViewManager.cxx index 0e5ed8656..74832ce2a 100644 --- a/src/PVViewer/PVViewer_ViewManager.cxx +++ b/src/PVViewer/PVViewer_ViewManager.cxx @@ -30,9 +30,6 @@ #include #include #include -#include -#include -#include #include #include @@ -72,7 +69,6 @@ PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* des connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); -// connect(this, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*))); } pqPVApplicationCore * PVViewer_ViewManager::GetPVApplication() diff --git a/src/PVViewer/PVViewer_ViewModel.cxx b/src/PVViewer/PVViewer_ViewModel.cxx index 3778b5f6e..764284255 100644 --- a/src/PVViewer/PVViewer_ViewModel.cxx +++ b/src/PVViewer/PVViewer_ViewModel.cxx @@ -30,7 +30,6 @@ PVViewer_Viewer::PVViewer_Viewer() MESSAGE("PVViewer_Viewer: creating view model ..."); } - /*! Create new instance of view window on desktop \a theDesktop. \retval SUIT_ViewWindow* - created view window pointer. diff --git a/src/PyInterp/CMakeLists.txt b/src/PyInterp/CMakeLists.txt index 7a3e6b3f9..b55001ef6 100755 --- a/src/PyInterp/CMakeLists.txt +++ b/src/PyInterp/CMakeLists.txt @@ -64,7 +64,6 @@ SET(_other_SOURCES PyInterp_Event.cxx PyInterp_Interp.cxx PyInterp_Request.cxx - PyInterp_Utils.cxx ) # sources / to compile diff --git a/src/PyInterp/PyInterp_Utils.cxx b/src/PyInterp/PyInterp_Utils.cxx deleted file mode 100644 index 6c5458107..000000000 --- a/src/PyInterp/PyInterp_Utils.cxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// -// Author : Adrien BRUNETON -// - -#include "PyInterp_Utils.h" - -#include - -/*! - \class PyLockWrapper - \brief Python GIL wrapper. -*/ - -/*! - \brief Constructor. Automatically acquires GIL. -*/ -PyLockWrapper::PyLockWrapper() -{ - _gil_state = PyGILState_Ensure(); - // Save current thread state for later comparison - _state = PyGILState_GetThisThreadState(); -} - -/*! - \brief Destructor. Automatically releases GIL. -*/ -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 d6f6e6f83..31bbd9f15 100644 --- a/src/PyInterp/PyInterp_Utils.h +++ b/src/PyInterp/PyInterp_Utils.h @@ -27,8 +27,14 @@ #include "PyInterp.h" #include +#ifdef _DEBUG_ + #include +#endif /** + * \class PyLockWrapper + * \brief Python GIL wrapper. + * * Utility class wrapping the Python GIL acquisition. This makes use of the high level * API (PyGILState_Ensure and PyGILState_Release), and is hence compatible with only * one running Python interpreter (no call to Py_NewInterpreter()). @@ -39,12 +45,35 @@ class PYINTERP_EXPORT PyLockWrapper { public: - PyLockWrapper(); - ~PyLockWrapper(); + /** + * \brief Constructor. Automatically acquires GIL. + */ + PyLockWrapper() + { + _gil_state = PyGILState_Ensure(); + // Save current thread state for later comparison + _state = PyGILState_GetThisThreadState(); + } + + /** + * \brief Destructor. Automatically releases GIL. + */ + ~PyLockWrapper() + { + PyThreadState* _currState = PyGILState_GetThisThreadState(); +#ifdef _DEBUG_ + if (_currState != _state) + { + std::cout << "!!!!!!!!! PyLockWrapper inconsistency - now entering infinite loop for debugging\n"; + while(1); + } +#endif + PyGILState_Release(_gil_state); + } private: PyGILState_STATE _gil_state; - PyThreadState * _state; + PyThreadState* _state; // "Rule of 3" - Forbid usage of copy operator and copy-constructor PyLockWrapper(const PyLockWrapper & another); @@ -53,7 +82,8 @@ private: /** - * Utility class to properly handle the reference counting required on Python objects. + * \class PyObjWrapper + * \brief Utility class to properly handle the reference counting required on Python objects. */ class PYINTERP_EXPORT PyObjWrapper { diff --git a/src/SVTK/CMakeLists.txt b/src/SVTK/CMakeLists.txt index 69f99a014..4f7796dbb 100755 --- a/src/SVTK/CMakeLists.txt +++ b/src/SVTK/CMakeLists.txt @@ -34,9 +34,14 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/OBJECT ${PROJECT_SOURCE_DIR}/src/Prs ${PROJECT_SOURCE_DIR}/src/VTKViewer - ${PROJECT_SOURCE_DIR}/src/OpenGLUtils ) +IF(SALOME_USE_GLVIEWER) + INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/OpenGLUtils + ) +ENDIF() + # additional preprocessor / compiler flags ADD_DEFINITIONS(${QT_DEFINITIONS} ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS}) @@ -47,9 +52,15 @@ SET(_link_LIBRARIES ${VTK_LIBRARIES} ${CAS_KERNEL} ${CAS_VIEWER} ${KERNEL_OpUtil} - qtx suit ViewerTools SalomeObject SalomePrs VTKViewer OpenGLUtils + qtx suit ViewerTools SalomeObject SalomePrs VTKViewer ) +IF(SALOME_USE_GLVIEWER) + LIST(APPEND _link_LIBRARIES + OpenGLUtils + ) +ENDIF() + # --- headers --- # header files / to be processed by moc diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 26e548d38..f8fc7c41d 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -101,7 +101,9 @@ #include "VTKViewer_Algorithm.h" #include "SVTK_Functor.h" -#include +#ifndef DISABLE_GLVIEWER + #include +#endif namespace SVTK @@ -1169,6 +1171,7 @@ QImage SVTK_ViewWindow::dumpViewContent() int aWidth = aSize[0]; int aHeight = aSize[1]; +#ifndef DISABLE_GLVIEWER OpenGLUtils_FrameBuffer aFrameBuffer; if( aFrameBuffer.init( aWidth, aHeight ) ) { @@ -1192,6 +1195,7 @@ QImage SVTK_ViewWindow::dumpViewContent() anImage = anImage.mirrored(); return anImage; } +#endif // if frame buffers are unsupported, use old functionality unsigned char *aData = diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 95465cd4d..d661e5e7d 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -801,10 +801,12 @@ void SalomeApp_Application::updateCommandsStatus() if ( a ) a->setEnabled( activeStudy() ); +#ifndef DISABLE_PYCONSOLE // Load script menu a = action( LoadScriptId ); if( a ) a->setEnabled( pythonConsole() ); +#endif // Properties menu a = action( PropertiesId ); -- 2.30.2