annotate base/RangeMapper.h @ 374:7cc6b7b0d819 sv1-v1.2pre3

* line up overview widget nicely with main pane (at least on first startup) * fix #1878396 renaming layer seems to have no visible effect * comment out some debug output
author Chris Cannam
date Wed, 06 Feb 2008 17:40:53 +0000
parents ca3b91119482
children 9525c9d7e54d
rev   line source
Chris@189 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@189 2
Chris@189 3 /*
Chris@189 4 Sonic Visualiser
Chris@189 5 An audio file viewer and annotation editor.
Chris@189 6 Centre for Digital Music, Queen Mary, University of London.
Chris@202 7 This file copyright 2006 QMUL.
Chris@189 8
Chris@189 9 This program is free software; you can redistribute it and/or
Chris@189 10 modify it under the terms of the GNU General Public License as
Chris@189 11 published by the Free Software Foundation; either version 2 of the
Chris@189 12 License, or (at your option) any later version. See the file
Chris@189 13 COPYING included with this distribution for more information.
Chris@189 14 */
Chris@189 15
Chris@189 16 #ifndef _RANGE_MAPPER_H_
Chris@189 17 #define _RANGE_MAPPER_H_
Chris@189 18
Chris@189 19 #include <QString>
Chris@189 20
Chris@189 21
Chris@189 22 class RangeMapper
Chris@189 23 {
Chris@189 24 public:
Chris@189 25 virtual ~RangeMapper() { }
Chris@189 26 virtual int getPositionForValue(float value) const = 0;
Chris@189 27 virtual float getValueForPosition(int position) const = 0;
Chris@189 28 virtual QString getUnit() const { return ""; }
Chris@189 29 };
Chris@189 30
Chris@189 31
Chris@189 32 class LinearRangeMapper : public RangeMapper
Chris@189 33 {
Chris@189 34 public:
Chris@189 35 LinearRangeMapper(int minpos, int maxpos,
Chris@189 36 float minval, float maxval,
Chris@189 37 QString unit = "");
Chris@189 38
Chris@189 39 virtual int getPositionForValue(float value) const;
Chris@189 40 virtual float getValueForPosition(int position) const;
Chris@189 41
Chris@189 42 virtual QString getUnit() const { return m_unit; }
Chris@189 43
Chris@189 44 protected:
Chris@189 45 int m_minpos;
Chris@189 46 int m_maxpos;
Chris@189 47 float m_minval;
Chris@189 48 float m_maxval;
Chris@189 49 QString m_unit;
Chris@189 50 };
Chris@189 51
Chris@189 52
Chris@189 53 class LogRangeMapper : public RangeMapper
Chris@189 54 {
Chris@189 55 public:
Chris@189 56 LogRangeMapper(int minpos, int maxpos,
Chris@356 57 float minval, float maxval,
Chris@189 58 QString m_unit = "");
Chris@189 59
Chris@356 60 static void convertRatioMinLog(float ratio, float minlog,
Chris@356 61 int minpos, int maxpos,
Chris@356 62 float &minval, float &maxval);
Chris@356 63
Chris@356 64 static void convertMinMax(int minpos, int maxpos,
Chris@356 65 float minval, float maxval,
Chris@356 66 float &ratio, float &minlog);
Chris@356 67
Chris@189 68 virtual int getPositionForValue(float value) const;
Chris@189 69 virtual float getValueForPosition(int position) const;
Chris@189 70
Chris@189 71 virtual QString getUnit() const { return m_unit; }
Chris@189 72
Chris@189 73 protected:
Chris@189 74 int m_minpos;
Chris@189 75 int m_maxpos;
Chris@189 76 float m_ratio;
Chris@189 77 float m_minlog;
Chris@189 78 float m_maxlog;
Chris@189 79 QString m_unit;
Chris@189 80 };
Chris@189 81
Chris@189 82
Chris@189 83 #endif