svcore  1.9
Dense3DModelPeakCache.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 2009 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 _DENSE_3D_MODEL_PEAK_CACHE_H_
00017 #define _DENSE_3D_MODEL_PEAK_CACHE_H_
00018 
00019 #include "DenseThreeDimensionalModel.h"
00020 #include "EditableDenseThreeDimensionalModel.h"
00021 #include "base/ResizeableBitset.h"
00022 
00023 class Dense3DModelPeakCache : public DenseThreeDimensionalModel
00024 {
00025     Q_OBJECT
00026 
00027 public:
00028     Dense3DModelPeakCache(DenseThreeDimensionalModel *source,
00029                           int columnsPerPeak);
00030     ~Dense3DModelPeakCache();
00031 
00032     virtual bool isOK() const {
00033         return m_source && m_source->isOK(); 
00034     }
00035 
00036     virtual int getSampleRate() const {
00037         return m_source->getSampleRate();
00038     }
00039 
00040     virtual int getStartFrame() const {
00041         return m_source->getStartFrame();
00042     }
00043 
00044     virtual int getEndFrame() const {
00045         return m_source->getEndFrame();
00046     }
00047 
00048     virtual Model *clone() const {
00049         return new Dense3DModelPeakCache(m_source, m_resolution);
00050     }
00051     
00052     virtual int getResolution() const {
00053         return m_source->getResolution() * m_resolution;
00054     }
00055 
00056     virtual int getWidth() const {
00057         return m_source->getWidth() / m_resolution + 1;
00058     }
00059 
00060     virtual int getHeight() const {
00061         return m_source->getHeight();
00062     }
00063 
00064     virtual float getMinimumLevel() const {
00065         return m_source->getMinimumLevel();
00066     }
00067 
00068     virtual float getMaximumLevel() const {
00069         return m_source->getMaximumLevel();
00070     }
00071 
00072     virtual bool isColumnAvailable(int column) const;
00073 
00074     virtual Column getColumn(int column) const;
00075 
00076     virtual float getValueAt(int column, int n) const;
00077 
00078     virtual QString getBinName(int n) const {
00079         return m_source->getBinName(n);
00080     }
00081 
00082     virtual bool shouldUseLogValueScale() const {
00083         return m_source->shouldUseLogValueScale();
00084     }
00085 
00086     QString getTypeName() const { return tr("Dense 3-D Peak Cache"); }
00087 
00088     virtual int getCompletion() const {
00089         return m_source->getCompletion();
00090     }
00091 
00092 protected slots:
00093     void sourceModelChanged();
00094     void sourceModelAboutToBeDeleted();
00095 
00096 private:
00097     DenseThreeDimensionalModel *m_source;
00098     mutable EditableDenseThreeDimensionalModel *m_cache;
00099     mutable ResizeableBitset m_coverage;
00100     int m_resolution;
00101 
00102     bool haveColumn(int column) const;
00103     void fillColumn(int column) const;
00104 };
00105 
00106 
00107 #endif