]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
bos #23995 Render single colored background for VTK view using gradient feature vsr/23995_vtk_gradient_bg
authorvsr <vsr@opencascade.com>
Thu, 1 Apr 2021 15:09:01 +0000 (18:09 +0300)
committervsr <vsr@opencascade.com>
Thu, 1 Apr 2021 15:09:01 +0000 (18:09 +0300)
src/SVTK/SVTK_ViewWindow.cxx

index 2208dda1692053b8ac825bc2afae7fb498475b08..b54e672a109dedbd1c4cdb14ca36ca4b345aae66 100644 (file)
 #include <GL/gl.h>
 #endif
 
+// Next macro is used to apply workaround: draw single color background as a gradient
+//#define USE_GRADIEND_FOR_SINGLE_COLOR_BACKGROUND
+
 namespace SVTK
 {
   int convertAction( const int accelAction )
@@ -623,6 +626,20 @@ void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
       {
         QColor c = bgData.color();
         if ( c.isValid() ) {
+#ifdef USE_GRADIEND_FOR_SINGLE_COLOR_BACKGROUND
+          // use gradient with the same color to render background
+          getRenderer()->SetTexturedBackground( false );
+          getRenderer()->SetGradientBackground( true );
+          VTKViewer_OpenGLRenderer* aRenderer =
+            VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
+          if( aRenderer )
+          {
+            aRenderer->SetGradientType( SVTK_Viewer::VerticalGradient );
+            aRenderer->SetBackground( c.redF(), c.greenF(), c.blueF() );
+            aRenderer->SetBackground2( c.redF(), c.greenF(), c.blueF() );
+            ok = true;
+          }
+#else
           // show solid-colored background
           getRenderer()->SetTexturedBackground( false );  // cancel texture mode
           getRenderer()->SetGradientBackground( false );  // cancel gradient mode
@@ -630,6 +647,7 @@ void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
                                         c.green()/255.0,
                                         c.blue()/255.0 ); // set background color
           ok = true;
+#endif
         }
         break;
       }