Colour3DPlotLayer.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam and QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _COLOUR_3D_PLOT_H_
00017 #define _COLOUR_3D_PLOT_H_
00018 
00019 #include "SliceableLayer.h"
00020 
00021 #include "data/model/DenseThreeDimensionalModel.h"
00022 
00023 class View;
00024 class QPainter;
00025 class QImage;
00026 
00040 class Colour3DPlotLayer : public SliceableLayer
00041 {
00042     Q_OBJECT
00043 
00044 public:
00045     Colour3DPlotLayer();
00046     ~Colour3DPlotLayer();
00047 
00048     virtual const ZoomConstraint *getZoomConstraint() const {
00049         return m_model ? m_model->getZoomConstraint() : 0;
00050     }
00051     virtual const Model *getModel() const { return m_model; }
00052     virtual void paint(View *v, QPainter &paint, QRect rect) const;
00053 
00054     virtual int getVerticalScaleWidth(View *v, QPainter &) const;
00055     virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
00056 
00057     virtual QString getFeatureDescription(View *v, QPoint &) const;
00058 
00059     virtual bool snapToFeatureFrame(View *v, int &frame, 
00060                                     size_t &resolution,
00061                                     SnapType snap) const;
00062 
00063     virtual bool isLayerScrollable(const View *v) const;
00064 
00065     virtual ColourSignificance getLayerColourSignificance() const {
00066         return ColourHasMeaningfulValue;
00067     }
00068 
00069     void setModel(const DenseThreeDimensionalModel *model);
00070 
00071     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
00072 
00073     virtual bool getValueExtents(float &, float &, bool &, QString &) const { return false; }
00074 
00075     virtual PropertyList getProperties() const;
00076     virtual PropertyType getPropertyType(const PropertyName &) const;
00077     virtual QString getPropertyLabel(const PropertyName &) const;
00078     virtual QString getPropertyIconName(const PropertyName &) const;
00079     virtual QString getPropertyGroupName(const PropertyName &) const;
00080     virtual int getPropertyRangeAndValue(const PropertyName &,
00081                                          int *min, int *max, int *deflt) const;
00082     virtual QString getPropertyValueLabel(const PropertyName &,
00083                                           int value) const;
00084     virtual void setProperty(const PropertyName &, int value);
00085     virtual void setProperties(const QXmlAttributes &);
00086     
00087     enum ColourScale { LinearScale, LogScale, PlusMinusOneScale };
00088 
00089     void setColourScale(ColourScale);
00090     ColourScale getColourScale() const { return m_colourScale; }
00091 
00092     void setColourMap(int map);
00093     int getColourMap() const;
00094 
00095     void setNormalizeColumns(bool n);
00096     bool getNormalizeColumns() const;
00097 
00098     void setNormalizeVisibleArea(bool n);
00099     bool getNormalizeVisibleArea() const;
00100 
00101     void setInvertVertical(bool i);
00102     bool getInvertVertical() const;
00103 
00104     virtual const Model *getSliceableModel() const { return m_model; }
00105 
00106     virtual void toXml(QTextStream &stream, QString indent = "",
00107                        QString extraAttributes = "") const;
00108 
00109 protected slots:
00110     void cacheInvalid();
00111     void cacheInvalid(size_t startFrame, size_t endFrame);
00112 
00113 protected:
00114     const DenseThreeDimensionalModel *m_model; // I do not own this
00115     
00116     mutable QImage *m_cache;
00117     mutable size_t m_cacheStart;
00118 
00119     ColourScale m_colourScale;
00120     int         m_colourMap;
00121     bool        m_normalizeColumns;
00122     bool        m_normalizeVisibleArea;
00123     bool        m_invertVertical;
00124 
00125     void getColumn(size_t col, DenseThreeDimensionalModel::Column &) const;
00126 
00127     virtual int getColourScaleWidth(QPainter &) const;
00128     virtual void fillCache(size_t firstBin, size_t lastBin) const;
00129     virtual void paintDense(View *v, QPainter &paint, QRect rect) const;
00130 };
00131 
00132 #endif

Generated on Wed Feb 20 15:45:25 2008 for SonicVisualiser by  doxygen 1.5.1