annotate layer/Colour3DPlotLayer.h @ 509:f8b98f63f200

* Add Absolute plot scale, in colour 3d plot layer only for the moment
author Chris Cannam
date Wed, 25 Feb 2009 17:41:34 +0000
parents 3f4b10e76ccd
children 0bd0b517e795
rev   line source
Chris@58 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@59 4 Sonic Visualiser
Chris@59 5 An audio file viewer and annotation editor.
Chris@59 6 Centre for Digital Music, Queen Mary, University of London.
Chris@182 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@0 8
Chris@59 9 This program is free software; you can redistribute it and/or
Chris@59 10 modify it under the terms of the GNU General Public License as
Chris@59 11 published by the Free Software Foundation; either version 2 of the
Chris@59 12 License, or (at your option) any later version. See the file
Chris@59 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _COLOUR_3D_PLOT_H_
Chris@0 17 #define _COLOUR_3D_PLOT_H_
Chris@0 18
Chris@193 19 #include "SliceableLayer.h"
Chris@0 20
Chris@128 21 #include "data/model/DenseThreeDimensionalModel.h"
Chris@0 22
Chris@0 23 class View;
Chris@0 24 class QPainter;
Chris@0 25 class QImage;
Chris@0 26
Chris@0 27 /**
Chris@0 28 * This is a view that displays dense 3-D data (time, some sort of
Chris@0 29 * binned y-axis range, value) as a colour plot with value mapped to
Chris@0 30 * colour range. Its source is a DenseThreeDimensionalModel.
Chris@0 31 *
Chris@0 32 * This was the original implementation for the spectrogram view, but
Chris@0 33 * it was replaced with a more efficient implementation that derived
Chris@0 34 * the spectrogram itself from a DenseTimeValueModel instead of using
Chris@0 35 * a three-dimensional model. This class is retained in case it
Chris@0 36 * becomes useful, but it will probably need some cleaning up if it's
Chris@0 37 * ever actually used.
Chris@0 38 */
Chris@0 39
Chris@193 40 class Colour3DPlotLayer : public SliceableLayer
Chris@0 41 {
Chris@0 42 Q_OBJECT
Chris@0 43
Chris@0 44 public:
Chris@44 45 Colour3DPlotLayer();
Chris@0 46 ~Colour3DPlotLayer();
Chris@0 47
Chris@156 48 virtual const ZoomConstraint *getZoomConstraint() const {
Chris@156 49 return m_model ? m_model->getZoomConstraint() : 0;
Chris@156 50 }
Chris@0 51 virtual const Model *getModel() const { return m_model; }
Chris@44 52 virtual void paint(View *v, QPainter &paint, QRect rect) const;
Chris@0 53
Chris@44 54 virtual int getVerticalScaleWidth(View *v, QPainter &) const;
Chris@44 55 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
Chris@25 56
Chris@44 57 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@25 58
Chris@44 59 virtual bool snapToFeatureFrame(View *v, int &frame,
Chris@28 60 size_t &resolution,
Chris@28 61 SnapType snap) const;
Chris@24 62
Chris@475 63 virtual void setLayerDormant(const View *v, bool dormant);
Chris@475 64
Chris@44 65 virtual bool isLayerScrollable(const View *v) const;
Chris@25 66
Chris@287 67 virtual ColourSignificance getLayerColourSignificance() const {
Chris@287 68 return ColourHasMeaningfulValue;
Chris@287 69 }
Chris@183 70
Chris@0 71 void setModel(const DenseThreeDimensionalModel *model);
Chris@0 72
Chris@115 73 virtual int getCompletion(View *) const { return m_model->getCompletion(); }
Chris@24 74
Chris@0 75 virtual PropertyList getProperties() const;
Chris@0 76 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@159 77 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@346 78 virtual QString getPropertyIconName(const PropertyName &) const;
Chris@159 79 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@0 80 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@216 81 int *min, int *max, int *deflt) const;
Chris@0 82 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@0 83 int value) const;
Chris@0 84 virtual void setProperty(const PropertyName &, int value);
Chris@197 85 virtual void setProperties(const QXmlAttributes &);
Chris@11 86
Chris@509 87 enum ColourScale {
Chris@509 88 LinearScale,
Chris@509 89 LogScale,
Chris@509 90 PlusMinusOneScale,
Chris@509 91 AbsoluteScale
Chris@509 92 };
Chris@159 93
Chris@159 94 void setColourScale(ColourScale);
Chris@159 95 ColourScale getColourScale() const { return m_colourScale; }
Chris@159 96
Chris@197 97 void setColourMap(int map);
Chris@197 98 int getColourMap() const;
Chris@197 99
Chris@197 100 void setNormalizeColumns(bool n);
Chris@197 101 bool getNormalizeColumns() const;
Chris@197 102
Chris@197 103 void setNormalizeVisibleArea(bool n);
Chris@197 104 bool getNormalizeVisibleArea() const;
Chris@197 105
Chris@357 106 void setInvertVertical(bool i);
Chris@357 107 bool getInvertVertical() const;
Chris@357 108
Chris@465 109 void setOpaque(bool i);
Chris@465 110 bool getOpaque() const;
Chris@465 111
Chris@444 112 virtual bool getValueExtents(float &min, float &max,
Chris@444 113 bool &logarithmic, QString &unit) const;
Chris@444 114
Chris@444 115 virtual bool getDisplayExtents(float &min, float &max) const;
Chris@444 116 virtual bool setDisplayExtents(float min, float max);
Chris@444 117
Chris@444 118 virtual int getVerticalZoomSteps(int &defaultStep) const;
Chris@444 119 virtual int getCurrentVerticalZoomStep() const;
Chris@444 120 virtual void setVerticalZoomStep(int);
Chris@444 121 virtual RangeMapper *getNewVerticalZoomRangeMapper() const;
Chris@444 122
Chris@193 123 virtual const Model *getSliceableModel() const { return m_model; }
Chris@193 124
Chris@316 125 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 126 QString extraAttributes = "") const;
Chris@197 127
Chris@0 128 protected slots:
Chris@0 129 void cacheInvalid();
Chris@0 130 void cacheInvalid(size_t startFrame, size_t endFrame);
Chris@461 131 void modelChanged();
Chris@461 132 void modelChanged(size_t, size_t);
Chris@0 133
Chris@0 134 protected:
Chris@0 135 const DenseThreeDimensionalModel *m_model; // I do not own this
Chris@0 136
Chris@0 137 mutable QImage *m_cache;
Chris@469 138 mutable QImage *m_peaksCache;
Chris@461 139 mutable size_t m_cacheValidStart;
Chris@461 140 mutable size_t m_cacheValidEnd;
Chris@98 141
Chris@159 142 ColourScale m_colourScale;
Chris@461 143 bool m_colourScaleSet;
Chris@197 144 int m_colourMap;
Chris@197 145 bool m_normalizeColumns;
Chris@197 146 bool m_normalizeVisibleArea;
Chris@357 147 bool m_invertVertical;
Chris@465 148 bool m_opaque;
Chris@469 149 size_t m_peakResolution;
Chris@197 150
Chris@444 151 int m_miny;
Chris@444 152 int m_maxy;
Chris@444 153
Chris@467 154 DenseThreeDimensionalModel::Column getColumn(size_t col) const;
Chris@159 155
Chris@469 156 int getColourScaleWidth(QPainter &) const;
Chris@469 157 void fillCache(size_t firstBin, size_t lastBin) const;
Chris@469 158 void paintDense(View *v, QPainter &paint, QRect rect) const;
Chris@472 159 void paintSmooth(View *v, QPainter &paint, QRect rect) const;
Chris@0 160 };
Chris@0 161
Chris@0 162 #endif