From 090d1b3e7cd65b34f4f3fc4ad047c758336989ae Mon Sep 17 00:00:00 2001 From: GLS-SSV Date: Sun, 21 Dec 2025 16:36:48 +0000 Subject: [PATCH 1/3] limited size of Distance string by adding conversion to parsecs, and using scientific notation for larger values --- Src/Orbiter/Astro.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Src/Orbiter/Astro.cpp b/Src/Orbiter/Astro.cpp index 6a30d7161..2e2b67239 100644 --- a/Src/Orbiter/Astro.cpp +++ b/Src/Orbiter/Astro.cpp @@ -154,14 +154,20 @@ char *DistStr (double dist, int precision) if (absd < 1e8) sprintf (strbuf, "% 0.*fM", precision-2, dist*1e-6); else if (absd < 1e9) sprintf (strbuf, "% 0.*fM", precision-3, dist*1e-6); else sprintf (strbuf, "% 0.*fG", precision-1, dist*1e-9); - } else if (absd < 1e2*AU) { + } else if (absd < 1e1*AU) { if (absd < 1e11) sprintf (strbuf, "% 0.*fG", precision-2, dist*1e-9); else if (absd < 1e12) sprintf (strbuf, "% 0.*fG", precision-3, dist*1e-9); - else sprintf (strbuf, "% 0.*fAU",precision-2, dist*iAU); + else sprintf (strbuf, "% 0.*fAU",precision-1, dist*iAU); + } else if (absd < 1e1*parsec) { + if (absd < 1e2*AU) sprintf (strbuf, "% 0.*fAU", precision-2, dist*iAU); + else if (absd < 1e3*AU) sprintf (strbuf, "% 0.*fAU", precision-3, dist*iAU); + else sprintf (strbuf, "% 0.*fpc", precision-1, dist*iparsec); + } else if (absd < 1e4*parsec) { + if (absd < 1e2*parsec) sprintf (strbuf, "% 0.*fpc", precision-2, dist*iparsec); + else if (absd < 1e3*parsec) sprintf (strbuf, "% 0.*fpc", precision-3, dist*iparsec); + else sprintf (strbuf, "% 0.0fpc", dist*iparsec); } else { - sprintf (strbuf, "% 0.0fAU", dist*iAU); - //FloatStr (dist*iparsec, precision+1); - //strcat (strbuf, "pc"); + sprintf (strbuf, "% 0.3epc", dist*iparsec); } return strbuf; } From ce2a3ad3321fcaa14b53a060e91d12b4107add43 Mon Sep 17 00:00:00 2001 From: GLS-SSV Date: Sun, 21 Dec 2025 16:37:27 +0000 Subject: [PATCH 2/3] removed unneeded Distance output while not in External view --- Src/Orbiter/MenuInfoBar.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Src/Orbiter/MenuInfoBar.cpp b/Src/Orbiter/MenuInfoBar.cpp index 0594c8fdd..ddf4508e7 100644 --- a/Src/Orbiter/MenuInfoBar.cpp +++ b/Src/Orbiter/MenuInfoBar.cpp @@ -746,9 +746,6 @@ class InfoTarget: public ImGuiDialog { if (g_camera->IsExternal()) { ImGui::SameLine(); ImGui::TextColored(white, " Dst %s", DistStr (g_camera->Distance())+1); - } else { - ImGui::SameLine(); - ImGui::TextColored(ImVec4(0,0,0,0), " Dst %s", DistStr (g_camera->Distance())+1); } if(prm.FPS == 1) From 77bdeb09c964552d91455f26c5fe327da2e76b5b Mon Sep 17 00:00:00 2001 From: GLS-SSV Date: Sun, 21 Dec 2025 19:17:25 +0000 Subject: [PATCH 3/3] improved usage of scientific notation in the information dialog and replaced the "10^" with the more conventional "e" --- Src/Orbiter/Astro.cpp | 24 ++++++++---------------- Src/Orbiter/Astro.h | 6 +++--- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Src/Orbiter/Astro.cpp b/Src/Orbiter/Astro.cpp index 2e2b67239..974d6585a 100644 --- a/Src/Orbiter/Astro.cpp +++ b/Src/Orbiter/Astro.cpp @@ -199,23 +199,15 @@ char *FloatStr (double f, int precision) return strbuf; } -char *SciStr (double f, int precision, char prefix) +char *SciStr (double f, int precision) { - const char *fmtstr[3] = { - "%0.*g", "% 0.*g", "%+0.*g" - }; - const char *fstr = fmtstr[0]; - if (prefix == ' ') fstr = fmtstr[1]; - else if (prefix == '+') fstr = fmtstr[2]; - - int i, len, e; - sprintf (strbuf, fstr, precision, f); - len = strlen (strbuf); - for (i = 0; i < len; i++) { - if (strbuf[i] == 'e') { - sscanf(strbuf+i+1, "%d", &e); - sprintf (strbuf+i, "ยท10^%d", e); - } + if (f < 1e4) + { + sprintf (strbuf, "%0.*g", precision, f); + } + else + { + sprintf (strbuf, "%0.*e", precision, f); } return strbuf; } diff --git a/Src/Orbiter/Astro.h b/Src/Orbiter/Astro.h index ffe4e046f..26ae0cc8f 100644 --- a/Src/Orbiter/Astro.h +++ b/Src/Orbiter/Astro.h @@ -108,9 +108,9 @@ char *FloatStr (double f, int precision = 4); // Formats floating point value f with given precision, using 'k', 'M' and 'G' // suffix as required. -char *SciStr (double f, int precision = 4, char prefix = '\0'); -// Formats floating point value f with given precision, using "*10^x" suffix -// notation as required +char *SciStr (double f, int precision = 4); +// Formats floating point value f with given precision, using scientific +// notation above 10000 char *DistStr (double d, int precision = 4); // as FloatStr, but uses 'AU' (astronomical units) instead of 'G'