Salome HOME
Issue "23472: [CEA 2164] Display problem when ParaView isn't the first viewer" -...
authorrnv <rnv@opencascade.com>
Fri, 15 Sep 2017 12:05:28 +0000 (15:05 +0300)
committerrnv <rnv@opencascade.com>
Fri, 15 Sep 2017 12:05:28 +0000 (15:05 +0300)
src/Qtx/Qtx.cxx
src/Qtx/Qtx.h
src/SUITApp/SUITApp.cxx
src/Session/SALOME_Session_Server.cxx

index 09e879e34cbb18157376850ac6b417de0181a159..0fe626c72be3b9b63541fdce106925ac203f2d99 100755 (executable)
@@ -38,6 +38,9 @@
 #include <QApplication>
 #include <QDesktopWidget>
 #include <QtDebug>
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+#include <QSurfaceFormat>
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -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.
index befacfb48854b19d30f332692295195d7c233a31..164b46c042dce5f94e8eeb728a9c18f4f8af8d5c 100755 (executable)
@@ -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
index 8c1fd4b6c84d9916e7f3dd0a8a0cff4ec81d726c..75331cfa114b068acf3216f5dad43f348a7dacb6 100644 (file)
@@ -57,9 +57,6 @@
 #include <QRegExp>
 #include <QString>
 #include <QStringList>
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
-#include <QSurfaceFormat>
-#endif
 
 #include <stdlib.h>
 
@@ -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 <qtdir>/plugins directory to the pluins search path for image plugins
index c39d700e02eeff3ef43db4e43cb439eee344db17..241423b8f0282d5cdb85371b26a6aaf63bdf1aa9 100755 (executable)
@@ -77,9 +77,6 @@
 #include <QWaitCondition>
 #include <QRegExp>
 #include <QTextStream>
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
-#include <QSurfaceFormat>
-#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