From 4519783ad1dbffeb279c75b8faa589cf538219be Mon Sep 17 00:00:00 2001 From: Andreas Pfaller Date: Fri, 22 Mar 2013 14:56:01 +0100 Subject: [PATCH] FinalGlideBar: Add On/Off/Auto display options Implements trac enhancement request #2554. --- NEWS.txt | 1 + src/Dialogs/Settings/Panels/GaugesConfigPanel.cpp | 35 ++++++++++++++++++++--- src/MapSettings.cpp | 1 + src/MapSettings.hpp | 9 ++++++ src/MapWindow/GlueMapWindowOverlays.cpp | 19 ++++++++++++ src/Profile/MapProfile.cpp | 2 ++ src/Profile/ProfileKeys.cpp | 1 + src/Profile/ProfileKeys.hpp | 1 + 8 files changed, 65 insertions(+), 4 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index 92b95572a..84df3728b 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -6,6 +6,7 @@ Version 6.6 - not yet released * map - optional distinct map zoom on each page (#1603) - add label selection "Task waypoints & airfields" + - allow configuration of "Final glide bar" display (#2554) * cross section - show airspace names (#1149, #2390) - use glide polar instead of current glide ratio (#2687) diff --git a/src/Dialogs/Settings/Panels/GaugesConfigPanel.cpp b/src/Dialogs/Settings/Panels/GaugesConfigPanel.cpp index 22ee5341d..e0fa5d35c 100644 --- a/src/Dialogs/Settings/Panels/GaugesConfigPanel.cpp +++ b/src/Dialogs/Settings/Panels/GaugesConfigPanel.cpp @@ -25,6 +25,8 @@ Copyright_License { #include "Profile/ProfileKeys.hpp" #include "Interface.hpp" #include "Widget/RowFormWidget.hpp" +#include "Form/DataField/Enum.hpp" +#include "Form/DataField/Listener.hpp" #include "Language/Language.hpp" #include "UIGlobals.hpp" @@ -33,10 +35,21 @@ enum ControlIndex { AutoCloseFlarmDialog, EnableTAGauge, EnableThermalProfile, - EnableFinalGlideBarMC0 + FinalGlideBarDisplayModeControl, + EnableFinalGlideBarMC0, }; -class GaugesConfigPanel final : public RowFormWidget { +static constexpr StaticEnumChoice final_glide_bar_display_mode_list[] = { + { (unsigned)FinalGlideBarDisplayMode::OFF, N_("Off"), + N_("Disable final glide bar.") }, + { (unsigned)FinalGlideBarDisplayMode::ON, N_("On"), + N_("Always show final glide bar.") }, + { (unsigned)FinalGlideBarDisplayMode::AUTO, N_("Auto"), + N_("Show final glide bar if approaching final glide range.") }, + { 0 } +}; + +class GaugesConfigPanel final : public RowFormWidget, DataFieldListener { public: GaugesConfigPanel() :RowFormWidget(UIGlobals::GetDialogLook()) {} @@ -49,6 +62,7 @@ void GaugesConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) { const UISettings &ui_settings = CommonInterface::GetUISettings(); + const MapSettings &settings_map = CommonInterface::GetMapSettings(); RowFormWidget::Prepare(parent, rc); @@ -67,13 +81,21 @@ GaugesConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) AddBoolean(_("Thermal band"), _("This enables the display of the thermal profile (climb band) display on the map."), - CommonInterface::GetMapSettings().show_thermal_profile); + settings_map.show_thermal_profile); + + AddEnum(_("Final glide bar"), + _("If set to \"On\" the final glide will always be shown, if set to \"Auto\" it will be shown when approaching the final glide possibility."), + final_glide_bar_display_mode_list, + (unsigned)settings_map.final_glide_bar_display_mode, + this); + SetExpertRow(FinalGlideBarDisplayModeControl); AddBoolean(_("Final glide bar MC0"), _("If set to ON the final glide bar will show a second arrow indicating the required height " "to reach the final waypoint at MC zero."), ui_settings.map.final_glide_bar_mc0_enabled); SetExpertRow(EnableFinalGlideBarMC0); + } bool @@ -82,6 +104,7 @@ GaugesConfigPanel::Save(bool &_changed) bool changed = false; UISettings &ui_settings = CommonInterface::SetUISettings(); + MapSettings &settings_map = CommonInterface::SetMapSettings(); changed |= SaveValue(EnableFLARMGauge, ProfileKeys::EnableFLARMGauge, ui_settings.traffic.enable_gauge); @@ -93,7 +116,11 @@ GaugesConfigPanel::Save(bool &_changed) ui_settings.enable_thermal_assistant_gauge); changed |= SaveValue(EnableThermalProfile, ProfileKeys::EnableThermalProfile, - CommonInterface::SetMapSettings().show_thermal_profile); + settings_map.show_thermal_profile); + + changed |= SaveValueEnum(FinalGlideBarDisplayModeControl, + ProfileKeys::FinalGlideBarDisplayMode, + settings_map.final_glide_bar_display_mode); changed |= SaveValue(EnableFinalGlideBarMC0, ProfileKeys::EnableFinalGlideBarMC0, ui_settings.map.final_glide_bar_mc0_enabled); diff --git a/src/MapSettings.cpp b/src/MapSettings.cpp index 42a12dfd4..6c92b3ea0 100644 --- a/src/MapSettings.cpp +++ b/src/MapSettings.cpp @@ -63,6 +63,7 @@ MapSettings::SetDefaults() show_flarm_alarm_level = true; show_thermal_profile = true; final_glide_bar_mc0_enabled = true; + final_glide_bar_display_mode = FinalGlideBarDisplayMode::ON; show_fai_triangle_areas = false; trail.SetDefaults(); diff --git a/src/MapSettings.hpp b/src/MapSettings.hpp index d137b445e..f4de05b35 100644 --- a/src/MapSettings.hpp +++ b/src/MapSettings.hpp @@ -65,6 +65,12 @@ enum class DisplayGroundTrack: uint8_t { AUTO, }; +enum class FinalGlideBarDisplayMode: uint8_t { + OFF, + ON, + AUTO, +}; + struct MapItemListSettings { /** Add an LocationMapItem to the MapItemList? */ @@ -170,6 +176,9 @@ struct MapSettings { /** Show FinalGlideBar mc0 arrow */ bool final_glide_bar_mc0_enabled; + /** FinalGlideBar display mode configuration */ + FinalGlideBarDisplayMode final_glide_bar_display_mode; + /** * Overlay FAI triangle areas on the map while flying? */ diff --git a/src/MapWindow/GlueMapWindowOverlays.cpp b/src/MapWindow/GlueMapWindowOverlays.cpp index 2bbbb8825..c73fd0a1c 100644 --- a/src/MapWindow/GlueMapWindowOverlays.cpp +++ b/src/MapWindow/GlueMapWindowOverlays.cpp @@ -238,6 +238,25 @@ GlueMapWindow::DrawFlightMode(Canvas &canvas, const PixelRect &rc) const void GlueMapWindow::DrawFinalGlide(Canvas &canvas, const PixelRect &rc) const { + + if (GetMapSettings().final_glide_bar_display_mode==FinalGlideBarDisplayMode::OFF) + return; + + if (GetMapSettings().final_glide_bar_display_mode==FinalGlideBarDisplayMode::AUTO) { + const TaskStats &task_stats = Calculated().task_stats; + const ElementStat &total = task_stats.total; + const GlideResult &solution = total.solution_remaining; + const GlideResult &solution_mc0 = total.solution_mc0; + const GlideSettings &glide_settings= GetComputerSettings().task.glide; + + if (!task_stats.task_valid || !solution.IsOk() || !solution_mc0.IsDefined()) + return; + + if (solution_mc0.SelectAltitudeDifference(glide_settings) < fixed(-1000) && + solution.SelectAltitudeDifference(glide_settings) < fixed(-1000)) + return; + } + final_glide_bar_renderer.Draw(canvas, rc, Calculated(), GetComputerSettings().task.glide, GetMapSettings().final_glide_bar_mc0_enabled); diff --git a/src/Profile/MapProfile.cpp b/src/Profile/MapProfile.cpp index 20a560b83..a1b497356 100644 --- a/src/Profile/MapProfile.cpp +++ b/src/Profile/MapProfile.cpp @@ -124,6 +124,8 @@ Profile::Load(MapSettings &settings) Get(ProfileKeys::EnableThermalProfile, settings.show_thermal_profile); Get(ProfileKeys::EnableFinalGlideBarMC0, settings.final_glide_bar_mc0_enabled); + GetEnum(ProfileKeys::FinalGlideBarDisplayMode, + settings.final_glide_bar_display_mode); Get(ProfileKeys::ShowFAITriangleAreas, settings.show_fai_triangle_areas); diff --git a/src/Profile/ProfileKeys.cpp b/src/Profile/ProfileKeys.cpp index 12e1b74d1..4bc8cf4ad 100644 --- a/src/Profile/ProfileKeys.cpp +++ b/src/Profile/ProfileKeys.cpp @@ -190,6 +190,7 @@ const TCHAR RiskGamma[] = _T("RiskGamma"); const TCHAR PredictWindDrift[] = _T("PredictWindDrift"); const TCHAR WindArrowStyle[] = _T("WindArrowStyle"); const TCHAR EnableFinalGlideBarMC0[] = _T("EnableFinalGlideBarMC0"); +const TCHAR FinalGlideBarDisplayMode[] = _T("FinalGlideBarDisplayMode"); const TCHAR ShowFAITriangleAreas[] = _T("ShowFAITriangleAreas"); const TCHAR AutoLogger[] = _T("AutoLogger"); const TCHAR DisableAutoLogger[] = _T("DisableAutoLogger"); diff --git a/src/Profile/ProfileKeys.hpp b/src/Profile/ProfileKeys.hpp index 20a1a3602..290e3897e 100644 --- a/src/Profile/ProfileKeys.hpp +++ b/src/Profile/ProfileKeys.hpp @@ -186,6 +186,7 @@ extern const TCHAR RiskGamma[]; extern const TCHAR PredictWindDrift[]; extern const TCHAR WindArrowStyle[]; extern const TCHAR EnableFinalGlideBarMC0[]; +extern const TCHAR FinalGlideBarDisplayMode[]; extern const TCHAR ShowFAITriangleAreas[]; extern const TCHAR AutoLogger[]; extern const TCHAR DisableAutoLogger[]; -- 2.11.4.GIT