Esempio n. 1
0
static void SetWaypointValues(bool first=false) {
  WndProperty* wp;

  TASK_POINT tp = task.getTaskPoint(twItemIndex);

  wp = (WndProperty*)wf->FindByName(_T("prpAATType"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    if (first) {
      dfe->addEnumText(gettext(_T("Cylinder")));
      dfe->addEnumText(gettext(_T("Sector")));
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(tp.AATType);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpAATCircleRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(lround(tp.AATCircleRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->set_visible(tp.AATType == 0);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpAATSectorRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(lround(tp.AATSectorRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->set_visible(tp.AATType > 0);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpAATStartRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(tp.AATStartRadial);
    wp->set_visible(tp.AATType > 0);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpAATFinishRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(tp.AATFinishRadial);
    wp->set_visible(tp.AATType > 0);
    wp->RefreshDisplay();
  }

}
Esempio n. 2
0
static void
UpdateDeviceControlVisibility(WndProperty &port_field,
                              WndProperty &speed_field,
                              WndProperty &driver_field)
{
  unsigned port = port_field.GetDataField()->GetAsInteger();
  enum DeviceConfig::port_type type = port < num_port_types
    ? port_types[port].type
    : (is_android()
       ? DeviceConfig::RFCOMM
       : DeviceConfig::SERIAL);

  speed_field.set_visible(DeviceConfig::UsesSpeed(type));
  driver_field.set_visible(DeviceConfig::UsesDriver(type));
}
Esempio n. 3
0
static void
ShowFontEditButtons(bool bVisible)
{
  WndProperty * wp;
  wp = (WndProperty*)wf->FindByName(_T("cmdInfoWindowFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdTitleWindowFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdMapWindowFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdTitleSmallWindowFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdMapWindowBoldFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdCDIWindowFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdMapLabelFont"));
  if (wp)
    wp->set_visible(bVisible);

  wp = (WndProperty*)wf->FindByName(_T("cmdMapLabelImportantFont"));
  if (wp)
    wp->set_visible(bVisible);
}
Esempio n. 4
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();
  }
}
Esempio n. 5
0
static void SetValues(bool first=false) {
  WndProperty* wp;

  wp = (WndProperty*)wf->FindByName(_T("prpTaskFinishLine"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    if (first) {
      dfe->addEnumText(gettext(_T("Cylinder")));
      dfe->addEnumText(gettext(_T("Line")));
      dfe->addEnumText(gettext(_T("FAI Sector")));
    }
    dfe->Set(settings_task.FinishType);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpTaskFinishRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(lround(settings_task.FinishRadius*DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpTaskStartLine"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    if (first) {
      dfe->addEnumText(gettext(_T("Cylinder")));
      dfe->addEnumText(gettext(_T("Line")));
      dfe->addEnumText(gettext(_T("FAI Sector")));
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(settings_task.StartType);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpTaskStartRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(lround(settings_task.StartRadius*DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpTaskFAISector"));
  if (wp) {
    wp->set_visible(settings_task.AATEnabled == 0);
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    if (first) {
      dfe->addEnumText(gettext(_T("Cylinder")));
      dfe->addEnumText(gettext(_T("FAI Sector")));
      dfe->addEnumText(gettext(_T("DAe 0.5/10")));
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(settings_task.SectorType);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpTaskSectorRadius"));
  if (wp) {
    wp->set_visible(settings_task.AATEnabled == 0);
    wp->GetDataField()->SetAsFloat(lround(settings_task.SectorRadius*DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpAutoAdvance"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    if (first) {
      dfe->addEnumText(gettext(_T("Manual")));
      dfe->addEnumText(gettext(_T("Auto")));
      dfe->addEnumText(gettext(_T("Arm")));
      dfe->addEnumText(gettext(_T("Arm start")));
    }
    dfe->Set(settings_task.AutoAdvance);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpMinTime"));
  if (wp) {
    wp->set_visible(settings_task.AATEnabled > 0);
    wp->GetDataField()->SetAsFloat(settings_task.AATTaskLength);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpEnableMultipleStartPoints"));
  if (wp) {
    wp->GetDataField()->Set(settings_task.EnableMultipleStartPoints);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(_T("prpAATEnabled"));
  if (wp) {
    bool aw = (settings_task.AATEnabled != 0);
    wp->GetDataField()->Set(aw);
    wp->RefreshDisplay();
  }

  WndButton* wb;
  wb = (WndButton *)wf->FindByName(_T("EditStartPoints"));
  if (wb) {
    wb->set_visible(settings_task.EnableMultipleStartPoints != 0);
  }

}
Esempio n. 6
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());
}