annotate data/model/DenseThreeDimensionalModel.h @ 392:183ee2a55fc7

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents 700cd3350391
children 1405f4a2caf3
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@202 7 This file copyright 2006 Chris Cannam and QMUL.
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@223 57 * This should return true only if getColumn(column) would not
Chris@223 58 * have to do any substantial work to calculate its return values.
Chris@223 59 * If this function returns false, it may still be possible to
Chris@223 60 * retrieve the column, but its values may have to be calculated.
Chris@182 61 */
Chris@182 62 virtual bool isColumnAvailable(size_t column) const = 0;
Chris@182 63
Chris@182 64 typedef std::vector<float> Column;
Chris@147 65
Chris@147 66 /**
Chris@182 67 * Get data from the given column of bin values.
Chris@147 68 */
Chris@182 69 virtual void getColumn(size_t column, Column &result) const = 0;
Chris@147 70
Chris@147 71 /**
Chris@182 72 * Get the single data point from the n'th bin of the given column.
Chris@147 73 */
Chris@182 74 virtual float getValueAt(size_t column, size_t n) const = 0;
Chris@147 75
Chris@182 76 /**
Chris@182 77 * Get the name of a given bin (i.e. a label to associate with
Chris@182 78 * that bin across all columns).
Chris@182 79 */
Chris@152 80 virtual QString getBinName(size_t n) const = 0;
Chris@147 81
Chris@182 82 /**
Chris@182 83 * Utility function to query whether a given bin is greater than
Chris@182 84 * its (vertical) neighbours.
Chris@182 85 */
Chris@182 86 bool isLocalPeak(size_t x, size_t y) {
Chris@182 87 float value = getValueAt(x, y);
Chris@182 88 if (y > 0 && value < getValueAt(x, y - 1)) return false;
Chris@182 89 if (y < getHeight() - 1 && value < getValueAt(x, y + 1)) return false;
Chris@182 90 return true;
Chris@182 91 }
Chris@182 92
Chris@182 93 /**
Chris@182 94 * Utility function to query whether a given bin is greater than a
Chris@182 95 * certain threshold.
Chris@182 96 */
Chris@182 97 bool isOverThreshold(size_t x, size_t y, float threshold) {
Chris@182 98 return getValueAt(x, y) > threshold;
Chris@182 99 }
Chris@182 100
Chris@345 101 QString getTypeName() const { return tr("Dense 3-D"); }
Chris@345 102
Chris@152 103 virtual int getCompletion() const = 0;
Chris@147 104
Chris@147 105 protected:
Chris@152 106 DenseThreeDimensionalModel() { }
Chris@147 107 };
Chris@147 108
Chris@147 109 #endif