From 78e7c7e321617ba124b5152a05e862e587332b91 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 26 Jun 2024 21:12:09 -0400 Subject: [PATCH] Add the ability to scale th statistics graphs --- apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 3 +++ include/openspace/engine/windowdelegate.h | 2 ++ include/openspace/rendering/renderengine.h | 1 + src/rendering/renderengine.cpp | 18 ++++++++++++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index e8392b5d27..c68e7cf398 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit e8392b5d271624ef421b46e000c13f5008299e4e +Subproject commit c68e7cf398dbdeb181724f39787887623a9e5946 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index fdba7c8016..1528a1c0c8 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -992,6 +992,9 @@ void setSgctDelegateFunctions() { return mousePosition; }; + sgctDelegate.setStatisticsGraphScale = [](float scale) { + sgct::Engine::instance().setStatsGraphScale(scale); + }; } std::string setWindowConfigPresetForGui(const std::string& labelFromCfgFile, diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index 7bfda13217..f81be481cd 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -124,6 +124,8 @@ struct WindowDelegate { glm::vec2 (*mousePositionViewportRelative)(const glm::vec2& mousePosition) = [](const glm::vec2&) { return glm::vec2(0); }; + + void (*setStatisticsGraphScale)(float scale) = [](float) {}; }; } // namespace openspace diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index f4806efd97..032efebf69 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -187,6 +187,7 @@ private: properties::IntListProperty _screenshotWindowIds; properties::BoolProperty _applyWarping; properties::BoolProperty _showStatistics; + properties::FloatProperty _statisticsScale; properties::BoolProperty _screenshotUseDate; properties::BoolProperty _showFrameInformation; properties::BoolProperty _disableMasterRendering; diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 7878152704..db8bf2ea75 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -146,6 +146,15 @@ namespace { openspace::properties::Property::Visibility::AdvancedUser }; + constexpr openspace::properties::Property::PropertyInfo StatisticsScaleInfo = { + "StatisticsScale", + "Statistics Scale", + "This value is scaling the statatistics window by the provided amount. For flat " + "projections this is rarely necessary, but it is important when using a setup " + "where the cornders of the image are masked out.", + openspace::properties::Property::Visibility::AdvancedUser + }; + constexpr openspace::properties::Property::PropertyInfo ScreenshotUseDateInfo = { "ScreenshotUseDate", "Screenshot Folder uses Date", @@ -313,6 +322,7 @@ RenderEngine::RenderEngine() , _screenshotWindowIds(ScreenshotWindowIdsInfo) , _applyWarping(ApplyWarpingInfo, false) , _showStatistics(ShowStatisticsInfo, false) + , _statisticsScale(StatisticsScaleInfo, 1.f, 0.f, 1.f) , _screenshotUseDate(ScreenshotUseDateInfo, false) , _showFrameInformation(ShowFrameNumberInfo, false) , _disableMasterRendering(DisableMasterInfo, false) @@ -387,9 +397,17 @@ RenderEngine::RenderEngine() _showStatistics.onChange([this]() { global::windowDelegate->showStatistics(_showStatistics); + // We need to reset the scale as it is not updated when the statistics window is + // not currently shown + global::windowDelegate->setStatisticsGraphScale(_statisticsScale); }); addProperty(_showStatistics); + _statisticsScale.onChange([this]() { + global::windowDelegate->setStatisticsGraphScale(_statisticsScale); + }); + addProperty(_statisticsScale); + _screenshotUseDate.onChange([this]() { // If there is no screenshot folder, don't bother with handling the change if (!FileSys.hasRegisteredToken("${STARTUP_SCREENSHOT}")) {