aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scale.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/scale.h b/scale.h
index ccf23c5..4c3f341 100644
--- a/scale.h
+++ b/scale.h
@@ -18,6 +18,11 @@ public:
virtual ~Scale() {}
+ T rangeMin() const { return m_rangeMin; }
+ T rangeMax() const { return m_rangeMax; }
+ T domainMin() const { return m_domainMin; }
+ T domainMax() const { return m_domainMax; }
+
void setRangeMin(T rangeMin) { m_rangeMin = rangeMin; valuesUpdated(); }
void setRangeMax(T rangeMax) { m_rangeMax = rangeMax; valuesUpdated(); }
void setDomainMin(T domainMin) { m_domainMin = domainMin; valuesUpdated(); }
@@ -30,6 +35,11 @@ public:
valuesUpdated();
}
+ void setRange(const Scale<T> &other)
+ {
+ setRange(other.m_rangeMin, other.m_rangeMax);
+ }
+
void setDomain(const T &domainMin, const T &domainMax)
{
m_domainMin = domainMin;
@@ -37,6 +47,11 @@ public:
valuesUpdated();
}
+ void setDomain(const Scale<T> &other)
+ {
+ setDomain(other.m_domainMin, other.m_domainMax);
+ }
+
void inverse()
{
std::swap(m_rangeMin, m_domainMin);
@@ -70,6 +85,13 @@ public:
return (value - Scale<T>::m_domainMin) * m_transformSlope + Scale<T>::m_rangeMin;
}
+ T slope() const { return m_transformSlope; }
+
+ T offset() const
+ {
+ return Scale<T>::m_rangeMin - Scale<T>::m_domainMin * m_transformSlope;
+ }
+
protected:
virtual void valuesUpdated()
{