Chris@152: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@152: Chris@152: /* Chris@152: Sonic Visualiser Chris@152: An audio file viewer and annotation editor. Chris@152: Centre for Digital Music, Queen Mary, University of London. Chris@202: This file copyright 2006 Chris Cannam and QMUL. Chris@152: Chris@152: This program is free software; you can redistribute it and/or Chris@152: modify it under the terms of the GNU General Public License as Chris@152: published by the Free Software Foundation; either version 2 of the Chris@152: License, or (at your option) any later version. See the file Chris@152: COPYING included with this distribution for more information. Chris@152: */ Chris@152: Chris@1581: #ifndef SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H Chris@1581: #define SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H Chris@152: Chris@152: #include "DenseThreeDimensionalModel.h" Chris@152: Chris@1777: #include Chris@536: Chris@533: #include Chris@533: Chris@152: class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel Chris@152: { Chris@152: Q_OBJECT Chris@152: Chris@152: public: Chris@1040: EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, Chris@1429: int resolution, Chris@1429: int height, Chris@1429: bool notifyOnAdd = true); Chris@152: Chris@1580: bool isOK() const override; Chris@1701: bool isReady(int *completion = 0) const override; Chris@1701: void setCompletion(int completion, bool update = true); Chris@1701: int getCompletion() const override; Chris@152: Chris@1580: sv_samplerate_t getSampleRate() const override; Chris@1580: sv_frame_t getStartFrame() const override; Chris@1725: sv_frame_t getTrueEndFrame() const override; Chris@152: Chris@152: /** Chris@611: * Set the frame offset of the first column. Chris@611: */ Chris@1038: virtual void setStartFrame(sv_frame_t); Chris@611: Chris@611: /** Chris@152: * Return the number of sample frames covered by each set of bins. Chris@152: */ Chris@1580: int getResolution() const override; Chris@152: Chris@152: /** Chris@152: * Set the number of sample frames covered by each set of bins. Chris@152: */ Chris@929: virtual void setResolution(int sz); Chris@152: Chris@152: /** Chris@182: * Return the number of columns. Chris@182: */ Chris@1580: int getWidth() const override; Chris@182: Chris@182: /** Chris@1252: * Return the number of bins in each column. Chris@152: */ Chris@1580: int getHeight() const override; Chris@152: Chris@152: /** Chris@1252: * Set the number of bins in each column. Chris@1252: * Chris@1252: * You can set (via setColumn) a vector of any length as a column, Chris@1252: * but any column being retrieved will be resized to this height Chris@1252: * (or the height that was supplied to the constructor, if this is Chris@1252: * never called) on retrieval. That is, the model owner determines Chris@1252: * the height of the model at a single stroke; the columns Chris@1252: * themselves don't have any effect on the height of the model. Chris@152: */ Chris@929: virtual void setHeight(int sz); Chris@152: Chris@152: /** Chris@152: * Return the minimum value of the value in each bin. Chris@152: */ Chris@1580: float getMinimumLevel() const override; Chris@152: Chris@152: /** Chris@152: * Set the minimum value of the value in a bin. Chris@152: */ Chris@152: virtual void setMinimumLevel(float sz); Chris@152: Chris@152: /** Chris@152: * Return the maximum value of the value in each bin. Chris@152: */ Chris@1580: float getMaximumLevel() const override; Chris@152: Chris@152: /** Chris@152: * Set the maximum value of the value in a bin. Chris@152: */ Chris@152: virtual void setMaximumLevel(float sz); Chris@152: Chris@182: /** Chris@182: * Get the set of bin values at the given column. Chris@152: */ Chris@1580: Column getColumn(int x) const override; Chris@152: Chris@152: /** Chris@182: * Get a single value, from the n'th bin of the given column. Chris@152: */ Chris@1580: float getValueAt(int x, int n) const override; Chris@152: Chris@152: /** Chris@182: * Set the entire set of bin values at the given column. Chris@152: */ Chris@929: virtual void setColumn(int x, const Column &values); Chris@152: Chris@881: /** Chris@881: * Return the name of bin n. This is a single label per bin that Chris@881: * does not vary from one column to the next. Chris@881: */ Chris@1580: QString getBinName(int n) const override; Chris@881: Chris@881: /** Chris@881: * Set the name of bin n. Chris@881: */ Chris@929: virtual void setBinName(int n, QString); Chris@881: Chris@881: /** Chris@881: * Set the names of all bins. Chris@881: */ Chris@152: virtual void setBinNames(std::vector names); Chris@152: Chris@881: /** Chris@886: * Return true if the bins have values as well as names. (The Chris@886: * values may have been derived from the names, e.g. by parsing Chris@886: * numbers from them.) If this returns true, getBinValue() may be Chris@886: * used to retrieve the values. Chris@886: */ Chris@1580: bool hasBinValues() const override; Chris@886: Chris@886: /** Chris@886: * Return the value of bin n, if any. This is a "vertical scale" Chris@886: * value which does not vary from one column to the next. This is Chris@886: * only meaningful if hasBinValues() returns true. Chris@886: */ Chris@1580: float getBinValue(int n) const override; Chris@886: Chris@886: /** Chris@886: * Set the values of all bins (separate from their labels). These Chris@886: * are "vertical scale" values which do not vary from one column Chris@886: * to the next. Chris@886: */ Chris@886: virtual void setBinValues(std::vector values); Chris@886: Chris@886: /** Chris@886: * Obtain the name of the unit of the values returned from Chris@886: * getBinValue(), if any. Chris@886: */ Chris@1580: QString getBinValueUnit() const override; Chris@886: Chris@886: /** Chris@886: * Set the name of the unit of the values return from Chris@886: * getBinValue() if any. Chris@886: */ Chris@886: virtual void setBinValueUnit(QString unit); Chris@886: Chris@886: /** Chris@881: * Return true if the distribution of values in the bins is such Chris@881: * as to suggest a log scale (mapping to colour etc) may be better Chris@881: * than a linear one. Chris@881: */ Chris@1580: bool shouldUseLogValueScale() const override; Chris@478: Chris@1580: QString getTypeName() const override { return tr("Editable Dense 3-D"); } Chris@345: Chris@1815: QString getDelimitedDataHeaderLine(QString delimiter, Chris@1815: DataExportOptions opts) const override; Chris@1815: Chris@1679: QString toDelimitedDataString(QString delimiter, Chris@1679: DataExportOptions options, Chris@1679: sv_frame_t startFrame, Chris@1679: sv_frame_t duration) const override; Chris@318: Chris@1580: void toXml(QTextStream &out, Chris@152: QString indent = "", Chris@1580: QString extraAttributes = "") const override; Chris@152: Chris@152: protected: Chris@1154: typedef std::vector ValueMatrix; Chris@152: ValueMatrix m_data; Chris@152: Chris@152: std::vector m_binNames; Chris@886: std::vector m_binValues; Chris@886: QString m_binValueUnit; Chris@152: Chris@1038: sv_frame_t m_startFrame; Chris@1040: sv_samplerate_t m_sampleRate; Chris@929: int m_resolution; Chris@929: int m_yBinCount; Chris@152: float m_minimum; Chris@152: float m_maximum; Chris@256: bool m_haveExtents; Chris@152: bool m_notifyOnAdd; Chris@1110: sv_frame_t m_sinceLastNotifyMin; Chris@1110: sv_frame_t m_sinceLastNotifyMax; Chris@152: int m_completion; Chris@152: Chris@1777: mutable QMutex m_mutex; Chris@152: }; Chris@152: Chris@152: #endif