ColourMapper.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-2007 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 SV_COLOUR_MAPPER_H
17 #define SV_COLOUR_MAPPER_H
18 
19 #include <QObject>
20 #include <QColor>
21 #include <QString>
22 #include <QPixmap>
23 
28 {
29 public:
30  ColourMapper(int map,
31  bool inverted,
32  double minValue,
33  double maxValue);
34  ~ColourMapper();
35 
36  ColourMapper(const ColourMapper &) =default;
37  ColourMapper &operator=(const ColourMapper &) =default;
38 
39  enum ColourMap {
46  Ice,
55  };
56 
57  int getMap() const { return m_map; }
58  bool isInverted() const { return m_inverted; }
59  double getMinValue() const { return m_min; }
60  double getMaxValue() const { return m_max; }
61 
65  static int getColourMapCount();
66 
71  static QString getColourMapLabel(int n);
72 
78  static QString getColourMapId(int n);
79 
84  static int getColourMapById(QString id);
85 
99  static int getBackwardCompatibilityColourMap(int n);
100 
106  QColor map(double value) const;
107 
112  QColor getContrastingColour() const;
113 
120  bool hasLightBackground() const;
121 
126  QPixmap getExamplePixmap(QSize size) const;
127 
128 protected:
129  int m_map;
131  double m_min;
132  double m_max;
133 };
134 
135 #endif
136 
int getMap() const
Definition: ColourMapper.h:57
static int getColourMapCount()
Return the number of known colour maps.
static int getBackwardCompatibilityColourMap(int n)
Older versions of colour-handling code save and reload colour maps by numerical index and can&#39;t prope...
double getMinValue() const
Definition: ColourMapper.h:59
static QString getColourMapLabel(int n)
Return a human-readable label for the colour map with the given index.
QPixmap getExamplePixmap(QSize size) const
Return a pixmap of the given size containing a preview swatch for the colour map. ...
bool hasLightBackground() const
Return true if the colour map is intended to be placed over a light background, false otherwise...
static int getColourMapById(QString id)
Return the index for the colour map with the given machine-readable id string, or -1 if the id is not...
double getMaxValue() const
Definition: ColourMapper.h:60
QColor map(double value) const
Map the given value to a colour.
A class for mapping intensity values onto various colour maps.
Definition: ColourMapper.h:27
ColourMapper & operator=(const ColourMapper &)=default
static QString getColourMapId(int n)
Return a machine-readable id string for the colour map with the given index.
ColourMapper(int map, bool inverted, double minValue, double maxValue)
QColor getContrastingColour() const
Return a colour that contrasts somewhat with the colours in the map, so as to be used for cursors etc...
bool isInverted() const
Definition: ColourMapper.h:58