From 2a1886ddc3dd45a3ace985b19dd1fcb9abc4b014 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 1 Apr 2021 18:09:01 +0300 Subject: [PATCH] bos #23995 Render single colored background for VTK view using gradient feature --- src/SVTK/SVTK_ViewWindow.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 2208dda16..b54e672a1 100644 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -112,6 +112,9 @@ #include #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; } -- 2.39.2