Commit 89ccc7a5 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

move axisdefinition.{h,cc} -> axes.{h,cc}

parent 45766e43
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ add_executable(signaltk
    src/signaltk/core/text.cc
    src/signaltk/core/image_api.cc
    src/signaltk/plot/plot_layout.cc
    src/signaltk/plot/axisdefinition.cc
    src/signaltk/plot/axes.cc
    src/signaltk/plot/domain.cc
    src/signaltk/plot/domainprovider.cc
    src/signaltk/plot/griddefinition.cc
+6 −43
Original line number Diff line number Diff line
@@ -7,37 +7,24 @@
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include "axisdefinition.h"
#include "domain.h"
#include "axes.h"

namespace signaltk {
namespace chart {

AxisDefinition::AxisDefinition(
    kPosition axis_position) :
    AxisDefinition(axis_position, nullptr) {}

AxisDefinition::AxisDefinition(
    kPosition axis_position,
    DomainProvider* domain) :
    position_(axis_position),
    domain_(domain),
AxisDefinition::AxisDefinition() :
    enabled_(false),
    has_ticks_(false),
    has_labels_(false) {}

void AxisDefinition::addTick(double tick_position) {
  has_ticks_ = true;
  ticks_.push_back(tick_position);
}

const std::vector<double> AxisDefinition::getTicks() const {
  if (has_ticks_ || domain_ == nullptr) {
  return ticks_;
}

  return domain_->getTicks();
}

void AxisDefinition::addLabel(
    double label_position,
    const std::string& label_text) {
@@ -51,37 +38,17 @@ void AxisDefinition::removeLabels() {

const std::vector<std::pair<double, std::string>> AxisDefinition::getLabels()
    const {
  if (has_labels_ || domain_ == nullptr) {
  return labels_;
}

  return domain_->getLabels();
}

bool AxisDefinition::hasLabels() const {
  return has_labels_ || domain_ != nullptr;
}

AxisDefinition::kPosition AxisDefinition::getPosition() const {
  return position_;
}

void AxisDefinition::setLabelPosition(kLabelPosition pos) {
  printf("set label pos: %i", pos);
  return has_labels_;
}

AxisDefinition::kLabelPosition AxisDefinition::getLabelPosition() const {
  return LABELS_INSIDE;
}

void AxisDefinition::setLabelRotation(double deg) {
  printf("axis label rot: %f\n", deg);
}

double AxisDefinition::getLabelRotation() const {
  return 0.0f;
}

void AxisDefinition::setTitle(const std::string& title) {
  title_ = title;
}
@@ -94,9 +61,5 @@ bool AxisDefinition::hasTitle() const {
  return title_.length() > 0;
}

void AxisDefinition::setDomain(DomainProvider* domain) {
  domain_ = domain;
}

}
}
+13 −32
Original line number Diff line number Diff line
@@ -7,8 +7,7 @@
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#ifndef _libstx_AXISDEFINITION_H
#define _libstx_AXISDEFINITION_H
#pragma once
#include <utility>
#include <string>
#include <vector>
@@ -21,16 +20,6 @@ namespace chart {
class AxisDefinition {
public:

  /**
   * The axis positions/placements
   */
  enum kPosition {
    TOP = 0,
    RIGHT = 1,
    BOTTOM = 2,
    LEFT = 3
  };

  /**
   * The axis tick position
   */
@@ -45,15 +34,7 @@ public:
   *
   * @param axis_position the position of the axis ({TOP,RIGHT,BOTTOM,LEFT})
   */
  AxisDefinition(kPosition axis_position);

  /**
   * Create a new axis definition from a domain
   *
   * @param axis_position the position of the axis ({TOP,RIGHT,BOTTOM,LEFT})
   * @param domain the domain. does not transfer ownership
   */
  AxisDefinition(kPosition axis_position, DomainProvider* domain);
  AxisDefinition();

  /**
   * Add a "tick" to this axis
@@ -90,11 +71,6 @@ public:
   */
  bool hasLabels() const;

  /**
   * Return the position/placement of this axis
   */
  kPosition getPosition() const;

  /**
   * Set the label position for this axis
   */
@@ -136,9 +112,7 @@ public:
   */
  void setDomain(DomainProvider* domain);

protected:
  kPosition position_;
  DomainProvider* domain_;
  bool enabled_;
  std::string title_;
  std::vector<double> ticks_;
  bool has_ticks_;
@@ -146,6 +120,13 @@ protected:
  bool has_labels_;
};

}
}
#endif
struct AxisDefinitions {
  AxisDefinition top;
  AxisDefinition right;
  AxisDefinition bottom;
  AxisDefinition left;
};

} // namespace chart
} // namespace signaltk
+0 −1
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
#include "plot_layout.h"
#include "../core/layer.h"
#include "series.h"
#include "axisdefinition.h"
#include "continuousdomain.h"
#include "domain.h"
#include "colorpalette.h"
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#include <tuple>
#include <signaltk/core/layer.h>
#include <signaltk/core/viewport.h>
#include "axisdefinition.h"
#include "axes.h"
#include "griddefinition.h"
#include "legenddefinition.h"