Commit d2d1ad72 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

remove more obsolete methods from core drawing api

parent 743eaf41
Loading
Loading
Loading
Loading
+3 −22
Original line number Diff line number Diff line
@@ -28,13 +28,6 @@ void CairoBackend::writePNG(const char* path) {
  cairo_surface_write_to_png(surface_, path);
}

void CairoBackend::beginChart(
    int width,
    int height,
    const std::string& class_name) {}

void CairoBackend::finishChart() {}

void CairoBackend::clear(double r, double g, double b, double a) {
  cairo_set_source_rgba(ctx_, r, g, b, a);
  cairo_rectangle(ctx_, 0, 0, width_, height_);
@@ -48,17 +41,9 @@ void CairoBackend::drawText(
    const std::string& halign,
    const std::string& valign,
    const std::string& class_name,
    double rotate) {}

void CairoBackend::drawPoint(
    double x,
    double y,
    const std::string& point_type,
    double point_size,
    const std::string& color,
    const std::string& class_name /* = "" */,
    const std::string& label /* = "" */,
    const std::string& series /* = "" */) {}
    double rotate) {
  // here be dragons
}

void CairoBackend::strokePath(
    const PathData* point_data,
@@ -92,8 +77,4 @@ void CairoBackend::strokePath(
  cairo_stroke(ctx_);
}

void CairoBackend::beginGroup(const std::string& class_name) {}

void CairoBackend::finishGroup() {}

} // namespace signaltk
+0 −21
Original line number Diff line number Diff line
@@ -24,13 +24,6 @@ public:

  void writePNG(const char* path);

  void beginChart(
      int width,
      int height,
      const std::string& class_name);

  void finishChart();

  void clear(double r, double g, double b, double a);

  void drawText(
@@ -42,25 +35,11 @@ public:
      const std::string& class_name,
      double rotate = 0.0f) override;

  void drawPoint(
      double x,
      double y,
      const std::string& point_type,
      double point_size,
      const std::string& color,
      const std::string& class_name /* = "" */,
      const std::string& label /* = "" */,
      const std::string& series /* = "" */) override;

  void strokePath(
      const PathData* point_data,
      size_t point_count,
      const StrokeStyle& stroke_style) override;

  void beginGroup(const std::string& class_name) override;

  void finishGroup() override;

  uint32_t width() const {
    return width_;
  }
+0 −20
Original line number Diff line number Diff line
@@ -24,16 +24,6 @@ class RenderTarget {
public:
  virtual ~RenderTarget() {}

  virtual void beginChart(
      int width,
      int height,
      const std::string& class_name) = 0;

  virtual void finishChart() = 0;

  virtual void beginGroup(const std::string& class_name) = 0;
  virtual void finishGroup() = 0;

  virtual void drawText(
      const std::string& text,
      double x,
@@ -43,16 +33,6 @@ public:
      const std::string& class_name,
      double rotate = 0.0f) = 0;

  virtual void drawPoint(
      double x,
      double y,
      const std::string& point_type,
      double point_size,
      const std::string& color,
      const std::string& class_name = "",
      const std::string& label = "",
      const std::string& series = "") = 0;

  virtual void strokePath(
      const PathData* point_data,
      size_t point_count,
+9 −11
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ void LineChart::render(
  x_domain_.get()->build();
  y_domain_.get()->build();

  target->beginGroup("lines");

  for (const auto& series : series_) {
    Path path;
@@ -142,15 +141,15 @@ void LineChart::render(
            "label");
      }

      target->drawPoint(
          ss_x,
          ss_y,
          point_style,
          point_size,
          color,
          "point",
          label,
          series->name());
      //target->drawPoint(
      //    ss_x,
      //    ss_y,
      //    point_style,
      //    point_size,
      //    color,
      //    "point",
      //    label,
      //    series->name());

      if (path.empty()) {
        path.moveTo(ss_x, ss_y);
@@ -168,7 +167,6 @@ void LineChart::render(
        style);
  }

  target->finishGroup();
}

AnyDomain* LineChart::getDomain(AnyDomain::kDimension dimension) {
+0 −14
Original line number Diff line number Diff line
@@ -33,10 +33,8 @@ void PlotLayout::render(RenderTarget* target) const {
  // FIXPAUL: initialize from rendertarget
  Viewport viewport(width_, height_);

  target->beginChart(width_, height_, "fm-chart");
  renderAxes(target, &viewport);
  renderGrids(target, &viewport);
  target->finishChart();
}

void PlotLayout::renderAxes(RenderTarget* target, Viewport* viewport) const {
@@ -130,7 +128,6 @@ void PlotLayout::renderTopAxis(
  int inner_width = viewport->innerWidth();

  top += kAxisPadding;
  target->beginGroup("axis bottom");

  /* draw title */
  if (axis->hasTitle()) {
@@ -182,7 +179,6 @@ void PlotLayout::renderTopAxis(
      top,
      style);

  target->finishGroup();
}


@@ -197,7 +193,6 @@ void PlotLayout::renderRightAxis(
  int inner_height = viewport->innerHeight();

  right += kAxisPadding;
  target->beginGroup("axis right");

  /* draw title */
  if (axis->hasTitle()) {
@@ -249,7 +244,6 @@ void PlotLayout::renderRightAxis(
      padding_top + inner_height,
      style);

  target->finishGroup();
}

void PlotLayout::renderBottomAxis(
@@ -263,7 +257,6 @@ void PlotLayout::renderBottomAxis(
  int inner_width = viewport->innerWidth();

  bottom += kAxisPadding;
  target->beginGroup("axis bottom");

  /* draw title */
  if (axis->hasTitle()) {
@@ -315,7 +308,6 @@ void PlotLayout::renderBottomAxis(
      height_ - bottom,
      style);

  target->finishGroup();
}

void PlotLayout::renderLeftAxis(
@@ -329,7 +321,6 @@ void PlotLayout::renderLeftAxis(
  int inner_height = viewport->innerHeight();

  left += kAxisPadding;
  target->beginGroup("axis left");

  /* draw title */
  if (axis->hasTitle()) {
@@ -382,7 +373,6 @@ void PlotLayout::renderLeftAxis(
      padding_top + inner_height,
      style);

  target->finishGroup();
}

void PlotLayout::renderGrids(RenderTarget* target, Viewport* viewport) const {
@@ -392,7 +382,6 @@ void PlotLayout::renderGrids(RenderTarget* target, Viewport* viewport) const {
    switch (grid->placement()) {

      case GridDefinition::GRID_HORIZONTAL:
        target->beginGroup("grid horizontal");
        for (const auto& tick : grid->ticks()) {
          auto line_y = viewport->paddingTop() +
              viewport->innerHeight() * (1.0 - tick);
@@ -404,11 +393,9 @@ void PlotLayout::renderGrids(RenderTarget* target, Viewport* viewport) const {
              line_y,
              style);
        }
        target->finishGroup();
        break;

      case GridDefinition::GRID_VERTICAL:
        target->beginGroup("grid vertical");
        for (const auto& tick : grid->ticks()) {
          auto line_x = viewport->paddingLeft() + viewport->innerWidth() * tick;

@@ -419,7 +406,6 @@ void PlotLayout::renderGrids(RenderTarget* target, Viewport* viewport) const {
              viewport->paddingTop() + viewport->innerHeight(),
              style);
        }
        target->finishGroup();
        break;

    }