# HG changeset patch # User Chris Cannam # Date 1160046186 0 # Node ID 0ed2b2e26b44435593d6b363c569d65a99d3fd87 # Parent 0e266fa2510f635f1dccb06a1f4900ce10e78c9c * 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). diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/DenseThreeDimensionalModel.h --- 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 #include -class DenseThreeDimensionalModel : public Model, - virtual public ZoomConstraint, - virtual public QObject +class DenseThreeDimensionalModel : public Model { Q_OBJECT diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/DenseTimeValueModel.h --- 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 diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/FFTModel.cpp --- 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), diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/Model.h --- 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 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; diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/PowerOfSqrtTwoZoomConstraint.h --- 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, diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/PowerOfTwoZoomConstraint.h --- 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 diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/RangeSummarisableTimeValueModel.h --- 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 diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/WaveFileModel.cpp --- 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; diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/WaveFileModel.h --- 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 diff -r 0e266fa2510f -r 0ed2b2e26b44 data/model/WritableWaveFileModel.h --- 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; }