# HG changeset patch # User Chris Cannam # Date 1470328173 -3600 # Node ID 2976f57164ac830fbd2bdb5f10763b5efcdaef82 # Parent 998e31e92dbe50c61478701b5f6e14c1dabce31f Reconnect double-click region select in spectrogram diff -r 998e31e92dbe -r 2976f57164ac layer/Colour3DPlotRenderer.cpp --- 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; +} diff -r 998e31e92dbe -r 2976f57164ac layer/Colour3DPlotRenderer.h --- 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; diff -r 998e31e92dbe -r 2976f57164ac layer/SpectrogramLayer.cpp --- 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