/* * Refresh UI based on location of target * and current task stats */ static void RefreshCalculator() { WndProperty* wp = NULL; bool nodisplay = false; bool bAAT = protected_task_manager.has_target(target_point); if (btnIsLocked) btnIsLocked->set_enabled(bAAT); if (!bAAT) { nodisplay = true; IsLocked = false; } else { protected_task_manager.get_target_range_radial(target_point, Range, Radial); IsLocked = protected_task_manager.target_is_locked(target_point); } LockCalculatorUI(); wp = (WndProperty*)wf->FindByName(_T("prpRange")); if (wp) { DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set(Range * fixed(100)); wp->RefreshDisplay(); wp->set_visible(!nodisplay); } wp = (WndProperty*)wf->FindByName(_T("prpRadial")); if (wp) { fixed rTemp = Radial; if (rTemp < fixed(-90)) rTemp += fixed(180); else if (rTemp > fixed(90)) rTemp -= fixed(180); DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set(rTemp); wp->RefreshDisplay(); wp->set_visible(!nodisplay); } if (btnMove) { btnMove->set_visible(false); // todo add functionality for a cursor/move button if (nodisplay) TargetMoveMode = false; } nodisplay = nodisplay || TargetMoveMode; wp = (WndProperty*)wf->FindByName(_T("prpTaskPoint")); if (wp) wp->set_visible(!TargetMoveMode); WndButton *wc = (WndButton *)wf->FindByName(_T("btnOK")); if (wc) wc->set_visible(!TargetMoveMode); if (btnIsLocked) { btnIsLocked->SetCaption(IsLocked ? _T("Locked") : _T("Auto")); btnIsLocked->set_visible(!nodisplay); } // update outputs fixed speedach = XCSoarInterface::Calculated().task_stats.total.travelled.get_speed(); fixed aattimeEst = XCSoarInterface::Calculated().common_stats.task_time_remaining + XCSoarInterface::Calculated().common_stats.task_time_elapsed; fixed aatTime = protected_task_manager.get_ordered_task_behaviour().aat_min_time; wp = (WndProperty*)wf->FindByName(_T("prpAATEst"));// Same as infobox if (wp) { DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set(aattimeEst / fixed(60)); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpAATDelta")); // same as infobox if (wp) { DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set((aatTime - aattimeEst) / fixed(60)); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpSpeedRemaining")); if (wp) { DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set(Units::ToUserTaskSpeed( XCSoarInterface::Calculated().task_stats.total.remaining_effective.get_speed())); wp->GetDataField()->SetUnits(Units::GetTaskSpeedName()); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpSpeedAchieved")); if (wp) { DataFieldFloat &df = *(DataFieldFloat *)wp->GetDataField(); df.SetAsFloat(Units::ToUserUnit(speedach, Units::TaskSpeedUnit)); df.SetUnits(Units::GetTaskSpeedName()); wp->RefreshDisplay(); } }
/** * Refreshes UI based on location of target and current task stats */ static void RefreshCalculator() { WndProperty* wp = NULL; bool nodisplay = false; bool bAAT; fixed aatTime; { ProtectedTaskManager::Lease lease(*protected_task_manager); bAAT = lease->HasTarget(target_point); if (!bAAT) { nodisplay = true; IsLocked = false; } else { lease->GetTargetRangeRadial(target_point, Range, Radial); IsLocked = lease->TargetIsLocked(target_point); } aatTime = lease->GetOrderedTaskBehaviour().aat_min_time; } if (chkbOptimized) { chkbOptimized->set_visible(bAAT); chkbOptimized->SetState(!IsLocked); } LockCalculatorUI(); wp = (WndProperty*)wf->FindByName(_T("prpRange")); if (wp) { DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set(Range * fixed(100)); wp->RefreshDisplay(); wp->set_visible(!nodisplay); } wp = (WndProperty*)wf->FindByName(_T("prpRadial")); if (wp) { fixed rTemp = Radial; if (rTemp < fixed(-90)) rTemp += fixed(180); else if (rTemp > fixed(90)) rTemp -= fixed(180); DataFieldFloat *df = (DataFieldFloat *)wp->GetDataField(); df->Set(rTemp); wp->RefreshDisplay(); wp->set_visible(!nodisplay); } // update outputs fixed aattimeEst = XCSoarInterface::Calculated().common_stats.task_time_remaining + XCSoarInterface::Calculated().common_stats.task_time_elapsed; ShowOptionalFormControl(*wf, _T("prpAATEst"), !nodisplay); ShowFormControl(*wf, _T("prpAATDelta"), !nodisplay); if (!nodisplay) { LoadOptionalFormProperty(*wf, _T("prpAATEst"), aattimeEst / fixed(60)); LoadFormProperty(*wf, _T("prpAATDelta"), (aattimeEst - aatTime) / 60); } const ElementStat &total = CommonInterface::Calculated().task_stats.total; if (total.remaining_effective.IsDefined()) LoadFormProperty(*wf, _T("prpSpeedRemaining"), UnitGroup::TASK_SPEED, total.remaining_effective.get_speed()); if (total.travelled.IsDefined()) LoadOptionalFormProperty(*wf, _T("prpSpeedAchieved"), UnitGroup::TASK_SPEED, total.travelled.get_speed()); }