comparison layer/WaveformLayer.h @ 287:cd2492c5fe45

* Add SingleColourLayer to manage colours for layers that have a single predominant colour (i.e. most of them).
author Chris Cannam
date Thu, 12 Jul 2007 16:14:59 +0000
parents 9dd432665059
children c0b9eec70639
comparison
equal deleted inserted replaced
286:7554ae119882 287:cd2492c5fe45
15 15
16 #ifndef _WAVEFORM_LAYER_H_ 16 #ifndef _WAVEFORM_LAYER_H_
17 #define _WAVEFORM_LAYER_H_ 17 #define _WAVEFORM_LAYER_H_
18 18
19 #include <QRect> 19 #include <QRect>
20 #include <QColor> 20
21 21 #include "SingleColourLayer.h"
22 #include "Layer.h"
23 22
24 #include "data/model/RangeSummarisableTimeValueModel.h" 23 #include "data/model/RangeSummarisableTimeValueModel.h"
25 24
26 class View; 25 class View;
27 class QPainter; 26 class QPainter;
28 class QPixmap; 27 class QPixmap;
29 28
30 class WaveformLayer : public Layer 29 class WaveformLayer : public SingleColourLayer
31 { 30 {
32 Q_OBJECT 31 Q_OBJECT
33 32
34 public: 33 public:
35 WaveformLayer(); 34 WaveformLayer();
41 virtual const Model *getModel() const { return m_model; } 40 virtual const Model *getModel() const { return m_model; }
42 virtual void paint(View *v, QPainter &paint, QRect rect) const; 41 virtual void paint(View *v, QPainter &paint, QRect rect) const;
43 42
44 virtual QString getFeatureDescription(View *v, QPoint &) const; 43 virtual QString getFeatureDescription(View *v, QPoint &) const;
45 44
45 virtual ColourSignificance getLayerColourSignificance() const {
46 return ColourAndBackgroundSignificant;
47 }
48
46 virtual int getVerticalScaleWidth(View *v, QPainter &) const; 49 virtual int getVerticalScaleWidth(View *v, QPainter &) const;
47 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const; 50 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
48
49 virtual bool hasLightBackground() const;
50 51
51 void setModel(const RangeSummarisableTimeValueModel *model); 52 void setModel(const RangeSummarisableTimeValueModel *model);
52 53
53 virtual PropertyList getProperties() const; 54 virtual PropertyList getProperties() const;
54 virtual QString getPropertyLabel(const PropertyName &) const; 55 virtual QString getPropertyLabel(const PropertyName &) const;
74 */ 75 */
75 void setAutoNormalize(bool); 76 void setAutoNormalize(bool);
76 bool getAutoNormalize() const { return m_autoNormalize; } 77 bool getAutoNormalize() const { return m_autoNormalize; }
77 78
78 /** 79 /**
79 * Set the basic display colour for waveforms. The parameter is
80 * a ColourDatabase index.
81 *
82 * The default is the first colour in the database.
83 *!!! NB should default to white if the associated View !hasLightBackground()
84 */
85 void setBaseColour(int);
86 int getBaseColour() const;
87
88 /**
89 * Set whether to display mean values as a lighter-coloured area 80 * Set whether to display mean values as a lighter-coloured area
90 * beneath the peaks. Rendering will be slightly faster without 81 * beneath the peaks. Rendering will be slightly faster without
91 * but arguably prettier with. 82 * but arguably prettier with.
92 * 83 *
93 * The default is to display means. 84 * The default is to display means.
189 float &diff, QString &unit) const; 180 float &diff, QString &unit) const;
190 181
191 virtual QString toXmlString(QString indent = "", 182 virtual QString toXmlString(QString indent = "",
192 QString extraAttributes = "") const; 183 QString extraAttributes = "") const;
193 184
194 void setProperties(const QXmlAttributes &attributes); 185 virtual void setProperties(const QXmlAttributes &attributes);
195 186
196 virtual int getVerticalZoomSteps(int &defaultStep) const; 187 virtual int getVerticalZoomSteps(int &defaultStep) const;
197 virtual int getCurrentVerticalZoomStep() const; 188 virtual int getCurrentVerticalZoomStep() const;
198 virtual void setVerticalZoomStep(int); 189 virtual void setVerticalZoomStep(int);
199 190
208 199
209 int getYForValue(const View *v, float value, size_t channel) const; 200 int getYForValue(const View *v, float value, size_t channel) const;
210 201
211 float getValueForY(const View *v, int y, size_t &channel) const; 202 float getValueForY(const View *v, int y, size_t &channel) const;
212 203
204 virtual void flagBaseColourChanged() { m_cacheValid = false; }
205
213 float m_gain; 206 float m_gain;
214 bool m_autoNormalize; 207 bool m_autoNormalize;
215 int m_colour;
216 bool m_showMeans; 208 bool m_showMeans;
217 bool m_greyscale; 209 bool m_greyscale;
218 ChannelMode m_channelMode; 210 ChannelMode m_channelMode;
219 int m_channel; 211 int m_channel;
220 Scale m_scale; 212 Scale m_scale;