svgui  1.9
ColourMapper.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006-2007 Chris Cannam and QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _COLOUR_MAPPER_H_
00017 #define _COLOUR_MAPPER_H_
00018 
00019 #include <QObject>
00020 #include <QColor>
00021 #include <QString>
00022 
00027 class ColourMapper : public QObject
00028 {
00029     Q_OBJECT
00030 
00031 public:
00032     ColourMapper(int map, float minValue, float maxValue);
00033     virtual ~ColourMapper();
00034 
00035     enum StandardMap {
00036         DefaultColours,
00037         Sunset,
00038         WhiteOnBlack,
00039         BlackOnWhite,
00040         RedOnBlue,
00041         YellowOnBlack,
00042         BlueOnBlack,
00043         FruitSalad,
00044         Banded,
00045         Highlight,
00046         Printer,
00047         HighGain
00048     };
00049 
00050     int getMap() const { return m_map; }
00051     float getMinValue() const { return m_min; }
00052     float getMaxValue() const { return m_max; }
00053 
00054     static int getColourMapCount();
00055     static QString getColourMapName(int n);
00056 
00057     QColor map(float value) const;
00058 
00059     QColor getContrastingColour() const; // for cursors etc
00060     bool hasLightBackground() const;
00061 
00062 protected:
00063     int m_map;
00064     float m_min;
00065     float m_max;
00066 };
00067 
00068 #endif
00069