From a8a40c46f5a09a68b5315a8b0431d9a1279914ca Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 15 Sep 2017 15:05:28 +0300 Subject: [PATCH] Issue "23472: [CEA 2164] Display problem when ParaView isn't the first viewer" - additional fix: avoid copy/paste. --- src/Qtx/Qtx.cxx | 38 +++++++++++++++++++++++++++ src/Qtx/Qtx.h | 4 +++ src/SUITApp/SUITApp.cxx | 14 ++++------ src/Session/SALOME_Session_Server.cxx | 30 ++------------------- 4 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index 09e879e34..0fe626c72 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -38,6 +38,9 @@ #include #include #include +#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) +#include +#endif #include #include @@ -2181,6 +2184,41 @@ Qt::HANDLE Qtx::getVisual() #endif // WIN32 + +#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) +/*! + \brief Set default QSurfaceFormat for an application. + + This application property should be set before a creation of the QApplication. +*/ +void Qtx::initDefaultSurfaceFormat() +{ + // Settings from Paraview: + // This piece of code was taken from QVTKOpenGLWidget::defaultFormat() method in + // order to avoid dependency of the SALOME_Session_Server on vtk libraries + QSurfaceFormat fmt; + fmt.setRenderableType(QSurfaceFormat::OpenGL); + fmt.setVersion(3, 2); + fmt.setProfile(QSurfaceFormat::CoreProfile); + fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer); + fmt.setRedBufferSize(1); + fmt.setGreenBufferSize(1); + fmt.setBlueBufferSize(1); + fmt.setDepthBufferSize(1); + fmt.setStencilBufferSize(0); + fmt.setAlphaBufferSize(1); + fmt.setStereo(false); + fmt.setSamples(0); + + // Settings for OCCT viewer window: + fmt.setDepthBufferSize(16); + fmt.setStencilBufferSize(1); + // fmt.setProfile(QSurfaceFormat::CompatibilityProfile); + + QSurfaceFormat::setDefaultFormat(fmt); +} +#endif + /*! \class Qtx::CmdLineArgs \brief Get access to the command line arguments in the C-like manner. diff --git a/src/Qtx/Qtx.h b/src/Qtx/Qtx.h index befacfb48..164b46c04 100755 --- a/src/Qtx/Qtx.h +++ b/src/Qtx/Qtx.h @@ -283,6 +283,10 @@ public: static void* getDisplay(); static Qt::HANDLE getVisual(); #endif + +#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) + static void initDefaultSurfaceFormat(); +#endif }; #endif diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 8c1fd4b6c..75331cfa1 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -57,9 +57,6 @@ #include #include #include -#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) -#include -#endif #include @@ -183,12 +180,11 @@ int main( int argc, char* argv[] ) } #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) - // initialization of the X11 visual on Linux - QSurfaceFormat format; - format.setDepthBufferSize(16); - format.setStencilBufferSize(1); - format.setProfile(QSurfaceFormat::CompatibilityProfile); - QSurfaceFormat::setDefaultFormat(format); + // RNV: setup the default format: + // QSurfaceFormat should be set before creation of QApplication, + // so to avoid conflicts beetween SALOME and ParaView QSurfaceFormats we should merge theirs formats + // (see void Qtx::initDefaultSurfaceFormat()) and set the resultant format here. + Qtx::initDefaultSurfaceFormat(); #endif // add /plugins directory to the pluins search path for image plugins diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index c39d700e0..241423b8f 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -77,9 +77,6 @@ #include #include #include -#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) -#include -#endif /*! - read arguments, define list of server to launch with their arguments. * - wait for naming service @@ -375,31 +372,8 @@ int main( int argc, char **argv ) // RNV: setup the default format: // QSurfaceFormat should be set before creation of QApplication, // so to avoid conflicts beetween SALOME and ParaView QSurfaceFormats we should merge theirs formats - // (see comments below) and set the resultant format here. - - // Settings from Paraview: - // This piece of code was taken from QVTKOpenGLWidget::defaultFormat() method in - // order to avoid dependency of the SALOME_Session_Server on vtk libraries - QSurfaceFormat fmt; - fmt.setRenderableType(QSurfaceFormat::OpenGL); - fmt.setVersion(3, 2); - fmt.setProfile(QSurfaceFormat::CoreProfile); - fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - fmt.setRedBufferSize(1); - fmt.setGreenBufferSize(1); - fmt.setBlueBufferSize(1); - fmt.setDepthBufferSize(1); - fmt.setStencilBufferSize(0); - fmt.setAlphaBufferSize(1); - fmt.setStereo(false); - fmt.setSamples(0); - - // Settings for OCCT viewer window: - fmt.setDepthBufferSize(16); - fmt.setStencilBufferSize(1); - // fmt.setProfile(QSurfaceFormat::CompatibilityProfile); - - QSurfaceFormat::setDefaultFormat(fmt); + // (see void Qtx::initDefaultSurfaceFormat()) and set the resultant format here. + Qtx::initDefaultSurfaceFormat(); #endif -- 2.39.2