annotate data/model/EditableDenseThreeDimensionalModel.h @ 353:1c6816220185

* more handy functions
author Chris Cannam
date Mon, 10 Dec 2007 17:37:13 +0000
parents 700cd3350391
children 1405f4a2caf3
rev   line source
Chris@152 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@152 2
Chris@152 3 /*
Chris@152 4 Sonic Visualiser
Chris@152 5 An audio file viewer and annotation editor.
Chris@152 6 Centre for Digital Music, Queen Mary, University of London.
Chris@202 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@152 8
Chris@152 9 This program is free software; you can redistribute it and/or
Chris@152 10 modify it under the terms of the GNU General Public License as
Chris@152 11 published by the Free Software Foundation; either version 2 of the
Chris@152 12 License, or (at your option) any later version. See the file
Chris@152 13 COPYING included with this distribution for more information.
Chris@152 14 */
Chris@152 15
Chris@152 16 #ifndef _EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H_
Chris@152 17 #define _EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H_
Chris@152 18
Chris@152 19 #include "DenseThreeDimensionalModel.h"
Chris@152 20
Chris@152 21 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel
Chris@152 22 {
Chris@152 23 Q_OBJECT
Chris@152 24
Chris@152 25 public:
Chris@152 26 EditableDenseThreeDimensionalModel(size_t sampleRate,
Chris@152 27 size_t resolution,
Chris@152 28 size_t yBinCount,
Chris@152 29 bool notifyOnAdd = true);
Chris@152 30
Chris@152 31 virtual bool isOK() const;
Chris@152 32
Chris@152 33 virtual size_t getSampleRate() const;
Chris@152 34 virtual size_t getStartFrame() const;
Chris@152 35 virtual size_t getEndFrame() const;
Chris@152 36
Chris@152 37 virtual Model *clone() const;
Chris@152 38
Chris@152 39
Chris@152 40 /**
Chris@152 41 * Return the number of sample frames covered by each set of bins.
Chris@152 42 */
Chris@152 43 virtual size_t getResolution() const;
Chris@152 44
Chris@152 45 /**
Chris@152 46 * Set the number of sample frames covered by each set of bins.
Chris@152 47 */
Chris@152 48 virtual void setResolution(size_t sz);
Chris@152 49
Chris@152 50 /**
Chris@182 51 * Return the number of columns.
Chris@182 52 */
Chris@182 53 virtual size_t getWidth() const;
Chris@182 54
Chris@182 55 /**
Chris@152 56 * Return the number of bins in each set of bins.
Chris@152 57 */
Chris@182 58 virtual size_t getHeight() const;
Chris@152 59
Chris@152 60 /**
Chris@152 61 * Set the number of bins in each set of bins.
Chris@152 62 */
Chris@182 63 virtual void setHeight(size_t sz);
Chris@152 64
Chris@152 65 /**
Chris@152 66 * Return the minimum value of the value in each bin.
Chris@152 67 */
Chris@152 68 virtual float getMinimumLevel() const;
Chris@152 69
Chris@152 70 /**
Chris@152 71 * Set the minimum value of the value in a bin.
Chris@152 72 */
Chris@152 73 virtual void setMinimumLevel(float sz);
Chris@152 74
Chris@152 75 /**
Chris@152 76 * Return the maximum value of the value in each bin.
Chris@152 77 */
Chris@152 78 virtual float getMaximumLevel() const;
Chris@152 79
Chris@152 80 /**
Chris@152 81 * Set the maximum value of the value in a bin.
Chris@152 82 */
Chris@152 83 virtual void setMaximumLevel(float sz);
Chris@152 84
Chris@182 85 /**
Chris@182 86 * Return true if there are data available for the given column.
Chris@182 87 */
Chris@182 88 virtual bool isColumnAvailable(size_t x) const { return x < getWidth(); }
Chris@152 89
Chris@152 90 /**
Chris@182 91 * Get the set of bin values at the given column.
Chris@152 92 */
Chris@182 93 virtual void getColumn(size_t x, Column &) const;
Chris@152 94
Chris@152 95 /**
Chris@182 96 * Get a single value, from the n'th bin of the given column.
Chris@152 97 */
Chris@182 98 virtual float getValueAt(size_t x, size_t n) const;
Chris@152 99
Chris@152 100 /**
Chris@182 101 * Set the entire set of bin values at the given column.
Chris@152 102 */
Chris@182 103 virtual void setColumn(size_t x, const Column &values);
Chris@152 104
Chris@152 105 virtual QString getBinName(size_t n) const;
Chris@152 106 virtual void setBinName(size_t n, QString);
Chris@152 107 virtual void setBinNames(std::vector<QString> names);
Chris@152 108
Chris@333 109 virtual void setCompletion(int completion, bool update = true);
Chris@152 110 virtual int getCompletion() const { return m_completion; }
Chris@152 111
Chris@345 112 QString getTypeName() const { return tr("Editable Dense 3-D"); }
Chris@345 113
Chris@318 114 virtual QString toDelimitedDataString(QString delimiter) const;
Chris@318 115
Chris@152 116 virtual void toXml(QTextStream &out,
Chris@152 117 QString indent = "",
Chris@152 118 QString extraAttributes = "") const;
Chris@152 119
Chris@152 120 protected:
Chris@182 121 typedef std::vector<Column> ValueMatrix;
Chris@152 122 ValueMatrix m_data;
Chris@152 123
Chris@152 124 std::vector<QString> m_binNames;
Chris@152 125
Chris@152 126 size_t m_sampleRate;
Chris@152 127 size_t m_resolution;
Chris@152 128 size_t m_yBinCount;
Chris@152 129 float m_minimum;
Chris@152 130 float m_maximum;
Chris@256 131 bool m_haveExtents;
Chris@152 132 bool m_notifyOnAdd;
Chris@152 133 long m_sinceLastNotifyMin;
Chris@152 134 long m_sinceLastNotifyMax;
Chris@152 135 int m_completion;
Chris@152 136
Chris@152 137 mutable QMutex m_mutex;
Chris@152 138 };
Chris@152 139
Chris@152 140 #endif