Ejemplo n.º 1
0
void
PolarConfigPanel::DataChanged()
{
  if (!loading)
    CommonInterface::SetComputerSettings().plane.polar_name = _T("Custom");

  UpdatePolarTitle();
  UpdatePolarInvalidLabel();
}
Ejemplo n.º 2
0
void
PolarConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  instance = this;
  loading = true;

  LoadWindow(polar_callbacks, parent,
             Layout::landscape
             ? _T("IDR_XML_POLARCONFIGPANEL_L")
             : _T("IDR_XML_POLARCONFIGPANEL"));

  buttonList = (WndButton *)ConfigPanel::GetForm()
    .FindByName(_T("cmdLoadInternalPolar"));
  assert(buttonList != NULL);
  buttonList->SetOnClickNotify(OnLoadInternal);

  buttonImport = (WndButton *)ConfigPanel::GetForm()
    .FindByName(_T("cmdLoadPolarFile"));
  assert(buttonImport != NULL);
  buttonImport->SetOnClickNotify(OnLoadFromFile);

  buttonExport = (WndButton *)ConfigPanel::GetForm()
    .FindByName(_T("cmdSavePolarFile"));
  assert(buttonExport != NULL);
  buttonExport->SetOnClickNotify(OnExport);

  SetLiftFieldStepAndMax(_T("prpPolarW1"));
  SetLiftFieldStepAndMax(_T("prpPolarW2"));
  SetLiftFieldStepAndMax(_T("prpPolarW3"));

  const ComputerSettings &settings = XCSoarInterface::GetComputerSettings();
  UpdatePolarPoints(settings.plane.v1, settings.plane.v2, settings.plane.v3,
                    settings.plane.w1, settings.plane.w2, settings.plane.w3);

  LoadFormProperty(form, _T("prpPolarReferenceMass"),
                   settings.plane.reference_mass);
  LoadFormProperty(form, _T("prpPolarDryMass"), settings.plane.dry_mass);
  LoadFormProperty(form, _T("prpPolarMaxBallast"), settings.plane.max_ballast);

  LoadFormProperty(form, _T("prpPolarWingArea"), settings.plane.wing_area);
  LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), ugHorizontalSpeed,
                   settings.plane.max_speed);

  UpdatePolarTitle();
  UpdatePolarInvalidLabel();

  const ComputerSettings &settings_computer = XCSoarInterface::GetComputerSettings();

  LoadFormProperty(form, _T("prpHandicap"),
                   settings_computer.plane.handicap);

  LoadFormProperty(form, _T("prpBallastSecsToEmpty"),
                   settings_computer.plane.dump_time);

  loading = false;
}
Ejemplo n.º 3
0
void
PolarConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  instance = this;
  loading = true;

  LoadWindow(polar_callbacks, parent,
             Layout::landscape
             ? _T("IDR_XML_POLARCONFIGPANEL_L")
             : _T("IDR_XML_POLARCONFIGPANEL"));

  buttonList = (WndButton *)ConfigPanel::GetForm()
    .FindByName(_T("cmdLoadInternalPolar"));
  assert(buttonList != NULL);
  buttonList->SetOnClickNotify(OnLoadInternal);

  buttonImport = (WndButton *)ConfigPanel::GetForm()
    .FindByName(_T("cmdLoadPolarFile"));
  assert(buttonImport != NULL);
  buttonImport->SetOnClickNotify(OnLoadFromFile);

  buttonExport = (WndButton *)ConfigPanel::GetForm()
    .FindByName(_T("cmdSavePolarFile"));
  assert(buttonExport != NULL);
  buttonExport->SetOnClickNotify(OnExport);

  const ComputerSettings &settings = CommonInterface::GetComputerSettings();

  DockWindow &dock = *(DockWindow *)form.FindByName(_T("shape"));
  PolarShapeEditWidget *shape_editor =
    new PolarShapeEditWidget(settings.plane.polar_shape);
  dock.SetWidget(shape_editor);
  shape_editor->SetDataAccessCallback(OnFieldData);

  LoadFormProperty(form, _T("prpPolarReferenceMass"),
                   settings.plane.reference_mass);
  LoadFormProperty(form, _T("prpPolarDryMass"), settings.plane.dry_mass);
  LoadFormProperty(form, _T("prpPolarMaxBallast"), settings.plane.max_ballast);

  LoadFormProperty(form, _T("prpPolarWingArea"), settings.plane.wing_area);
  LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), UnitGroup::HORIZONTAL_SPEED,
                   settings.plane.max_speed);

  UpdatePolarTitle();
  UpdatePolarInvalidLabel();

  const ComputerSettings &settings_computer = CommonInterface::GetComputerSettings();

  LoadFormProperty(form, _T("prpHandicap"),
                   settings_computer.plane.handicap);

  LoadFormProperty(form, _T("prpBallastSecsToEmpty"),
                   settings_computer.plane.dump_time);

  loading = false;
}
Ejemplo n.º 4
0
void
PolarConfigPanel::LoadInternal()
{
  ComboList list;
  unsigned len = PolarStore::Count();
  for (unsigned i = 0; i < len; i++)
    list.Append(i, PolarStore::GetItem(i).name);

  list.Sort();

  /* let the user select */

  int result = ComboPicker(UIGlobals::GetMainWindow(), _("Load Polar"), list, NULL);
  if (result >= 0) {
    const PolarStore::Item &item = PolarStore::GetItem(list[result].DataFieldIndex);

    UpdatePolarPoints(Units::ToSysUnit(fixed(item.v1), unKiloMeterPerHour),
                      Units::ToSysUnit(fixed(item.v2), unKiloMeterPerHour),
                      Units::ToSysUnit(fixed(item.v3), unKiloMeterPerHour),
                      fixed(item.w1), fixed(item.w2), fixed(item.w3));

    LoadFormProperty(form, _T("prpPolarReferenceMass"), fixed(item.reference_mass));
    LoadFormProperty(form, _T("prpPolarDryMass"), fixed(item.reference_mass));
    LoadFormProperty(form, _T("prpPolarMaxBallast"), fixed(item.max_ballast));

    if (item.wing_area > 0.0)
      LoadFormProperty(form, _T("prpPolarWingArea"), fixed(item.wing_area));

    if (item.v_no > 0.0)
      LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), ugHorizontalSpeed,
                       fixed(item.v_no));

    if (item.contest_handicap > 0)
      LoadFormProperty(form, _T("prpHandicap"), item.contest_handicap);

    CommonInterface::SetComputerSettings().plane.polar_name = item.name;
    UpdatePolarTitle();
    UpdatePolarInvalidLabel();
  }
}
Ejemplo n.º 5
0
void
PolarConfigPanel::LoadFromFile()
{
  ComboList list;
  PolarFileVisitor fv(list);

  // Fill list
  VisitDataFiles(_T("*.plr"), fv);

  // Sort list
  list.Sort();

  // Show selection dialog
  int result = ComboPicker(UIGlobals::GetMainWindow(),
                           _("Load Polar From File"), list, NULL);
  if (result >= 0) {
    const TCHAR* path = list[result].StringValue;
    PolarInfo polar;
    PolarGlue::LoadFromFile(polar, path);

    UpdatePolarPoints(polar.v1, polar.v2, polar.v3, polar.w1, polar.w2, polar.w3);

    LoadFormProperty(form, _T("prpPolarReferenceMass"), polar.reference_mass);
    LoadFormProperty(form, _T("prpPolarDryMass"), polar.reference_mass);
    LoadFormProperty(form, _T("prpPolarMaxBallast"), polar.max_ballast);

    if (positive(polar.wing_area))
      LoadFormProperty(form, _T("prpPolarWingArea"), polar.wing_area);

    if (positive(polar.v_no))
      LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), ugHorizontalSpeed,
                       polar.v_no);

    CommonInterface::SetComputerSettings().plane.polar_name =
        list[result].StringValueFormatted;
    UpdatePolarTitle();
    UpdatePolarInvalidLabel();
  }
}
Ejemplo n.º 6
0
void
PolarConfigPanel::LoadInternal()
{
  ComboList list;
  unsigned len = PolarStore::Count();
  for (unsigned i = 0; i < len; i++)
    list.Append(i, PolarStore::GetItem(i).name);

  list.Sort();

  /* let the user select */

  int result = ComboPicker(_("Load Polar"), list, NULL);
  if (result >= 0) {
    const PolarStore::Item &item = PolarStore::GetItem(list[result].DataFieldIndex);

    LoadPolarShape(form, item.ToPolarShape());

    LoadFormProperty(form, _T("prpPolarReferenceMass"), fixed(item.reference_mass));
    LoadFormProperty(form, _T("prpPolarDryMass"), fixed(item.reference_mass));
    LoadFormProperty(form, _T("prpPolarMaxBallast"), fixed(item.max_ballast));

    if (item.wing_area > 0.0)
      LoadFormProperty(form, _T("prpPolarWingArea"), fixed(item.wing_area));

    if (item.v_no > 0.0)
      LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), UnitGroup::HORIZONTAL_SPEED,
                       fixed(item.v_no));

    if (item.contest_handicap > 0)
      LoadFormProperty(form, _T("prpHandicap"), item.contest_handicap);

    CommonInterface::SetComputerSettings().plane.polar_name = item.name;
    UpdatePolarTitle();
    UpdatePolarInvalidLabel();
  }
}