annotate layer/Colour3DPlotLayer.h @ 282:d9319859a4cf tip

(none)
author benoitrigolleau
date Fri, 31 Oct 2008 11:00:24 +0000
parents fc9323a41f5a
children
rev   line source
lbajardsilogic@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
lbajardsilogic@0 2
lbajardsilogic@0 3 /*
lbajardsilogic@0 4 Sonic Visualiser
lbajardsilogic@0 5 An audio file viewer and annotation editor.
lbajardsilogic@0 6 Centre for Digital Music, Queen Mary, University of London.
lbajardsilogic@0 7 This file copyright 2006 Chris Cannam and QMUL.
lbajardsilogic@0 8
lbajardsilogic@0 9 This program is free software; you can redistribute it and/or
lbajardsilogic@0 10 modify it under the terms of the GNU General Public License as
lbajardsilogic@0 11 published by the Free Software Foundation; either version 2 of the
lbajardsilogic@0 12 License, or (at your option) any later version. See the file
lbajardsilogic@0 13 COPYING included with this distribution for more information.
lbajardsilogic@0 14 */
lbajardsilogic@0 15
lbajardsilogic@0 16 #ifndef _COLOUR_3D_PLOT_H_
lbajardsilogic@0 17 #define _COLOUR_3D_PLOT_H_
lbajardsilogic@0 18
lbajardsilogic@0 19 #include "SliceableLayer.h"
lbajardsilogic@0 20
lbajardsilogic@0 21 #include "data/model/DenseThreeDimensionalModel.h"
lbajardsilogic@0 22
lbajardsilogic@0 23 class View;
lbajardsilogic@0 24 class QPainter;
lbajardsilogic@0 25 class QImage;
lbajardsilogic@0 26
lbajardsilogic@0 27 /**
lbajardsilogic@0 28 * This is a view that displays dense 3-D data (time, some sort of
lbajardsilogic@0 29 * binned y-axis range, value) as a colour plot with value mapped to
lbajardsilogic@0 30 * colour range. Its source is a DenseThreeDimensionalModel.
lbajardsilogic@0 31 *
lbajardsilogic@0 32 * This was the original implementation for the spectrogram view, but
lbajardsilogic@0 33 * it was replaced with a more efficient implementation that derived
lbajardsilogic@0 34 * the spectrogram itself from a DenseTimeValueModel instead of using
lbajardsilogic@0 35 * a three-dimensional model. This class is retained in case it
lbajardsilogic@0 36 * becomes useful, but it will probably need some cleaning up if it's
lbajardsilogic@0 37 * ever actually used.
lbajardsilogic@0 38 */
lbajardsilogic@0 39
lbajardsilogic@0 40 class Colour3DPlotLayer : public SliceableLayer
lbajardsilogic@0 41 {
lbajardsilogic@0 42 Q_OBJECT
lbajardsilogic@0 43
lbajardsilogic@0 44 public:
lbajardsilogic@0 45 Colour3DPlotLayer();
lbajardsilogic@0 46 ~Colour3DPlotLayer();
lbajardsilogic@0 47
lbajardsilogic@0 48 virtual const ZoomConstraint *getZoomConstraint() const {
lbajardsilogic@0 49 return m_model ? m_model->getZoomConstraint() : 0;
lbajardsilogic@0 50 }
lbajardsilogic@0 51 virtual const Model *getModel() const { return m_model; }
lbajardsilogic@0 52 virtual void paint(View *v, QPainter &paint, QRect rect) const;
lbajardsilogic@0 53
lbajardsilogic@0 54 virtual int getVerticalScaleWidth(View *v, QPainter &) const;
lbajardsilogic@0 55 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
lbajardsilogic@0 56
lbajardsilogic@0 57 virtual QString getFeatureDescription(View *v, QPoint &) const;
lbajardsilogic@0 58
lbajardsilogic@0 59 virtual bool snapToFeatureFrame(View *v, int &frame,
lbajardsilogic@0 60 size_t &resolution,
lbajardsilogic@0 61 SnapType snap) const;
lbajardsilogic@0 62
lbajardsilogic@0 63 virtual bool isLayerScrollable(const View *v) const;
lbajardsilogic@0 64
lbajardsilogic@0 65 virtual bool isLayerColourSignificant() const { return true; }
lbajardsilogic@0 66
lbajardsilogic@0 67 void setModel(const DenseThreeDimensionalModel *model);
lbajardsilogic@0 68
lbajardsilogic@0 69 virtual int getCompletion(View *) const { return m_model->getCompletion(); }
lbajardsilogic@0 70
lbajardsilogic@0 71 virtual bool getValueExtents(float &, float &, bool &, QString &) const { return false; }
lbajardsilogic@0 72
lbajardsilogic@0 73 virtual PropertyList getProperties() const;
lbajardsilogic@0 74 virtual PropertyType getPropertyType(const PropertyName &) const;
lbajardsilogic@0 75 virtual QString getPropertyLabel(const PropertyName &) const;
lbajardsilogic@0 76 virtual QString getPropertyGroupName(const PropertyName &) const;
lbajardsilogic@0 77 virtual int getPropertyRangeAndValue(const PropertyName &,
lbajardsilogic@0 78 int *min, int *max, int *deflt) const;
lbajardsilogic@0 79 virtual QString getPropertyValueLabel(const PropertyName &,
lbajardsilogic@0 80 int value) const;
lbajardsilogic@0 81 virtual void setProperty(const PropertyName &, int value);
lbajardsilogic@0 82 virtual void setProperties(const QXmlAttributes &);
lbajardsilogic@0 83
lbajardsilogic@0 84 enum ColourScale { LinearScale, LogScale, PlusMinusOneScale };
lbajardsilogic@0 85
lbajardsilogic@0 86 void setColourScale(ColourScale);
lbajardsilogic@0 87 ColourScale getColourScale() const { return m_colourScale; }
lbajardsilogic@0 88
lbajardsilogic@0 89 void setColourMap(int map);
lbajardsilogic@0 90 int getColourMap() const;
lbajardsilogic@0 91
lbajardsilogic@0 92 void setNormalizeColumns(bool n);
lbajardsilogic@0 93 bool getNormalizeColumns() const;
lbajardsilogic@0 94
lbajardsilogic@0 95 void setNormalizeVisibleArea(bool n);
lbajardsilogic@0 96 bool getNormalizeVisibleArea() const;
lbajardsilogic@0 97
lbajardsilogic@0 98 virtual const Model *getSliceableModel() const { return m_model; }
lbajardsilogic@0 99
lbajardsilogic@0 100 virtual QString toXmlString(QString indent = "",
lbajardsilogic@0 101 QString extraAttributes = "") const;
lbajardsilogic@0 102
lbajardsilogic@0 103 protected slots:
lbajardsilogic@0 104 void cacheInvalid();
lbajardsilogic@0 105 void cacheInvalid(size_t startFrame, size_t endFrame);
lbajardsilogic@0 106
lbajardsilogic@0 107 protected:
lbajardsilogic@0 108 const DenseThreeDimensionalModel *m_model; // I do not own this
lbajardsilogic@0 109
lbajardsilogic@0 110 mutable QImage *m_cache;
lbajardsilogic@0 111 mutable size_t m_cacheStart;
lbajardsilogic@0 112
lbajardsilogic@0 113 ColourScale m_colourScale;
lbajardsilogic@0 114 int m_colourMap;
lbajardsilogic@0 115 bool m_normalizeColumns;
lbajardsilogic@0 116 bool m_normalizeVisibleArea;
lbajardsilogic@0 117
lbajardsilogic@0 118 void getColumn(size_t col, DenseThreeDimensionalModel::Column &) const;
lbajardsilogic@0 119
lbajardsilogic@0 120 virtual int getColourScaleWidth(QPainter &) const;
lbajardsilogic@0 121 virtual void fillCache(size_t firstBin, size_t lastBin) const;
lbajardsilogic@0 122 virtual void paintDense(View *v, QPainter &paint, QRect rect) const;
lbajardsilogic@0 123 };
lbajardsilogic@0 124
lbajardsilogic@0 125 #endif