示例#1
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;
}
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;
}
示例#3
0
AirspaceSorter::AirspaceSorter(const Airspaces &airspaces,
                               const GeoPoint &Location,
                               const fixed distance_factor)
{
  airspaces.lock();
  m_airspaces_all.reserve(airspaces.size());

  for (Airspaces::AirspaceTree::const_iterator it = airspaces.begin();
       it != airspaces.end(); ++it) {

    AirspaceSelectInfo info;
    
    const AbstractAirspace &airspace = *it->get_airspace();

    info.airspace = &airspace;

    const GeoPoint closest_loc = airspace.closest_point(Location);
    const GeoVector vec(Location, closest_loc);

    info.Distance = vec.Distance*distance_factor;
    info.Direction = vec.Bearing;

    tstring Name = airspace.get_name_text(true);

    info.FourChars = 
      ((Name.c_str()[0] & 0xff) << 24)
      +((Name.c_str()[1] & 0xff) << 16)
      +((Name.c_str()[2] & 0xff) << 8)
      +((Name.c_str()[3] & 0xff));

    m_airspaces_all.push_back(info);
  }
  airspaces.unlock();

  sort_name(m_airspaces_all);
}