annotate layer/SingleColourLayer.h @ 1127:9fb8dfd7ce4c spectrogram-minor-refactor

Fix threshold in spectrogram -- it wasn't working in the last release. There is a new protocol for this. Formerly the threshold parameter had a range from -50dB to 0 with the default at -50, and -50 treated internally as "no threshold". However, there was a hardcoded, hidden internal threshold for spectrogram colour mapping at -80dB with anything below this being rounded to zero. Now the threshold parameter has range -81 to -1 with the default at -80, -81 is treated internally as "no threshold", and there is no hidden internal threshold. So the default behaviour is the same as before, an effective -80dB threshold, but it is now possible to change this in both directions. Sessions reloaded from prior versions may look slightly different because, if the session says there should be no threshold, there will now actually be no threshold instead of having the hidden internal one. Still need to do something in the UI to make it apparent that the -81dB setting removes the threshold entirely. This is at least no worse than the previous, also obscured, magic -50dB setting.
author Chris Cannam
date Mon, 01 Aug 2016 16:21:01 +0100
parents a5488775f880
children a34a2a25907c
rev   line source
Chris@287 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@287 2
Chris@287 3 /*
Chris@287 4 Sonic Visualiser
Chris@287 5 An audio file viewer and annotation editor.
Chris@287 6 Centre for Digital Music, Queen Mary, University of London.
Chris@287 7 This file copyright 2007 QMUL.
Chris@287 8
Chris@287 9 This program is free software; you can redistribute it and/or
Chris@287 10 modify it under the terms of the GNU General Public License as
Chris@287 11 published by the Free Software Foundation; either version 2 of the
Chris@287 12 License, or (at your option) any later version. See the file
Chris@287 13 COPYING included with this distribution for more information.
Chris@287 14 */
Chris@287 15
Chris@287 16 #ifndef _SINGLE_COLOUR_LAYER_H_
Chris@287 17 #define _SINGLE_COLOUR_LAYER_H_
Chris@287 18
Chris@287 19 #include "Layer.h"
Chris@287 20 #include <QColor>
Chris@287 21 #include <vector>
Chris@293 22 #include <map>
Chris@287 23
Chris@287 24 class SingleColourLayer : public Layer
Chris@287 25 {
Chris@397 26 Q_OBJECT
Chris@397 27
Chris@287 28 public:
Chris@615 29 /**
Chris@615 30 * Set the colour used to draw primary items in the layer. The
Chris@615 31 * colour value is a colour database index as returned by
Chris@615 32 * ColourDatabase::getColourIndex().
Chris@615 33 */
Chris@287 34 virtual void setBaseColour(int);
Chris@615 35
Chris@615 36 /**
Chris@615 37 * Retrieve the current primary drawing colour, as a
Chris@615 38 * ColourDatabase index value.
Chris@615 39 */
Chris@287 40 virtual int getBaseColour() const;
Chris@287 41
Chris@615 42 /**
Chris@615 43 * Return true if the layer currently has a dark colour on a light
Chris@615 44 * background, false if it has a light colour on a dark
Chris@615 45 * background.
Chris@615 46 */
Chris@287 47 virtual bool hasLightBackground() const;
Chris@287 48
Chris@615 49 /**
Chris@615 50 * Implements Layer::getLayerColourSignificance()
Chris@615 51 */
Chris@287 52 virtual ColourSignificance getLayerColourSignificance() const {
Chris@287 53 return ColourDistinguishes;
Chris@287 54 }
Chris@287 55
Chris@299 56 virtual QPixmap getLayerPresentationPixmap(QSize size) const;
Chris@299 57
Chris@287 58 virtual PropertyList getProperties() const;
Chris@287 59 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@287 60 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@287 61 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@287 62 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@287 63 int *min, int *max, int *deflt) const;
Chris@287 64 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@287 65 int value) const;
Chris@287 66 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@287 67 virtual void setProperty(const PropertyName &, int value);
Chris@287 68
Chris@316 69 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 70 QString extraAttributes = "") const;
Chris@287 71
Chris@287 72 virtual void setProperties(const QXmlAttributes &attributes);
Chris@287 73
Chris@919 74 virtual void setDefaultColourFor(LayerGeometryProvider *v);
Chris@287 75
Chris@287 76 protected:
Chris@287 77 SingleColourLayer();
jakob@768 78 virtual ~SingleColourLayer();
Chris@287 79
Chris@287 80 virtual QColor getBaseQColor() const;
Chris@919 81 virtual QColor getBackgroundQColor(LayerGeometryProvider *v) const;
Chris@919 82 virtual QColor getForegroundQColor(LayerGeometryProvider *v) const;
Chris@919 83 std::vector<QColor> getPartialShades(LayerGeometryProvider *v) const;
Chris@287 84
Chris@287 85 virtual void flagBaseColourChanged() { }
Chris@287 86 virtual int getDefaultColourHint(bool /* darkBackground */,
Chris@287 87 bool & /* impose */) { return -1; }
Chris@287 88
Chris@293 89 typedef std::map<int, int> ColourRefCount;
Chris@293 90 static ColourRefCount m_colourRefCount;
Chris@287 91
Chris@287 92 int m_colour;
Chris@294 93 bool m_colourExplicitlySet;
Chris@366 94 bool m_defaultColourSet;
jakob@768 95
jakob@768 96 private:
jakob@768 97 void refColor();
jakob@768 98 void unrefColor();
Chris@287 99 };
Chris@287 100
Chris@287 101 #endif