Commit 431aaf33 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

wire up domain clause and drawable

parent 2b40af33
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
namespace fnordmetric {
namespace ui {

const char AnyDomain::kDimensionLetters[] = "xyz";

template <> Domain<int>* Domain<int>::mkDomain() {
  return new ContinuousDomain<int>();
}
+37 −3
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ namespace ui {
 */
class AnyDomain {
public:
  static const char kDimensionLetters[];

  enum kDimension {
    DIM_X = 0,
    DIM_Y = 1,
@@ -35,6 +37,14 @@ public:

  virtual const std::vector<std::pair<double, std::string>> getLabels()
      const = 0;

  virtual void setInverted(bool inverted) = 0;

};

class AnyContinuousDomain {
public:
  virtual void setLogarithmic(bool logarithmic) = 0;
};

/**
@@ -65,7 +75,7 @@ public:
};

template <typename T>
class ContinuousDomain : public Domain<T> {
class ContinuousDomain : public Domain<T>, public AnyContinuousDomain {
public:
  static const int kDefaultNumTicks = 8;

@@ -143,9 +153,27 @@ public:
    return labels;
  }

  void setMin(T min) {
    min_value_ = min;
  }

  void setMax(T max) {
    max_value_ = max;
  }

  void setInverted(bool inverted) {
    RAISE(
        util::RuntimeException,
        "not yet implemented: ContinuousDomain::setInverted");
  }

  void setLogarithmic(bool logarithmic) {
    is_logarithmic_ = logarithmic;
  }

protected:
  double min_value_;
  double max_value_;
  T min_value_;
  T max_value_;
  bool is_logarithmic_;
};

@@ -236,6 +264,12 @@ public:
        value) != categories_.end();
  }

  void setInverted(bool inverted) {
    RAISE(
        util::RuntimeException,
        "not yet implemented: DiscreteDomain::setInverted");
  }

protected:
  std::vector<T> categories_;
};
+1 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ AnyDomain* LineChart2D<TX, TY>::getDomain(AnyDomain::kDimension dimension) {
      return y_domain_.get();

    case AnyDomain::DIM_Z:
      RAISE(util::RuntimeException, "LineChart2D does not have a Y domain");
      RAISE(util::RuntimeException, "LineChart2D does not have a Z domain");
      return nullptr;
  }
}