annotate data/model/DenseThreeDimensionalModel.h @ 182:f75f8a1cd7b1

* Some dull work to continue unifying the fft model and editable dense 3d model interfaces
author Chris Cannam
date Mon, 09 Oct 2006 10:49:46 +0000
parents 0ed2b2e26b44
children 91fdc752e540
rev   line source
Chris@147 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@147 2
Chris@147 3 /*
Chris@147 4 Sonic Visualiser
Chris@147 5 An audio file viewer and annotation editor.
Chris@147 6 Centre for Digital Music, Queen Mary, University of London.
Chris@147 7 This file copyright 2006 Chris Cannam.
Chris@147 8
Chris@147 9 This program is free software; you can redistribute it and/or
Chris@147 10 modify it under the terms of the GNU General Public License as
Chris@147 11 published by the Free Software Foundation; either version 2 of the
Chris@147 12 License, or (at your option) any later version. See the file
Chris@147 13 COPYING included with this distribution for more information.
Chris@147 14 */
Chris@147 15
Chris@147 16 #ifndef _DENSE_THREE_DIMENSIONAL_MODEL_H_
Chris@147 17 #define _DENSE_THREE_DIMENSIONAL_MODEL_H_
Chris@147 18
Chris@150 19 #include "Model.h"
Chris@147 20 #include "base/ZoomConstraint.h"
Chris@147 21
Chris@147 22 #include <QMutex>
Chris@147 23 #include <vector>
Chris@147 24
Chris@179 25 class DenseThreeDimensionalModel : public Model
Chris@147 26 {
Chris@147 27 Q_OBJECT
Chris@147 28
Chris@147 29 public:
Chris@147 30 /**
Chris@182 31 * Return the number of sample frames covered by each column of bins.
Chris@147 32 */
Chris@152 33 virtual size_t getResolution() const = 0;
Chris@147 34
Chris@147 35 /**
Chris@182 36 * Return the number of columns of bins in the model.
Chris@147 37 */
Chris@182 38 virtual size_t getWidth() const = 0;
Chris@147 39
Chris@147 40 /**
Chris@182 41 * Return the number of bins in each column.
Chris@182 42 */
Chris@182 43 virtual size_t getHeight() const = 0;
Chris@182 44
Chris@182 45 /**
Chris@182 46 * Return the minimum permissible value in each bin.
Chris@147 47 */
Chris@152 48 virtual float getMinimumLevel() const = 0;
Chris@147 49
Chris@147 50 /**
Chris@182 51 * Return the maximum permissible value in each bin.
Chris@147 52 */
Chris@152 53 virtual float getMaximumLevel() const = 0;
Chris@147 54
Chris@182 55 /**
Chris@182 56 * Return true if there are data available for the given column.
Chris@182 57 * This should return true only if getBinValues(windowStartFrame)
Chris@182 58 * would not have to do any substantial work to calculate its
Chris@182 59 * return values. If this function returns false, it may still be
Chris@182 60 * possible to get the bin values for that column, but they may
Chris@182 61 * have to be calculated.
Chris@182 62 */
Chris@182 63 virtual bool isColumnAvailable(size_t column) const = 0;
Chris@182 64
Chris@182 65 typedef std::vector<float> Column;
Chris@147 66
Chris@147 67 /**
Chris@182 68 * Get data from the given column of bin values.
Chris@147 69 */
Chris@182 70 virtual void getColumn(size_t column, Column &result) const = 0;
Chris@147 71
Chris@147 72 /**
Chris@182 73 * Get the single data point from the n'th bin of the given column.
Chris@147 74 */
Chris@182 75 virtual float getValueAt(size_t column, size_t n) const = 0;
Chris@147 76
Chris@182 77 /**
Chris@182 78 * Get the name of a given bin (i.e. a label to associate with
Chris@182 79 * that bin across all columns).
Chris@182 80 */
Chris@152 81 virtual QString getBinName(size_t n) const = 0;
Chris@147 82
Chris@182 83 /**
Chris@182 84 * Utility function to query whether a given bin is greater than
Chris@182 85 * its (vertical) neighbours.
Chris@182 86 */
Chris@182 87 bool isLocalPeak(size_t x, size_t y) {
Chris@182 88 float value = getValueAt(x, y);
Chris@182 89 if (y > 0 && value < getValueAt(x, y - 1)) return false;
Chris@182 90 if (y < getHeight() - 1 && value < getValueAt(x, y + 1)) return false;
Chris@182 91 return true;
Chris@182 92 }
Chris@182 93
Chris@182 94 /**
Chris@182 95 * Utility function to query whether a given bin is greater than a
Chris@182 96 * certain threshold.
Chris@182 97 */
Chris@182 98 bool isOverThreshold(size_t x, size_t y, float threshold) {
Chris@182 99 return getValueAt(x, y) > threshold;
Chris@182 100 }
Chris@182 101
Chris@152 102 virtual int getCompletion() const = 0;
Chris@147 103
Chris@147 104 protected:
Chris@152 105 DenseThreeDimensionalModel() { }
Chris@147 106 };
Chris@147 107
Chris@147 108 #endif