From 46efbb0801e689491fe69fdb13863206c7df1f17 Mon Sep 17 00:00:00 2001 From: mfranz <mfranz> Date: Tue, 1 Aug 2006 21:43:13 +0000 Subject: [PATCH] - "almost zero" is zero - improve/add <format> warning --- src/Instrumentation/HUD/HUD_label.cxx | 3 ++- src/Instrumentation/HUD/HUD_tape.cxx | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Instrumentation/HUD/HUD_label.cxx b/src/Instrumentation/HUD/HUD_label.cxx index 16a234873..eb7d979f2 100644 --- a/src/Instrumentation/HUD/HUD_label.cxx +++ b/src/Instrumentation/HUD/HUD_label.cxx @@ -69,7 +69,8 @@ HUD::Label::Label(HUD *hud, const SGPropertyNode *n, float x, float y) : _mode = check_format(_format.c_str()); if (_mode == INVALID) { - SG_LOG(SG_INPUT, SG_ALERT, "HUD: invalid format '" << _format.c_str() << '\''); + SG_LOG(SG_INPUT, SG_ALERT, "HUD: invalid format '" << _format.c_str() + << "' in <label> '" << _name << '\''); _format = "INVALID"; _mode = NONE; } diff --git a/src/Instrumentation/HUD/HUD_tape.cxx b/src/Instrumentation/HUD/HUD_tape.cxx index 9b4609384..af7add2a2 100644 --- a/src/Instrumentation/HUD/HUD_tape.cxx +++ b/src/Instrumentation/HUD/HUD_tape.cxx @@ -53,6 +53,8 @@ HUD::Tape::Tape(HUD *hud, const SGPropertyNode *n, float x, float y) : _label_fmt = check_format(_format.c_str()); if (_label_fmt != INT && _label_fmt != LONG && _label_fmt != FLOAT && _label_fmt != DOUBLE) { + SG_LOG(SG_INPUT, SG_ALERT, "HUD: invalid <format> '" << _format.c_str() + << "' in <tape> '" << _name << "' (must be number format)"); _label_fmt = INT; _format = "%d"; } @@ -546,6 +548,9 @@ void HUD::Tape::draw(void) // (HUD_scale * pscale) char *HUD::Tape::format_value(float v) { + if (fabsf(v) < 1e-8) + v = 0.0f; + if (_label_fmt == INT) snprintf(_buf, BUFSIZE, _format.c_str(), int(v + 0.5f)); else if (_label_fmt == LONG)