ColourScale.h
Go to the documentation of this file.
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-2016 Chris Cannam and QMUL.
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 COLOUR_SCALE_H
17 #define COLOUR_SCALE_H
18 
19 #include "ColourMapper.h"
20 
21 enum class ColourScaleType {
22  Linear,
23  Meter,
24  Log,
25  Phase,
27  Absolute
28 };
29 
35 {
36 public:
37  struct Parameters {
38  Parameters() : colourMap(0), scaleType(ColourScaleType::Linear),
39  minValue(0.0), maxValue(1.0), inverted(false),
40  threshold(0.0), gain(1.0), multiple(1.0) { }
41 
43  int colourMap;
44 
47 
49  double minValue;
50 
52  double maxValue;
53 
55  bool inverted;
56 
59  double threshold;
60 
62  double gain;
63 
69  double multiple;
70  };
71 
80  ColourScale(Parameters parameters);
81  ~ColourScale();
82 
83  ColourScale(const ColourScale &) = default;
84  ColourScale &operator=(const ColourScale &) = default;
85 
89  ColourScaleType getScale() const;
90 
97  int getPixel(double value) const;
98 
105  QColor getColourForPixel(int pixel, int rotation) const;
106 
111  QColor getColour(double value, int rotation) const {
112  return getColourForPixel(getPixel(value), rotation);
113  }
114 
115 private:
118  double m_mappedMin;
119  double m_mappedMax;
120  static int m_maxPixel;
121 };
122 
123 #endif
double threshold
Threshold below which every value is mapped to background pixel 0.
Definition: ColourScale.h:59
static int m_maxPixel
Definition: ColourScale.h:120
QColor getColour(double value, int rotation) const
Return the colour corresponding to the given value.
Definition: ColourScale.h:111
ColourMapper m_mapper
Definition: ColourScale.h:117
Map values within a range onto a set of colours, with a given distribution (linear, log etc) and optional colourmap rotation.
Definition: ColourScale.h:34
bool inverted
Whether the colour scale should be mapped inverted.
Definition: ColourScale.h:55
double maxValue
Maximum value in source range.
Definition: ColourScale.h:52
int colourMap
A colour map index as used by ColourMapper.
Definition: ColourScale.h:43
double m_mappedMax
Definition: ColourScale.h:119
double gain
Gain to apply before thresholding, mapping, and clamping.
Definition: ColourScale.h:62
double minValue
Minimum value in source range.
Definition: ColourScale.h:49
A class for mapping intensity values onto various colour maps.
Definition: ColourMapper.h:27
double m_mappedMin
Definition: ColourScale.h:118
ColourScaleType scaleType
Distribution for the scale.
Definition: ColourScale.h:46
ColourScaleType
Definition: ColourScale.h:21
double multiple
Multiple to apply after thresholding and mapping.
Definition: ColourScale.h:69
Parameters m_params
Definition: ColourScale.h:116