comparison base/RangeMapper.h @ 189:0703252c9fe8

* Add spectrum icon * Start range mapper class for use in mapping between e.g. dial positions and underlying values
author Chris Cannam
date Mon, 16 Oct 2006 13:13:57 +0000
parents
children 91fdc752e540
comparison
equal deleted inserted replaced
188:f86b74d1b143 189:0703252c9fe8
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _RANGE_MAPPER_H_
17 #define _RANGE_MAPPER_H_
18
19 #include <QString>
20
21
22 class RangeMapper
23 {
24 public:
25 virtual ~RangeMapper() { }
26 virtual int getPositionForValue(float value) const = 0;
27 virtual float getValueForPosition(int position) const = 0;
28 virtual QString getUnit() const { return ""; }
29 };
30
31
32 class LinearRangeMapper : public RangeMapper
33 {
34 public:
35 LinearRangeMapper(int minpos, int maxpos,
36 float minval, float maxval,
37 QString unit = "");
38
39 virtual int getPositionForValue(float value) const;
40 virtual float getValueForPosition(int position) const;
41
42 virtual QString getUnit() const { return m_unit; }
43
44 protected:
45 int m_minpos;
46 int m_maxpos;
47 float m_minval;
48 float m_maxval;
49 QString m_unit;
50 };
51
52
53 class LogRangeMapper : public RangeMapper
54 {
55 public:
56 LogRangeMapper(int minpos, int maxpos,
57 float ratio, float minlog,
58 QString m_unit = "");
59
60 virtual int getPositionForValue(float value) const;
61 virtual float getValueForPosition(int position) const;
62
63 virtual QString getUnit() const { return m_unit; }
64
65 protected:
66 int m_minpos;
67 int m_maxpos;
68 float m_ratio;
69 float m_minlog;
70 float m_maxlog;
71 QString m_unit;
72 };
73
74
75 #endif