Ejemplo n.º 1
0
static void
OnCalcClicked(gcc_unused WndButton &Sender)
{
  assert(wf != NULL);

  if (page == ANALYSIS_PAGE_BAROGRAPH)
    dlgBasicSettingsShowModal();

  if (page == ANALYSIS_PAGE_CLIMB) {
    wf->hide();
    dlgTaskManagerShowModal(*(SingleWindow *)wf->GetRootOwner());
    wf->show();
  }

  if (page == ANALYSIS_PAGE_WIND)
    dlgWindSettingsShowModal();

  if (page == ANALYSIS_PAGE_POLAR)
    dlgBasicSettingsShowModal();

  if (page == ANALYSIS_PAGE_TEMPTRACE)
    dlgBasicSettingsShowModal();

  if ((page == ANALYSIS_PAGE_TASK) || (page == ANALYSIS_PAGE_TASK_SPEED)) {
    wf->hide();
    dlgTaskManagerShowModal(*(SingleWindow *)wf->GetRootOwner());
    wf->show();
  }

  if (page == ANALYSIS_PAGE_AIRSPACE)
    dlgAirspaceWarningsShowModal(wf->GetMainWindow(),
                                 glide_computer->GetAirspaceWarnings());

  Update();
}
Ejemplo n.º 2
0
static void
OnCalcClicked()
{
  assert(wf != NULL);

  if (page == AnalysisPage::BAROGRAPH)
    dlgBasicSettingsShowModal();

  if (page == AnalysisPage::CLIMB) {
    wf->Hide();
    dlgTaskManagerShowModal();
    wf->Show();
  }

  if (page == AnalysisPage::WIND)
    ShowWindSettingsDialog();

  if (page == AnalysisPage::POLAR)
    dlgBasicSettingsShowModal();

  if (page == AnalysisPage::TEMPTRACE)
    dlgBasicSettingsShowModal();

  if ((page == AnalysisPage::TASK) || (page == AnalysisPage::TASK_SPEED)) {
    wf->Hide();
    dlgTaskManagerShowModal();
    wf->Show();
  }

  if (page == AnalysisPage::AIRSPACE)
    dlgAirspaceWarningsShowModal(wf->GetMainWindow(),
                                 glide_computer->GetAirspaceWarnings());

  Update();
}
Ejemplo n.º 3
0
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifdef _WIN32_WCE
        LPWSTR lpCmdLine,
#else
        LPSTR lpCmdLine2,
#endif
        int nCmdShow)
