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

break up PlotLayout into free functions

parent fc82bd13
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include <iostream>
#include "brush.h"

namespace signaltk {
+0 −1
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ public:
    std::get<3>(padding_) = val;
  }

protected:
  int width_;
  int height_;
  std::tuple<int, int, int, int> padding_;
+9 −13
Original line number Diff line number Diff line
/**
 * This file is part of the "libstx" project
 *   Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
 * This file is part of the "signaltk" project
 *   Copyright (c) 2018 Paul Asmuth
 *   Copyright (c) 2014 Paul Asmuth, Google Inc.
 *
 * libstx is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
@@ -14,23 +15,18 @@ namespace chart {

GridDefinition::GridDefinition(
    kPlacement placement) :
    placement_(placement),
    domain_(nullptr) {}

void GridDefinition::setDomain(DomainProvider* domain) {
  domain_ = domain;
}
    placement_(placement) {}

GridDefinition::kPlacement GridDefinition::placement() const {
  return placement_;
}

const std::vector<double> GridDefinition::ticks() const {
  if (domain_ == nullptr || domain_->empty()) {
    return std::vector<double>();
  } else {
    return domain_->get()->getTicks();
void GridDefinition::addTick(double tick_position) {
  ticks_.push_back(tick_position);
}

const std::vector<double> GridDefinition::ticks() const {
  return ticks_;
}

}
+10 −8
Original line number Diff line number Diff line
/**
 * This file is part of the "libstx" project
 *   Copyright (c) 2011-2014 Paul Asmuth, Google Inc.
 * This file is part of the "signaltk" project
 *   Copyright (c) 2018 Paul Asmuth
 *   Copyright (c) 2014 Paul Asmuth, Google Inc.
 *
 * libstx is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#ifndef _libstx_UI_GRIDDEFINITION_H
#define _libstx_UI_GRIDDEFINITION_H
#pragma once
#include "domain.h"
#include "domainprovider.h"

@@ -29,18 +29,20 @@ public:
  GridDefinition(kPlacement placement);

  /**
   * Set the domain for this grid
   * Add a "tick" to this axis
   *
   * @param tick_position the position of the tick [0.0-1.0]
   */
  void setDomain(DomainProvider* domain);
  void addTick(double tick_position);

  kPlacement placement() const;

  const std::vector<double> ticks() const;

protected:
  kPlacement placement_;
  DomainProvider* domain_;
  std::vector<double> ticks_;
};

}
}
#endif
+1 −6
Original line number Diff line number Diff line
@@ -22,14 +22,9 @@ char LineChart::kDefaultPointStyle[] = "none";
char LineChart::kDefaultPointSize[] = "3";

LineChart::LineChart(
    PlotLayout* canvas) :
    show_labels_(false) {}

LineChart::LineChart(
    PlotLayout* canvas,
    AnyDomain* x_domain,
    AnyDomain* y_domain) :
    LineChart(canvas) {
    show_labels_(false) {
  x_domain_.reset(x_domain);
  y_domain_.reset(y_domain);
}
Loading