当前位置: 首页>>代码示例>>C++>>正文


C++ ChartRenderer类代码示例

本文整理汇总了C++中ChartRenderer的典型用法代码示例。如果您正苦于以下问题:C++ ChartRenderer类的具体用法?C++ ChartRenderer怎么用?C++ ChartRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ChartRenderer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fixed

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);
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:26,代码来源:TraceHistoryRenderer.cpp

示例2: DrawLegs

static void
DrawLegs(ChartRenderer &chart,
         const TaskManager &task_manager,
         const NMEAInfo& basic,
         const DerivedInfo& calculated,
         const bool task_relative)
{
  const TaskStats &task_stats = calculated.ordered_task_stats;

  if (!task_stats.start.task_started)
    return;

  const auto start_time = task_relative
    ? basic.time - task_stats.total.time_elapsed
    : calculated.flight.takeoff_time;

  const OrderedTask &task = task_manager.GetOrderedTask();
  for (unsigned i = 0, n = task.TaskSize(); i < n; ++i) {
    const OrderedTaskPoint &tp = task.GetTaskPoint(i);
    if (!IsTaskLegVisible(tp))
      continue;

    auto x = tp.GetEnteredState().time - start_time;
    if (x >= 0) {
      x /= 3600;
      chart.DrawLine(x, chart.GetYMin(), x, chart.GetYMax(),
                     ChartLook::STYLE_REDTHICK);
    }
  }
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:30,代码来源:BarographRenderer.cpp

示例3:

void
ThermalBandRenderer::ScaleChart(const DerivedInfo &calculated,
                                 const ComputerSettings &settings_computer,
                                 ChartRenderer &chart) const
{
  chart.ScaleYFromValue(fixed(0));
  chart.ScaleYFromValue(calculated.thermal_band.max_thermal_height);

  chart.ScaleXFromValue(fixed(0));
  chart.ScaleXFromValue(fixed(0.5));
  chart.ScaleXFromValue(settings_computer.polar.glide_polar_task.GetMC());
}
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:12,代码来源:ThermalBandRenderer.cpp

示例4: fixed

void
CrossSectionRenderer::PaintGrid(Canvas &canvas, ChartRenderer &chart) const
{
  canvas.SetTextColor(look.text_color);

  chart.DrawXGrid(Units::ToSysDistance(fixed(5)),
                  look.grid_pen, fixed(5), true);
  chart.DrawYGrid(Units::ToSysAltitude(fixed(1000)),
                  look.grid_pen, fixed(1000), true);

  chart.DrawXLabel(_T("D"), Units::GetDistanceName());
  chart.DrawYLabel(_T("h"), Units::GetAltitudeName());
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:13,代码来源:CrossSectionRenderer.cpp

示例5: fixed

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;
  }
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:15,代码来源:TraceHistoryRenderer.cpp

示例6: mc

void
CrossSectionRenderer::PaintGlide(ChartRenderer &chart) const
{
  if (!gps_info.NavAltitudeAvailable() || !glide_polar.IsValid())
    return;

  const fixed altitude = gps_info.nav_altitude;

  const MacCready mc(glide_settings, glide_polar);
  const GlideState task(vec, fixed(0), altitude,
                        calculated_info.GetWindOrZero());
  const GlideResult result = mc.SolveStraight(task);
  if (!result.IsOk())
    return;

  chart.DrawLine(fixed(0), altitude, result.vector.distance,
                 result.GetArrivalAltitude(),
                 ChartLook::STYLE_BLUETHIN);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:19,代码来源:CrossSectionRenderer.cpp

示例7:

void
CrossSectionRenderer::PaintAircraft(Canvas &canvas, const ChartRenderer &chart,
                                    const PixelRect rc) const
{
  if (!gps_info.NavAltitudeAvailable())
    return;

  canvas.Select(look.aircraft_brush);
  canvas.SelectNullPen();

  RasterPoint line[4];
  line[0] = chart.ToScreen(fixed(0), 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);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:20,代码来源:CrossSectionRenderer.cpp

示例8: x_last

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));
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:36,代码来源:TraceHistoryRenderer.cpp

示例9: fixed

void
TerrainXSRenderer::Draw(Canvas &canvas, const ChartRenderer &chart, const short *elevations) const
{
  const fixed max_distance = chart.GetXMax();

  StaticArray<RasterPoint, CrossSectionRenderer::NUM_SLICES + 2> points;

  canvas.SelectNullPen();

  RasterBuffer::TerrainType last_type = RasterBuffer::TerrainType::UNKNOWN;
  fixed last_distance = fixed(0);

  for (unsigned j = 0; j < CrossSectionRenderer::NUM_SLICES; ++j) {
    const fixed distance_factor =
        fixed(j) / (CrossSectionRenderer::NUM_SLICES - 1);
    const fixed distance = distance_factor * max_distance;

    short h = elevations[j];
    RasterBuffer::TerrainType type = RasterBuffer::GetTerrainType(h);

    if (type == RasterBuffer::TerrainType::WATER)
      h = 0;

    // Close and paint polygon
    if (j != 0 &&
        type != last_type &&
        last_type != RasterBuffer::TerrainType::UNKNOWN) {
      const fixed center_distance = (distance + last_distance) / 2;
      points.append() = chart.ToScreen(center_distance, fixed(0));
      points.append() = chart.ToScreen(center_distance, fixed(-500));

      DrawPolygon(canvas, last_type, points.begin(), points.size());
    }

    if (type != RasterBuffer::TerrainType::UNKNOWN) {
      if (j == 0) {
        // Start first polygon
        points.append() = chart.ToScreen(distance, fixed(-500));
        points.append() = chart.ToScreen(distance, fixed(h));
      } else if (type != last_type) {
        // Start new polygon
        points.clear();

        const fixed center_distance = (distance + last_distance) / 2;
        points.append() = chart.ToScreen(center_distance, fixed(-500));
        points.append() = chart.ToScreen(center_distance, fixed(0));
      }

      if (j + 1 == CrossSectionRenderer::NUM_SLICES) {
        // Close and paint last polygon
        points.append() = chart.ToScreen(distance, fixed(h));
        points.append() = chart.ToScreen(distance, fixed(-500));

        DrawPolygon(canvas, type, points.begin(), points.size());
      } else if (type == last_type && j != 0) {
        // Add single point to polygon
        points.append() = chart.ToScreen(distance, fixed(h));
      }
    }

    last_type = type;
    last_distance = distance;
  }
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:64,代码来源:TerrainXSRenderer.cpp

示例10: blend

void
ThermalBandRenderer::_DrawThermalBand(const MoreData &basic,
                                      const DerivedInfo& calculated,
                                      const ComputerSettings &settings_computer,
                                      ChartRenderer &chart,
                                      const TaskBehaviour& task_props,
                                      const bool is_infobox,
                                      const OrderedTaskBehaviour *ordered_props) const
{
  const ThermalBandInfo &thermal_band = calculated.thermal_band;

  // calculate height above safety height
  fixed hoffset = task_props.route_planner.safety_height_terrain +
    calculated.GetTerrainBaseFallback();

  fixed h = fixed(0);
  if (basic.NavAltitudeAvailable()) {
    h = basic.nav_altitude - hoffset;
    chart.ScaleYFromValue(h);
  }

  bool draw_start_height = false;
  fixed hstart = fixed(0);

  draw_start_height = ordered_props
    && calculated.ordered_task_stats.task_valid
    && ordered_props->start_constraints.max_height != 0
    && calculated.terrain_valid;
  if (draw_start_height) {
    hstart = fixed(ordered_props->start_constraints.max_height);
    if (ordered_props->start_constraints.max_height_ref == AltitudeReference::AGL &&
        calculated.terrain_valid)
      hstart += calculated.terrain_altitude;

    hstart -= hoffset;
    chart.ScaleYFromValue(hstart);
  }

  // no thermalling has been done above safety height
  if (!positive(calculated.thermal_band.max_thermal_height))
    return;

  // calculate averages
  int numtherm = 0;

  fixed Wmax = fixed(0);
  fixed Wav = fixed(0);
  fixed Wt[ThermalBandInfo::NUMTHERMALBUCKETS];
  fixed ht[ThermalBandInfo::NUMTHERMALBUCKETS];

  for (unsigned i = 0; i < ThermalBandInfo::NUMTHERMALBUCKETS; ++i) {
    if (thermal_band.thermal_profile_n[i] < 6) 
      continue;

    if (positive(thermal_band.thermal_profile_w[i])) {
      // height of this thermal point [0,mth]
      // requires 5 items in bucket before displaying, to eliminate kinks
      fixed wthis = thermal_band.thermal_profile_w[i] / thermal_band.thermal_profile_n[i];
      ht[numtherm] = i * calculated.thermal_band.max_thermal_height 
        / ThermalBandInfo::NUMTHERMALBUCKETS;
      Wt[numtherm] = wthis;
      Wmax = std::max(Wmax, wthis);
      Wav+= wthis;
      numtherm++;
    }
  }
  chart.ScaleXFromValue(Wmax);
  if (!numtherm)
    return;
  chart.ScaleXFromValue(fixed(1.5)*Wav/numtherm);

  if ((!draw_start_height) && (numtherm<=1))
    // don't display if insufficient statistics
    // but do draw if start height needs to be drawn
    return;

  const Pen *fpen = is_infobox ? NULL : &look.pen;

  // position of thermal band
  if (numtherm > 1) {
    std::vector< std::pair<fixed, fixed> > thermal_profile;
    thermal_profile.reserve(numtherm);
    for (int i = 0; i < numtherm; ++i)
      thermal_profile.emplace_back(Wt[i], ht[i]);

    if (!is_infobox) {
#ifdef ENABLE_OPENGL
      const GLEnable blend(GL_BLEND);
#endif
      chart.DrawFilledY(thermal_profile, look.brush, fpen);
    } else
      chart.DrawFilledY(thermal_profile, look.brush, fpen);
  }

  // position of thermal band
  if (basic.NavAltitudeAvailable()) {
    const Pen &pen = is_infobox && look.inverse
      ? look.white_pen : look.black_pen;
    chart.DrawLine(fixed(0), h,
                   settings_computer.polar.glide_polar_task.GetMC(), h, pen);
//.........这里部分代码省略.........
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:101,代码来源:ThermalBandRenderer.cpp

示例11: fixed

void
ChartWindow::DrawChart(ChartRenderer &renderer)
{
  renderer.ScaleXFromValue(fixed(0));
  renderer.ScaleXFromValue(fixed(100));

  renderer.ScaleYFromValue(fixed(0));
  renderer.ScaleYFromValue(fixed(100));

  if (chart == 0) {
    renderer.DrawLine(fixed(0), fixed(10), fixed(100), fixed(70),
                      look.GetPen(ChartLook::STYLE_BLUETHIN));
  } else if (chart == 1) {
    renderer.ScaleXFromValue(fixed(-50));
    renderer.ScaleXFromValue(fixed(110));
    renderer.ScaleYFromValue(fixed(110));

    renderer.DrawLine(fixed(0), fixed(10), fixed(100), fixed(70),
                      look.GetPen(ChartLook::STYLE_BLUETHIN));

    renderer.DrawLine(fixed(0), fixed(10), fixed(100), fixed(80),
                      look.GetPen(ChartLook::STYLE_DASHGREEN));

    renderer.DrawLine(fixed(0), fixed(10), fixed(100), fixed(100),
                      look.GetPen(ChartLook::STYLE_MEDIUMBLACK));

    renderer.DrawXGrid(fixed(20), look.GetPen(ChartLook::STYLE_THINDASHPAPER),
                       fixed(20), true);

    renderer.DrawYGrid(fixed(20), look.GetPen(ChartLook::STYLE_THINDASHPAPER),
                       fixed(20), true);
}
}
开发者ID:StefanL74,项目名称:XCSoar,代码行数:33,代码来源:RunChartRenderer.cpp

示例12: RenderTaskLegs

void
RenderTaskLegs(ChartRenderer &chart,
               const TaskManager &task_manager,
               const NMEAInfo& basic,
               const DerivedInfo& calculated,
               const double y)
{
  const TaskStats &task_stats = calculated.ordered_task_stats;

  if (!task_stats.start.task_started)
    return;

  TCHAR sTmp[5];

  const OrderedTask &task = task_manager.GetOrderedTask();
  for (unsigned i = 0, n = task.TaskSize(); i < n; ++i) {
    const OrderedTaskPoint &tp = task.GetTaskPoint(i);
    if (!IsTaskLegVisible(tp))
      continue;

    auto x = tp.GetEnteredState().time - calculated.flight.takeoff_time;
    if (x >= 0) {
      x /= 3600;
      if (y>=0) {
        if (i==0) {
          chart.DrawBlankRectangle(chart.GetXMin(), chart.GetYMin(),
                                   x, chart.GetYMax());
        } else if (i+1 == task.TaskSize()) {
          chart.DrawBlankRectangle(x, chart.GetYMin(),
                                   chart.GetXMax(), chart.GetYMax());
        }
        chart.DrawLine(x, chart.GetYMin(), x, chart.GetYMax(),
                       ChartLook::STYLE_GRIDZERO);
      }
      if (y>=0) {
        StringFormatUnsafe(sTmp, _T("%d"), i);
        chart.DrawLabel(sTmp, x, chart.GetYMax()*y + chart.GetYMin()*(1-y));
      }
    }
  }
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:41,代码来源:TaskLegRenderer.cpp

示例13: if

void
ChartWindow::DrawChart(ChartRenderer &renderer)
{
  renderer.ScaleXFromValue(0);
  renderer.ScaleXFromValue(100);

  renderer.ScaleYFromValue(0);
  renderer.ScaleYFromValue(100);

  if (chart == 0) {
    renderer.DrawLine(0, 10, 100, 70,
                      look.GetPen(ChartLook::STYLE_BLUETHINDASH));
  } else if (chart == 1) {
    renderer.ScaleXFromValue(-50);
    renderer.ScaleXFromValue(110);
    renderer.ScaleYFromValue(110);

    renderer.DrawLine(0, 10, 100, 70,
                      look.GetPen(ChartLook::STYLE_BLUETHINDASH));

    renderer.DrawLine(0, 10, 100, 80,
                      look.GetPen(ChartLook::STYLE_GREENDASH));

    renderer.DrawLine(0, 10, 100, 100,
                      look.GetPen(ChartLook::STYLE_BLACK));

    renderer.DrawXGrid(20, 20, ChartRenderer::UnitFormat::NUMERIC);

    renderer.DrawYGrid(20, 20, ChartRenderer::UnitFormat::NUMERIC);

    renderer.DrawLabel(_T("hello"), 50, 50);
    renderer.DrawXLabel(_T("VVV"),_T("m/s"));
    renderer.DrawYLabel(_T("AAA"),_T("m/s"));
  }
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:35,代码来源:RunChartRenderer.cpp


注:本文中的ChartRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。