annotate layer/Colour3DPlotRenderer.cpp @ 1119:be5b91ec81a0 spectrogram-minor-refactor

Inch toward using the mag cache (currently will crash with debug exception)
author Chris Cannam
date Wed, 20 Jul 2016 08:42:04 +0100
parents 175d4e15884d
children 65cdaf8d6b50
rev   line source
Chris@1071 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1071 2
Chris@1071 3 /*
Chris@1071 4 Sonic Visualiser
Chris@1071 5 An audio file viewer and annotation editor.
Chris@1071 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1071 7 This file copyright 2006-2016 Chris Cannam and QMUL.
Chris@1071 8
Chris@1071 9 This program is free software; you can redistribute it and/or
Chris@1071 10 modify it under the terms of the GNU General Public License as
Chris@1071 11 published by the Free Software Foundation; either version 2 of the
Chris@1071 12 License, or (at your option) any later version. See the file
Chris@1071 13 COPYING included with this distribution for more information.
Chris@1071 14 */
Chris@1071 15
Chris@1071 16 #include "Colour3DPlotRenderer.h"
Chris@1074 17 #include "RenderTimer.h"
Chris@1071 18
Chris@1117 19 #include "base/Profiler.h"
Chris@1117 20
Chris@1075 21 #include "data/model/DenseThreeDimensionalModel.h"
Chris@1075 22 #include "data/model/Dense3DModelPeakCache.h"
Chris@1075 23 #include "data/model/FFTModel.h"
Chris@1075 24
Chris@1077 25 #include "LayerGeometryProvider.h"
Chris@1082 26 #include "VerticalBinLayer.h"
Chris@1109 27 #include "PaintAssistant.h"
Chris@1109 28
Chris@1109 29 #include "view/ViewManager.h" // for main model sample rate. Pity
Chris@1075 30
Chris@1079 31 #include <vector>
Chris@1079 32
Chris@1094 33 //#define DEBUG_SPECTROGRAM_REPAINT 1
Chris@1094 34
Chris@1079 35 using namespace std;
Chris@1079 36
Chris@1073 37 Colour3DPlotRenderer::RenderResult
Chris@1113 38 Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect)
Chris@1076 39 {
Chris@1090 40 return render(v, paint, rect, false);
Chris@1076 41 }
Chris@1076 42
Chris@1076 43 Colour3DPlotRenderer::RenderResult
Chris@1113 44 Colour3DPlotRenderer::renderTimeConstrained(const LayerGeometryProvider *v,
Chris@1090 45 QPainter &paint, QRect rect)
Chris@1076 46 {
Chris@1090 47 return render(v, paint, rect, true);
Chris@1076 48 }
Chris@1076 49
Chris@1096 50 QRect
Chris@1096 51 Colour3DPlotRenderer::getLargestUncachedRect()
Chris@1096 52 {
Chris@1096 53 int h = m_cache.getSize().height();
Chris@1096 54
Chris@1096 55 QRect areaLeft(0, 0, m_cache.getValidLeft(), h);
Chris@1096 56 QRect areaRight(m_cache.getValidRight(), 0,
Chris@1096 57 m_cache.getSize().width() - m_cache.getValidRight(), h);
Chris@1096 58
Chris@1096 59 if (areaRight.width() > areaLeft.width()) {
Chris@1096 60 return areaRight;
Chris@1096 61 } else {
Chris@1096 62 return areaLeft;
Chris@1096 63 }
Chris@1096 64 }
Chris@1096 65
Chris@1076 66 Colour3DPlotRenderer::RenderResult
Chris@1113 67 Colour3DPlotRenderer::render(const LayerGeometryProvider *v,
Chris@1090 68 QPainter &paint, QRect rect, bool timeConstrained)
Chris@1073 69 {
Chris@1109 70 RenderType renderType = decideRenderType(v);
Chris@1109 71
Chris@1109 72 if (renderType != DrawBufferPixelResolution) {
Chris@1109 73 // Rendering should be fast in bin-resolution and direct draw
Chris@1109 74 // cases because we are quite well zoomed-in, and the sums are
Chris@1109 75 // easier this way. Calculating boundaries later will be
Chris@1109 76 // fiddly for partial paints otherwise.
Chris@1109 77 timeConstrained = false;
Chris@1109 78 }
Chris@1109 79
Chris@1109 80 if (renderType == DirectTranslucent) {
Chris@1109 81 renderDirectTranslucent(v, paint, rect);
Chris@1109 82 return { rect, {} }; //!!! this return arg is not very useful
Chris@1109 83 }
Chris@1109 84
Chris@1079 85 sv_frame_t startFrame = v->getStartFrame();
Chris@1079 86
Chris@1079 87 int x0 = v->getXForViewX(rect.x());
Chris@1079 88 int x1 = v->getXForViewX(rect.x() + rect.width());
Chris@1079 89 if (x0 < 0) x0 = 0;
Chris@1079 90 if (x1 > v->getPaintWidth()) x1 = v->getPaintWidth();
Chris@1079 91
Chris@1079 92 m_cache.resize(v->getPaintSize());
Chris@1079 93 m_cache.setZoomLevel(v->getZoomLevel());
Chris@1079 94
Chris@1119 95 m_magCache.resize(v->getPaintSize().width());
Chris@1119 96 m_magCache.setZoomLevel(v->getZoomLevel());
Chris@1119 97
Chris@1090 98 cerr << "cache start " << m_cache.getStartFrame()
Chris@1090 99 << " valid left " << m_cache.getValidLeft()
Chris@1090 100 << " valid right " << m_cache.getValidRight()
Chris@1094 101 << endl;
Chris@1094 102 cerr << " view start " << startFrame
Chris@1090 103 << " x0 " << x0
Chris@1090 104 << " x1 " << x1
Chris@1090 105 << endl;
Chris@1090 106
Chris@1079 107 if (m_cache.isValid()) { // some part of the cache is valid
Chris@1079 108
Chris@1079 109 if (v->getXForFrame(m_cache.getStartFrame()) ==
Chris@1079 110 v->getXForFrame(startFrame) &&
Chris@1079 111 m_cache.getValidLeft() <= x0 &&
Chris@1079 112 m_cache.getValidRight() >= x1) {
Chris@1090 113
Chris@1090 114 cerr << "cache hit" << endl;
Chris@1090 115
Chris@1079 116 // cache is valid for the complete requested area
Chris@1079 117 paint.drawImage(rect, m_cache.getImage(), rect);
Chris@1119 118
Chris@1119 119 //!!! a dev debug check
Chris@1119 120 if (!m_magCache.areColumnsSet(x0, x1 - x0)) {
Chris@1119 121 cerr << "Columns (" << x0 << " -> " << x1-x0
Chris@1119 122 << ") not set in mag cache" << endl;
Chris@1119 123 throw std::logic_error("Columns not set in mag cache");
Chris@1119 124 }
Chris@1119 125
Chris@1119 126 MagnitudeRange range = m_magCache.getRange(x0, x1-x0);
Chris@1119 127
Chris@1119 128 return { rect, range };
Chris@1079 129
Chris@1079 130 } else {
Chris@1090 131 cerr << "cache partial hit" << endl;
Chris@1090 132
Chris@1079 133 // cache doesn't begin at the right frame or doesn't
Chris@1079 134 // contain the complete view, but might be scrollable or
Chris@1079 135 // partially usable
Chris@1090 136 m_cache.scrollTo(v, startFrame);
Chris@1119 137 m_magCache.scrollTo(v, startFrame);
Chris@1079 138
Chris@1079 139 // if we are not time-constrained, then we want to paint
Chris@1081 140 // the whole area in one go; we don't return a partial
Chris@1081 141 // paint. To avoid providing the more complex logic to
Chris@1081 142 // handle painting discontiguous areas, if the only valid
Chris@1079 143 // part of cache is in the middle, just make the whole
Chris@1079 144 // thing invalid and start again.
Chris@1079 145 if (!timeConstrained) {
Chris@1079 146 if (m_cache.getValidLeft() > x0 &&
Chris@1079 147 m_cache.getValidRight() < x1) {
Chris@1079 148 m_cache.invalidate();
Chris@1079 149 }
Chris@1079 150 }
Chris@1079 151 }
Chris@1090 152 } else {
Chris@1118 153 // cache is completely invalid
Chris@1090 154 m_cache.setStartFrame(startFrame);
Chris@1119 155 m_magCache.setStartFrame(startFrame);
Chris@1075 156 }
Chris@1075 157
Chris@1079 158 bool rightToLeft = false;
Chris@1079 159
Chris@1079 160 if (!m_cache.isValid() && timeConstrained) {
Chris@1081 161 // When rendering the whole area, in a context where we might
Chris@1081 162 // not be able to complete the work, start from somewhere near
Chris@1081 163 // the middle so that the region of interest appears first
Chris@1079 164
Chris@1079 165 //!!! (perhaps we should avoid doing this if past repaints
Chris@1079 166 //!!! have been fast enough to do the whole in one shot)
Chris@1079 167 if (x0 == 0 && x1 == v->getPaintWidth()) {
Chris@1079 168 x0 = int(x1 * 0.3);
Chris@1079 169 }
Chris@1079 170 }
Chris@1079 171
Chris@1079 172 if (m_cache.isValid()) {
Chris@1090 173
Chris@1079 174 // When rendering only a part of the cache, we need to make
Chris@1079 175 // sure that the part we're rendering is adjacent to (or
Chris@1079 176 // overlapping) a valid area of cache, if we have one. The
Chris@1079 177 // alternative is to ditch the valid area of cache and render
Chris@1079 178 // only the requested area, but that's risky because this can
Chris@1079 179 // happen when just waving the pointer over a small part of
Chris@1079 180 // the view -- if we lose the partly-built cache every time
Chris@1079 181 // the user does that, we'll never finish building it.
Chris@1079 182 int left = x0;
Chris@1079 183 int width = x1 - x0;
Chris@1079 184 bool isLeftOfValidArea = false;
Chris@1079 185 m_cache.adjustToTouchValidArea(left, width, isLeftOfValidArea);
Chris@1079 186 x0 = left;
Chris@1079 187 x1 = x0 + width;
Chris@1079 188
Chris@1079 189 // That call also told us whether we should be painting
Chris@1079 190 // sub-regions of our target region in right-to-left order in
Chris@1079 191 // order to ensure contiguity
Chris@1079 192 rightToLeft = isLeftOfValidArea;
Chris@1079 193 }
Chris@1075 194
Chris@1109 195 // Note, we always paint the full height to cache. We want to
Chris@1109 196 // ensure the cache is coherent without having to worry about
Chris@1109 197 // vertical matching of required and valid areas as well as
Chris@1109 198 // horizontal.
Chris@1094 199
Chris@1109 200 if (renderType == DrawBufferBinResolution) {
Chris@1109 201
Chris@1094 202 renderToCacheBinResolution(v, x0, x1 - x0);
Chris@1109 203
Chris@1109 204 } else { // must be DrawBufferPixelResolution, handled DirectTranslucent earlier
Chris@1109 205
Chris@1094 206 renderToCachePixelResolution(v, x0, x1 - x0, rightToLeft, timeConstrained);
Chris@1094 207 }
Chris@1079 208
Chris@1079 209 QRect pr = rect & m_cache.getValidArea();
Chris@1079 210 paint.drawImage(pr.x(), pr.y(), m_cache.getImage(),
Chris@1079 211 pr.x(), pr.y(), pr.width(), pr.height());
Chris@1079 212
Chris@1079 213 if (!timeConstrained && (pr != rect)) {
Chris@1079 214 //!!! on a first cut, there is a risk that this will happen
Chris@1079 215 //!!! when we are at start/end of model -- trap, report, and
Chris@1079 216 //!!! then fix
Chris@1079 217 throw std::logic_error("internal error: failed to render entire requested rect even when not time-constrained");
Chris@1079 218 }
Chris@1079 219
Chris@1079 220 return { pr, {} };
Chris@1079 221
Chris@1073 222 //!!! todo: timing/incomplete paint
Chris@1073 223
Chris@1073 224 //!!! todo: peak frequency style
Chris@1073 225
Chris@1073 226 //!!! todo: transparent style from Colour3DPlot
Chris@1074 227
Chris@1079 228 //!!! todo: view magnitudes / normalise visible area
Chris@1079 229
Chris@1079 230 //!!! todo: alter documentation for view mag stuff (cached paints
Chris@1079 231 //!!! do not update MagnitudeRange)
Chris@1079 232
Chris@1079 233 //!!! todo, here or in caller: illuminateLocalFeatures
Chris@1079 234
Chris@1110 235 //!!! todo: colourmap rotation
Chris@1110 236
Chris@1079 237 //!!! fft model scaling?
Chris@1079 238
Chris@1079 239 //!!! should we own the Dense3DModelPeakCache here? or should it persist
Chris@1073 240 }
Chris@1073 241
Chris@1109 242 Colour3DPlotRenderer::RenderType
Chris@1113 243 Colour3DPlotRenderer::decideRenderType(const LayerGeometryProvider *v) const
Chris@1094 244 {
Chris@1100 245 const DenseThreeDimensionalModel *model = m_sources.source;
Chris@1109 246 if (!model || !v || !(v->getViewManager())) {
Chris@1109 247 return DrawBufferPixelResolution; // or anything
Chris@1109 248 }
Chris@1109 249
Chris@1094 250 int binResolution = model->getResolution();
Chris@1094 251 int zoomLevel = v->getZoomLevel();
Chris@1109 252 sv_samplerate_t modelRate = model->getSampleRate();
Chris@1109 253
Chris@1109 254 double rateRatio = v->getViewManager()->getMainModelSampleRate() / modelRate;
Chris@1109 255 double relativeBinResolution = binResolution * rateRatio;
Chris@1109 256
Chris@1109 257 if (m_params.binDisplay == BinDisplay::PeakFrequencies) {
Chris@1109 258 // no alternative works here
Chris@1109 259 return DrawBufferPixelResolution;
Chris@1109 260 }
Chris@1109 261
Chris@1109 262 if (!m_params.alwaysOpaque && !m_params.interpolate) {
Chris@1109 263
Chris@1109 264 // consider translucent option -- only if not smoothing & not
Chris@1109 265 // explicitly requested opaque & sufficiently zoomed-in
Chris@1109 266
Chris@1117 267 if (model->getHeight() * 3 < v->getPaintHeight() &&
Chris@1117 268 relativeBinResolution >= 3 * zoomLevel) {
Chris@1109 269 return DirectTranslucent;
Chris@1109 270 }
Chris@1109 271 }
Chris@1109 272
Chris@1109 273 if (relativeBinResolution > zoomLevel) {
Chris@1109 274 return DrawBufferBinResolution;
Chris@1109 275 } else {
Chris@1109 276 return DrawBufferPixelResolution;
Chris@1109 277 }
Chris@1109 278 }
Chris@1109 279
Chris@1109 280 void
Chris@1113 281 Colour3DPlotRenderer::renderDirectTranslucent(const LayerGeometryProvider *v,
Chris@1109 282 QPainter &paint,
Chris@1109 283 QRect rect)
Chris@1109 284 {
Chris@1117 285 Profiler profiler("Colour3DPlotRenderer::renderDirectTranslucent");
Chris@1117 286
Chris@1115 287 QPoint illuminatePos;
Chris@1115 288 bool illuminate = v->shouldIlluminateLocalFeatures
Chris@1115 289 (m_sources.verticalBinLayer, illuminatePos);
Chris@1109 290
Chris@1109 291 const DenseThreeDimensionalModel *model = m_sources.source;
Chris@1109 292
Chris@1109 293 int x0 = rect.left();
Chris@1109 294 int x1 = rect.right() + 1;
Chris@1109 295
Chris@1109 296 int h = v->getPaintHeight();
Chris@1109 297
Chris@1109 298 sv_frame_t modelStart = model->getStartFrame();
Chris@1109 299 sv_frame_t modelEnd = model->getEndFrame();
Chris@1109 300 int modelResolution = model->getResolution();
Chris@1109 301
Chris@1109 302 double rateRatio =
Chris@1109 303 v->getViewManager()->getMainModelSampleRate() / model->getSampleRate();
Chris@1109 304
Chris@1109 305 // the s-prefix values are source, i.e. model, column and bin numbers
Chris@1109 306 int sx0 = int((double(v->getFrameForX(x0)) / rateRatio - double(modelStart))
Chris@1109 307 / modelResolution);
Chris@1109 308 int sx1 = int((double(v->getFrameForX(x1)) / rateRatio - double(modelStart))
Chris@1109 309 / modelResolution);
Chris@1109 310
Chris@1109 311 int sh = model->getHeight();
Chris@1109 312
Chris@1109 313 const int buflen = 40;
Chris@1109 314 char labelbuf[buflen];
Chris@1109 315
Chris@1115 316 int minbin = 0; //!!!
Chris@1109 317 int maxbin = sh - 1; //!!!
Chris@1109 318
Chris@1109 319 int psx = -1;
Chris@1109 320
Chris@1109 321 vector<float> preparedColumn;
Chris@1109 322
Chris@1109 323 int modelWidth = model->getWidth();
Chris@1109 324
Chris@1109 325 for (int sx = sx0; sx <= sx1; ++sx) {
Chris@1109 326
Chris@1109 327 if (sx < 0 || sx >= modelWidth) {
Chris@1109 328 continue;
Chris@1109 329 }
Chris@1109 330
Chris@1109 331 if (sx != psx) {
Chris@1109 332
Chris@1109 333 //!!! this is in common with renderDrawBuffer - pull it out
Chris@1109 334
Chris@1109 335 // order:
Chris@1109 336 // get column -> scale -> record extents ->
Chris@1109 337 // normalise -> peak pick -> apply display gain ->
Chris@1109 338 // distribute/interpolate
Chris@1109 339
Chris@1109 340 ColumnOp::Column fullColumn = model->getColumn(sx);
Chris@1109 341
Chris@1109 342 // cerr << "x " << x << ", sx " << sx << ", col height " << fullColumn.size()
Chris@1109 343 // << ", minbin " << minbin << ", maxbin " << maxbin << endl;
Chris@1109 344
Chris@1109 345 ColumnOp::Column column =
Chris@1109 346 vector<float>(fullColumn.data() + minbin,
Chris@1109 347 fullColumn.data() + maxbin + 1);
Chris@1109 348
Chris@1109 349 //!!! fft scale if (m_colourScale != ColourScaleType::Phase) {
Chris@1109 350 // column = ColumnOp::fftScale(column, m_fftSize);
Chris@1109 351 // }
Chris@1109 352
Chris@1109 353 //!!! extents recordColumnExtents(column,
Chris@1109 354 // sx,
Chris@1109 355 // overallMag,
Chris@1109 356 // overallMagChanged);
Chris@1109 357
Chris@1109 358 // if (m_colourScale != ColourScaleType::Phase) {
Chris@1115 359 preparedColumn = ColumnOp::normalize(column, m_params.normalization);
Chris@1109 360 // }
Chris@1109 361
Chris@1109 362 if (m_params.binDisplay == BinDisplay::PeakBins) {
Chris@1115 363 preparedColumn = ColumnOp::peakPick(preparedColumn);
Chris@1109 364 }
Chris@1109 365
Chris@1109 366 psx = sx;
Chris@1109 367 }
Chris@1109 368
Chris@1109 369 sv_frame_t fx = sx * modelResolution + modelStart;
Chris@1109 370
Chris@1109 371 if (fx + modelResolution <= modelStart || fx > modelEnd) continue;
Chris@1109 372
Chris@1109 373 int rx0 = v->getXForFrame(int(double(fx) * rateRatio));
Chris@1109 374 int rx1 = v->getXForFrame(int(double(fx + modelResolution + 1) * rateRatio));
Chris@1109 375
Chris@1109 376 int rw = rx1 - rx0;
Chris@1109 377 if (rw < 1) rw = 1;
Chris@1109 378
Chris@1109 379 bool showLabel = (rw > 10 &&
Chris@1109 380 paint.fontMetrics().width("0.000000") < rw - 3 &&
Chris@1109 381 paint.fontMetrics().height() < (h / sh));
Chris@1109 382
Chris@1109 383 for (int sy = minbin; sy <= maxbin; ++sy) {
Chris@1109 384
Chris@1109 385 int ry0 = m_sources.verticalBinLayer->getIYForBin(v, sy);
Chris@1109 386 int ry1 = m_sources.verticalBinLayer->getIYForBin(v, sy + 1);
Chris@1116 387
Chris@1116 388 if (m_params.invertVertical) {
Chris@1116 389 ry0 = h - ry0 - 1;
Chris@1116 390 ry1 = h - ry1 - 1;
Chris@1116 391 }
Chris@1116 392
Chris@1109 393 QRect r(rx0, ry1, rw, ry0 - ry1);
Chris@1109 394
Chris@1109 395 float value = preparedColumn[sy - minbin];
Chris@1112 396 QColor colour = m_params.colourScale.getColour(value,
Chris@1112 397 m_params.colourRotation);
Chris@1109 398
Chris@1109 399 if (rw == 1) {
Chris@1109 400 paint.setPen(colour);
Chris@1109 401 paint.setBrush(Qt::NoBrush);
Chris@1109 402 paint.drawLine(r.x(), r.y(), r.x(), r.y() + r.height() - 1);
Chris@1109 403 continue;
Chris@1109 404 }
Chris@1109 405
Chris@1109 406 QColor pen(255, 255, 255, 80);
Chris@1109 407 QColor brush(colour);
Chris@1109 408
Chris@1109 409 if (rw > 3 && r.height() > 3) {
Chris@1109 410 brush.setAlpha(160);
Chris@1109 411 }
Chris@1109 412
Chris@1109 413 paint.setPen(Qt::NoPen);
Chris@1109 414 paint.setBrush(brush);
Chris@1109 415
Chris@1115 416 if (illuminate) {
Chris@1115 417 if (r.contains(illuminatePos)) {
Chris@1115 418 paint.setPen(v->getForeground());
Chris@1115 419 }
Chris@1115 420 }
Chris@1109 421
Chris@1109 422 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT
Chris@1109 423 // cerr << "rect " << r.x() << "," << r.y() << " "
Chris@1109 424 // << r.width() << "x" << r.height() << endl;
Chris@1109 425 #endif
Chris@1109 426
Chris@1109 427 paint.drawRect(r);
Chris@1109 428
Chris@1109 429 if (showLabel) {
Chris@1109 430 double value = model->getValueAt(sx, sy);
Chris@1109 431 snprintf(labelbuf, buflen, "%06f", value);
Chris@1109 432 QString text(labelbuf);
Chris@1109 433 PaintAssistant::drawVisibleText
Chris@1109 434 (v,
Chris@1109 435 paint,
Chris@1109 436 rx0 + 2,
Chris@1109 437 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(),
Chris@1109 438 text,
Chris@1109 439 PaintAssistant::OutlinedText);
Chris@1109 440 }
Chris@1109 441 }
Chris@1109 442 }
Chris@1109 443
Chris@1094 444 }
Chris@1094 445
Chris@1080 446 void
Chris@1113 447 Colour3DPlotRenderer::renderToCachePixelResolution(const LayerGeometryProvider *v,
Chris@1094 448 int x0, int repaintWidth,
Chris@1094 449 bool rightToLeft,
Chris@1094 450 bool timeConstrained)
Chris@1079 451 {
Chris@1117 452 Profiler profiler("Colour3DPlotRenderer::renderToCachePixelResolution");
Chris@1094 453 cerr << "renderToCachePixelResolution" << endl;
Chris@1094 454
Chris@1094 455 // Draw to the draw buffer, and then copy from there. The draw
Chris@1094 456 // buffer is at the same resolution as the target in the cache, so
Chris@1094 457 // no extra scaling needed.
Chris@1079 458
Chris@1100 459 const DenseThreeDimensionalModel *model = m_sources.source;
Chris@1079 460 if (!model || !model->isOK() || !model->isReady()) {
Chris@1079 461 throw std::logic_error("no source model provided, or model not ready");
Chris@1079 462 }
Chris@1079 463
Chris@1079 464 int h = v->getPaintHeight();
Chris@1079 465
Chris@1094 466 clearDrawBuffer(repaintWidth, h);
Chris@1079 467
Chris@1094 468 vector<int> binforx(repaintWidth);
Chris@1079 469 vector<double> binfory(h);
Chris@1079 470
Chris@1079 471 bool usePeaksCache = false;
Chris@1079 472 int binsPerPeak = 1;
Chris@1094 473 int zoomLevel = v->getZoomLevel();
Chris@1094 474 int binResolution = model->getResolution();
Chris@1079 475
Chris@1094 476 for (int x = 0; x < repaintWidth; ++x) {
Chris@1094 477 sv_frame_t f0 = v->getFrameForX(x0 + x);
Chris@1094 478 double s0 = double(f0 - model->getStartFrame()) / binResolution;
Chris@1094 479 binforx[x] = int(s0 + 0.0001);
Chris@1094 480 }
Chris@1080 481
Chris@1094 482 if (m_sources.peaks) { // peaks cache exists
Chris@1080 483
Chris@1094 484 binsPerPeak = m_sources.peaks->getColumnsPerPeak();
Chris@1094 485 usePeaksCache = (binResolution * binsPerPeak) < zoomLevel;
Chris@1094 486
Chris@1094 487 if (m_params.colourScale.getScale() ==
Chris@1105 488 ColourScaleType::Phase) {
Chris@1094 489 usePeaksCache = false;
Chris@1079 490 }
Chris@1079 491 }
Chris@1082 492
Chris@1094 493 cerr << "[PIX] zoomLevel = " << zoomLevel
Chris@1094 494 << ", binResolution " << binResolution
Chris@1094 495 << ", binsPerPeak " << binsPerPeak
Chris@1094 496 << ", peak cache " << m_sources.peaks
Chris@1094 497 << ", usePeaksCache = " << usePeaksCache
Chris@1094 498 << endl;
Chris@1094 499
Chris@1080 500 for (int y = 0; y < h; ++y) {
Chris@1090 501 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1);
Chris@1080 502 }
Chris@1079 503
Chris@1097 504 int attainedWidth;
Chris@1097 505
Chris@1103 506 if (m_params.binDisplay == BinDisplay::PeakFrequencies) {
Chris@1097 507 attainedWidth = renderDrawBufferPeakFrequencies(v,
Chris@1097 508 repaintWidth,
Chris@1097 509 h,
Chris@1097 510 binforx,
Chris@1097 511 binfory,
Chris@1097 512 rightToLeft,
Chris@1097 513 timeConstrained);
Chris@1097 514
Chris@1097 515 } else {
Chris@1097 516 attainedWidth = renderDrawBuffer(repaintWidth,
Chris@1080 517 h,
Chris@1080 518 binforx,
Chris@1080 519 binfory,
Chris@1080 520 usePeaksCache,
Chris@1080 521 rightToLeft,
Chris@1080 522 timeConstrained);
Chris@1097 523 }
Chris@1083 524
Chris@1094 525 if (attainedWidth == 0) return;
Chris@1084 526
Chris@1094 527 // draw buffer is pixel resolution, no scaling factors or padding involved
Chris@1084 528
Chris@1084 529 int paintedLeft = x0;
Chris@1084 530 if (rightToLeft) {
Chris@1084 531 paintedLeft += (repaintWidth - attainedWidth);
Chris@1084 532 }
Chris@1084 533
Chris@1094 534 m_cache.drawImage(paintedLeft, attainedWidth,
Chris@1094 535 m_drawBuffer,
Chris@1094 536 paintedLeft - x0, attainedWidth);
Chris@1094 537 }
Chris@1084 538
Chris@1094 539 void
Chris@1113 540 Colour3DPlotRenderer::renderToCacheBinResolution(const LayerGeometryProvider *v,
Chris@1094 541 int x0, int repaintWidth)
Chris@1094 542 {
Chris@1117 543 Profiler profiler("Colour3DPlotRenderer::renderToCacheBinResolution");
Chris@1094 544 cerr << "renderToCacheBinResolution" << endl;
Chris@1094 545
Chris@1094 546 // Draw to the draw buffer, and then scale-copy from there. Draw
Chris@1094 547 // buffer is at bin resolution, i.e. buffer x == source column
Chris@1094 548 // number. We use toolkit smooth scaling for interpolation.
Chris@1084 549
Chris@1100 550 const DenseThreeDimensionalModel *model = m_sources.source;
Chris@1094 551 if (!model || !model->isOK() || !model->isReady()) {
Chris@1094 552 throw std::logic_error("no source model provided, or model not ready");
Chris@1094 553 }
Chris@1094 554
Chris@1094 555 // The draw buffer will contain a fragment at bin resolution. We
Chris@1094 556 // need to ensure that it starts and ends at points where a
Chris@1094 557 // time-bin boundary occurs at an exact pixel boundary, and with a
Chris@1094 558 // certain amount of overlap across existing pixels so that we can
Chris@1094 559 // scale and draw from it without smoothing errors at the edges.
Chris@1094 560
Chris@1094 561 // If (getFrameForX(x) / increment) * increment ==
Chris@1094 562 // getFrameForX(x), then x is a time-bin boundary. We want two
Chris@1094 563 // such boundaries at either side of the draw buffer -- one which
Chris@1094 564 // we draw up to, and one which we subsequently crop at.
Chris@1094 565
Chris@1094 566 sv_frame_t leftBoundaryFrame = -1, leftCropFrame = -1;
Chris@1094 567 sv_frame_t rightBoundaryFrame = -1, rightCropFrame = -1;
Chris@1094 568
Chris@1094 569 int drawBufferWidth;
Chris@1094 570 int binResolution = model->getResolution();
Chris@1094 571
Chris@1094 572 for (int x = x0; ; --x) {
Chris@1094 573 sv_frame_t f = v->getFrameForX(x);
Chris@1094 574 if ((f / binResolution) * binResolution == f) {
Chris@1094 575 if (leftCropFrame == -1) leftCropFrame = f;
Chris@1094 576 else if (x < x0 - 2) {
Chris@1094 577 leftBoundaryFrame = f;
Chris@1094 578 break;
Chris@1094 579 }
Chris@1094 580 }
Chris@1094 581 }
Chris@1094 582 for (int x = x0 + repaintWidth; ; ++x) {
Chris@1094 583 sv_frame_t f = v->getFrameForX(x);
Chris@1094 584 if ((f / binResolution) * binResolution == f) {
Chris@1094 585 if (rightCropFrame == -1) rightCropFrame = f;
Chris@1094 586 else if (x > x0 + repaintWidth + 2) {
Chris@1094 587 rightBoundaryFrame = f;
Chris@1094 588 break;
Chris@1094 589 }
Chris@1094 590 }
Chris@1094 591 }
Chris@1094 592 drawBufferWidth = int
Chris@1094 593 ((rightBoundaryFrame - leftBoundaryFrame) / binResolution);
Chris@1094 594
Chris@1094 595 int h = v->getPaintHeight();
Chris@1094 596
Chris@1095 597 // For our purposes here, the draw buffer needs to be exactly our
Chris@1095 598 // target size (so we recreate always rather than just clear it)
Chris@1095 599
Chris@1095 600 recreateDrawBuffer(drawBufferWidth, h);
Chris@1094 601
Chris@1094 602 vector<int> binforx(drawBufferWidth);
Chris@1094 603 vector<double> binfory(h);
Chris@1094 604
Chris@1094 605 for (int x = 0; x < drawBufferWidth; ++x) {
Chris@1094 606 binforx[x] = int(leftBoundaryFrame / binResolution) + x;
Chris@1094 607 }
Chris@1094 608
Chris@1094 609 cerr << "[BIN] binResolution " << binResolution
Chris@1094 610 << endl;
Chris@1094 611
Chris@1094 612 for (int y = 0; y < h; ++y) {
Chris@1094 613 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1);
Chris@1094 614 }
Chris@1094 615
Chris@1094 616 int attainedWidth = renderDrawBuffer(drawBufferWidth,
Chris@1094 617 h,
Chris@1094 618 binforx,
Chris@1094 619 binfory,
Chris@1094 620 false,
Chris@1094 621 false,
Chris@1094 622 false);
Chris@1094 623
Chris@1094 624 if (attainedWidth == 0) return;
Chris@1094 625
Chris@1094 626 int scaledLeft = v->getXForFrame(leftBoundaryFrame);
Chris@1094 627 int scaledRight = v->getXForFrame(rightBoundaryFrame);
Chris@1095 628
Chris@1095 629 cerr << "scaling draw buffer from width " << m_drawBuffer.width()
Chris@1095 630 << " to " << (scaledRight - scaledLeft) << " (nb drawBufferWidth = "
Chris@1095 631 << drawBufferWidth << ")" << endl;
Chris@1094 632
Chris@1094 633 QImage scaled = m_drawBuffer.scaled
Chris@1094 634 (scaledRight - scaledLeft, h,
Chris@1094 635 Qt::IgnoreAspectRatio, (m_params.interpolate ?
Chris@1094 636 Qt::SmoothTransformation :
Chris@1094 637 Qt::FastTransformation));
Chris@1084 638
Chris@1094 639 int scaledLeftCrop = v->getXForFrame(leftCropFrame);
Chris@1094 640 int scaledRightCrop = v->getXForFrame(rightCropFrame);
Chris@1094 641
Chris@1094 642 int targetLeft = scaledLeftCrop;
Chris@1094 643 if (targetLeft < 0) {
Chris@1094 644 targetLeft = 0;
Chris@1094 645 }
Chris@1094 646
Chris@1094 647 int targetWidth = scaledRightCrop - targetLeft;
Chris@1094 648 if (targetLeft + targetWidth > m_cache.getSize().width()) {
Chris@1094 649 targetWidth = m_cache.getSize().width() - targetLeft;
Chris@1094 650 }
Chris@1094 651
Chris@1094 652 int sourceLeft = targetLeft - scaledLeft;
Chris@1094 653 if (sourceLeft < 0) {
Chris@1094 654 sourceLeft = 0;
Chris@1094 655 }
Chris@1094 656
Chris@1094 657 int sourceWidth = targetWidth;
Chris@1094 658
Chris@1094 659 cerr << "repaintWidth = " << repaintWidth
Chris@1094 660 << ", targetWidth = " << targetWidth << endl;
Chris@1094 661
Chris@1094 662 if (targetWidth > 0) {
Chris@1094 663 m_cache.drawImage(targetLeft, targetWidth,
Chris@1094 664 scaled,
Chris@1094 665 sourceLeft, sourceWidth);
Chris@1084 666 }
Chris@1079 667 }
Chris@1083 668
Chris@1083 669 int
Chris@1083 670 Colour3DPlotRenderer::renderDrawBuffer(int w, int h,
Chris@1083 671 const vector<int> &binforx,
Chris@1083 672 const vector<double> &binfory,
Chris@1083 673 bool usePeaksCache,
Chris@1083 674 bool rightToLeft,
Chris@1083 675 bool timeConstrained)
Chris@1083 676 {
Chris@1083 677 // Callers must have checked that the appropriate subset of
Chris@1083 678 // Sources data members are set for the supplied flags (e.g. that
Chris@1083 679 // peaks model exists if usePeaksCache)
Chris@1083 680
Chris@1083 681 RenderTimer timer(timeConstrained ?
Chris@1083 682 RenderTimer::FastRender :
Chris@1083 683 RenderTimer::NoTimeout);
Chris@1083 684
Chris@1083 685 int minbin = int(binfory[0] + 0.0001);
Chris@1083 686 int maxbin = int(binfory[h-1]);
Chris@1083 687 if (minbin < 0) minbin = 0;
Chris@1083 688 if (maxbin < 0) maxbin = minbin+1;
Chris@1083 689
Chris@1083 690 int divisor = 1;
Chris@1100 691 const DenseThreeDimensionalModel *sourceModel = m_sources.source;
Chris@1083 692 if (usePeaksCache) {
Chris@1083 693 divisor = m_sources.peaks->getColumnsPerPeak();
Chris@1083 694 sourceModel = m_sources.peaks;
Chris@1083 695 }
Chris@1083 696
Chris@1083 697 int psx = -1;
Chris@1083 698
Chris@1083 699 int start = 0;
Chris@1083 700 int finish = w;
Chris@1083 701 int step = 1;
Chris@1083 702
Chris@1083 703 if (rightToLeft) {
Chris@1083 704 start = w-1;
Chris@1083 705 finish = -1;
Chris@1083 706 step = -1;
Chris@1083 707 }
Chris@1083 708
Chris@1083 709 int columnCount = 0;
Chris@1083 710
Chris@1083 711 vector<float> preparedColumn;
Chris@1094 712
Chris@1094 713 int modelWidth = sourceModel->getWidth();
Chris@1094 714 cerr << "modelWidth " << modelWidth << endl;
Chris@1083 715
Chris@1083 716 for (int x = start; x != finish; x += step) {
Chris@1083 717
Chris@1083 718 // x is the on-canvas pixel coord; sx (later) will be the
Chris@1083 719 // source column index
Chris@1083 720
Chris@1083 721 ++columnCount;
Chris@1083 722
Chris@1083 723 if (binforx[x] < 0) continue;
Chris@1083 724
Chris@1083 725 int sx0 = binforx[x] / divisor;
Chris@1083 726 int sx1 = sx0;
Chris@1083 727 if (x+1 < w) sx1 = binforx[x+1] / divisor;
Chris@1083 728 if (sx0 < 0) sx0 = sx1 - 1;
Chris@1083 729 if (sx0 < 0) continue;
Chris@1083 730 if (sx1 <= sx0) sx1 = sx0 + 1;
Chris@1083 731
Chris@1083 732 vector<float> pixelPeakColumn;
Chris@1083 733
Chris@1083 734 for (int sx = sx0; sx < sx1; ++sx) {
Chris@1083 735
Chris@1083 736 #ifdef DEBUG_SPECTROGRAM_REPAINT
Chris@1094 737 cerr << "sx = " << sx << endl;
Chris@1083 738 #endif
Chris@1083 739
Chris@1094 740 if (sx < 0 || sx >= modelWidth) {
Chris@1083 741 continue;
Chris@1083 742 }
Chris@1083 743
Chris@1083 744 if (sx != psx) {
Chris@1083 745
Chris@1083 746 // order:
Chris@1083 747 // get column -> scale -> record extents ->
Chris@1083 748 // normalise -> peak pick -> apply display gain ->
Chris@1083 749 // distribute/interpolate
Chris@1083 750
Chris@1083 751 ColumnOp::Column fullColumn = sourceModel->getColumn(sx);
Chris@1090 752
Chris@1094 753 // cerr << "x " << x << ", sx " << sx << ", col height " << fullColumn.size()
Chris@1094 754 // << ", minbin " << minbin << ", maxbin " << maxbin << endl;
Chris@1090 755
Chris@1083 756 ColumnOp::Column column =
Chris@1083 757 vector<float>(fullColumn.data() + minbin,
Chris@1083 758 fullColumn.data() + maxbin + 1);
Chris@1083 759
Chris@1105 760 //!!! fft scale if (m_colourScale != ColourScaleType::Phase) {
Chris@1083 761 // column = ColumnOp::fftScale(column, m_fftSize);
Chris@1083 762 // }
Chris@1083 763
Chris@1083 764 //!!! extents recordColumnExtents(column,
Chris@1083 765 // sx,
Chris@1083 766 // overallMag,
Chris@1083 767 // overallMagChanged);
Chris@1083 768
Chris@1105 769 // if (m_colourScale != ColourScaleType::Phase) {
Chris@1083 770 column = ColumnOp::normalize(column, m_params.normalization);
Chris@1083 771 // }
Chris@1083 772
Chris@1103 773 if (m_params.binDisplay == BinDisplay::PeakBins) {
Chris@1083 774 column = ColumnOp::peakPick(column);
Chris@1083 775 }
Chris@1083 776
Chris@1083 777 preparedColumn =
Chris@1083 778 ColumnOp::distribute(column, //!!! gain? ColumnOp::applyGain(column, m_gain),
Chris@1083 779 h,
Chris@1083 780 binfory,
Chris@1083 781 minbin,
Chris@1083 782 m_params.interpolate);
Chris@1083 783
Chris@1083 784 psx = sx;
Chris@1083 785 }
Chris@1083 786
Chris@1083 787 if (sx == sx0) {
Chris@1083 788 pixelPeakColumn = preparedColumn;
Chris@1083 789 } else {
Chris@1083 790 for (int i = 0; in_range_for(pixelPeakColumn, i); ++i) {
Chris@1083 791 pixelPeakColumn[i] = std::max(pixelPeakColumn[i],
Chris@1083 792 preparedColumn[i]);
Chris@1083 793 }
Chris@1083 794 }
Chris@1083 795 }
Chris@1083 796
Chris@1083 797 if (!pixelPeakColumn.empty()) {
Chris@1083 798 for (int y = 0; y < h; ++y) {
Chris@1116 799 int py;
Chris@1116 800 if (m_params.invertVertical) {
Chris@1116 801 py = y;
Chris@1116 802 } else {
Chris@1116 803 py = h - y - 1;
Chris@1116 804 }
Chris@1083 805 m_drawBuffer.setPixel
Chris@1083 806 (x,
Chris@1116 807 py,
Chris@1083 808 m_params.colourScale.getPixel(pixelPeakColumn[y]));
Chris@1083 809 }
Chris@1083 810 }
Chris@1083 811
Chris@1083 812 double fractionComplete = double(columnCount) / double(w);
Chris@1083 813 if (timer.outOfTime(fractionComplete)) {
Chris@1083 814 return columnCount;
Chris@1083 815 }
Chris@1083 816 }
Chris@1083 817
Chris@1083 818 return columnCount;
Chris@1083 819 }
Chris@1083 820
Chris@1097 821 int
Chris@1113 822 Colour3DPlotRenderer::renderDrawBufferPeakFrequencies(const LayerGeometryProvider *v,
Chris@1097 823 int w, int h,
Chris@1097 824 const vector<int> &binforx,
Chris@1097 825 const vector<double> &binfory,
Chris@1097 826 bool rightToLeft,
Chris@1097 827 bool timeConstrained)
Chris@1097 828 {
Chris@1097 829 // Callers must have checked that the appropriate subset of
Chris@1097 830 // Sources data members are set for the supplied flags (e.g. that
Chris@1097 831 // fft model exists)
Chris@1097 832
Chris@1097 833 RenderTimer timer(timeConstrained ?
Chris@1097 834 RenderTimer::FastRender :
Chris@1097 835 RenderTimer::NoTimeout);
Chris@1097 836
Chris@1097 837 int minbin = int(binfory[0] + 0.0001);
Chris@1097 838 int maxbin = int(binfory[h-1]);
Chris@1097 839 if (minbin < 0) minbin = 0;
Chris@1097 840 if (maxbin < 0) maxbin = minbin+1;
Chris@1097 841
Chris@1100 842 const FFTModel *fft = m_sources.fft;
Chris@1097 843
Chris@1097 844 FFTModel::PeakSet peakfreqs;
Chris@1097 845
Chris@1097 846 int psx = -1;
Chris@1097 847
Chris@1097 848 int start = 0;
Chris@1097 849 int finish = w;
Chris@1097 850 int step = 1;
Chris@1097 851
Chris@1097 852 if (rightToLeft) {
Chris@1097 853 start = w-1;
Chris@1097 854 finish = -1;
Chris@1097 855 step = -1;
Chris@1097 856 }
Chris@1097 857
Chris@1097 858 int columnCount = 0;
Chris@1097 859
Chris@1097 860 vector<float> preparedColumn;
Chris@1097 861
Chris@1097 862 int modelWidth = fft->getWidth();
Chris@1097 863 cerr << "modelWidth " << modelWidth << endl;
Chris@1097 864
Chris@1097 865 double minFreq = (double(minbin) * fft->getSampleRate()) / fft->getFFTSize();
Chris@1097 866 double maxFreq = (double(maxbin) * fft->getSampleRate()) / fft->getFFTSize();
Chris@1097 867
Chris@1103 868 bool logarithmic = (m_params.binScale == BinScale::Log);
Chris@1097 869
Chris@1097 870 for (int x = start; x != finish; x += step) {
Chris@1097 871
Chris@1097 872 // x is the on-canvas pixel coord; sx (later) will be the
Chris@1097 873 // source column index
Chris@1097 874
Chris@1097 875 ++columnCount;
Chris@1097 876
Chris@1097 877 if (binforx[x] < 0) continue;
Chris@1097 878
Chris@1097 879 int sx0 = binforx[x];
Chris@1097 880 int sx1 = sx0;
Chris@1097 881 if (x+1 < w) sx1 = binforx[x+1];
Chris@1097 882 if (sx0 < 0) sx0 = sx1 - 1;
Chris@1097 883 if (sx0 < 0) continue;
Chris@1097 884 if (sx1 <= sx0) sx1 = sx0 + 1;
Chris@1097 885
Chris@1097 886 vector<float> pixelPeakColumn;
Chris@1097 887
Chris@1097 888 for (int sx = sx0; sx < sx1; ++sx) {
Chris@1097 889
Chris@1097 890 if (sx < 0 || sx >= modelWidth) {
Chris@1097 891 continue;
Chris@1097 892 }
Chris@1097 893
Chris@1097 894 if (sx != psx) {
Chris@1097 895
Chris@1097 896 ColumnOp::Column fullColumn = fft->getColumn(sx);
Chris@1097 897
Chris@1097 898 ColumnOp::Column column =
Chris@1097 899 vector<float>(fullColumn.data() + minbin,
Chris@1097 900 fullColumn.data() + maxbin + 1);
Chris@1097 901
Chris@1105 902 //!!! fft scale if (m_colourScale != ColourScaleType::Phase) {
Chris@1097 903 // column = ColumnOp::fftScale(column, getFFTSize());
Chris@1097 904 // }
Chris@1097 905
Chris@1097 906 //!!! extents recordColumnExtents(column,
Chris@1097 907 // sx,
Chris@1097 908 // overallMag,
Chris@1097 909 // overallMagChanged);
Chris@1097 910
Chris@1105 911 //!!! if (m_colourScale != ColourScaleType::Phase) {
Chris@1097 912 column = ColumnOp::normalize(column, m_params.normalization);
Chris@1097 913 //!!! }
Chris@1097 914
Chris@1097 915 preparedColumn = column;
Chris@1097 916 //!!! gain? preparedColumn = ColumnOp::applyGain(column, m_params.gain);
Chris@1097 917
Chris@1097 918 psx = sx;
Chris@1097 919 }
Chris@1097 920
Chris@1097 921 if (sx == sx0) {
Chris@1097 922 pixelPeakColumn = preparedColumn;
Chris@1097 923 peakfreqs = fft->getPeakFrequencies(FFTModel::AllPeaks, sx,
Chris@1097 924 minbin, maxbin - 1);
Chris@1097 925 } else {
Chris@1097 926 for (int i = 0; in_range_for(pixelPeakColumn, i); ++i) {
Chris@1097 927 pixelPeakColumn[i] = std::max(pixelPeakColumn[i],
Chris@1097 928 preparedColumn[i]);
Chris@1097 929 }
Chris@1097 930 }
Chris@1097 931 }
Chris@1097 932
Chris@1097 933 if (!pixelPeakColumn.empty()) {
Chris@1097 934 for (FFTModel::PeakSet::const_iterator pi = peakfreqs.begin();
Chris@1097 935 pi != peakfreqs.end(); ++pi) {
Chris@1097 936
Chris@1097 937 int bin = pi->first;
Chris@1097 938 double freq = pi->second;
Chris@1097 939
Chris@1097 940 if (bin < minbin) continue;
Chris@1097 941 if (bin > maxbin) break;
Chris@1097 942
Chris@1097 943 double value = pixelPeakColumn[bin - minbin];
Chris@1097 944
Chris@1097 945 double y = v->getYForFrequency
Chris@1097 946 (freq, minFreq, maxFreq, logarithmic);
Chris@1097 947
Chris@1097 948 int iy = int(y + 0.5);
Chris@1097 949 if (iy < 0 || iy >= h) continue;
Chris@1097 950
Chris@1097 951 m_drawBuffer.setPixel
Chris@1097 952 (x,
Chris@1097 953 iy,
Chris@1097 954 m_params.colourScale.getPixel(value));
Chris@1097 955 }
Chris@1097 956 }
Chris@1097 957
Chris@1097 958 double fractionComplete = double(columnCount) / double(w);
Chris@1097 959 if (timer.outOfTime(fractionComplete)) {
Chris@1097 960 return columnCount;
Chris@1097 961 }
Chris@1097 962 }
Chris@1097 963
Chris@1097 964 return columnCount;
Chris@1097 965 }
Chris@1097 966
Chris@1079 967 void
Chris@1095 968 Colour3DPlotRenderer::recreateDrawBuffer(int w, int h)
Chris@1079 969 {
Chris@1095 970 m_drawBuffer = QImage(w, h, QImage::Format_Indexed8);
Chris@1079 971
Chris@1095 972 for (int pixel = 0; pixel < 256; ++pixel) {
Chris@1095 973 m_drawBuffer.setColor
Chris@1095 974 ((unsigned char)pixel,
Chris@1112 975 m_params.colourScale.getColourForPixel
Chris@1112 976 (pixel, m_params.colourRotation).rgb());
Chris@1079 977 }
Chris@1079 978
Chris@1079 979 m_drawBuffer.fill(0);
Chris@1079 980 }
Chris@1079 981
Chris@1095 982 void
Chris@1095 983 Colour3DPlotRenderer::clearDrawBuffer(int w, int h)
Chris@1095 984 {
Chris@1095 985 if (m_drawBuffer.width() < w || m_drawBuffer.height() != h) {
Chris@1095 986 recreateDrawBuffer(w, h);
Chris@1095 987 } else {
Chris@1095 988 m_drawBuffer.fill(0);
Chris@1095 989 }
Chris@1095 990 }
Chris@1079 991
Chris@1095 992