コード例 #1
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);
    }
}
コード例 #2
0
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);
  }
}