# HG changeset patch # User Chris Cannam # Date 1396425093 -3600 # Node ID 9cfcb2924ee3594bf9700c64afd2217c23a7e51c # Parent ad01e7d4a956016453871ee0746dc0ee99c8c91d# Parent 09e2677e34e7156a1091fc37c4d24db6b83f5604 Merge from branch tonioni diff -r 09e2677e34e7 -r 9cfcb2924ee3 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Tue Apr 01 21:18:31 2014 +0100 +++ b/layer/Colour3DPlotLayer.cpp Wed Apr 02 08:51:33 2014 +0100 @@ -579,6 +579,13 @@ return true; } +bool +Colour3DPlotLayer::getYScaleValue(const View *v, int y, + float &value, QString &unit) const +{ + return false;//!!! +} + int Colour3DPlotLayer::getVerticalZoomSteps(int &defaultStep) const { @@ -952,6 +959,7 @@ size_t cacheHeight = m_model->getHeight(); if (m_cache && (m_cache->height() != int(cacheHeight))) { + // height has changed: delete everything rather than resizing delete m_cache; delete m_peaksCache; m_cache = 0; @@ -959,6 +967,7 @@ } if (m_cache && (m_cache->width() != int(cacheWidth))) { + // width has changed and we have an existing cache: resize it QImage *newCache = new QImage(m_cache->copy(0, 0, cacheWidth, cacheHeight)); delete m_cache; @@ -966,7 +975,7 @@ if (m_peaksCache) { QImage *newPeaksCache = new QImage(m_peaksCache->copy - (0, 0, cacheWidth / m_peakResolution, cacheHeight)); + (0, 0, cacheWidth / m_peakResolution + 1, cacheHeight)); delete m_peaksCache; m_peaksCache = newPeaksCache; } @@ -991,6 +1000,9 @@ m_cacheValidEnd = 0; } +// cerr << "cache size = " << m_cache->width() << "x" << m_cache->height() +// << " peaks cache size = " << m_peaksCache->width() << "x" << m_peaksCache->height() << endl; + if (m_cacheValidStart <= firstBin && m_cacheValidEnd >= lastBin) { #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT cerr << "Cache is valid in this region already" << endl; @@ -1117,6 +1129,12 @@ values = getColumn(c); + if (c >= m_cache->width()) { + cerr << "ERROR: column " << c << " >= cache width " + << m_cache->width() << endl; + continue; + } + for (size_t y = 0; y < cacheHeight; ++y) { float value = min; @@ -1145,7 +1163,11 @@ if (m_invertVertical) { m_cache->setPixel(c, cacheHeight - y - 1, pixel); } else { - m_cache->setPixel(c, y, pixel); + if (y >= m_cache->height()) { + cerr << "ERROR: row " << y << " >= cache height " << m_cache->height() << endl; + } else { + m_cache->setPixel(c, y, pixel); + } } } @@ -1153,11 +1175,23 @@ size_t notch = (c % m_peakResolution); if (notch == m_peakResolution-1 || c == fillEnd) { size_t pc = c / m_peakResolution; + if (pc >= m_peaksCache->width()) { + cerr << "ERROR: peak column " << pc + << " (from col " << c << ") >= peaks cache width " + << m_peaksCache->width() << endl; + continue; + } for (size_t y = 0; y < cacheHeight; ++y) { if (m_invertVertical) { m_peaksCache->setPixel(pc, cacheHeight - y - 1, peaks[y]); } else { - m_peaksCache->setPixel(pc, y, peaks[y]); + if (y >= m_peaksCache->height()) { + cerr << "ERROR: row " << y + << " >= peaks cache height " + << m_peaksCache->height() << endl; + } else { + m_peaksCache->setPixel(pc, y, peaks[y]); + } } } for (int y = 0; y < cacheHeight; ++y) { diff -r 09e2677e34e7 -r 9cfcb2924ee3 layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Tue Apr 01 21:18:31 2014 +0100 +++ b/layer/Colour3DPlotLayer.h Wed Apr 02 08:51:33 2014 +0100 @@ -151,6 +151,9 @@ virtual bool getDisplayExtents(float &min, float &max) const; virtual bool setDisplayExtents(float min, float max); + virtual bool getYScaleValue(const View *, int /* y */, + float &/* value */, QString &/* unit */) const; + virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; virtual void setVerticalZoomStep(int); @@ -188,17 +191,32 @@ bool m_smooth; size_t m_peakResolution; + // Minimum and maximum bin numbers visible within the view. We + // always snap to whole bins at view edges. int m_miny; int m_maxy; + + /** + * Return the y coordinate at which the given bin "starts" + * (i.e. at the bottom of the bin, if the given bin is an integer + * and the vertical scale is the usual way up). Bin number may be + * fractional, to obtain a position part-way through a bin. + */ + float getYForBin(View *, float bin) const; + + /** + * Return the bin number, possibly fractional, at the given y + * coordinate. Note that the whole numbers occur at the positions + * at which the bins "start" (i.e. the bottom of the visible bin, + * if the vertical scale is the usual way up). + */ + float getBinForY(View *, float y) const; DenseThreeDimensionalModel::Column getColumn(size_t col) const; int getColourScaleWidth(QPainter &) const; void fillCache(size_t firstBin, size_t lastBin) const; void paintDense(View *v, QPainter &paint, QRect rect) const; - - float getYForBin(View *, float bin) const; - float getBinForY(View *, float y) const; }; #endif diff -r 09e2677e34e7 -r 9cfcb2924ee3 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Apr 01 21:18:31 2014 +0100 +++ b/layer/SpectrogramLayer.cpp Wed Apr 02 08:51:33 2014 +0100 @@ -3459,6 +3459,11 @@ return n; } + + virtual int getPositionForValueUnclamped(float value) const { + // We don't really support this + return getPositionForValue(value); + } virtual float getValueForPosition(int position) const { @@ -3478,6 +3483,11 @@ return dist; } + virtual float getValueForPositionUnclamped(int position) const { + // We don't really support this + return getValueForPosition(position); + } + virtual QString getUnit() const { return "Hz"; } protected: diff -r 09e2677e34e7 -r 9cfcb2924ee3 view/Pane.cpp --- a/view/Pane.cpp Tue Apr 01 21:18:31 2014 +0100 +++ b/view/Pane.cpp Wed Apr 02 08:51:33 2014 +0100 @@ -1233,47 +1233,6 @@ tr("Double-click middle button to relocate with any tool")); kr.registerShortcut(tr("Menu"), tr("Right"), tr("Show pane context menu")); - - kr.setCategory(tr("Navigate Tool Mouse Actions")); - - kr.registerShortcut(tr("Navigate"), tr("Left"), - tr("Click left button and drag to move around")); - kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"), - tr("Shift-click left button and drag to zoom to a rectangular area")); - kr.registerShortcut(tr("Relocate"), tr("Double-Click Left"), - tr("Double-click left button to jump to clicked location")); - kr.registerShortcut(tr("Edit"), tr("Double-Click Left"), - tr("Double-click left button on an item to edit it")); - - kr.setCategory(tr("Select Tool Mouse Actions")); - kr.registerShortcut(tr("Select"), tr("Left"), - tr("Click left button and drag to select region; drag region edge to resize")); - kr.registerShortcut(tr("Multi Select"), tr("Ctrl+Left"), -#ifdef Q_OS_MAC - tr("Cmd-click left button and drag to select an additional region")); -#else - tr("Ctrl-click left button and drag to select an additional region")); -#endif - kr.registerShortcut(tr("Fine Select"), tr("Shift+Left"), - tr("Shift-click left button and drag to select without snapping to items or grid")); - - kr.setCategory(tr("Edit Tool Mouse Actions")); - kr.registerShortcut(tr("Move"), tr("Left"), - tr("Click left button on an item or selected region and drag to move")); - kr.registerShortcut(tr("Edit"), tr("Double-Click Left"), - tr("Double-click left button on an item to edit it")); - - kr.setCategory(tr("Draw Tool Mouse Actions")); - kr.registerShortcut(tr("Draw"), tr("Left"), - tr("Click left button and drag to create new item")); - - kr.setCategory(tr("Measure Tool Mouse Actions")); - kr.registerShortcut(tr("Measure Area"), tr("Left"), - tr("Click left button and drag to measure a rectangular area")); - kr.registerShortcut(tr("Measure Item"), tr("Double-Click Left"), - tr("Click left button and drag to measure extents of an item or shape")); - kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"), - tr("Shift-click left button and drag to zoom to a rectangular area")); } Layer *