void
TraceHistoryRenderer::ScaleChart(ChartRenderer &chart,
                                  const TraceVariableHistory& var,
                                  const bool centered) const
{
  chart.padding_bottom = 0;
  chart.padding_left = 0;
  chart.ScaleXFromValue(fixed(0));
  chart.ScaleXFromValue(fixed(var.capacity()-1));

  fixed vmin = fixed(0);
  fixed vmax = fixed(0);
  for (auto it = var.begin(); it != var.end(); ++it) {
    vmin = std::min(*it, vmin);
    vmax = std::max(*it, vmax);
  }
  if (!(vmax>vmin)) {
    vmax += fixed(1);
  }
  if (centered) {
    vmax = std::max(vmax, -vmin);
    vmin = std::min(vmin, -vmax);
  }
  chart.ScaleYFromValue(vmax);
  chart.ScaleYFromValue(vmin);
}
Beispiel #2
0
void
InfoBoxContentSpark::SetVSpeedComment(InfoBoxData &data,
                                      const TraceVariableHistory &var)
{
  if (var.empty())
    return;

  TCHAR sTmp[32];
  FormatUserVerticalSpeed(var.last(), sTmp,
                          ARRAY_SIZE(sTmp));
  data.SetComment(sTmp);

  data.SetCustom();
}
Beispiel #3
0
void
InfoBoxContentSpark::label_vspeed(InfoBoxWindow &infobox,
                                  const TraceVariableHistory& var)
{
  if (var.empty())
    return;

  TCHAR sTmp[32];
  Units::FormatUserVSpeed(var.last(), sTmp,
                          sizeof(sTmp) / sizeof(sTmp[0]));
  infobox.SetComment(sTmp);

  infobox.SetValue(_T(""));
  infobox.invalidate();
}
void 
TraceHistoryRenderer::render_line(ChartRenderer &chart,
                                  const TraceVariableHistory& var) const
{
  fixed x_last, y_last;
  unsigned i=0;
  for (auto it = var.begin(); it != var.end(); ++it, ++i) {
    fixed x= fixed(i);
    fixed y= *it;
    if (i)
      chart.DrawLine(x_last, y_last, x, y, look.line_pen);
    x_last = x;
    y_last = y;
  }
}
void
TraceHistoryRenderer::RenderAxis(ChartRenderer &chart,
                                  const TraceVariableHistory& var) const
{
  chart.DrawLine(fixed(0), fixed(0), 
                 fixed(var.capacity()-1), fixed(0), 
                 look.axis_pen);
}
Beispiel #6
0
void
InfoBoxContentSpark::do_paint(InfoBoxWindow &infobox, Canvas &canvas,
                              const TraceVariableHistory& var,
                              const bool center)
{
  if (var.empty())
    return;

  TraceHistoryRenderer::RenderVario(canvas, get_spark_rect(infobox), var, center,
                                    CommonInterface::SettingsComputer().glide_polar_task.get_mc());
}
Beispiel #7
0
void
InfoBoxContentSpark::Paint(Canvas &canvas, const PixelRect &rc,
                           const TraceVariableHistory &var, const bool center)
{
  if (var.empty())
    return;

  const Look &look = UIGlobals::GetLook();
  TraceHistoryRenderer renderer(look.trace_history, look.vario, look.chart);
  renderer.RenderVario(canvas, GetSparkRect(rc), var, center,
                       CommonInterface::GetComputerSettings().polar.glide_polar_task.GetMC());
}
void 
TraceHistoryRenderer::render_filled_posneg(ChartRenderer &chart,
                                           const TraceVariableHistory& var) const
{
  fixed x_last(fixed(0)), y_last(fixed(0));
  unsigned i=0;
  for (auto it = var.begin(); it != var.end(); ++it, ++i) {
    fixed x= fixed(i);
    fixed y= *it;
    if (i) {
      if (sgn(y)*sgn(y_last)<0) {
        if (positive(y_last))
          chart.DrawFilledLine(x_last, y_last, x_last+fixed(0.5), fixed(0),
                               vario_look.lift_brush);
        else if (negative(y_last))
          chart.DrawFilledLine(x_last, y_last, x_last+fixed(0.5), fixed(0),
                               vario_look.sink_brush);

        x_last = x-fixed(0.5);
        y_last = fixed(0);

      }
      if (positive(y) || positive(y_last))
        chart.DrawFilledLine(x_last, y_last, x, y, vario_look.lift_brush);
      else if (negative(y) || negative(y_last))
        chart.DrawFilledLine(x_last, y_last, x, y, vario_look.sink_brush);
    }
    x_last = x;
    y_last = y;
  }
  if (look.inverse)
    chart.GetCanvas().SelectWhiteBrush();
  else
    chart.GetCanvas().SelectBlackBrush();
  chart.DrawDot(x_last, y_last, Layout::Scale(2));
}
void
TraceHistoryRenderer::RenderVario(Canvas& canvas,
                                  const PixelRect rc,
                                  const TraceVariableHistory& var,
                                  const bool centered,
                                  const fixed mc) const
{
  ChartRenderer chart(chart_look, canvas, rc);
  ScaleChart(chart, var, centered);
  chart.ScaleYFromValue(mc);

  if (positive(mc)) {
    canvas.SetBackgroundTransparent();
    chart.DrawLine(fixed(0), mc, 
                   fixed(var.capacity()-1), mc, 
                   ChartLook::STYLE_DASHGREEN);
  }

  render_filled_posneg(chart, var);
  RenderAxis(chart, var);
}