Commit 80102a5b authored by Paul Asmuth's avatar Paul Asmuth
Browse files

move GridDefinition into gridlines.{h,cc}

parent 7d1d3c20
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ add_executable(signaltk
    src/signaltk/plot/axes.cc
    src/signaltk/plot/domain.cc
    src/signaltk/plot/domainprovider.cc
    src/signaltk/plot/griddefinition.cc
    src/signaltk/plot/legenddefinition.cc
    src/signaltk/plot/series.cc
    src/signaltk/plot/timedomain.cc
+0 −33
Original line number Diff line number Diff line
/**
 * 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/>.
 */
#include "griddefinition.h"

namespace signaltk {
namespace chart {

GridDefinition::GridDefinition(
    kPlacement placement) :
    placement_(placement) {}

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

void GridDefinition::addTick(double tick_position) {
  ticks_.push_back(tick_position);
}

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

}
}
+0 −48
Original line number Diff line number Diff line
/**
 * 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/>.
 */
#pragma once
#include "domain.h"
#include "domainprovider.h"

namespace signaltk {
namespace chart {

class GridDefinition {
public:

  enum kPlacement {
    GRID_HORIZONTAL = 0,
    GRID_VERTICAL = 1
  };

  /**
   * Create a new grid definition
   */
  GridDefinition(kPlacement placement);

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

  kPlacement placement() const;

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

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

}
}
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,22 @@
namespace signaltk {
namespace chart {

GridDefinition::GridDefinition(
    kPlacement placement) :
    placement_(placement) {}

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

void GridDefinition::addTick(double tick_position) {
  ticks_.push_back(tick_position);
}

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

void renderGrid(
    const GridDefinition& grid,
    const Viewport& viewport,
+29 −3
Original line number Diff line number Diff line
@@ -15,13 +15,39 @@
#include <tuple>
#include <signaltk/core/layer.h>
#include <signaltk/core/viewport.h>
#include "axes.h"
#include "griddefinition.h"
#include "legenddefinition.h"

namespace signaltk {
namespace chart {

class GridDefinition {
public:

  enum kPlacement {
    GRID_HORIZONTAL = 0,
    GRID_VERTICAL = 1
  };

  /**
   * Create a new grid definition
   */
  GridDefinition(kPlacement placement);

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

  kPlacement placement() const;

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

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

/**
 * Render the grid
 */