Ejemplo n.º 1
0
void
OZPreviewRenderer::Draw(Canvas &canvas, const ObservationZonePoint &oz,
                        const RasterPoint pt, unsigned radius,
                        const TaskLook &look,
                        const AirspaceRendererSettings &airspace_settings,
                        const AirspaceLook &airspace_look)
{
  fixed scale;
  GeoPoint center;

  if (IsAncientHardware()) {
    scale = fixed(radius) / ((const CylinderZone &)oz).GetRadius();
    center = oz.GetReference();
  } else {
    OZBoundary boundary = oz.GetBoundary();

    auto it = boundary.begin();
    GeoBounds bounds(*it);
    for (auto it_end = boundary.end(); it != it_end; ++it)
      bounds.Extend(*it);

    center = bounds.GetCenter();

    fixed geo_heigth = GeoPoint(center.longitude, bounds.north).Distance(
                       GeoPoint(center.longitude, bounds.south));
    fixed geo_width = GeoPoint(bounds.west, center.latitude).Distance(
                      GeoPoint(bounds.east, center.latitude));

    scale = fixed(radius * 2) / std::max(geo_heigth, geo_width);
  }

  WindowProjection projection;
  projection.SetScreenSize(radius * 2, radius * 2);
  projection.SetScreenOrigin(pt.x, pt.y);
  projection.SetGeoLocation(center);
  projection.SetScale(scale);
  projection.SetScreenAngle(Angle::Zero());
  projection.UpdateScreenBounds();

  OZRenderer ozv(look, airspace_look, airspace_settings);
  ozv.Draw(canvas, OZRenderer::LAYER_SHADE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, oz, 1);
}
Ejemplo n.º 2
0
void
OZPreviewRenderer::Draw(Canvas &canvas, const ObservationZonePoint &oz,
                        const PixelPoint pt, unsigned radius,
                        const TaskLook &look,
                        const AirspaceRendererSettings &airspace_settings,
                        const AirspaceLook &airspace_look)
{
  double scale;
  GeoPoint center;

  if (IsAncientHardware()) {
    scale = double(radius) / ((const CylinderZone &)oz).GetRadius();
    center = oz.GetReference();
  } else {
    OZBoundary boundary = oz.GetBoundary();

    GeoBounds bounds = GeoBounds::Invalid();
    for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i)
      bounds.Extend(*i);

    center = bounds.GetCenter();

    auto geo_width = bounds.GetGeoWidth();
    auto geo_heigth = bounds.GetGeoHeight();

    scale = double(radius * 2) / std::max(geo_heigth, geo_width);
  }

  WindowProjection projection;
  projection.SetScreenSize({radius * 2, radius * 2});
  projection.SetScreenOrigin(pt.x, pt.y);
  projection.SetGeoLocation(center);
  projection.SetScale(scale);
  projection.SetScreenAngle(Angle::Zero());
  projection.UpdateScreenBounds();

  OZRenderer ozv(look, airspace_look, airspace_settings);
  ozv.Draw(canvas, OZRenderer::LAYER_SHADE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, oz, 1);
  ozv.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, oz, 1);
}
Ejemplo n.º 3
0
void
OZWindow::OnPaint(Canvas &canvas)
{
    canvas.ClearWhite();
    if (oz == NULL)
        return;

    const int offset = 0;

    roz.Draw(canvas, OZRenderer::LAYER_SHADE, projection, *oz, offset);
    roz.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, *oz, offset);
    roz.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, *oz, offset);

    /* debugging for ObservationZone::GetBoundary() */
    Pen pen(1, COLOR_RED);
    canvas.Select(pen);
    const OZBoundary boundary = oz->GetBoundary();
    for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i) {
        RasterPoint p = projection.GeoToScreen(*i);
        canvas.DrawLine(p.x - 3, p.y - 3, p.x + 3, p.y + 3);
        canvas.DrawLine(p.x + 3, p.y - 3, p.x - 3, p.y + 3);
    }
}