mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Add the ability to limit-rate the dashboard updating (#3527)
Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -248,10 +248,10 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
addProperty(_destination.nodeName);
|
||||
|
||||
_buffer.resize(128);
|
||||
_localBuffer.resize(128);
|
||||
}
|
||||
|
||||
void DashboardItemAngle::render(glm::vec2& penPosition) {
|
||||
void DashboardItemAngle::update() {
|
||||
ZoneScoped;
|
||||
|
||||
std::pair<glm::dvec3, std::string> sourceInfo = positionAndLabel(_source);
|
||||
@@ -261,19 +261,14 @@ void DashboardItemAngle::render(glm::vec2& penPosition) {
|
||||
const glm::dvec3 a = referenceInfo.first - sourceInfo.first;
|
||||
const glm::dvec3 b = destinationInfo.first - sourceInfo.first;
|
||||
|
||||
std::fill(_buffer.begin(), _buffer.end(), char(0));
|
||||
std::fill(_localBuffer.begin(), _localBuffer.end(), char(0));
|
||||
if (glm::length(a) == 0.0 || glm::length(b) == 0) {
|
||||
char* end = std::format_to(
|
||||
_buffer.data(),
|
||||
_localBuffer.data(),
|
||||
"Could not compute angle at {} between {} and {}",
|
||||
sourceInfo.second, destinationInfo.second, referenceInfo.second
|
||||
);
|
||||
const std::string_view text = std::string_view(
|
||||
_buffer.data(),
|
||||
end - _buffer.data()
|
||||
);
|
||||
penPosition.y -= _font->height();
|
||||
RenderFont(*_font, penPosition, text);
|
||||
_buffer = std::string(_localBuffer.data(), end - _localBuffer.data());
|
||||
}
|
||||
else {
|
||||
const double angle = glm::degrees(
|
||||
@@ -281,15 +276,11 @@ void DashboardItemAngle::render(glm::vec2& penPosition) {
|
||||
);
|
||||
|
||||
char* end = std::format_to(
|
||||
_buffer.data(),
|
||||
_localBuffer.data(),
|
||||
"Angle at {} between {} and {}: {} degrees",
|
||||
sourceInfo.second, destinationInfo.second, referenceInfo.second, angle
|
||||
);
|
||||
const std::string_view text = std::string_view(
|
||||
_buffer.data(), end - _buffer.data()
|
||||
);
|
||||
penPosition.y -= _font->height();
|
||||
RenderFont(*_font, penPosition, text);
|
||||
_buffer = std::string(_localBuffer.data(), end - _localBuffer.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
explicit DashboardItemAngle(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemAngle() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
Component _reference;
|
||||
Component _destination;
|
||||
|
||||
std::vector<char> _buffer;
|
||||
std::vector<char> _localBuffer;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -84,7 +84,7 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_timeFormat);
|
||||
}
|
||||
|
||||
void DashboardItemDate::render(glm::vec2& penPosition) {
|
||||
void DashboardItemDate::update() {
|
||||
ZoneScoped;
|
||||
|
||||
std::string time = SpiceManager::ref().dateFromEphemerisTime(
|
||||
@@ -93,13 +93,8 @@ void DashboardItemDate::render(glm::vec2& penPosition) {
|
||||
);
|
||||
|
||||
try {
|
||||
penPosition.y -= _font->height();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_formatString.value(), std::make_format_args(time))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_formatString.value(), std::make_format_args(time));
|
||||
}
|
||||
catch (const std::format_error&) {
|
||||
LERRORC("DashboardItemDate", "Illegal format string");
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
explicit DashboardItemDate(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemDate() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
|
||||
_formatString = p.formatString.value_or(_formatString);
|
||||
addProperty(_formatString);
|
||||
|
||||
_buffer.resize(256);
|
||||
_localBuffer.resize(256);
|
||||
}
|
||||
|
||||
std::pair<glm::dvec3, std::string> DashboardItemDistance::positionAndLabel(
|
||||
@@ -321,7 +321,7 @@ std::pair<glm::dvec3, std::string> DashboardItemDistance::positionAndLabel(
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardItemDistance::render(glm::vec2& penPosition) {
|
||||
void DashboardItemDistance::update() {
|
||||
ZoneScoped;
|
||||
|
||||
std::pair<glm::dvec3, std::string> sourceInfo = positionAndLabel(
|
||||
@@ -344,11 +344,11 @@ void DashboardItemDistance::render(glm::vec2& penPosition) {
|
||||
dist = std::pair(convertedD, nameForDistanceUnit(unit, convertedD != 1.0));
|
||||
}
|
||||
|
||||
std::fill(_buffer.begin(), _buffer.end(), char(0));
|
||||
std::fill(_localBuffer.begin(), _localBuffer.end(), char(0));
|
||||
try {
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
char* end = std::vformat_to(
|
||||
_buffer.data(),
|
||||
_localBuffer.data(),
|
||||
_formatString.value(),
|
||||
std::make_format_args(
|
||||
sourceInfo.second,
|
||||
@@ -358,9 +358,7 @@ void DashboardItemDistance::render(glm::vec2& penPosition) {
|
||||
)
|
||||
);
|
||||
|
||||
penPosition.y -= _font->height();
|
||||
const std::string_view t = std::string_view(_buffer.data(), end - _buffer.data());
|
||||
RenderFont(*_font, penPosition, t);
|
||||
_buffer = std::string(_localBuffer.data(), end - _localBuffer.data());
|
||||
}
|
||||
catch (const std::format_error&) {
|
||||
LERRORC("DashboardItemDate", "Illegal format string");
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
explicit DashboardItemDistance(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemDistance() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
Component _source;
|
||||
Component _destination;
|
||||
|
||||
std::vector<char> _buffer;
|
||||
std::vector<char> _localBuffer;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -136,13 +136,11 @@ DashboardItemElapsedTime::DashboardItemElapsedTime(const ghoul::Dictionary& dict
|
||||
addProperty(_lowestTimeUnit);
|
||||
}
|
||||
|
||||
void DashboardItemElapsedTime::render(glm::vec2& penPosition) {
|
||||
void DashboardItemElapsedTime::update() {
|
||||
ZoneScoped;
|
||||
|
||||
const double delta = global::timeManager->time().j2000Seconds() - _referenceJ2000;
|
||||
|
||||
penPosition.y -= _font->height();
|
||||
|
||||
if (_simplifyTime) {
|
||||
using namespace std::chrono;
|
||||
|
||||
@@ -161,21 +159,13 @@ void DashboardItemElapsedTime::render(glm::vec2& penPosition) {
|
||||
// Remove the " " at the end
|
||||
time = time.substr(0, time.size() - 1);
|
||||
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_formatString.value(), std::make_format_args(time))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_formatString.value(), std::make_format_args(time));
|
||||
}
|
||||
else {
|
||||
std::string time = std::format("{} s", delta);
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_formatString.value(), std::make_format_args(time))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_formatString.value(), std::make_format_args(time));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
explicit DashboardItemElapsedTime(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemElapsedTime() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
@@ -200,11 +200,10 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona
|
||||
_shouldClearCache = true;
|
||||
});
|
||||
addProperty(_clearCache);
|
||||
|
||||
_buffer.resize(128);
|
||||
_localBuffer.resize(128);
|
||||
}
|
||||
|
||||
void DashboardItemFramerate::render(glm::vec2& penPosition) {
|
||||
void DashboardItemFramerate::update() {
|
||||
ZoneScoped;
|
||||
|
||||
if (_shouldClearCache) {
|
||||
@@ -224,28 +223,21 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) {
|
||||
|
||||
const FrametimeType frametimeType = FrametimeType(_frametimeType.value());
|
||||
|
||||
std::fill(_buffer.begin(), _buffer.end(), char(0));
|
||||
std::fill(_localBuffer.begin(), _localBuffer.end(), char(0));
|
||||
char* end = format(
|
||||
_buffer,
|
||||
_localBuffer,
|
||||
frametimeType,
|
||||
_minDeltaTimeCache,
|
||||
_maxDeltaTimeCache
|
||||
);
|
||||
const std::string_view text = std::string_view(_buffer.data(), end - _buffer.data());
|
||||
|
||||
const int nLines = text.empty() ?
|
||||
0 :
|
||||
static_cast<int>((std::count(text.begin(), text.end(), '\n') + 1));
|
||||
|
||||
penPosition.y -= _font->height() * static_cast<float>(nLines);
|
||||
RenderFont(*_font, penPosition, text);
|
||||
_buffer = std::string(_localBuffer.data(), end - _localBuffer.data());
|
||||
}
|
||||
|
||||
glm::vec2 DashboardItemFramerate::size() const {
|
||||
ZoneScoped;
|
||||
|
||||
const FrametimeType t = FrametimeType(_frametimeType.value());
|
||||
char* end = format(_buffer, t, _minDeltaTimeCache, _maxDeltaTimeCache);
|
||||
char* end = format(_localBuffer, t, _minDeltaTimeCache, _maxDeltaTimeCache);
|
||||
const std::string_view res = std::string_view(_buffer.data(), end - _buffer.data());
|
||||
|
||||
if (res.empty()) {
|
||||
|
||||
@@ -40,8 +40,9 @@ class DashboardItemFramerate : public DashboardTextItem {
|
||||
public:
|
||||
explicit DashboardItemFramerate(const ghoul::Dictionary& dictionary);
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
glm::vec2 size() const override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
@@ -51,7 +52,7 @@ private:
|
||||
double _minDeltaTimeCache = 1.0;
|
||||
double _maxDeltaTimeCache = -1.0;
|
||||
bool _shouldClearCache = true;
|
||||
mutable std::vector<char> _buffer;
|
||||
mutable std::vector<char> _localBuffer;
|
||||
};
|
||||
|
||||
} // openspace
|
||||
|
||||
@@ -123,7 +123,7 @@ DashboardItemInputState::DashboardItemInputState(const ghoul::Dictionary& dictio
|
||||
addProperty(_showJoystick);
|
||||
}
|
||||
|
||||
void DashboardItemInputState::render(glm::vec2& penPosition) {
|
||||
void DashboardItemInputState::update() {
|
||||
ZoneScoped;
|
||||
|
||||
std::vector<std::string> text;
|
||||
@@ -167,9 +167,7 @@ void DashboardItemInputState::render(glm::vec2& penPosition) {
|
||||
}
|
||||
|
||||
if (!text.empty()) {
|
||||
penPosition.y -= _font->height();
|
||||
const std::string t = ghoul::join(std::move(text), "\n");
|
||||
RenderFont(*_font, penPosition, t);
|
||||
_buffer = ghoul::join(std::move(text), "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
explicit DashboardItemInputState(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemInputState() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ DashboardItemMission::DashboardItemMission(const ghoul::Dictionary& dictionary)
|
||||
: DashboardTextItem(dictionary, 15.f)
|
||||
{}
|
||||
|
||||
void DashboardItemMission::update() {}
|
||||
|
||||
void DashboardItemMission::render(glm::vec2& penPosition) {
|
||||
ZoneScoped;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
explicit DashboardItemMission(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemMission() override = default;
|
||||
|
||||
void update() override;
|
||||
void render(glm::vec2& penPosition) override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/distanceconversion.h>
|
||||
#include <ghoul/font/font.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace openspace {
|
||||
@@ -50,7 +48,7 @@ DashboardItemParallelConnection::DashboardItemParallelConnection(
|
||||
: DashboardTextItem(dictionary)
|
||||
{}
|
||||
|
||||
void DashboardItemParallelConnection::render(glm::vec2& penPosition) {
|
||||
void DashboardItemParallelConnection::update() {
|
||||
ZoneScoped;
|
||||
|
||||
const ParallelConnection::Status status = global::parallelPeer->status();
|
||||
@@ -59,50 +57,44 @@ void DashboardItemParallelConnection::render(glm::vec2& penPosition) {
|
||||
|
||||
int nLines = 1;
|
||||
|
||||
std::string connectionInfo;
|
||||
int nClients = static_cast<int>(nConnections);
|
||||
if (status == ParallelConnection::Status::Host) {
|
||||
nClients--;
|
||||
constexpr std::string_view Singular = "Hosting session with {} client";
|
||||
constexpr std::string_view Plural = "Hosting session with {} clients";
|
||||
|
||||
connectionInfo =
|
||||
_buffer =
|
||||
(nClients == 1) ?
|
||||
std::format(Singular, nClients) :
|
||||
std::format(Plural, nClients);
|
||||
}
|
||||
else if (status == ParallelConnection::Status::ClientWithHost) {
|
||||
nClients--;
|
||||
connectionInfo = "Session hosted by '" + hostName + "'";
|
||||
_buffer = "Session hosted by '" + hostName + "'";
|
||||
}
|
||||
else if (status == ParallelConnection::Status::ClientWithoutHost) {
|
||||
connectionInfo = "Host is disconnected";
|
||||
_buffer = "Host is disconnected";
|
||||
}
|
||||
|
||||
if (status == ParallelConnection::Status::ClientWithHost ||
|
||||
status == ParallelConnection::Status::ClientWithoutHost)
|
||||
{
|
||||
connectionInfo += "\n";
|
||||
_buffer += "\n";
|
||||
|
||||
if (nClients > 2) {
|
||||
constexpr std::string_view Plural = "You and {} more clients are tuned in";
|
||||
connectionInfo += std::format(Plural, nClients - 1);
|
||||
_buffer += std::format(Plural, nClients - 1);
|
||||
}
|
||||
else if (nClients == 2) {
|
||||
constexpr std::string_view Singular = "You and {} more client are tuned in";
|
||||
connectionInfo += std::format(Singular, nClients - 1);
|
||||
_buffer += std::format(Singular, nClients - 1);
|
||||
}
|
||||
else if (nClients == 1) {
|
||||
connectionInfo += "You are the only client";
|
||||
_buffer += "You are the only client";
|
||||
}
|
||||
|
||||
nLines = 2;
|
||||
}
|
||||
|
||||
if (!connectionInfo.empty()) {
|
||||
penPosition.y -= _font->height() * nLines;
|
||||
RenderFont(*_font, penPosition, connectionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec2 DashboardItemParallelConnection::size() const {
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
explicit DashboardItemParallelConnection(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemParallelConnection() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ DashboardItemPropertyValue::DashboardItemPropertyValue(
|
||||
addProperty(_displayString);
|
||||
}
|
||||
|
||||
void DashboardItemPropertyValue::render(glm::vec2& penPosition) {
|
||||
void DashboardItemPropertyValue::update() {
|
||||
ZoneScoped;
|
||||
|
||||
if (_propertyIsDirty) {
|
||||
@@ -119,209 +119,136 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) {
|
||||
return;
|
||||
}
|
||||
const std::string_view type = _property->className();
|
||||
penPosition.y -= _font->height();
|
||||
if (type == "DoubleProperty") {
|
||||
double value = static_cast<properties::DoubleProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(value))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(value));
|
||||
}
|
||||
else if (type == "FloatProperty") {
|
||||
float value = static_cast<properties::FloatProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(value))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(value));
|
||||
}
|
||||
else if (type == "IntProperty") {
|
||||
int value = static_cast<properties::IntProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(value))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(value));
|
||||
}
|
||||
else if (type == "LongProperty") {
|
||||
long value = static_cast<properties::LongProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(value))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(value));
|
||||
}
|
||||
else if (type == "ShortProperty") {
|
||||
short value = static_cast<properties::ShortProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(value))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(value));
|
||||
}
|
||||
else if (type == "UIntProperty") {
|
||||
unsigned int v = static_cast<properties::UIntProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v));
|
||||
}
|
||||
else if (type == "ULongProperty") {
|
||||
unsigned long v = static_cast<properties::ULongProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v));
|
||||
}
|
||||
else if (type == "UShortProperty") {
|
||||
unsigned short v = static_cast<properties::UShortProperty*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v));
|
||||
}
|
||||
else if (type == "DVec2Property") {
|
||||
glm::dvec2 v = static_cast<properties::DVec2Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v.x, v.y));
|
||||
}
|
||||
else if (type == "DVec3Property") {
|
||||
glm::dvec3 v = static_cast<properties::DVec3Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y, v.z))
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z)
|
||||
);
|
||||
}
|
||||
else if (type == "DVec4Property") {
|
||||
glm::dvec4 v = static_cast<properties::DVec4Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
)
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
);
|
||||
}
|
||||
else if (type == "IVec2Property") {
|
||||
glm::ivec2 v = static_cast<properties::IVec2Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v.x, v.y));
|
||||
}
|
||||
else if (type == "IVec3Property") {
|
||||
glm::ivec3 v = static_cast<properties::IVec3Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y, v.z))
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z)
|
||||
);
|
||||
}
|
||||
else if (type == "IVec4Property") {
|
||||
glm::ivec4 v = static_cast<properties::IVec4Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
)
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
);
|
||||
}
|
||||
else if (type == "UVec2Property") {
|
||||
glm::uvec2 v = static_cast<properties::UVec2Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v.x, v.y));
|
||||
}
|
||||
else if (type == "UVec3Property") {
|
||||
glm::uvec3 v = static_cast<properties::UVec3Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y, v.z))
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z)
|
||||
);
|
||||
}
|
||||
else if (type == "UVec4Property") {
|
||||
glm::uvec4 v = static_cast<properties::UVec4Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
)
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
);
|
||||
}
|
||||
else if (type == "Vec2Property") {
|
||||
glm::vec2 v = static_cast<properties::Vec2Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(v.x, v.y));
|
||||
}
|
||||
else if (type == "Vec3Property") {
|
||||
glm::vec3 v = static_cast<properties::Vec3Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(v.x, v.y, v.z))
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z)
|
||||
);
|
||||
}
|
||||
else if (type == "Vec4Property") {
|
||||
glm::vec4 v = static_cast<properties::Vec4Property*>(_property)->value();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
)
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_displayString.value(),
|
||||
std::make_format_args(v.x, v.y, v.z, v.w)
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Fallback if we don't have a special case above
|
||||
|
||||
std::string value = _property->stringValue();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(_displayString.value(), std::make_format_args(value))
|
||||
);
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(_displayString.value(), std::make_format_args(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
DashboardItemPropertyValue(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemPropertyValue() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
|
||||
addProperty(_regularFormat);
|
||||
}
|
||||
|
||||
void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
|
||||
void DashboardItemSimulationIncrement::update() {
|
||||
ZoneScoped;
|
||||
|
||||
const double targetDt = global::timeManager->targetDeltaTime();
|
||||
@@ -188,35 +188,26 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
|
||||
std::string pauseText = global::timeManager->isPaused() ? " (Paused)" : "";
|
||||
|
||||
try {
|
||||
penPosition.y -= _font->height();
|
||||
if (targetDt != currentDt && !global::timeManager->isPaused()) {
|
||||
// We are in the middle of a transition
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(
|
||||
_transitionFormat.value(),
|
||||
std::make_format_args(
|
||||
targetDeltaTime.first, targetDeltaTime.second,
|
||||
pauseText,
|
||||
currentDeltaTime.first, currentDeltaTime.second
|
||||
)
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_transitionFormat.value(),
|
||||
std::make_format_args(
|
||||
targetDeltaTime.first, targetDeltaTime.second,
|
||||
pauseText,
|
||||
currentDeltaTime.first, currentDeltaTime.second
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
std::vformat(
|
||||
_regularFormat.value(),
|
||||
std::make_format_args(
|
||||
targetDeltaTime.first,
|
||||
targetDeltaTime.second,
|
||||
pauseText
|
||||
)
|
||||
// @CPP26(abock): This can be replaced with std::runtime_format
|
||||
_buffer = std::vformat(
|
||||
_regularFormat.value(),
|
||||
std::make_format_args(
|
||||
targetDeltaTime.first,
|
||||
targetDeltaTime.second,
|
||||
pauseText
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
explicit DashboardItemSimulationIncrement(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemSimulationIncrement() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
glm::vec2 size() const override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
@@ -60,6 +60,8 @@ DashboardItemSpacing::DashboardItemSpacing(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_spacing);
|
||||
}
|
||||
|
||||
void DashboardItemSpacing::update() {}
|
||||
|
||||
void DashboardItemSpacing::render(glm::vec2& penPosition) {
|
||||
penPosition.y -= _spacing;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
explicit DashboardItemSpacing(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemSpacing() override = default;
|
||||
|
||||
void update() override;
|
||||
void render(glm::vec2& penPosition) override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <ghoul/font/font.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <optional>
|
||||
|
||||
@@ -66,11 +64,8 @@ DashboardItemText::DashboardItemText(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_text);
|
||||
}
|
||||
|
||||
void DashboardItemText::render(glm::vec2& penPosition) {
|
||||
ZoneScoped;
|
||||
|
||||
penPosition.y -= _font->height();
|
||||
RenderFont(*_font, penPosition, _text.value());
|
||||
void DashboardItemText::update() {
|
||||
_buffer = _text.value();
|
||||
}
|
||||
|
||||
glm::vec2 DashboardItemText::size() const {
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
explicit DashboardItemText(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemText() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/distanceconversion.h>
|
||||
#include <ghoul/font/font.h>
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
@@ -109,15 +107,15 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary
|
||||
addProperty(_requestedUnit);
|
||||
}
|
||||
|
||||
void DashboardItemVelocity::render(glm::vec2& penPosition) {
|
||||
void DashboardItemVelocity::update() {
|
||||
ZoneScoped;
|
||||
|
||||
const glm::dvec3 currentPos = global::renderEngine->scene()->camera()->positionVec3();
|
||||
const glm::dvec3 dt = currentPos - _prevPosition;
|
||||
_prevPosition = currentPos;
|
||||
|
||||
const double speedPerFrame = glm::length(dt);
|
||||
|
||||
const double secondsPerFrame = global::windowDelegate->averageDeltaTime();
|
||||
|
||||
const double speedPerSecond = speedPerFrame / secondsPerFrame;
|
||||
|
||||
std::pair<double, std::string_view> dist;
|
||||
@@ -130,14 +128,7 @@ void DashboardItemVelocity::render(glm::vec2& penPosition) {
|
||||
dist = std::pair(convertedD, nameForDistanceUnit(unit, convertedD != 1.0));
|
||||
}
|
||||
|
||||
penPosition.y -= _font->height();
|
||||
RenderFont(
|
||||
*_font,
|
||||
penPosition,
|
||||
std::format("Camera velocity: {:.4f} {}/s", dist.first, dist.second)
|
||||
);
|
||||
|
||||
_prevPosition = currentPos;
|
||||
_buffer = std::format("Camera velocity: {:.4f} {}/s", dist.first, dist.second);
|
||||
}
|
||||
|
||||
glm::vec2 DashboardItemVelocity::size() const {
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
explicit DashboardItemVelocity(const ghoul::Dictionary& dictionary);
|
||||
~DashboardItemVelocity() override = default;
|
||||
|
||||
void render(glm::vec2& penPosition) override;
|
||||
void update() override;
|
||||
|
||||
glm::vec2 size() const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user