示例#1
0
static void
PaintTask(Canvas &canvas, const WindowProjection &projection,
          const OrderedTask &task,
          const GeoPoint &location, const MapSettings &settings_map,
          const TaskLook &task_look,
          const AirspaceLook &airspace_look,
          const RasterTerrain *terrain)
{
  BackgroundRenderer background;
  background.SetTerrain(terrain);
  background.Draw(canvas, projection, settings_map.terrain);

  OZRenderer ozv(task_look, airspace_look, settings_map.airspace);
  RenderTaskPoint tpv(canvas, projection, task_look,
                      task.GetTaskProjection(),
                      ozv, false, RenderTaskPoint::NONE, location);
  TaskRenderer dv(tpv, projection.GetScreenBounds());
  dv.Draw(task);
}
示例#2
0
static void
PaintTask(Canvas &canvas, const WindowProjection &projection,
          const OrderedTask &task,
          const GeoPoint &location, const MapSettings &settings_map,
          const TaskLook &task_look,
          const AirspaceLook &airspace_look,
          const RasterTerrain *terrain, const Airspaces *airspaces)
{
  BackgroundRenderer background;
  background.SetTerrain(terrain);
  background.Draw(canvas, projection, settings_map.terrain);

  if (airspaces != NULL) {
    AirspaceRenderer airspace_renderer(airspace_look);
    airspace_renderer.SetAirspaces(airspaces);

#ifndef ENABLE_OPENGL
    BufferCanvas buffer_canvas, stencil_canvas;
    buffer_canvas.set(canvas);
    stencil_canvas.set(canvas);
#endif

    airspace_renderer.Draw(canvas,
#ifndef ENABLE_OPENGL
                           buffer_canvas, stencil_canvas,
#endif
                           projection,
                           settings_map.airspace);
  }

#ifdef ENABLE_OPENGL
  /* desaturate the map background, to focus on the task */
  canvas.FadeToWhite(0xc0);
#endif

  OZRenderer ozv(task_look, airspace_look, settings_map.airspace);
  RenderTaskPoint tpv(canvas, projection, task_look,
                      task.GetTaskProjection(),
                      ozv, false, RenderTaskPoint::NONE, location);
  TaskRenderer dv(tpv, projection.GetScreenBounds());
  dv.Draw(task);
}
示例#3
0
void
PrintHelper::orderedtask_print(const OrderedTask &task,
                               const AircraftState &state)
{
    abstracttask_print(task, state);
    if (!task.CheckTask())
        return;

    std::ofstream fi("output/results/res-isolines.txt");
    for (unsigned i = 0; i < task.TaskSize(); ++i) {
        const OrderedTaskPoint &tp = task.GetPoint(i);
        fi << "## point " << i << "\n";
        if (tp.GetType() == TaskPointType::AAT) {
            aatpoint_print(fi, (const AATPoint &)tp, state,
                           task.GetTaskProjection(), 1);
        } else {
            orderedtaskpoint_print(fi, tp, state, 1);
        }
        fi << "\n";
    }

    std::ofstream f1("output/results/res-task.txt");

    f1 << "#### Task points\n";
    for (unsigned i = 0; i < task.TaskSize(); ++i) {
        f1 << "## point " << i << " ###################\n";
        const OrderedTaskPoint &tp = task.GetPoint(i);
        if (tp.GetType() == TaskPointType::AAT) {
            aatpoint_print(f1, (const AATPoint &)tp, state,
                           task.GetTaskProjection(), 0);
        } else {
            orderedtaskpoint_print(f1, tp, state, 0);
        }
        f1 << "\n";
    }

    std::ofstream f5("output/results/res-ssample.txt");
    f5 << "#### Task sampled points\n";
    for (unsigned i =0 ; i < task.TaskSize(); ++i) {
        const OrderedTaskPoint &tp = task.GetPoint(i);
        f5 << "## point " << i << "\n";
        sampledtaskpoint_print_samples(f5, tp, state);
        f5 << "\n";
    }

    std::ofstream f2("output/results/res-max.txt");
    f2 << "#### Max task\n";
    for (unsigned i = 0; i < task.TaskSize(); ++i) {
        const OrderedTaskPoint &tp = task.GetPoint(i);
        f2 << tp.GetLocationMax().longitude << " "
           << tp.GetLocationMax().latitude << "\n";
    }

    std::ofstream f3("output/results/res-min.txt");
    f3 << "#### Min task\n";
    for (unsigned i = 0; i < task.TaskSize(); ++i) {
        const OrderedTaskPoint &tp = task.GetPoint(i);
        f3 << tp.GetLocationMin().longitude << " "
           << tp.GetLocationMin().latitude << "\n";
    }

    std::ofstream f4("output/results/res-rem.txt");
    f4 << "#### Remaining task\n";
    for (unsigned i = 0; i < task.TaskSize(); ++i) {
        const OrderedTaskPoint &tp = task.GetPoint(i);
        f4 << tp.GetLocationRemaining().longitude << " "
           << tp.GetLocationRemaining().latitude << "\n";
    }
}
示例#4
0
void 
PrintHelper::orderedtask_print(OrderedTask& task, const AircraftState &state) 
{
  abstracttask_print(task, state);
  if (!task.stats.task_valid)
    return;

  std::ofstream fi("results/res-isolines.txt");
  for (unsigned i=0; i<task.task_points.size(); i++) {
    fi << "## point " << i << "\n";
    if (task.task_points[i]->type == TaskPoint::AAT) {
      aatpoint_print(fi, (AATPoint&)*task.task_points[i], state,
                     task.GetTaskProjection(), 1);
    } else {
      orderedtaskpoint_print(fi,*task.task_points[i],state,1);
    }
    fi << "\n";
  }

  std::ofstream f1("results/res-task.txt");

  f1 << "#### Task points\n";
  for (unsigned i=0; i<task.task_points.size(); i++) {
    f1 << "## point " << i << " ###################\n";
    if (task.task_points[i]->type == TaskPoint::AAT) {
      aatpoint_print(f1, (AATPoint&)*task.task_points[i], state,
                     task.GetTaskProjection(), 0);
    } else {
      orderedtaskpoint_print(f1,*task.task_points[i],state,0);
    }
    f1 << "\n";
  }

  std::ofstream f5("results/res-ssample.txt");
  f5 << "#### Task sampled points\n";
  for (unsigned i=0; i<task.task_points.size(); i++) {
    f5 << "## point " << i << "\n";
    sampledtaskpoint_print_samples(f5,*task.task_points[i],state);
    f5 << "\n";
  }

  std::ofstream f2("results/res-max.txt");
  f2 << "#### Max task\n";
  for (unsigned i=0; i<task.task_points.size(); i++) {
    OrderedTaskPoint *tp = task.task_points[i];
    f2 <<  tp->GetLocationMax().longitude << " "
       <<  tp->GetLocationMax().latitude << "\n";
  }

  std::ofstream f3("results/res-min.txt");
  f3 << "#### Min task\n";
  for (unsigned i=0; i<task.task_points.size(); i++) {
    OrderedTaskPoint *tp = task.task_points[i];
    f3 <<  tp->GetLocationMin().longitude << " "
       <<  tp->GetLocationMin().latitude << "\n";
  }

  std::ofstream f4("results/res-rem.txt");
  f4 << "#### Remaining task\n";
  for (unsigned i=0; i<task.task_points.size(); i++) {
    OrderedTaskPoint *tp = task.task_points[i];
    f4 <<  tp->GetLocationRemaining().longitude << " "
       <<  tp->GetLocationRemaining().latitude << "\n";
  }
}
示例#5
0
void
PaintTask(Canvas &canvas, const WindowProjection &projection,
          const OrderedTask &task,
          const GeoPoint &location,
          const MapSettings &settings_map,
          const TaskLook &task_look,
          const AirspaceLook &airspace_look,
          const RasterTerrain *terrain, const Airspaces *airspaces,
          bool fai_sectors,
          int highlight_index)
{
  BackgroundRenderer background;
  background.SetTerrain(terrain);
  background.Draw(canvas, projection, settings_map.terrain);

  if (airspaces != NULL) {
    AirspaceRenderer airspace_renderer(airspace_look);
    airspace_renderer.SetAirspaces(airspaces);

#ifndef ENABLE_OPENGL
    BufferCanvas stencil_canvas;
    stencil_canvas.Create(canvas);
#endif

    airspace_renderer.Draw(canvas,
#ifndef ENABLE_OPENGL
                           stencil_canvas,
#endif
                           projection, settings_map.airspace);
  }

#ifdef ENABLE_OPENGL
  /* desaturate the map background, to focus on the task */
  canvas.FadeToWhite(0xc0);
#endif

  if (fai_sectors && IsFAITriangleApplicable(task)) {
    static constexpr Color fill_color = COLOR_YELLOW;
#if defined(ENABLE_OPENGL) || defined(USE_MEMORY_CANVAS)
#ifdef ENABLE_OPENGL
    const ScopeAlphaBlend alpha_blend;
#endif

    canvas.Select(Brush(fill_color.WithAlpha(40)));
    canvas.Select(Pen(1, COLOR_BLACK.WithAlpha(80)));
    RenderFAISectors(canvas, projection, task);
#else
    BufferCanvas buffer_canvas;
    buffer_canvas.Create(canvas);
    buffer_canvas.ClearWhite();
#ifdef HAVE_HATCHED_BRUSH
    buffer_canvas.Select(airspace_look.brushes[3]);
    buffer_canvas.SetTextColor(fill_color);
    buffer_canvas.SetBackgroundColor(COLOR_WHITE);
#else
    buffer_canvas.Select(Brush(fill_color));
#endif
    buffer_canvas.SelectNullPen();
    RenderFAISectors(buffer_canvas, projection, task);
    canvas.CopyAnd(buffer_canvas);

    canvas.SelectHollowBrush();
    canvas.SelectBlackPen();
    RenderFAISectors(canvas, projection, task);
#endif
  }

  OZRenderer ozv(task_look, airspace_look, settings_map.airspace);
  TaskPointRenderer tpv(canvas, projection, task_look,
                        task.GetTaskProjection(),
                        ozv, false, TaskPointRenderer::NONE,
                        location);
  TaskRenderer dv(tpv, projection.GetScreenBounds());
  dv.Draw(task);

  // highlight a task point
  if (highlight_index >= 0 && highlight_index < (int) task.TaskSize()) {
    /* TODO: clumsy way of highlighting. maybe it should be done by
     *       painting the task point with a different pen and brush,
     *       e.g. red, 4px wide
     */
    auto pt = projection.GeoToScreen(task.GetPoint(highlight_index).
                                     GetLocation());
    canvas.Select(task_look.highlight_pen);
    canvas.DrawLine(pt.x - 7, pt.y - 7, pt.x + 7, pt.y + 7);
    canvas.DrawLine(pt.x + 7, pt.y - 7, pt.x - 7, pt.y + 7);
  }
}