Exemplo n.º 1
0
void
WaypointEditWidget::Prepare(gcc_unused ContainerWindow &parent,
                            gcc_unused const PixelRect &rc)
{
  AddText(_("Name"), nullptr, value.name.c_str());
  AddText(_("Comment"), nullptr, value.comment.c_str());
  Add(_("Location"), nullptr, new GeoPointDataField(value.location,UIGlobals::GetFormatSettings().coordinate_format));
  AddFloat(_("Altitude"), nullptr,
           _T("%.0f %s"), _T("%.0f"),
           0, 30000, 5, false,
           UnitGroup::ALTITUDE, value.elevation);
  AddEnum(_("Type"), nullptr, waypoint_types,
          value.IsAirport() ? 1u : (value.IsLandable() ? 2u : 0u ));
}
Exemplo n.º 2
0
void
WaypointEditWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
    AddText(_("Name"), nullptr, value.name.c_str());
    AddText(_("Comment"), nullptr, value.comment.c_str());
    Add(_("Location"), nullptr, new GeoPointDataField(value.location,
            // TODO: use configured CoordinateFormat
            CoordinateFormat::DDMMSS));
    AddFloat(_("Altitude"), nullptr,
             _T("%.0f %s"), _T("%.0f"),
             fixed(0), fixed(30000), fixed(5), false,
             UnitGroup::ALTITUDE, value.elevation);
    AddEnum(_("Type"), nullptr, waypoint_types,
            value.IsAirport() ? 1u : (value.IsLandable() ? 2u : 0u ));
}
Exemplo n.º 3
0
  static bool
  CompareType(const Waypoint &waypoint, TypeFilter type)
  {
    switch (type) {
    case TF_ALL:
      return true;

    case TF_AIRPORT:
      return waypoint.IsAirport();

    case TF_LANDABLE:
      return waypoint.IsLandable();

    case TF_TURNPOINT:
      return waypoint.IsTurnpoint();

    case TF_START:
      return waypoint.IsStartpoint();

    case TF_FINISH:
      return waypoint.IsFinishpoint();

    case TF_FAI_TRIANGLE_LEFT:
      return triangle_validator->IsFAITrianglePoint(waypoint, fixed(-1));

    case TF_FAI_TRIANGLE_RIGHT:
      return triangle_validator->IsFAITrianglePoint(waypoint, fixed_one);

    case TF_FILE_1:
      return waypoint.file_num == 1;

    case TF_FILE_2:
      return waypoint.file_num == 2;

    case TF_LAST_USED:
      return false;
    }

    /* not reachable */
    return false;
  }
