From 62c5267e64bf60d9a561699d5ae06a15fb77da96 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:16:29 +0000 Subject: [PATCH] [Gui] fix the FPS text visibilty issues raised in #19371 (#19385) * [Gui] fix the FPS text visibilty issues * [Gui] code efficiency based on suggestions * [Gui] update color parameter * [Gui] Fix Lint feedback * [Gui] check if string is empty --- src/Gui/PreferencePages/DlgSettings3DView.ui | 2 +- src/Gui/Quarter/SoQTQuarterAdaptor.cpp | 11 ++++++----- src/Gui/Quarter/SoQTQuarterAdaptor.h | 4 +++- src/Gui/View3DInventorViewer.cpp | 12 +++++++++++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Gui/PreferencePages/DlgSettings3DView.ui b/src/Gui/PreferencePages/DlgSettings3DView.ui index a37f8cbc28..4bbdc75615 100644 --- a/src/Gui/PreferencePages/DlgSettings3DView.ui +++ b/src/Gui/PreferencePages/DlgSettings3DView.ui @@ -103,7 +103,7 @@ in the corner -- in % of height/width of viewport - Axis letter color + Axis letter and FPS counter color diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp index db8a3535c6..72dddc75a3 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp @@ -634,10 +634,11 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition() } -void -SIM::Coin3D::Quarter::SoQTQuarterAdaptor::draw2DString(const char* str, - SbVec2s glsize, - SbVec2f position) +void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::draw2DString( + const char* str, + SbVec2s glsize, + SbVec2f position, + App::Color color = App::Color(1.0F, 1.0F, 0.0F)) // retains yellow as default color { // Store GL state. glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT); @@ -668,7 +669,7 @@ SIM::Coin3D::Quarter::SoQTQuarterAdaptor::draw2DString(const char* str, // glRasterPos2f(position[0], position[1] - 1); // printString(str); - glColor3f(1.0, 1.0, 0.0); + glColor3f(color.r, color.g, color.b); glRasterPos2f(position[0], position[1]); printString(str); diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.h b/src/Gui/Quarter/SoQTQuarterAdaptor.h index 5bd96da736..8cfe271cb9 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.h +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.h @@ -27,6 +27,8 @@ #include #include +#include + #include "QuarterWidget.h" @@ -150,7 +152,7 @@ private: SoNode * m_storedcamera = nullptr; protected: - static void draw2DString(const char * str, SbVec2s glsize, SbVec2f position); + static void draw2DString(const char * str, SbVec2s glsize, SbVec2f position, App::Color color); static void printString(const char * str); SbVec2f framesPerSecond; // NOLINT }; diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 5cae26dcb7..cd21a948d5 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2451,7 +2451,17 @@ void View3DInventorViewer::renderScene() stream.precision(1); stream.setf(std::ios::fixed | std::ios::showpoint); stream << framesPerSecond[0] << " ms / " << framesPerSecond[1] << " fps"; - draw2DString(stream.str().c_str(), SbVec2s(10, 10), SbVec2f(0.1F, 0.1F)); // NOLINT + ParameterGrp::handle hGrpOverlayL = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/MainWindow/DockWindows/OverlayLeft"); + std::string overlayLeftWidgets = hGrpOverlayL->GetASCII("Widgets", ""); + ParameterGrp::handle hGrpView = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/View"); + unsigned long axisLetterColor = + hGrpView->GetUnsigned("AxisLetterColor", 4294902015); // default FPS color (yellow) + draw2DString(stream.str().c_str(), + SbVec2s(10, 10), + SbVec2f((overlayLeftWidgets.empty() ? 0.1f : 1.1f), 0.1f), + App::Color(static_cast(axisLetterColor))); // NOLINT } if (naviCubeEnabled) {