Exemplo n.º 1
0
void
ShowMapItemListDialog(const MapItemList &list,
                      const DialogLook &dialog_look,
                      const MapLook &look,
                      const TrafficLook &traffic_look,
                      const FinalGlideBarLook &final_glide_look,
                      const MapSettings &settings,
                      ProtectedAirspaceWarningManager *airspace_warnings)
{
  switch (list.size()) {
  case 0:
    /* no map items in the list */
    return;

  case 1:
    /* only one map item, show it */
    ShowMapItemDialog(*list[0], airspace_warnings);
    break;

  default:
    /* more than one map item: show a list */

    int i = ShowMapItemListDialog(list, dialog_look, look,
                                  traffic_look, final_glide_look, settings);
    assert(i >= -1 && i < (int)list.size());
    if (i >= 0)
      ShowMapItemDialog(*list[i], airspace_warnings);
  }
}
Exemplo n.º 2
0
bool
GlueMapWindow::ShowMapItems(const GeoPoint &location,
                            bool show_empty_message) const
{
  fixed range = visible_projection.DistancePixelsToMeters(Layout::GetHitRadius());

  MapItemList list;
  MapItemListBuilder builder(list, location, range);

  builder.AddLocation(Basic(), terrain);

  if (route_planner)
    builder.AddArrivalAltitudes(*route_planner, terrain,
                                GetComputerSettings().task.safety_height_arrival);

  if (Basic().location_available)
    builder.AddSelfIfNear(Basic().location, Calculated().heading);

  if (task)
    builder.AddTaskOZs(*task);

  const Airspaces *airspace_database = airspace_renderer.GetAirspaces();
  if (airspace_database)
    builder.AddVisibleAirspace(*airspace_database,
                               airspace_renderer.GetWarningManager(),
                               GetComputerSettings().airspace,
                               GetMapSettings().airspace, Basic(),
                               Calculated());

  if (marks && render_projection.GetMapScale() <= fixed_int_constant(30000))
    builder.AddMarkers(*marks);

  if (render_projection.GetMapScale() <= fixed_int_constant(4000))
    builder.AddThermals(Calculated().thermal_locator, Basic(), Calculated());

  if (waypoints)
    builder.AddWaypoints(*waypoints);

  if (Basic().flarm.available)
    builder.AddTraffic(Basic().flarm);

  // Sort the list of map items
  list.Sort();

  // Show the list dialog
  if (list.empty()) {
    if (show_empty_message)
      ShowMessageBox(_("There is nothing interesting near this location."),
                  _("Map elements at this location"), MB_OK | MB_ICONINFORMATION);

    return false;
  }

  ShowMapItemListDialog(UIGlobals::GetMainWindow(), list,
                        UIGlobals::GetDialogLook(), look, traffic_look,
                        final_glide_bar_renderer.GetLook(), GetMapSettings(),
                        glide_computer != NULL
                        ? &glide_computer->GetAirspaceWarnings() : NULL);
  return true;
}
Exemplo n.º 3
0
void
ShowMapItemListDialog(SingleWindow &parent,
                      const GeoVector &_vector,
                      const MapItemList &_list, short _elevation,
                      const MapLook &_look,
                      const TrafficLook &_traffic_look,
                      const MapSettings &_settings,
                      ProtectedAirspaceWarningManager *_airspace_warnings)
{
  switch (_list.size()) {
  case 0:
    /* no map items in the list */
    return;

  case 1:
    /* only one map item, show it */
    ShowMapItemDialog(*_list[0], parent);
    break;

  default:
    /* more than one map item: show a list */
    vector = _vector;
    list = &_list;
    elevation = _elevation;

    look = &_look;
    traffic_look = &_traffic_look;
    settings = &_settings;
    airspace_warnings = _airspace_warnings;

    int i = ShowMapItemListDialog(parent);
    assert(i >= -1 && i < (int)_list.size());
    if (i >= 0)
      ShowMapItemDialog(*_list[i], parent);
  }
}
Exemplo n.º 4
0
bool
GlueMapWindow::ShowMapItems(const GeoPoint &location,
                            bool show_empty_message) const
{
  /* not using MapWindowBlackboard here because this method is called
     by the main thread */
  const ComputerSettings &computer_settings =
    CommonInterface::GetComputerSettings();
  const MapSettings &settings = CommonInterface::GetMapSettings();
  const MoreData &basic = CommonInterface::Basic();
  const DerivedInfo &calculated = CommonInterface::Calculated();

  fixed range = visible_projection.DistancePixelsToMeters(Layout::GetHitRadius());

  MapItemList list;
  MapItemListBuilder builder(list, location, range);

  if (settings.item_list.add_location)
      builder.AddLocation(basic, terrain);

  if (settings.item_list.add_arrival_altitude && route_planner)
    builder.AddArrivalAltitudes(*route_planner, terrain,
                                computer_settings.task.safety_height_arrival);

  if (basic.location_available)
    builder.AddSelfIfNear(basic.location, basic.attitude.heading);

  if (task)
    builder.AddTaskOZs(*task);

  const Airspaces *airspace_database = airspace_renderer.GetAirspaces();
  if (airspace_database)
    builder.AddVisibleAirspace(*airspace_database,
                               airspace_renderer.GetWarningManager(),
                               computer_settings.airspace,
                               settings.airspace, basic,
                               calculated);

  if (marks && visible_projection.GetMapScale() <= fixed(30000))
    builder.AddMarkers(*marks);

  if (visible_projection.GetMapScale() <= fixed(4000))
    builder.AddThermals(calculated.thermal_locator, basic, calculated);

  if (waypoints)
    builder.AddWaypoints(*waypoints);

#ifdef HAVE_NOAA
  if (noaa_store)
    builder.AddWeatherStations(*noaa_store);
#endif

  builder.AddTraffic(basic.flarm.traffic, computer_settings.team_code);

  // Sort the list of map items
  list.Sort();

  // Show the list dialog
  if (list.empty()) {
    if (show_empty_message)
      ShowMessageBox(_("There is nothing interesting near this location."),
                  _("Map elements at this location"), MB_OK | MB_ICONINFORMATION);

    return false;
  }

  ShowMapItemListDialog(UIGlobals::GetMainWindow(), list,
                        UIGlobals::GetDialogLook(), look, traffic_look,
                        final_glide_bar_renderer.GetLook(), settings,
                        glide_computer != NULL
                        ? &glide_computer->GetAirspaceWarnings() : NULL);
  return true;
}