[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
This commit is contained in:
Syres916
2025-02-11 19:16:29 +00:00
committed by GitHub
parent 271c446493
commit 62c5267e64
4 changed files with 21 additions and 8 deletions

View File

@@ -103,7 +103,7 @@ in the corner -- in % of height/width of viewport</string>
<item row="1" column="3">
<widget class="Gui::PrefColorButton" name="axisLetterColor">
<property name="toolTip">
<string>Axis letter color</string>
<string>Axis letter and FPS counter color</string>
</property>
<property name="color" stdset="0">
<color>

View File

@@ -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);

View File

@@ -27,6 +27,8 @@
#include <Inventor/lists/SoCallbackList.h>
#include <Inventor/sensors/SoTimerSensor.h>
#include <App/Color.h>
#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
};

View File

@@ -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<uint32_t>(axisLetterColor))); // NOLINT
}
if (naviCubeEnabled) {