#endif
{
  Airspaces airspace_database;
  AirspaceWarningManager airspace_warning(airspace_database);
  airspace_warnings = new ProtectedAirspaceWarningManager(airspace_warning);

  InitialiseDataPath();
  ScreenGlobalInit screen_init;

#ifdef WIN32
  ResourceLoader::Init(hInstance);
#endif

  LoadFiles(airspace_database);

  Fonts::Initialize();

  Airspaces::AirspaceTree::const_iterator it = airspace_database.begin();

  AirspaceInterceptSolution ais;
  for (unsigned i = 0; i < 5 && it != airspace_database.end(); ++i, ++it)
    airspace_warning.GetWarning(*it->get_airspace())
      .UpdateSolution((AirspaceWarning::State)i, ais);

  SingleWindow main_window;
  main_window.set(_T("STATIC"), _T("RunAirspaceWarningDialog"),
                  0, 0, 640, 480);
  main_window.show();

  Layout::Initialize(640, 480);

  Fonts::Initialize();

  DialogLook dialog_look;
  dialog_look.Initialise(Fonts::map_bold, Fonts::map,
                         Fonts::map_bold, Fonts::map_bold);
  SetXMLDialogLook(dialog_look);

  dlgAirspaceWarningsShowModal(main_window, *airspace_warnings);

  Fonts::Deinitialize();
  DeinitialiseDataPath();

  delete airspace_warnings;

  return 0;
}
Ejemplo n.º 4
0
bool
MainWindow::OnUser(unsigned id)
{
  ProtectedAirspaceWarningManager *airspace_warnings;

  switch ((Command)id) {
  case Command::AIRSPACE_WARNING:
    airspace_warnings = GetAirspaceWarnings();
    if (!airspace_warning_pending || airspace_warnings == NULL)
      return true;

    airspace_warning_pending = false;
    if (dlgAirspaceWarningVisible())
      /* already visible */
      return true;

    /* un-blank the display, play a sound and show the dialog */
    ResetUserIdle();
    PlayResource(_T("IDR_WAV_BEEPBWEEP"));
    dlgAirspaceWarningsShowModal(*this, *airspace_warnings, true);
    return true;

  case Command::GPS_UPDATE:
    UIReceiveSensorData();
    return true;

  case Command::CALCULATED_UPDATE:
    UIReceiveCalculatedData();
    return true;

  case Command::RESTORE_PAGE:
    if (restore_page_pending)
      PageActions::Restore();
    return true;

  case Command::THERMAL_NOTIFICATION:
    PlayResource(_T("IDR_WAV_CLEAR"));
    return true;

#ifdef ANDROID
  case Command::CRASH:
    ShowMessageBox(_T("How embarassing, we're terribly sorry!\n"
                      "Please submit a bug report and "
                      "include the file from the 'crash' directory.\n"
                      "http://bugs.xcsoar.org/newticket\n"
                      "After your report, we'll fix it ASAP."),
                   _T("XCSoar has crashed recently"),
                   MB_OK|MB_ICONERROR);
    return true;
#endif
  }

  return false;
}
Ejemplo n.º 5
0
void 
InputEvents::eventNearestAirspaceDetails(gcc_unused const TCHAR *misc)
{
  const MoreData &basic = CommonInterface::Basic();
  const DerivedInfo &calculated = CommonInterface::Calculated();
  const ComputerSettings &settings_computer =
    CommonInterface::GetComputerSettings();

  ProtectedAirspaceWarningManager *airspace_warnings = GetAirspaceWarnings();
  if (airspace_warnings != NULL && !airspace_warnings->warning_empty()) {
    // Prevent the dialog from closing itself without active warning
    // This is relevant if there are only acknowledged airspaces in the list
    // AutoClose will be reset when the dialog is closed again by hand
    dlgAirspaceWarningsShowModal(*XCSoarInterface::main_window,
                                 *airspace_warnings);
    return;
  }

  const AircraftState aircraft_state =
    ToAircraftState(basic, calculated);
  AirspaceVisiblePredicate visible(settings_computer.airspace,
                          CommonInterface::GetMapSettings().airspace,
                          aircraft_state);
  GlidePolar polar = settings_computer.polar.glide_polar_task;
  polar.SetMC(max(polar.GetMC(),fixed_one));
  AirspaceAircraftPerformanceGlide perf(polar);
  AirspaceSoonestSort ans(aircraft_state, perf, fixed(1800), visible);

  const AbstractAirspace* as = ans.find_nearest(airspace_database);
  if (!as) {
    return;
  } 

  dlgAirspaceDetails(*as, airspace_warnings);

  // clear previous warning if any
  XCSoarInterface::main_window->popup.Acknowledge(PopupMessage::MSG_AIRSPACE);

  // TODO code: No control via status data (ala DoStatusMEssage)
  // - can we change this?
//  Message::AddMessage(5000, Message::MSG_AIRSPACE, text);
}
Ejemplo n.º 6
0
static void
Main()
{
  Airspaces airspace_database;
  AirspaceWarningManager airspace_warning(airspace_database);
  airspace_warnings = new ProtectedAirspaceWarningManager(airspace_warning);

  LoadFiles(airspace_database);

  Airspaces::AirspaceTree::const_iterator it = airspace_database.begin();

  AirspaceInterceptSolution ais;
  for (unsigned i = 0; i < 5 && it != airspace_database.end(); ++i, ++it)
    airspace_warning.GetWarning(it->GetAirspace())
      .UpdateSolution((AirspaceWarning::State)i, ais);

  dlgAirspaceWarningsShowModal(*airspace_warnings);

  delete airspace_warnings;
}
Ejemplo n.º 7
0
inline void
AnalysisWidget::OnCalcClicked()
{
  switch (page) {
  case AnalysisPage::BAROGRAPH:
    dlgBasicSettingsShowModal();
    break;

  case AnalysisPage::CLIMB:
  case AnalysisPage::TASK:
  case AnalysisPage::TASK_SPEED:
    dlgTaskManagerShowModal();
    break;

  case AnalysisPage::WIND:
    ShowWindSettingsDialog();
    break;

  case AnalysisPage::POLAR:
    dlgBasicSettingsShowModal();
    break;

  case AnalysisPage::TEMPTRACE:
    dlgBasicSettingsShowModal();
    break;

  case AnalysisPage::AIRSPACE:
    dlgAirspaceWarningsShowModal(dialog.GetMainWindow(),
                                 glide_computer.GetAirspaceWarnings());
    break;

  case AnalysisPage::THERMAL_BAND:
  case AnalysisPage::OLC:
  case AnalysisPage::COUNT:
    break;
  }

  Update();
}
Ejemplo n.º 8
0
void
AirspaceWarningWidget::OnAction(int id)
{
  switch ((Action)id) {
  case ACK:
    if (state == AirspaceWarning::WARNING_INSIDE)
      manager.AcknowledgeInside(airspace);
    else
      manager.AcknowledgeWarning(airspace);
    monitor.Schedule();
    PageActions::RestoreBottom();
    break;

  case ACK_DAY:
    manager.AcknowledgeDay(airspace);
    monitor.Schedule();
    PageActions::RestoreBottom();
    break;

  case MORE:
    dlgAirspaceWarningsShowModal(manager);
    return;
  }
}
Ejemplo n.º 9
0
void
AirspaceWarningMonitor::Check()
{
  const auto &calculated = CommonInterface::Calculated();

  if (widget == nullptr && calculated.airspace_warnings.latest == last)
    return;

  /* there's a new airspace warning */

  last = calculated.airspace_warnings.latest;

  auto *airspace_warnings = GetAirspaceWarnings();
  if (airspace_warnings == nullptr) {
    HideWidget();
    return;
  }

  if (!HasPointer()) {
    /* "classic" list-only view for devices without touch screen */

    if (dlgAirspaceWarningVisible())
      /* already visible */
      return;

    // un-blank the display, play a sound
    ResetUserIdle();
    PlayResource(_T("IDR_WAV_BEEPBWEEP"));

    // show airspace warnings dialog
    if (CommonInterface::GetUISettings().enable_airspace_warning_dialog)
      dlgAirspaceWarningsShowModal(*airspace_warnings, true);
    return;
  }

  const AbstractAirspace *airspace = nullptr;
  AirspaceWarning::State state;
  AirspaceInterceptSolution solution;

  {
    const ProtectedAirspaceWarningManager::Lease lease(*airspace_warnings);
    auto w = lease->begin();
    if (w != lease->end() && w->IsAckExpired()) {
      airspace = &w->GetAirspace();
      state = w->GetWarningState();
      solution = w->GetSolution();
    }
  }

  if (airspace == nullptr) {
    HideWidget();
    return;
  }

  if (CommonInterface::GetUISettings().enable_airspace_warning_dialog) {
    /* show airspace warning */
    if (widget != nullptr) {
      if (widget->Update(*airspace, state, solution))
        return;

      HideWidget();
    }

    widget = new AirspaceWarningWidget(*this, *airspace_warnings,
                                       *airspace, state, solution);
    PageActions::SetCustomBottom(widget);
  }

  // un-blank the display, play a sound
  ResetUserIdle();
  PlayResource(_T("IDR_WAV_BEEPBWEEP"));
}