From 61a22ca5298100db0de79cfab56c79d9ac2b27c4 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 26 Dec 2024 23:29:28 +0100 Subject: [PATCH] Hide console badge when rendering offscreen --- application/testing/CMakeLists.txt | 1 + library/src/window_impl.cxx | 2 ++ vtkext/private/module/vtkF3DRenderer.cxx | 6 ++++++ vtkext/private/module/vtkF3DRenderer.h | 5 +++++ vtkext/private/module/vtkF3DUIActor.cxx | 8 +++++++- vtkext/private/module/vtkF3DUIActor.h | 7 +++++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/application/testing/CMakeLists.txt b/application/testing/CMakeLists.txt index 10121bff51..9173ee1b41 100644 --- a/application/testing/CMakeLists.txt +++ b/application/testing/CMakeLists.txt @@ -129,6 +129,7 @@ function(f3d_test) set(f3d_test_env_vars ${F3D_TEST_ENV}) list(APPEND f3d_test_env_vars "CTEST_F3D_PROGRESS_BAR=1") + list(APPEND f3d_test_env_vars "CTEST_F3D_CONSOLE_BADGE=1") if (F3D_TEST_NO_DATA_FORCE_RENDER) list(APPEND f3d_test_env_vars "CTEST_F3D_NO_DATA_FORCE_RENDER=1") endif () diff --git a/library/src/window_impl.cxx b/library/src/window_impl.cxx index ec7cab309f..c9bebf15c3 100644 --- a/library/src/window_impl.cxx +++ b/library/src/window_impl.cxx @@ -186,6 +186,8 @@ window_impl::window_impl(const options& options, const std::optional& type this->Internals->Camera = std::make_unique(); this->Internals->Camera->SetVTKRenderer(this->Internals->Renderer); + this->Internals->Renderer->SetConsoleBadgeEnabled(!offscreen || std::getenv("CTEST_F3D_CONSOLE_BADGE")); + this->Initialize(); log::debug("VTK window class type is ", this->Internals->RenWin->GetClassName()); diff --git a/vtkext/private/module/vtkF3DRenderer.cxx b/vtkext/private/module/vtkF3DRenderer.cxx index 31e50b1e02..97938dcc26 100644 --- a/vtkext/private/module/vtkF3DRenderer.cxx +++ b/vtkext/private/module/vtkF3DRenderer.cxx @@ -2639,3 +2639,9 @@ void vtkF3DRenderer::SetUIDeltaTime(double time) { this->UIActor->SetDeltaTime(time); } + +//---------------------------------------------------------------------------- +void vtkF3DRenderer::SetConsoleBadgeEnabled(bool enabled) +{ + this->UIActor->SetConsoleBadgeEnabled(enabled); +} diff --git a/vtkext/private/module/vtkF3DRenderer.h b/vtkext/private/module/vtkF3DRenderer.h index 40c030da9d..c0e5533332 100644 --- a/vtkext/private/module/vtkF3DRenderer.h +++ b/vtkext/private/module/vtkF3DRenderer.h @@ -377,6 +377,11 @@ class vtkF3DRenderer : public vtkOpenGLRenderer */ void SetUIDeltaTime(double time); + /** + * Set console badge enabled status + */ + void SetConsoleBadgeEnabled(bool enabled); + private: vtkF3DRenderer(); ~vtkF3DRenderer() override; diff --git a/vtkext/private/module/vtkF3DUIActor.cxx b/vtkext/private/module/vtkF3DUIActor.cxx index f73c8beeb8..5f5f745328 100644 --- a/vtkext/private/module/vtkF3DUIActor.cxx +++ b/vtkext/private/module/vtkF3DUIActor.cxx @@ -48,6 +48,12 @@ void vtkF3DUIActor::SetConsoleVisibility(bool show) this->ConsoleVisible = show; } +//---------------------------------------------------------------------------- +void vtkF3DUIActor::SetConsoleBadgeEnabled(bool enabled) +{ + this->ConsoleBadgeEnabled = enabled; +} + //---------------------------------------------------------------------------- void vtkF3DUIActor::SetCheatSheet(const std::vector& cheatsheet) { @@ -113,7 +119,7 @@ int vtkF3DUIActor::RenderOverlay(vtkViewport* vp) { this->RenderConsole(); } - else + else if (this->ConsoleBadgeEnabled) { this->RenderConsoleBadge(); } diff --git a/vtkext/private/module/vtkF3DUIActor.h b/vtkext/private/module/vtkF3DUIActor.h index a8ef79a1c5..419d5d67ab 100644 --- a/vtkext/private/module/vtkF3DUIActor.h +++ b/vtkext/private/module/vtkF3DUIActor.h @@ -62,6 +62,12 @@ class vtkF3DUIActor : public vtkProp */ void SetConsoleVisibility(bool show); + /** + * Set the console badge enabled status + * False by default + */ + void SetConsoleBadgeEnabled(bool enabled); + /** * Set the cheatsheet string * Empty by default @@ -150,6 +156,7 @@ class vtkF3DUIActor : public vtkProp std::vector CheatSheet; bool ConsoleVisible = false; + bool ConsoleBadgeEnabled = false; bool FpsCounterVisible = false; int FpsValue = 0;