Mercurial > hg > svgui
changeset 1139:2976f57164ac spectrogram-minor-refactor
Reconnect double-click region select in spectrogram
author | Chris Cannam |
---|---|
date | Thu, 04 Aug 2016 17:29:33 +0100 |
parents | 998e31e92dbe |
children | ca910d8070c8 |
files | layer/Colour3DPlotRenderer.cpp layer/Colour3DPlotRenderer.h layer/SpectrogramLayer.cpp |
diffstat | 3 files changed, 21 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp Thu Aug 04 14:02:56 2016 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Thu Aug 04 17:29:33 2016 +0100 @@ -25,6 +25,7 @@ #include "LayerGeometryProvider.h" #include "VerticalBinLayer.h" #include "PaintAssistant.h" +#include "ImageRegionFinder.h" #include "view/ViewManager.h" // for main model sample rate. Pity @@ -1035,4 +1036,11 @@ } } - +QRect +Colour3DPlotRenderer::findSimilarRegionExtents(QPoint p) const +{ + QImage image = m_cache.getImage(); + ImageRegionFinder finder; + QRect rect = finder.findRegionExtents(&image, p); + return rect; +}
--- a/layer/Colour3DPlotRenderer.h Thu Aug 04 14:02:56 2016 +0100 +++ b/layer/Colour3DPlotRenderer.h Thu Aug 04 17:29:33 2016 +0100 @@ -222,6 +222,13 @@ QColor getColour(double value) const { return m_params.colourScale.getColour(value, m_params.colourRotation); } + + /** + * Return the enclosing rectangle for the region of similar colour + * to the given point within the cache. Return an empty QRect if + * this is not possible. \see ImageRegionFinder + */ + QRect findSimilarRegionExtents(QPoint point) const; private: Sources m_sources;
--- a/layer/SpectrogramLayer.cpp Thu Aug 04 14:02:56 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Thu Aug 04 17:29:33 2016 +0100 @@ -28,7 +28,6 @@ #include "data/model/Dense3DModelPeakCache.h" #include "ColourMapper.h" -#include "ImageRegionFinder.h" #include "PianoScale.h" #include "PaintAssistant.h" #include "Colour3DPlotRenderer.h" @@ -1727,27 +1726,18 @@ } void -SpectrogramLayer::measureDoubleClick(LayerGeometryProvider *, QMouseEvent *) +SpectrogramLayer::measureDoubleClick(LayerGeometryProvider *v, QMouseEvent *e) { -/*!!! replace this - const View *view = v->getView(); - - ScrollableImageCache &cache = getImageCacheReference(view); - - cerr << "cache width: " << cache.getSize().width() << ", height: " - << cache.getSize().height() << endl; - - QImage image = cache.getImage(); - - ImageRegionFinder finder; - QRect rect = finder.findRegionExtents(&image, e->pos()); + const Colour3DPlotRenderer *renderer = getRenderer(v); + if (!renderer) return; + + QRect rect = renderer->findSimilarRegionExtents(e->pos()); if (rect.isValid()) { MeasureRect mr; setMeasureRectFromPixrect(v, mr, rect); CommandHistory::getInstance()->addCommand (new AddMeasurementRectCommand(this, mr)); } -*/ } bool