Ejemplo n.º 1
0
void
RowFormWidget::AddReadOnly(const TCHAR *label, const TCHAR *help,
                           const TCHAR *display_format,
                           UnitGroup unit_group, fixed value)
{
  WndProperty *edit = Add(label, help, true);
  const Unit unit = Units::GetUserUnitByGroup(unit_group);
  value = Units::ToUserUnit(value, unit);
  DataFieldFloat *df = new DataFieldFloat(display_format, display_format,
                                          fixed(0), fixed(0),
                                          value, fixed(1), false, NULL);
  df->SetUnits(Units::GetUnitName(unit));
  edit->SetDataField(df);
}
Ejemplo n.º 2
0
static void
OnBugsData(DataField *_Sender, DataField::DataAccessKind_t Mode)
{
  DataFieldFloat *Sender = (DataFieldFloat *)_Sender;

  switch (Mode) {
  case DataField::daChange:
    glide_polar.SetBugs(fixed_one - (Sender->GetAsFixed() / 100));
    changed = true;
    break;

  case DataField::daSpecial:
    return;
  }
}
Ejemplo n.º 3
0
void
LoadFormProperty(WndForm &form, const TCHAR *control_name,
                 UnitGroup_t unit_group, fixed value)
{
  assert(control_name != NULL);

  WndProperty *ctl = (WndProperty *)form.FindByName(control_name);
  if (ctl == NULL)
    return;

  Units_t unit = Units::GetUserUnitByGroup(unit_group);

  DataFieldFloat *df = (DataFieldFloat *)ctl->GetDataField();
  df->SetUnits(Units::GetUnitName(unit));
  df->SetAsFloat(Units::ToUserUnit(value, unit));
  ctl->RefreshDisplay();
}
Ejemplo n.º 4
0
void
InfoBoxContentAltitude::PnlSetupOnQNH(DataField *_Sender, DataField::DataAccessKind_t Mode)
{
  DataFieldFloat *Sender = (DataFieldFloat *)_Sender;
  SETTINGS_COMPUTER &settings_computer =
    CommonInterface::SetSettingsComputer();

  switch (Mode) {
  case DataField::daChange:
    settings_computer.pressure.SetQNH(Sender->GetAsFixed());
    settings_computer.pressure_available.Update(CommonInterface::Basic().clock);
    device_blackboard.SetQNH(Sender->GetAsFixed());
    break;

  case DataField::daSpecial:
    return;
  }
}
Ejemplo n.º 5
0
static void
PnlSetupOnQNH(DataField *_Sender, DataField::DataAccessKind_t Mode)
{
  DataFieldFloat *Sender = (DataFieldFloat *)_Sender;
  ComputerSettings &settings_computer =
    CommonInterface::SetComputerSettings();

  switch (Mode) {
  case DataField::daChange:
    settings_computer.pressure = AtmosphericPressure::HectoPascal(Units::ToSysPressure(Sender->GetAsFixed()));
    settings_computer.pressure_available.Update(CommonInterface::Basic().clock);
    device_blackboard->SetQNH(Units::ToSysPressure(Sender->GetAsFixed()));
    break;

  case DataField::daSpecial:
    return;
  }
}
Ejemplo n.º 6
0
WndProperty *
RowFormWidget::AddFloat(const TCHAR *label, const TCHAR *help,
                        const TCHAR *display_format,
                        const TCHAR *edit_format,
                        fixed min_value, fixed max_value,
                        fixed step, bool fine,
                        UnitGroup unit_group, fixed value,
                        DataField::DataAccessCallback callback)
{
  WndProperty *edit = Add(label, help);
  const Unit unit = Units::GetUserUnitByGroup(unit_group);
  value = Units::ToUserUnit(value, unit);
  DataFieldFloat *df = new DataFieldFloat(edit_format, display_format,
                                          min_value, max_value,
                                          value, step, fine, callback);
  df->SetUnits(Units::GetUnitName(unit));
  edit->SetDataField(df);
  return edit;
}
Ejemplo n.º 7
0
void
PolarConfigPanel::SetLiftFieldStepAndMax(const TCHAR *control)
{
  WndProperty *ctl = (WndProperty *)form.FindByName(control);
  DataFieldFloat* df = (DataFieldFloat*)ctl->GetDataField();
  switch (Units::current.vertical_speed_unit) {
    case unFeetPerMinute:
      df->SetStep(fixed_ten);
      df->SetMin(fixed(-2000));
      break;
    case unKnots:
      df->SetStep(fixed(0.1));
      df->SetMin(fixed(-20));
      break;
    case unMeterPerSecond:
      df->SetStep(fixed(0.05));
      df->SetMin(fixed(-10));
      break;
    default:
      break;
  }
}
Ejemplo n.º 8
0
void
PolarConfigPanel::SetLiftFieldStepAndMax(const TCHAR *control)
{
  WndProperty *ctl = (WndProperty *)form.FindByName(control);
  DataFieldFloat* df = (DataFieldFloat*)ctl->GetDataField();
  switch (Units::current.vertical_speed_unit) {
    case Unit::FEET_PER_MINUTE:
      df->SetStep(fixed_ten);
      df->SetMin(fixed(-2000));
      break;
    case Unit::KNOTS:
      df->SetStep(fixed(0.1));
      df->SetMin(fixed(-20));
      break;
    case Unit::METER_PER_SECOND:
      df->SetStep(fixed(0.05));
      df->SetMin(fixed(-10));
      break;
    default:
      break;
  }
}
Ejemplo n.º 9
0
/*
 * 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();
  }
}
Ejemplo n.º 10
0
/**
 * 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());
}