コード例 #1
0
void
RenderObservationZone::Draw(Canvas &canvas, const Projection &projection,
                            const ObservationZonePoint &_oz) const
{
  switch (_oz.shape) {
  case ObservationZonePoint::LINE:
  case ObservationZonePoint::FAI_SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    if (layer != LAYER_ACTIVE)
      canvas.segment(p_center.x, p_center.y,
                     projection.GeoToScreenDistance(oz.getRadius()),
                     oz.getStartRadial() - projection.GetScreenAngle(),
                     oz.getEndRadial() - projection.GetScreenAngle());
    else {
      RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart());
      RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd());

      canvas.two_lines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZonePoint::CYLINDER: {
    const CylinderZone &oz = (const CylinderZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      RasterPoint p_center = projection.GeoToScreen(oz.get_location());
      canvas.circle(p_center.x, p_center.y,
                    projection.GeoToScreenDistance(oz.getRadius()));
    }

    break;
  }

  case ObservationZonePoint::BGA_START:
  case ObservationZonePoint::SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      RasterPoint p_center = projection.GeoToScreen(oz.get_location());

      canvas.segment(p_center.x, p_center.y,
                     projection.GeoToScreenDistance(oz.getRadius()),
                     oz.getStartRadial() - projection.GetScreenAngle(),
                     oz.getEndRadial() - projection.GetScreenAngle());

      RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart());
      RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd());
      canvas.two_lines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZonePoint::KEYHOLE:
  case ObservationZonePoint::BGAFIXEDCOURSE:
  case ObservationZonePoint::BGAENHANCEDOPTION: {
    const SectorZone &oz = (const SectorZone &)_oz;
    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    canvas.keyhole(p_center.x, p_center.y,
                   projection.GeoToScreenDistance(fixed(500)),
                   projection.GeoToScreenDistance(oz.getRadius()),
                   oz.getStartRadial() - projection.GetScreenAngle(),
                   oz.getEndRadial() - projection.GetScreenAngle());

    break;
  }

  case ObservationZonePoint::ANNULAR_SECTOR: {
    const AnnularSectorZone &oz = (const AnnularSectorZone &)_oz;
    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    canvas.annulus(p_center.x, p_center.y,
                   projection.GeoToScreenDistance(oz.getInnerRadius()),
                   projection.GeoToScreenDistance(oz.getRadius()),
                   oz.getStartRadial() - projection.GetScreenAngle(),
                   oz.getEndRadial() - projection.GetScreenAngle());
  }

  }
}
コード例 #2
0
ファイル: OZRenderer.cpp プロジェクト: mobotics/XCSoar
void
OZRenderer::Draw(Canvas &canvas, Layer layer, const Projection &projection,
                 const ObservationZonePoint &_oz, int offset)
{
  if (layer == LAYER_SHADE && offset < 0)
    return;

  Prepare(canvas, layer, offset);

  switch (_oz.shape) {
  case ObservationZonePoint::LINE:
  case ObservationZonePoint::FAI_SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    if (layer != LAYER_ACTIVE)
      canvas.DrawSegment(p_center.x, p_center.y,
                         projection.GeoToScreenDistance(oz.getRadius()),
                         oz.getStartRadial() - projection.GetScreenAngle(),
                         oz.getEndRadial() - projection.GetScreenAngle());
    else {
      RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart());
      RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd());

      canvas.DrawTwoLines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZonePoint::CYLINDER: {
    const CylinderZone &oz = (const CylinderZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      RasterPoint p_center = projection.GeoToScreen(oz.get_location());
      canvas.circle(p_center.x, p_center.y,
                    projection.GeoToScreenDistance(oz.getRadius()));
    }

    break;
  }

  case ObservationZonePoint::BGA_START:
  case ObservationZonePoint::SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      RasterPoint p_center = projection.GeoToScreen(oz.get_location());

      canvas.DrawSegment(p_center.x, p_center.y,
                         projection.GeoToScreenDistance(oz.getRadius()),
                         oz.getStartRadial() - projection.GetScreenAngle(),
                         oz.getEndRadial() - projection.GetScreenAngle());

      RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart());
      RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd());
      canvas.DrawTwoLines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZonePoint::KEYHOLE:
  case ObservationZonePoint::BGAFIXEDCOURSE:
  case ObservationZonePoint::BGAENHANCEDOPTION: {
    const SectorZone &oz = (const SectorZone &)_oz;
    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    canvas.DrawKeyhole(p_center.x, p_center.y,
                       projection.GeoToScreenDistance(fixed(500)),
                       projection.GeoToScreenDistance(oz.getRadius()),
                       oz.getStartRadial() - projection.GetScreenAngle(),
                       oz.getEndRadial() - projection.GetScreenAngle());

    break;
  }

  case ObservationZonePoint::ANNULAR_SECTOR: {
    const AnnularSectorZone &oz = (const AnnularSectorZone &)_oz;
    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    canvas.DrawAnnulus(p_center.x, p_center.y,
                       projection.GeoToScreenDistance(oz.getInnerRadius()),
                       projection.GeoToScreenDistance(oz.getRadius()),
                       oz.getStartRadial() - projection.GetScreenAngle(),
                       oz.getEndRadial() - projection.GetScreenAngle());
  }

  }

  Finish(canvas, layer);
}