Mercurial > hg > svcore
changeset 179:0ed2b2e26b44
* Tidy up inheritance hierarchy of model classes -- remove ZoomConstraint as
a base class (make it a member instead) and remove virtual inheritances of
QObject (no longer necessary).
author | Chris Cannam |
---|---|
date | Thu, 05 Oct 2006 11:03:06 +0000 |
parents | 0e266fa2510f |
children | bd1260261412 |
files | data/model/DenseThreeDimensionalModel.h data/model/DenseTimeValueModel.h data/model/FFTModel.cpp data/model/Model.h data/model/PowerOfSqrtTwoZoomConstraint.h data/model/PowerOfTwoZoomConstraint.h data/model/RangeSummarisableTimeValueModel.h data/model/WaveFileModel.cpp data/model/WaveFileModel.h data/model/WritableWaveFileModel.h |
diffstat | 10 files changed, 35 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/data/model/DenseThreeDimensionalModel.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/DenseThreeDimensionalModel.h Thu Oct 05 11:03:06 2006 +0000 @@ -22,9 +22,7 @@ #include <QMutex> #include <vector> -class DenseThreeDimensionalModel : public Model, - virtual public ZoomConstraint, - virtual public QObject +class DenseThreeDimensionalModel : public Model { Q_OBJECT
--- a/data/model/DenseTimeValueModel.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/DenseTimeValueModel.h Thu Oct 05 11:03:06 2006 +0000 @@ -25,8 +25,7 @@ * against time). For example, audio waveform data. */ -class DenseTimeValueModel : public Model, - virtual public QObject +class DenseTimeValueModel : public Model { Q_OBJECT
--- a/data/model/FFTModel.cpp Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/FFTModel.cpp Thu Oct 05 11:03:06 2006 +0000 @@ -114,8 +114,6 @@ } FFTModel::FFTModel(const FFTModel &model) : - QObject(), - ZoomConstraint(), //!!! want a real ZoomConstraint for this! DenseThreeDimensionalModel(), m_server(model.m_server), m_xshift(model.m_xshift),
--- a/data/model/Model.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/Model.h Thu Oct 05 11:03:06 2006 +0000 @@ -23,12 +23,14 @@ typedef std::vector<float> SampleBlock; +class ZoomConstraint; + /** * Model is the base class for all data models that represent any sort * of data on a time scale based on an audio frame rate. */ -class Model : virtual public QObject, +class Model : public QObject, public XmlExportable { Q_OBJECT @@ -93,6 +95,15 @@ } static const int COMPLETION_UNKNOWN; + /** + * If this model imposes a zoom constraint, i.e. some limit to the + * set of resolutions at which its data can meaningfully be + * displayed, then return it. + */ + virtual const ZoomConstraint *getZoomConstraint() const { + return 0; + } + virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const;
--- a/data/model/PowerOfSqrtTwoZoomConstraint.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.h Thu Oct 05 11:03:06 2006 +0000 @@ -25,7 +25,6 @@ RoundingDirection dir = RoundNearest) const; -protected: virtual size_t getNearestBlockSize(size_t requestedBlockSize, int &type, int &power,
--- a/data/model/PowerOfTwoZoomConstraint.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/PowerOfTwoZoomConstraint.h Thu Oct 05 11:03:06 2006 +0000 @@ -24,11 +24,6 @@ virtual size_t getNearestBlockSize(size_t requestedBlockSize, RoundingDirection dir = RoundNearest) const; -/* - virtual size_t getNextBlockSize(size_t blockSize, - RoundingDirection dir = RoundNearest) - const; -*/ }; #endif
--- a/data/model/RangeSummarisableTimeValueModel.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/RangeSummarisableTimeValueModel.h Thu Oct 05 11:03:06 2006 +0000 @@ -28,9 +28,7 @@ * example: think "peaks and minima" for "ranges". */ -class RangeSummarisableTimeValueModel : public DenseTimeValueModel, - virtual public ZoomConstraint, - virtual public QObject +class RangeSummarisableTimeValueModel : public DenseTimeValueModel { Q_OBJECT
--- a/data/model/WaveFileModel.cpp Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/WaveFileModel.cpp Thu Oct 05 11:03:06 2006 +0000 @@ -33,6 +33,9 @@ using std::cerr; using std::endl; +PowerOfSqrtTwoZoomConstraint +WaveFileModel::m_zoomConstraint; + WaveFileModel::WaveFileModel(QString path) : m_path(path), m_myReader(true), @@ -221,9 +224,9 @@ } int cacheType = 0; - int power = getMinCachePower(); - blockSize = getNearestBlockSize(blockSize, cacheType, power, - ZoomConstraint::RoundUp); + int power = m_zoomConstraint.getMinCachePower(); + blockSize = m_zoomConstraint.getNearestBlockSize + (blockSize, cacheType, power, ZoomConstraint::RoundUp); size_t channels = getChannelCount(); @@ -277,10 +280,10 @@ size_t cacheBlock, div; if (cacheType == 0) { - cacheBlock = (1 << getMinCachePower()); + cacheBlock = (1 << m_zoomConstraint.getMinCachePower()); div = (1 << power) / cacheBlock; } else { - cacheBlock = ((unsigned int)((1 << getMinCachePower()) * sqrt(2) + 0.01)); + cacheBlock = ((unsigned int)((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2) + 0.01)); div = ((unsigned int)((1 << power) * sqrt(2) + 0.01)) / cacheBlock; } @@ -442,8 +445,8 @@ WaveFileModel::RangeCacheFillThread::run() { size_t cacheBlockSize[2]; - cacheBlockSize[0] = (1 << m_model.getMinCachePower()); - cacheBlockSize[1] = ((unsigned int)((1 << m_model.getMinCachePower()) * + cacheBlockSize[0] = (1 << m_model.m_zoomConstraint.getMinCachePower()); + cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) * sqrt(2) + 0.01)); size_t frame = 0;
--- a/data/model/WaveFileModel.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/WaveFileModel.h Thu Oct 05 11:03:06 2006 +0000 @@ -27,8 +27,7 @@ class AudioFileReader; -class WaveFileModel : public RangeSummarisableTimeValueModel, - virtual public PowerOfSqrtTwoZoomConstraint +class WaveFileModel : public RangeSummarisableTimeValueModel { Q_OBJECT @@ -40,6 +39,8 @@ bool isOK() const; bool isReady(int *) const; + const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; } + size_t getFrameCount() const; size_t getChannelCount() const; size_t getSampleRate() const; @@ -107,6 +108,7 @@ QTimer *m_updateTimer; size_t m_lastFillExtent; bool m_exiting; + static PowerOfSqrtTwoZoomConstraint m_zoomConstraint; }; #endif
--- a/data/model/WritableWaveFileModel.h Thu Oct 05 11:02:05 2006 +0000 +++ b/data/model/WritableWaveFileModel.h Thu Oct 05 11:03:06 2006 +0000 @@ -21,8 +21,7 @@ class WavFileWriter; class WavFileReader; -class WritableWaveFileModel : public RangeSummarisableTimeValueModel, - virtual public PowerOfSqrtTwoZoomConstraint +class WritableWaveFileModel : public RangeSummarisableTimeValueModel { Q_OBJECT @@ -36,6 +35,11 @@ bool isOK() const; bool isReady(int *) const; + const ZoomConstraint *getZoomConstraint() const { + static PowerOfSqrtTwoZoomConstraint zc; + return &zc; + } + size_t getFrameCount() const; size_t getChannelCount() const { return m_channels; } size_t getSampleRate() const { return m_sampleRate; }