lbajardsilogic@0: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ lbajardsilogic@0: lbajardsilogic@0: /* lbajardsilogic@0: Sonic Visualiser lbajardsilogic@0: An audio file viewer and annotation editor. lbajardsilogic@0: Centre for Digital Music, Queen Mary, University of London. lbajardsilogic@0: This file copyright 2006 Chris Cannam and QMUL. lbajardsilogic@0: lbajardsilogic@0: This program is free software; you can redistribute it and/or lbajardsilogic@0: modify it under the terms of the GNU General Public License as lbajardsilogic@0: published by the Free Software Foundation; either version 2 of the lbajardsilogic@0: License, or (at your option) any later version. See the file lbajardsilogic@0: COPYING included with this distribution for more information. lbajardsilogic@0: */ lbajardsilogic@0: lbajardsilogic@0: #ifndef _COLOUR_3D_PLOT_H_ lbajardsilogic@0: #define _COLOUR_3D_PLOT_H_ lbajardsilogic@0: lbajardsilogic@0: #include "SliceableLayer.h" lbajardsilogic@0: lbajardsilogic@0: #include "data/model/DenseThreeDimensionalModel.h" lbajardsilogic@0: lbajardsilogic@0: class View; lbajardsilogic@0: class QPainter; lbajardsilogic@0: class QImage; lbajardsilogic@0: lbajardsilogic@0: /** lbajardsilogic@0: * This is a view that displays dense 3-D data (time, some sort of lbajardsilogic@0: * binned y-axis range, value) as a colour plot with value mapped to lbajardsilogic@0: * colour range. Its source is a DenseThreeDimensionalModel. lbajardsilogic@0: * lbajardsilogic@0: * This was the original implementation for the spectrogram view, but lbajardsilogic@0: * it was replaced with a more efficient implementation that derived lbajardsilogic@0: * the spectrogram itself from a DenseTimeValueModel instead of using lbajardsilogic@0: * a three-dimensional model. This class is retained in case it lbajardsilogic@0: * becomes useful, but it will probably need some cleaning up if it's lbajardsilogic@0: * ever actually used. lbajardsilogic@0: */ lbajardsilogic@0: lbajardsilogic@0: class Colour3DPlotLayer : public SliceableLayer lbajardsilogic@0: { lbajardsilogic@0: Q_OBJECT lbajardsilogic@0: lbajardsilogic@0: public: lbajardsilogic@0: Colour3DPlotLayer(); lbajardsilogic@0: ~Colour3DPlotLayer(); lbajardsilogic@0: lbajardsilogic@0: virtual const ZoomConstraint *getZoomConstraint() const { lbajardsilogic@0: return m_model ? m_model->getZoomConstraint() : 0; lbajardsilogic@0: } lbajardsilogic@0: virtual const Model *getModel() const { return m_model; } lbajardsilogic@0: virtual void paint(View *v, QPainter &paint, QRect rect) const; lbajardsilogic@0: lbajardsilogic@0: virtual int getVerticalScaleWidth(View *v, QPainter &) const; lbajardsilogic@0: virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const; lbajardsilogic@0: lbajardsilogic@0: virtual QString getFeatureDescription(View *v, QPoint &) const; lbajardsilogic@0: lbajardsilogic@0: virtual bool snapToFeatureFrame(View *v, int &frame, lbajardsilogic@0: size_t &resolution, lbajardsilogic@0: SnapType snap) const; lbajardsilogic@0: lbajardsilogic@0: virtual bool isLayerScrollable(const View *v) const; lbajardsilogic@0: lbajardsilogic@0: virtual bool isLayerColourSignificant() const { return true; } lbajardsilogic@0: lbajardsilogic@0: void setModel(const DenseThreeDimensionalModel *model); lbajardsilogic@0: lbajardsilogic@0: virtual int getCompletion(View *) const { return m_model->getCompletion(); } lbajardsilogic@0: lbajardsilogic@0: virtual bool getValueExtents(float &, float &, bool &, QString &) const { return false; } lbajardsilogic@0: lbajardsilogic@0: virtual PropertyList getProperties() const; lbajardsilogic@0: virtual PropertyType getPropertyType(const PropertyName &) const; lbajardsilogic@0: virtual QString getPropertyLabel(const PropertyName &) const; lbajardsilogic@0: virtual QString getPropertyGroupName(const PropertyName &) const; lbajardsilogic@0: virtual int getPropertyRangeAndValue(const PropertyName &, lbajardsilogic@0: int *min, int *max, int *deflt) const; lbajardsilogic@0: virtual QString getPropertyValueLabel(const PropertyName &, lbajardsilogic@0: int value) const; lbajardsilogic@0: virtual void setProperty(const PropertyName &, int value); lbajardsilogic@0: virtual void setProperties(const QXmlAttributes &); lbajardsilogic@0: lbajardsilogic@0: enum ColourScale { LinearScale, LogScale, PlusMinusOneScale }; lbajardsilogic@0: lbajardsilogic@0: void setColourScale(ColourScale); lbajardsilogic@0: ColourScale getColourScale() const { return m_colourScale; } lbajardsilogic@0: lbajardsilogic@0: void setColourMap(int map); lbajardsilogic@0: int getColourMap() const; lbajardsilogic@0: lbajardsilogic@0: void setNormalizeColumns(bool n); lbajardsilogic@0: bool getNormalizeColumns() const; lbajardsilogic@0: lbajardsilogic@0: void setNormalizeVisibleArea(bool n); lbajardsilogic@0: bool getNormalizeVisibleArea() const; lbajardsilogic@0: lbajardsilogic@0: virtual const Model *getSliceableModel() const { return m_model; } lbajardsilogic@0: lbajardsilogic@0: virtual QString toXmlString(QString indent = "", lbajardsilogic@0: QString extraAttributes = "") const; lbajardsilogic@0: lbajardsilogic@0: protected slots: lbajardsilogic@0: void cacheInvalid(); lbajardsilogic@0: void cacheInvalid(size_t startFrame, size_t endFrame); lbajardsilogic@0: lbajardsilogic@0: protected: lbajardsilogic@0: const DenseThreeDimensionalModel *m_model; // I do not own this lbajardsilogic@0: lbajardsilogic@0: mutable QImage *m_cache; lbajardsilogic@0: mutable size_t m_cacheStart; lbajardsilogic@0: lbajardsilogic@0: ColourScale m_colourScale; lbajardsilogic@0: int m_colourMap; lbajardsilogic@0: bool m_normalizeColumns; lbajardsilogic@0: bool m_normalizeVisibleArea; lbajardsilogic@0: lbajardsilogic@0: void getColumn(size_t col, DenseThreeDimensionalModel::Column &) const; lbajardsilogic@0: lbajardsilogic@0: virtual int getColourScaleWidth(QPainter &) const; lbajardsilogic@0: virtual void fillCache(size_t firstBin, size_t lastBin) const; lbajardsilogic@0: virtual void paintDense(View *v, QPainter &paint, QRect rect) const; lbajardsilogic@0: }; lbajardsilogic@0: lbajardsilogic@0: #endif