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@189
|
57 float ratio, float minlog,
|
Chris@189
|
58 QString m_unit = "");
|
Chris@189
|
59
|
Chris@189
|
60 virtual int getPositionForValue(float value) const;
|
Chris@189
|
61 virtual float getValueForPosition(int position) const;
|
Chris@189
|
62
|
Chris@189
|
63 virtual QString getUnit() const { return m_unit; }
|
Chris@189
|
64
|
Chris@189
|
65 protected:
|
Chris@189
|
66 int m_minpos;
|
Chris@189
|
67 int m_maxpos;
|
Chris@189
|
68 float m_ratio;
|
Chris@189
|
69 float m_minlog;
|
Chris@189
|
70 float m_maxlog;
|
Chris@189
|
71 QString m_unit;
|
Chris@189
|
72 };
|
Chris@189
|
73
|
Chris@189
|
74
|
Chris@189
|
75 #endif
|