annotate layer/SingleColourLayer.h @ 1534:bfd8b22fd67c

Fix #1904 Scrolling colour 3d plot does not always work when in View normalisation mode. We shouldn't imagine we've just invalidated the cache if the truth is that we've only just created the renderer
author Chris Cannam
date Wed, 09 Oct 2019 13:45:17 +0100
parents a18e78b9c78b
children
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@1315 16 #ifndef SV_SINGLE_COLOUR_LAYER_H
Chris@1315 17 #define SV_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@1406 47 bool hasLightBackground() const override;
Chris@287 48
Chris@615 49 /**
Chris@615 50 * Implements Layer::getLayerColourSignificance()
Chris@615 51 */
Chris@1406 52 ColourSignificance getLayerColourSignificance() const override {
Chris@287 53 return ColourDistinguishes;
Chris@287 54 }
Chris@287 55
Chris@1406 56 QPixmap getLayerPresentationPixmap(QSize size) const override;
Chris@299 57
Chris@1406 58 PropertyList getProperties() const override;
Chris@1406 59 QString getPropertyLabel(const PropertyName &) const override;
Chris@1406 60 PropertyType getPropertyType(const PropertyName &) const override;
Chris@1406 61 QString getPropertyGroupName(const PropertyName &) const override;
Chris@1406 62 int getPropertyRangeAndValue(const PropertyName &,
Chris@1406 63 int *min, int *max, int *deflt) const override;
Chris@1406 64 QString getPropertyValueLabel(const PropertyName &,
Chris@1406 65 int value) const override;
Chris@1406 66 RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override;
Chris@1406 67 void setProperty(const PropertyName &, int value) override;
Chris@287 68
Chris@1406 69 void toXml(QTextStream &stream, QString indent = "",
Chris@1406 70 QString extraAttributes = "") const override;
Chris@287 71
Chris@1406 72 void setProperties(const QXmlAttributes &attributes) override;
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