void InfoBoxContentTaskTimeUnderMaxHeight::Update(InfoBoxWindow &infobox) { const CommonStats &common_stats = XCSoarInterface::Calculated().common_stats; const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats; const fixed maxheight = fixed(protected_task_manager-> get_ordered_task_behaviour().start_max_height); if (!task_stats.task_valid || !positive(maxheight) || !protected_task_manager || !positive(common_stats.TimeUnderStartMaxHeight)) { infobox.SetInvalid(); return; } const int dd = (int)(XCSoarInterface::Basic().Time - common_stats.TimeUnderStartMaxHeight); TCHAR HHMMSSsmart[32]; TCHAR SSsmart[32]; Units::TimeToTextSmart(HHMMSSsmart, SSsmart, dd); infobox.SetValue(HHMMSSsmart); infobox.SetComment(_("Time Below")); }
void InfoBoxContentFinalETEVMG::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::Basic().GroundSpeedAvailable) { infobox.SetInvalid(); return; } const fixed d = XCSoarInterface::Calculated().task_stats. total.remaining.get_distance(); const fixed &v = XCSoarInterface::Basic().GroundSpeed; if (!XCSoarInterface::Calculated().task_stats.task_valid || !positive(d) || !positive(v)) { infobox.SetInvalid(); return; } TCHAR HHMMSSsmart[32]; TCHAR SSsmart[32]; const int dd = (int)(d/v); Units::TimeToTextSmart(HHMMSSsmart, SSsmart, dd); infobox.SetValue(HHMMSSsmart); infobox.SetComment(SSsmart); }
void InfoBoxContentNextETA::Update(InfoBoxWindow &infobox) { // use proper non-terminal next task stats if (!XCSoarInterface::Calculated().task_stats.task_valid || !XCSoarInterface::Calculated().task_stats.current_leg.achievable()) { infobox.SetInvalid(); return; } TCHAR tmp[32]; int dd = (int)(XCSoarInterface::Calculated().task_stats.current_leg. solution_remaining.TimeElapsed) + DetectCurrentTime(XCSoarInterface::Basic()); const BrokenTime t = BrokenTime::FromSecondOfDayChecked(abs(dd)); // Set Value _stprintf(tmp, _T("%02u:%02u"), t.hour, t.minute); infobox.SetValue(tmp); // Set Comment _stprintf(tmp, _T("%02u"), t.second); infobox.SetComment(tmp); }
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 InfoBoxContentNextLD::Update(InfoBoxWindow &infobox) { // pilots want this to be assuming terminal flight to this wp, and this // is what current_leg gradient does. if (!XCSoarInterface::Calculated().task_stats.task_valid) { infobox.SetInvalid(); return; } fixed gradient = XCSoarInterface::Calculated().task_stats.current_leg.gradient; if (!positive(gradient)) { infobox.SetValue(_T("+++")); return; } if (::GradientValid(gradient)) { TCHAR tmp[32]; _stprintf(tmp, _T("%d"), (int)gradient); infobox.SetValue(tmp); } else { infobox.SetInvalid(); } }
void InfoBoxContentFreeRAM::Update(InfoBoxWindow &infobox) { #ifdef HAVE_MEM_INFO TCHAR tmp[32]; TCHAR unit; unsigned long freeRAM = SystemFreeRAM(); double f = freeRAM; if (freeRAM >= 1024 * 1024 *1024) { f /= (1024 * 1024 * 1024); unit = _T('G'); } else if (freeRAM >= 1024 * 1024) { f /= (1024 * 1024); unit = _T('M'); } else if (freeRAM >= 1024) { f /= 1024; unit = _T('K'); } else unit = _T('B'); _stprintf(tmp, _T("%.1f%c"), f, unit); infobox.SetValue(tmp); #else infobox.SetInvalid(); #endif }
void InfoBoxContentThermalBand::Update(InfoBoxWindow &infobox) { infobox.SetComment(_T("")); infobox.SetValue(_T("")); infobox.invalidate(); }
static void SetVSpeed(InfoBoxWindow &infobox, fixed value) { TCHAR buffer[32]; Units::FormatUserVSpeed(value, buffer, 32, false); infobox.SetValue(buffer[0] == _T('+') ? buffer + 1 : buffer); infobox.SetValueUnit(Units::Current.VerticalSpeedUnit); }
void InfoBoxContentTrack::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::Basic().track_available) { infobox.SetInvalid(); return; } infobox.SetValue(XCSoarInterface::Basic().track, _T("T")); }
void InfoBoxContentTrack::Update(InfoBoxWindow &infobox) { if (XCSoarInterface::Basic().gps.NAVWarning) { infobox.SetInvalid(); return; } infobox.SetValue(XCSoarInterface::Basic().TrackBearing, _T("T")); }
void InfoBoxContentWindBearing::Update(InfoBoxWindow &infobox) { const DerivedInfo &info = CommonInterface::Calculated(); if (!info.wind_available) { infobox.SetInvalid(); return; } infobox.SetValue(info.wind.bearing, _T("T")); }
void InfoBoxContentHorizon::Update(InfoBoxWindow &infobox) { infobox.SetComment(_T("")); if (!CommonInterface::Basic().acceleration.available) { infobox.SetInvalid(); return; } infobox.SetValue(_T("")); infobox.invalidate(); }
void InfoBoxContentCPULoad::Update(InfoBoxWindow &infobox) { TCHAR tmp[32]; unsigned percent_load = SystemLoadCPU(); if (percent_load <= 100) { _stprintf(tmp, _T("%d%%"), percent_load); infobox.SetValue(tmp); } else { infobox.SetInvalid(); } }
void InfoBoxContentBarogram::Update(InfoBoxWindow &infobox) { const NMEA_INFO &basic = CommonInterface::Basic(); TCHAR sTmp[32]; Units::FormatUserAltitude(basic.NavAltitude, sTmp, sizeof(sTmp) / sizeof(sTmp[0])); infobox.SetComment(sTmp); infobox.SetValue(_T("")); infobox.invalidate(); }
void InfoBoxContentLDCruise::Update(InfoBoxWindow &infobox) { if (XCSoarInterface::Calculated().CruiseLD == fixed(999)) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; _stprintf(tmp, _T("%2.0f"), (double)XCSoarInterface::Calculated().CruiseLD); infobox.SetValue(tmp); }
void InfoBoxContentHumidity::Update(InfoBoxWindow &infobox) { const NMEAInfo &basic = XCSoarInterface::Basic(); if (!basic.humidity_available) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; _stprintf(tmp, _T("%d"), (int)basic.humidity); infobox.SetValue(tmp); }
void InfoBoxContentGLoad::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::Basic().acceleration.Available) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; _stprintf(tmp, _T("%2.2f"), (double)XCSoarInterface::Basic().acceleration.Gload); infobox.SetValue(tmp); }
void InfoBoxContentMacCready::Update(InfoBoxWindow &infobox) { const SETTINGS_COMPUTER &settings_computer = CommonInterface::SettingsComputer(); SetVSpeed(infobox, settings_computer.glide_polar_task.GetMC()); // Set Comment if (XCSoarInterface::SettingsComputer().auto_mc) infobox.SetComment(_("AUTO")); else infobox.SetComment(_("MANUAL")); }
void InfoBoxContentTeamDistance::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::SettingsComputer().TeammateCodeValid) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; Units::FormatUserDistance(XCSoarInterface::Calculated().TeammateRange, tmp, 32, false); infobox.SetValue(tmp); // Set Unit infobox.SetValueUnit(Units::DistanceUnit); // Set Comment if (!XCSoarInterface::SettingsComputer().TeamFlarmIdTarget.defined()) infobox.SetComment(_T("---")); else if (!string_is_empty(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget)) infobox.SetComment(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget); else infobox.SetComment(_T("???")); if (XCSoarInterface::Basic().flarm.FindTraffic( XCSoarInterface::SettingsComputer().TeamFlarmIdTarget) != NULL) infobox.SetColorBottom(2); else infobox.SetColorBottom(1); }
void InfoBoxContentBearing::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::Calculated().task_stats.task_valid || XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining. Vector.Distance <= fixed(10)) { infobox.SetInvalid(); return; } // Set Value infobox.SetValue(XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining.Vector.Bearing, _T("T")); }
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 InfoBoxContentHomeDistance::Update(InfoBoxWindow &infobox) { const CommonStats &common_stats = XCSoarInterface::Calculated().common_stats; // Set Value TCHAR tmp[32]; Units::FormatUserDistance(common_stats.vector_home.Distance, tmp, 32, false); infobox.SetValue(tmp); // Set Unit infobox.SetValueUnit(Units::DistanceUnit); infobox.SetComment(common_stats.vector_home.Bearing); }
void InfoBoxContentLDVario::Update(InfoBoxWindow &infobox) { if (XCSoarInterface::Calculated().LDvario == fixed(999) || !XCSoarInterface::Basic().TotalEnergyVarioAvailable || !XCSoarInterface::Basic().AirspeedAvailable) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; _stprintf(tmp, _T("%2.0f"), (double)XCSoarInterface::Calculated().LDvario); infobox.SetValue(tmp); }
void InfoBoxContentSpark::label_vspeed(InfoBoxWindow &infobox, const TraceVariableHistory& var) { if (var.empty()) return; TCHAR sTmp[32]; Units::FormatUserVSpeed(var.last(), sTmp, sizeof(sTmp) / sizeof(sTmp[0])); infobox.SetComment(sTmp); infobox.SetValue(_T("")); infobox.invalidate(); }
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 InfoBoxContentTaskSpeedInstant::Update(InfoBoxWindow &infobox) { const TaskStats &task_stats = XCSoarInterface::Calculated().task_stats; if (!task_stats.task_valid) { infobox.SetInvalid(); return; } // Set Value SetValueFromFixed(infobox, _T("%2.0f"), Units::ToUserTaskSpeed(task_stats.get_pirker_speed())); // Set Unit infobox.SetValueUnit(Units::Current.TaskSpeedUnit); }
void InfoBoxContentWindArrow::OnCustomPaint(InfoBoxWindow &infobox, Canvas &canvas) { const auto &info = CommonInterface::Calculated(); auto rc = infobox.GetValueRect(); RasterPoint pt = { PixelScalar((rc.left + rc.right) / 2), PixelScalar((rc.top + rc.bottom) / 2), }; UPixelScalar padding = Layout::FastScale(5); UPixelScalar size = std::min(rc.right - rc.left, rc.bottom - rc.top); if (size > padding) size -= padding; auto angle = info.wind.bearing - info.heading; auto length = std::min(size, (UPixelScalar)std::max(10, iround(info.wind.norm * 4))); auto offset = -length / 2; auto style = CommonInterface::GetMapSettings().wind_arrow_style; WindArrowRenderer renderer(UIGlobals::GetMapLook().wind); renderer.DrawArrow(canvas, pt, angle, length, style, offset); }
void InfoBoxContentTaskProgress::on_custom_paint(InfoBoxWindow &infobox, Canvas &canvas) { TaskProgressRenderer::DrawTaskProgress(CommonInterface::Calculated().common_stats. ordered_summary, canvas, infobox.get_value_and_comment_rect()); }
void InfoBoxContentBearing::Update(InfoBoxWindow &infobox) { if (!XCSoarInterface::Calculated().task_stats.task_valid || XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining. Vector.Distance <= fixed(10)) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; _stprintf(tmp, _T("%2.0f")_T(DEG)_T("T"), (double)XCSoarInterface::Calculated().task_stats.current_leg. solution_remaining.Vector.Bearing.value_degrees()); infobox.SetValue(tmp); }
void InfoBoxContentTeamBearingDiff::Update(InfoBoxWindow &infobox) { #ifndef OLD_TASK infobox.SetInvalid(); return; #else if (!way_points.verify_index(XCSoarInterface::SettingsComputer(). TeamCodeRefWaypoint) || !XCSoarInterface::SettingsComputer().TeammateCodeValid) { infobox.SetInvalid(); return; } // Set Value TCHAR tmp[32]; double Value = XCSoarInterface::Calculated().TeammateBearing - XCSoarInterface::Basic().TrackBearing; if (Value < -180.0) Value += 360.0; else if (Value > 180.0) Value -= 360.0; #ifndef __MINGW32__ if (Value > 1) _stprintf(tmp, TEXT("%2.0f°»"), Value); else if (Value < -1) _stprintf(tmp, TEXT("«%2.0f°"), -Value); else _tcscpy(tmp, TEXT("«»")); #else if (Value > 1) _stprintf(tmp, TEXT("%2.0f°»"), Value); else if (Value < -1) _stprintf(tmp, TEXT("«%2.0f°"), -Value); else _tcscpy(tmp, TEXT("«»")); #endif infobox.SetValue(tmp); #endif // Set Comment if (!XCSoarInterface::SettingsComputer().TeamFlarmIdTarget.defined()) infobox.SetComment(_T("---")); else if (!string_is_empty(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget)) infobox.SetComment(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget); else infobox.SetComment(_T("???")); if (XCSoarInterface::Basic().flarm.FindTraffic( XCSoarInterface::SettingsComputer().TeamFlarmIdTarget) != NULL) infobox.SetColorBottom(2); else infobox.SetColorBottom(1); }