void InfoBoxContentAltitudeAGL::Update(InfoBoxWindow &infobox) { TCHAR sTmp[32]; if (!XCSoarInterface::Calculated().TerrainValid) { infobox.SetInvalid(); return; } // Set Value Units::FormatUserAltitude(XCSoarInterface::Basic().AltitudeAGL, sTmp, sizeof(sTmp) / sizeof(sTmp[0]), false); infobox.SetValue(sTmp); // Set Comment Units::FormatAlternateUserAltitude(XCSoarInterface::Basic().AltitudeAGL, sTmp, sizeof(sTmp) / sizeof(sTmp[0])); infobox.SetComment(sTmp); // Set Unit infobox.SetValueUnit(Units::AltitudeUnit); if (XCSoarInterface::Basic().AltitudeAGL < XCSoarInterface::SettingsComputer().safety_height_terrain) // red infobox.SetColor(1); else infobox.SetColor(0); }
void InfoBoxContentTaskAATimeDelta::Update(InfoBoxWindow &infobox) { const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats; const CommonStats &common_stats = XCSoarInterface::Calculated().common_stats; if (!task_stats.task_valid || !task_stats.total.achievable() || !positive(task_stats.total.TimeRemaining) || !positive(common_stats.aat_time_remaining)) { infobox.SetInvalid(); return; } TCHAR tmp[32]; fixed diff = task_stats.total.TimeRemaining - common_stats.aat_time_remaining; int dd = abs((int)diff) % (3600 * 24); int hours = (dd / 3600); int mins = (dd / 60 - hours * 60); int seconds = (dd - mins * 60 - hours * 3600); hours = hours % 24; if (hours > 0) { // hh:mm, ss // Set Value _stprintf(tmp, negative(diff) ? _T("-%02d:%02d") : _T("%02d:%02d"), hours, mins); infobox.SetValue(tmp); // Set Comment _stprintf(tmp, _T("%02d"), seconds); infobox.SetComment(tmp); } else { // mm:ss // Set Value _stprintf(tmp, negative(diff) ? _T("-%02d:%02d") : _T("%02d:%02d"), mins, seconds); infobox.SetValue(tmp); // Set Comment infobox.SetComment(_T("")); } // Set Color if (negative(diff)) // Red infobox.SetColor(1); else if (task_stats.total.TimeRemaining < common_stats.aat_time_remaining + fixed(5)) // Blue infobox.SetColor(2); else // Black infobox.SetColor(0); }
void InfoBoxContentAltitudeAGL::Update(InfoBoxWindow &infobox) { const DerivedInfo &calculated = CommonInterface::Calculated(); TCHAR sTmp[32]; if (!calculated.altitude_agl_valid) { infobox.SetInvalid(); return; } // Set Value Units::FormatUserAltitude(calculated.altitude_agl, sTmp, ARRAY_SIZE(sTmp), false); infobox.SetValue(sTmp); // Set Comment Units::FormatAlternateUserAltitude(calculated.altitude_agl, sTmp, ARRAY_SIZE(sTmp)); infobox.SetComment(sTmp); // Set Unit infobox.SetValueUnit(Units::Current.AltitudeUnit); // Set Color (red/black) infobox.SetColor(calculated.altitude_agl < XCSoarInterface::SettingsComputer().task.route_planner.safety_height_terrain ? 1 : 0); }
void InfoBoxContentAltitudeAGL::Update(InfoBoxWindow &infobox) { const DERIVED_INFO &calculated = CommonInterface::Calculated(); TCHAR sTmp[32]; if (!calculated.AltitudeAGLValid) { infobox.SetInvalid(); return; } // Set Value Units::FormatUserAltitude(calculated.AltitudeAGL, sTmp, sizeof(sTmp) / sizeof(sTmp[0]), false); infobox.SetValue(sTmp); // Set Comment Units::FormatAlternateUserAltitude(calculated.AltitudeAGL, sTmp, sizeof(sTmp) / sizeof(sTmp[0])); infobox.SetComment(sTmp); // Set Unit infobox.SetValueUnit(Units::Current.AltitudeUnit); // Set Color (red/black) infobox.SetColor(calculated.AltitudeAGL < XCSoarInterface::SettingsComputer().route_planner.safety_height_terrain ? 1 : 0); }
void InfoBoxContentTaskAATimeDelta::Update(InfoBoxWindow &infobox) { const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats; const CommonStats &common_stats = XCSoarInterface::Calculated().common_stats; if (!task_stats.task_valid || !task_stats.total.achievable() || !positive(task_stats.total.TimeRemaining) || !positive(common_stats.aat_time_remaining)) { infobox.SetInvalid(); return; } fixed diff = task_stats.total.TimeRemaining - common_stats.aat_time_remaining; TCHAR HHMMSSsmart[32]; TCHAR SSsmart[32]; const int dd = abs((int)diff); Units::TimeToTextSmart(HHMMSSsmart, SSsmart, dd); TCHAR tmp[32]; _stprintf(tmp, negative(diff) ? _T("-%s") : _T("%s"), HHMMSSsmart); infobox.SetValue(tmp); infobox.SetComment(SSsmart); // Set Color (red/blue/black) infobox.SetColor(negative(diff) ? 1 : task_stats.total.TimeRemaining < common_stats.aat_time_remaining + fixed(5) ? 2 : 0); }
void InfoBoxContentAlternateGR::Update(InfoBoxWindow &infobox) { if (protected_task_manager == NULL) { infobox.SetInvalid(); return; } const AbortTask::AlternateVector alternates = protected_task_manager->getAlternates(); if (alternates.size() > 0 && index >= alternates.size()) index = alternates.size() - 1; TCHAR tmp[32]; _stprintf(tmp, _T("Altrn %d GR"), index+1); infobox.SetTitle(tmp); const Waypoint* way_point = (alternates.size()>index) ? &alternates[index].first : NULL; SetCommentFromWaypointName(infobox, way_point); if (!way_point) { infobox.SetInvalid(); return; } const GlideResult& solution = alternates[index].second; fixed gradient = ::AngleToGradient(solution.destination_angle_ground()); if (negative(gradient)) { infobox.SetColor(0); infobox.SetValue(_T("+++")); return; } if (::GradientValid(gradient)) { TCHAR tmp[32]; _stprintf(tmp, _T("%d"), (int)gradient); infobox.SetValue(tmp); } else { infobox.SetInvalid(); } // Set Color (blue/black) infobox.SetColor(solution.glide_reachable(true) ? 2 : 0); }
void InfoBoxContentThermal30s::Update(InfoBoxWindow &infobox) { SetVSpeed(infobox, XCSoarInterface::Calculated().average); // Set Color (red/black) infobox.SetColor(XCSoarInterface::Calculated().average * fixed_two < XCSoarInterface::Calculated().common_stats.current_risk_mc ? 1 : 0); }
void InfoBoxContentNextWaypoint::Update(InfoBoxWindow &infobox) { // use proper non-terminal next task stats const Waypoint* way_point = protected_task_manager.getActiveWaypoint(); if (!way_point) { infobox.SetTitle(_("Next")); infobox.SetInvalid(); return; } SetTitleFromWaypointName(infobox, way_point); if (!XCSoarInterface::Calculated().task_stats.task_valid || XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining. Vector.Distance <= fixed(10)) { infobox.SetInvalid(); return; } // Set Value Angle Value = (XCSoarInterface::Calculated().task_stats.current_leg. solution_remaining.Vector.Bearing - XCSoarInterface::Basic(). TrackBearing); SetValueBearingDifference(infobox, Value); // Set Comment infobox.SetComment(way_point->Comment.c_str()); // Set Color if (XCSoarInterface::Calculated().task_stats.current_leg. solution_remaining.is_final_glide()) // blue infobox.SetColor(2); else // black infobox.SetColor(0); }
void InfoBoxContentVarioDistance::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::Calculated().task_stats.task_valid) { infobox.SetInvalid(); return; } SetVSpeed(infobox, XCSoarInterface::Calculated().task_stats.total.vario.get_value()); // Set Color (red/black) infobox.SetColor(negative( XCSoarInterface::Calculated().task_stats.total.vario.get_value()) ? 1 : 0); }
void InfoBoxContentThermalAvg::Update(InfoBoxWindow &infobox) { const OneClimbInfo &thermal = CommonInterface::Calculated().current_thermal; if (!thermal.IsDefined()) { infobox.SetInvalid(); return; } SetVSpeed(infobox, thermal.lift_rate); // Set Color (red/black) infobox.SetColor(thermal.lift_rate * fixed(1.5) < XCSoarInterface::Calculated().common_stats.current_risk_mc ? 1 : 0); }
void InfoBoxContentNextWaypoint::Update(InfoBoxWindow &infobox) { // use proper non-terminal next task stats const Waypoint* way_point = protected_task_manager != NULL ? protected_task_manager->getActiveWaypoint() : NULL; if (!way_point) { infobox.SetTitle(_("Next")); infobox.SetInvalid(); return; } SetTitleFromWaypointName(infobox, way_point); // Set Comment if (way_point->radio_frequency.IsDefined()) { StaticString<128> comment; const unsigned freq = way_point->radio_frequency.GetKiloHertz(); _sntprintf(comment.buffer(), comment.MAX_SIZE, _T("%u.%03u %s"), freq / 1000, freq % 1000, way_point->Comment.c_str()); infobox.SetComment(comment); } else infobox.SetComment(way_point->Comment.c_str()); const GlideResult &solution_remaining = XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining; if (!XCSoarInterface::Basic().track_available || !XCSoarInterface::Calculated().task_stats.task_valid || !solution_remaining.defined() || solution_remaining.Vector.Distance <= fixed(10)) { infobox.SetValueInvalid(); return; } // Set Value Angle Value = solution_remaining.Vector.Bearing - XCSoarInterface::Basic().track; SetValueBearingDifference(infobox, Value); // Set Color (blue/black) infobox.SetColor(solution_remaining.is_final_glide() ? 2 : 0); }
void InfoBoxContentAlternateName::Update(InfoBoxWindow &infobox) { if (protected_task_manager == NULL) { infobox.SetInvalid(); return; } const AbortTask::AlternateVector alternates = protected_task_manager->getAlternates(); if (alternates.size() > 0 && index >= alternates.size()) index = alternates.size() - 1; TCHAR tmp[32]; _stprintf(tmp, _T("Altrn %d"), index+1); infobox.SetTitle(tmp); const Waypoint* way_point = (alternates.size()>index) ? &alternates[index].first : NULL; SetCommentFromWaypointName(infobox, way_point); if (!way_point) { infobox.SetInvalid(); return; } const GlideResult& solution = alternates[index].second; // Set Value Angle Value = solution.Vector.Bearing - XCSoarInterface::Basic().track; SetValueBearingDifference(infobox, Value); // Set Color (blue/black) infobox.SetColor(solution.glide_reachable(true) ? 2 : 0); }
void InfoBoxContentNextWaypoint::Update(InfoBoxWindow &infobox) { const Waypoint* way_point = protected_task_manager.getActiveWaypoint(); if (!way_point) { // Set Title infobox.SetTitle(_T("Next")); infobox.SetInvalid(); return; } // Set Title TCHAR tmp[32]; if (XCSoarInterface::SettingsMap().DisplayTextType == DISPLAYFIRSTTHREE) { _tcsncpy(tmp, way_point->Name.c_str(), 3); tmp[3] = '\0'; } else if (XCSoarInterface::SettingsMap().DisplayTextType == DISPLAYNUMBER) { _stprintf(tmp, _T("%d"), way_point->id); } else { _tcsncpy(tmp, way_point->Name.c_str(), (sizeof(tmp) / sizeof(TCHAR)) - 1); tmp[(sizeof(tmp) / sizeof(TCHAR)) - 1] = '\0'; } infobox.SetTitle(tmp); if (!XCSoarInterface::Calculated().task_stats.task_valid || XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining. Vector.Distance <= fixed(10)) { infobox.SetInvalid(); return; } // Set Value double Value = (XCSoarInterface::Calculated().task_stats.current_leg. solution_remaining.Vector.Bearing - XCSoarInterface::Basic(). TrackBearing).as_delta().value_degrees(); #ifndef __MINGW32__ if (Value > 1) _stprintf(tmp, _T("%2.0f°»"), Value); else if (Value < -1) _stprintf(tmp, _T("«%2.0f°"), -Value); else _tcscpy(tmp, _T("«»")); #else if (Value > 1) _stprintf(tmp, _T("%2.0f°»"), Value); else if (Value < -1) _stprintf(tmp, _T("«%2.0f°"), -Value); else _tcscpy(tmp, _T("«»")); #endif infobox.SetValue(tmp); // Set Comment infobox.SetComment(way_point->Comment.c_str()); // Set Color if (XCSoarInterface::Calculated().task_stats.current_leg. solution_remaining.is_final_glide()) // blue infobox.SetColor(2); else // black infobox.SetColor(0); }