Chris@147: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@147: Chris@147: /* Chris@147: Sonic Visualiser Chris@147: An audio file viewer and annotation editor. Chris@147: Centre for Digital Music, Queen Mary, University of London. Chris@147: This file copyright 2006 Chris Cannam. Chris@147: Chris@147: This program is free software; you can redistribute it and/or Chris@147: modify it under the terms of the GNU General Public License as Chris@147: published by the Free Software Foundation; either version 2 of the Chris@147: License, or (at your option) any later version. See the file Chris@147: COPYING included with this distribution for more information. Chris@147: */ Chris@147: Chris@147: #ifndef _DENSE_THREE_DIMENSIONAL_MODEL_H_ Chris@147: #define _DENSE_THREE_DIMENSIONAL_MODEL_H_ Chris@147: Chris@150: #include "Model.h" Chris@147: #include "base/ZoomConstraint.h" Chris@147: Chris@147: #include Chris@147: #include Chris@147: Chris@179: class DenseThreeDimensionalModel : public Model Chris@147: { Chris@147: Q_OBJECT Chris@147: Chris@147: public: Chris@147: /** Chris@182: * Return the number of sample frames covered by each column of bins. Chris@147: */ Chris@152: virtual size_t getResolution() const = 0; Chris@147: Chris@147: /** Chris@182: * Return the number of columns of bins in the model. Chris@147: */ Chris@182: virtual size_t getWidth() const = 0; Chris@147: Chris@147: /** Chris@182: * Return the number of bins in each column. Chris@182: */ Chris@182: virtual size_t getHeight() const = 0; Chris@182: Chris@182: /** Chris@182: * Return the minimum permissible value in each bin. Chris@147: */ Chris@152: virtual float getMinimumLevel() const = 0; Chris@147: Chris@147: /** Chris@182: * Return the maximum permissible value in each bin. Chris@147: */ Chris@152: virtual float getMaximumLevel() const = 0; Chris@147: Chris@182: /** Chris@182: * Return true if there are data available for the given column. Chris@182: * This should return true only if getBinValues(windowStartFrame) Chris@182: * would not have to do any substantial work to calculate its Chris@182: * return values. If this function returns false, it may still be Chris@182: * possible to get the bin values for that column, but they may Chris@182: * have to be calculated. Chris@182: */ Chris@182: virtual bool isColumnAvailable(size_t column) const = 0; Chris@182: Chris@182: typedef std::vector Column; Chris@147: Chris@147: /** Chris@182: * Get data from the given column of bin values. Chris@147: */ Chris@182: virtual void getColumn(size_t column, Column &result) const = 0; Chris@147: Chris@147: /** Chris@182: * Get the single data point from the n'th bin of the given column. Chris@147: */ Chris@182: virtual float getValueAt(size_t column, size_t n) const = 0; Chris@147: Chris@182: /** Chris@182: * Get the name of a given bin (i.e. a label to associate with Chris@182: * that bin across all columns). Chris@182: */ Chris@152: virtual QString getBinName(size_t n) const = 0; Chris@147: Chris@182: /** Chris@182: * Utility function to query whether a given bin is greater than Chris@182: * its (vertical) neighbours. Chris@182: */ Chris@182: bool isLocalPeak(size_t x, size_t y) { Chris@182: float value = getValueAt(x, y); Chris@182: if (y > 0 && value < getValueAt(x, y - 1)) return false; Chris@182: if (y < getHeight() - 1 && value < getValueAt(x, y + 1)) return false; Chris@182: return true; Chris@182: } Chris@182: Chris@182: /** Chris@182: * Utility function to query whether a given bin is greater than a Chris@182: * certain threshold. Chris@182: */ Chris@182: bool isOverThreshold(size_t x, size_t y, float threshold) { Chris@182: return getValueAt(x, y) > threshold; Chris@182: } Chris@182: Chris@152: virtual int getCompletion() const = 0; Chris@147: Chris@147: protected: Chris@152: DenseThreeDimensionalModel() { } Chris@147: }; Chris@147: Chris@147: #endif