Mercurial > hg > svcore
changeset 464:9525c9d7e54d
* Add vertical zoom and pan to time-value layer.
Still some defects, particularly in logarithmic mode.
Now need to get this in note layer as well!
* Some fixes to log colouring in segmentation mode of time-value layer.
author | Chris Cannam |
---|---|
date | Fri, 24 Oct 2008 14:52:40 +0000 |
parents | 93806ad9481e |
children | 63b8ba45d953 |
files | base/LogRange.cpp base/RangeMapper.cpp base/RangeMapper.h transform/TransformFactory.h |
diffstat | 4 files changed, 30 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/base/LogRange.cpp Thu Oct 23 16:32:00 2008 +0000 +++ b/base/LogRange.cpp Fri Oct 24 14:52:40 2008 +0000 @@ -16,6 +16,7 @@ #include "LogRange.h" #include <algorithm> +#include <iostream> #include <cmath> void @@ -24,6 +25,8 @@ if (min > max) std::swap(min, max); if (max == min) max = min + 1; +// std::cerr << "LogRange::mapRange: min = " << min << ", max = " << max << std::endl; + if (min >= 0.f) { max = log10f(max); // we know max != 0 @@ -31,6 +34,8 @@ if (min == 0.f) min = std::min(logthresh, max); else min = log10f(min); +// std::cerr << "LogRange::mapRange: positive: min = " << min << ", max = " << max << std::endl; + } else if (max <= 0.f) { min = log10f(-min); // we know min != 0 @@ -40,12 +45,16 @@ std::swap(min, max); +// std::cerr << "LogRange::mapRange: negative: min = " << min << ", max = " << max << std::endl; + } else { // min < 0 and max > 0 max = log10f(std::max(max, -min)); min = std::min(logthresh, max); + +// std::cerr << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << std::endl; } if (min == max) min = max - 1;
--- a/base/RangeMapper.cpp Thu Oct 23 16:32:00 2008 +0000 +++ b/base/RangeMapper.cpp Fri Oct 24 14:52:40 2008 +0000 @@ -22,12 +22,13 @@ LinearRangeMapper::LinearRangeMapper(int minpos, int maxpos, float minval, float maxval, - QString unit) : + QString unit, bool inverted) : m_minpos(minpos), m_maxpos(maxpos), m_minval(minval), m_maxval(maxval), - m_unit(unit) + m_unit(unit), + m_inverted(inverted) { assert(m_maxval != m_minval); assert(m_maxpos != m_minpos); @@ -43,12 +44,14 @@ if (position > m_maxpos) position = m_maxpos; // std::cerr << "LinearRangeMapper::getPositionForValue: " << value << " -> " // << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << std::endl; - return position; + if (m_inverted) return m_maxpos - position; + else return position; } float LinearRangeMapper::getValueForPosition(int position) const { + if (m_inverted) position = m_maxpos - position; float value = m_minval + ((float(position - m_minpos) / float(m_maxpos - m_minpos)) * (m_maxval - m_minval)); @@ -61,10 +64,11 @@ LogRangeMapper::LogRangeMapper(int minpos, int maxpos, float minval, float maxval, - QString unit) : + QString unit, bool inverted) : m_minpos(minpos), m_maxpos(maxpos), - m_unit(unit) + m_unit(unit), + m_inverted(inverted) { convertMinMax(minpos, maxpos, minval, maxval, m_minlog, m_ratio); @@ -104,17 +108,19 @@ int position = (log10(value) - m_minlog) * m_ratio + m_minpos; if (position < m_minpos) position = m_minpos; if (position > m_maxpos) position = m_maxpos; - std::cerr << "LogRangeMapper::getPositionForValue: " << value << " -> " - << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl; - return position; +// std::cerr << "LogRangeMapper::getPositionForValue: " << value << " -> " +// << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl; + if (m_inverted) return m_maxpos - position; + else return position; } float LogRangeMapper::getValueForPosition(int position) const { + if (m_inverted) position = m_maxpos - position; float value = powf(10, (position - m_minpos) / m_ratio + m_minlog); - std::cerr << "LogRangeMapper::getValueForPosition: " << position << " -> " - << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl; +// std::cerr << "LogRangeMapper::getValueForPosition: " << position << " -> " +// << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl; return value; }
--- a/base/RangeMapper.h Thu Oct 23 16:32:00 2008 +0000 +++ b/base/RangeMapper.h Fri Oct 24 14:52:40 2008 +0000 @@ -34,7 +34,7 @@ public: LinearRangeMapper(int minpos, int maxpos, float minval, float maxval, - QString unit = ""); + QString unit = "", bool inverted = false); virtual int getPositionForValue(float value) const; virtual float getValueForPosition(int position) const; @@ -47,6 +47,7 @@ float m_minval; float m_maxval; QString m_unit; + bool m_inverted; }; @@ -55,7 +56,7 @@ public: LogRangeMapper(int minpos, int maxpos, float minval, float maxval, - QString m_unit = ""); + QString m_unit = "", bool inverted = false); static void convertRatioMinLog(float ratio, float minlog, int minpos, int maxpos, @@ -77,6 +78,7 @@ float m_minlog; float m_maxlog; QString m_unit; + bool m_inverted; };