void
CrossSectionWindow::PaintTerrain(Canvas &canvas, Chart &chart)
{
  if (terrain == NULL)
    return;

  const GeoPoint p_diff = vec.EndPoint(start) - start;

  RasterTerrain::Lease map(*terrain);

  RasterPoint points[2 + AIRSPACE_SCANSIZE_X];

  points[0].x = chart.screenX(vec.distance);
  points[0].y = chart.screenY(fixed_zero);
  points[1].x = chart.screenX(fixed_zero);
  points[1].y = chart.screenY(fixed_zero);

  unsigned i = 2;
  for (unsigned j = 0; j < AIRSPACE_SCANSIZE_X; ++j) {
    const fixed t_this = fixed(j) / (AIRSPACE_SCANSIZE_X - 1);
    const GeoPoint p_this = start + p_diff * t_this;

    short h = map->GetHeight(p_this);
    if (RasterBuffer::is_special(h)) {
      if (RasterBuffer::is_water(h))
        /* water is at 0m MSL */
        /* XXX paint in blue? */
        h = 0;
      else
        /* skip "unknown" values */
        continue;
    }

    points[i].x = chart.screenX(t_this * vec.distance);
    points[i].y = chart.screenY(fixed(h));
    i++;
  }

  if (i >= 4) {
    canvas.SelectNullPen();
    canvas.Select(look.terrain_brush);
    canvas.polygon(&points[0], i);
  }
}
void
CrossSectionWindow::PaintAircraft(Canvas &canvas, const Chart &chart,
                                  const PixelRect rc)
{
  canvas.Select(look.aircraft_brush);
  canvas.SelectNullPen();

  RasterPoint line[4];
  line[0].x = chart.screenX(fixed_zero);
  line[0].y = chart.screenY(gps_info.nav_altitude);
  line[1].x = rc.left;
  line[1].y = line[0].y;
  line[2].x = line[1].x;
  line[2].y = line[0].y - (line[0].x - line[1].x) / 2;
  line[3].x = (line[1].x + line[0].x) / 2;
  line[3].y = line[0].y;
  canvas.DrawTriangleFan(line, 4);
}
Example #3
0
void
CrossSectionWindow::PaintAircraft(Canvas &canvas, const Chart &chart,
                                  const PixelRect rc)
{
  Brush brush(text_color);
  canvas.select(brush);

  Pen pen(1, text_color);
  canvas.select(pen);

  RasterPoint line[4];
  line[0].x = chart.screenX(fixed_zero);
  line[0].y = chart.screenY(gps_info.NavAltitude);
  line[1].x = rc.left;
  line[1].y = line[0].y;
  line[2].x = line[1].x;
  line[2].y = line[0].y - (line[0].x - line[1].x) / 2;
  line[3].x = (line[1].x + line[0].x) / 2;
  line[3].y = line[0].y;
  canvas.polygon(line, 4);
}