Exemplo n.º 4
0
bool
CAI302Device::WriteNavpoint(unsigned id, const Waypoint &wp,
                            OperationEnvironment &env)
{
  if (!DownloadMode(env))
    return false;

  char name[64], remark[64];
  ToASCII(name, ARRAY_SIZE(name), wp.name.c_str());
  ToASCII(remark, ARRAY_SIZE(remark), wp.comment.c_str());

  if (!CAI302::DownloadNavpoint(port, wp.location, (int)wp.elevation, id,
                                wp.IsTurnpoint(), wp.IsAirport(), false,
                                wp.IsLandable(), wp.IsStartpoint(),
                                wp.IsFinishpoint(), wp.flags.home,
                                false, wp.IsTurnpoint(), false,
                                name, remark, env)) {
    mode = Mode::UNKNOWN;
    return false;
  }

  return true;
}
Exemplo n.º 5
0
void
WaypointWriter::WriteFlags(TextWriter &writer, const Waypoint &wp)
{
  if (wp.IsAirport())
    writer.write('A');
  if (wp.flags.turn_point)
    writer.write('T');
  if (wp.IsLandable())
    writer.write('L');
  if (wp.flags.home)
    writer.write('H');
  if (wp.flags.start_point)
    writer.write('S');
  if (wp.flags.finish_point)
    writer.write('F');

  // set as turnpoint by default if nothing else
  if (!wp.flags.turn_point &&
      !wp.IsLandable() &&
      !wp.flags.home &&
      !wp.flags.start_point &&
      !wp.flags.finish_point)
    writer.write('T');
}
Exemplo n.º 6
0
void
WaypointIconRenderer::DrawLandable(const Waypoint &waypoint,
                                   const PixelPoint &point,
                                   Reachability reachable)
{

    if (!settings.vector_landable_rendering) {
        const MaskedIcon *icon;

        if (reachable == ReachableTerrain)
            icon = waypoint.IsAirport()
                   ? &look.airport_reachable_icon
                   : &look.field_reachable_icon;
        else if (reachable == ReachableStraight)
            icon = waypoint.IsAirport()
                   ? &look.airport_marginal_icon
                   : &look.field_marginal_icon;
        else
            icon = waypoint.IsAirport()
                   ? &look.airport_unreachable_icon
                   : &look.field_unreachable_icon;

        icon->Draw(canvas, point);
        return;
    }

    // SW rendering of landables
    double scale = std::max(Layout::VptScale(settings.landable_rendering_scale),
                            110u) / 177.;
    double radius = 10 * scale;

    canvas.SelectBlackPen();

    const bool is_reachable = reachable != Invalid && reachable != Unreachable;

    switch (settings.landable_style) {
    case WaypointRendererSettings::LandableStyle::PURPLE_CIRCLE:
        // Render landable with reachable state
        if (is_reachable) {
            canvas.Select(reachable == ReachableTerrain
                          ? look.reachable_brush
                          : look.terrain_unreachable_brush);
            DrawLandableBase(canvas, point, waypoint.IsAirport(), 1.5 * radius);
        }
        canvas.Select(look.magenta_brush);
        break;

    case WaypointRendererSettings::LandableStyle::BW:
        if (is_reachable)
            canvas.Select(reachable == ReachableTerrain
                          ? look.reachable_brush
                          : look.terrain_unreachable_brush);
        else if (waypoint.IsAirport())
            canvas.Select(look.white_brush);
        else
            canvas.Select(look.light_gray_brush);
        break;

    case WaypointRendererSettings::LandableStyle::TRAFFIC_LIGHTS:
        if (is_reachable)
            canvas.Select(reachable == ReachableTerrain
                          ? look.reachable_brush
                          : look.orange_brush);
        else
            canvas.Select(look.unreachable_brush);
        break;
    }

    DrawLandableBase(canvas, point, waypoint.IsAirport(), radius);

    // Render runway indication
    const Runway &runway = waypoint.runway;
    if (runway.IsDirectionDefined()) {
        double len;
        if (settings.scale_runway_length && runway.IsLengthDefined())
            len = radius / 2. +
                  (((int) runway.GetLength() - 500) / 500) * radius / 4.;
        else
            len = radius;
        len += 2 * scale;
        Angle runwayDrawingAngle = runway.GetDirection() - screen_rotation;
        canvas.Select(look.white_brush);
        DrawLandableRunway(canvas, point, runwayDrawingAngle, len, 5 * scale);
    }
}
void
WaypointIconRenderer::DrawLandable(const Waypoint &waypoint,
                                   const RasterPoint &point,
                                   Reachability reachable)
{

  if (!settings.vector_landable_rendering) {
    const MaskedIcon *icon;

    if (reachable == ReachableTerrain)
      icon = waypoint.IsAirport()
        ? &look.airport_reachable_icon
        : &look.field_reachable_icon;
    else if (reachable == ReachableStraight)
      icon = waypoint.IsAirport()
        ? &look.airport_marginal_icon
        : &look.field_marginal_icon;
    else
      icon = waypoint.IsAirport()
        ? &look.airport_unreachable_icon
        : &look.field_unreachable_icon;

    icon->draw(canvas, point);
    return;
  }

  // SW rendering of landables
  fixed scale = fixed(Layout::SmallScale(settings.landable_rendering_scale)) /
                fixed_int_constant(150);
  fixed radius = fixed_int_constant(10) * scale;

  canvas.black_pen();
  if (settings.landable_style == wpLandableWinPilot) {
    // Render landable with reachable state
    if (reachable != Unreachable) {
      canvas.select(reachable == ReachableTerrain
                    ? look.reachable_brush
                    : look.terrain_unreachable_brush);
      DrawLandableBase(canvas, point, waypoint.IsAirport(),
                       radius + radius / fixed_two);
    }
    canvas.select(look.magenta_brush);
  } else if (settings.landable_style == wpLandableAltB) {
    if (reachable != Unreachable)
      canvas.select(reachable == ReachableTerrain
                    ? look.reachable_brush
                    : look.orange_brush);
    else
      canvas.select(look.unreachable_brush);
  } else {
    if (reachable != Unreachable)
      canvas.select(reachable == ReachableTerrain
                    ? look.reachable_brush
                    : look.terrain_unreachable_brush);
    else if (waypoint.IsAirport())
      canvas.select(look.white_brush);
    else
      canvas.select(look.light_gray_brush);
  }
  DrawLandableBase(canvas, point, waypoint.IsAirport(), radius);

  // Render runway indication
  const Runway &runway = waypoint.runway;
  if (runway.IsDirectionDefined()) {
    fixed len;
    if (settings.scale_runway_length && runway.IsLengthDefined())
      len = (radius / fixed_two) +
        (((int) runway.GetLength() - 500) / 500) * (radius / fixed_four);
    else
      len = radius;
    len += fixed_two * scale;
    Angle runwayDrawingAngle = runway.GetDirection() - screen_rotation;
    canvas.select(look.white_brush);
    DrawLandableRunway(canvas, point, runwayDrawingAngle, len,
                       fixed_int_constant(5) * scale);
  }
}