Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 248:28c8e8e3c537
* Fix many compile warnings, remove some debug output
author | Chris Cannam |
---|---|
date | Mon, 30 Apr 2007 13:36:23 +0000 |
parents | 9465b5375235 |
children | 9dd432665059 |
comparison
equal
deleted
inserted
replaced
247:0e9f59f991aa | 248:28c8e8e3c537 |
---|---|
278 | 278 |
279 int f0 = sx0 * modelResolution; | 279 int f0 = sx0 * modelResolution; |
280 int f1 = f0 + modelResolution; | 280 int f1 = f0 + modelResolution; |
281 | 281 |
282 float binHeight = float(v->height()) / m_model->getHeight(); | 282 float binHeight = float(v->height()) / m_model->getHeight(); |
283 int sy = (v->height() - y) / binHeight; | 283 int sy = int((v->height() - y) / binHeight); |
284 | 284 |
285 float value = m_model->getValueAt(sx0, sy); | 285 float value = m_model->getValueAt(sx0, sy); |
286 | 286 |
287 // std::cerr << "bin value (" << sx0 << "," << sy << ") is " << value << std::endl; | 287 // std::cerr << "bin value (" << sx0 << "," << sy << ") is " << value << std::endl; |
288 | 288 |
300 | 300 |
301 return text; | 301 return text; |
302 } | 302 } |
303 | 303 |
304 int | 304 int |
305 Colour3DPlotLayer::getColourScaleWidth(QPainter &paint) const | 305 Colour3DPlotLayer::getColourScaleWidth(QPainter &) const |
306 { | 306 { |
307 int cw = 20; | 307 int cw = 20; |
308 return cw; | 308 return cw; |
309 } | 309 } |
310 | 310 |
311 int | 311 int |
312 Colour3DPlotLayer::getVerticalScaleWidth(View *v, QPainter &paint) const | 312 Colour3DPlotLayer::getVerticalScaleWidth(View *, QPainter &paint) const |
313 { | 313 { |
314 if (!m_model) return 0; | 314 if (!m_model) return 0; |
315 | 315 |
316 QString sampleText = QString("[%1]").arg(m_model->getHeight()); | 316 QString sampleText = QString("[%1]").arg(m_model->getHeight()); |
317 int tw = paint.fontMetrics().width(sampleText); | 317 int tw = paint.fontMetrics().width(sampleText); |
362 | 362 |
363 for (size_t i = 0; i < m_model->getHeight(); ++i) { | 363 for (size_t i = 0; i < m_model->getHeight(); ++i) { |
364 | 364 |
365 if ((i % step) != 0) continue; | 365 if ((i % step) != 0) continue; |
366 | 366 |
367 int y0 = v->height() - (i * binHeight) - 1; | 367 int y0 = int(v->height() - (i * binHeight) - 1); |
368 | 368 |
369 QString text = m_model->getBinName(i); | 369 QString text = m_model->getBinName(i); |
370 if (text == "") text = QString("[%1]").arg(i + 1); | 370 if (text == "") text = QString("[%1]").arg(i + 1); |
371 | 371 |
372 paint.drawLine(cw, y0, w, y0); | 372 paint.drawLine(cw, y0, w, y0); |
373 | 373 |
374 int cy = y0 - (step * binHeight)/2; | 374 int cy = int(y0 - (step * binHeight)/2); |
375 int ty = cy + paint.fontMetrics().ascent()/2; | 375 int ty = cy + paint.fontMetrics().ascent()/2; |
376 | 376 |
377 paint.drawText(cw + 5, ty, text); | 377 paint.drawText(cw + 5, ty, text); |
378 } | 378 } |
379 } | 379 } |
432 size_t cacheWidth = lastBin - firstBin + 1; | 432 size_t cacheWidth = lastBin - firstBin + 1; |
433 size_t cacheHeight = m_model->getHeight(); | 433 size_t cacheHeight = m_model->getHeight(); |
434 | 434 |
435 if (m_cache && | 435 if (m_cache && |
436 (m_cacheStart != firstBin || | 436 (m_cacheStart != firstBin || |
437 m_cache->width() != cacheWidth || | 437 m_cache->width() != int(cacheWidth) || |
438 m_cache->height() != cacheHeight)) { | 438 m_cache->height() != int(cacheHeight))) { |
439 | 439 |
440 delete m_cache; | 440 delete m_cache; |
441 m_cache = 0; | 441 m_cache = 0; |
442 } | 442 } |
443 | 443 |
576 | 576 |
577 if (sx0 > 0) --sx0; | 577 if (sx0 > 0) --sx0; |
578 fillCache(sx0 < 0 ? 0 : sx0, | 578 fillCache(sx0 < 0 ? 0 : sx0, |
579 sx1 < 0 ? 0 : sx1); | 579 sx1 < 0 ? 0 : sx1); |
580 | 580 |
581 if (m_model->getHeight() >= v->height() || | 581 if (int(m_model->getHeight()) >= v->height() || |
582 modelResolution < v->getZoomLevel() / 2) { | 582 int(modelResolution) < v->getZoomLevel() / 2) { |
583 paintDense(v, paint, rect); | 583 paintDense(v, paint, rect); |
584 return; | 584 return; |
585 } | 585 } |
586 | 586 |
587 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT | 587 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT |
594 char labelbuf[10]; | 594 char labelbuf[10]; |
595 | 595 |
596 for (int sx = sx0; sx <= sx1; ++sx) { | 596 for (int sx = sx0; sx <= sx1; ++sx) { |
597 | 597 |
598 int scx = 0; | 598 int scx = 0; |
599 if (sx > m_cacheStart) scx = sx - m_cacheStart; | 599 if (sx > int(m_cacheStart)) scx = sx - m_cacheStart; |
600 | 600 |
601 int fx = sx * int(modelResolution); | 601 int fx = sx * int(modelResolution); |
602 | 602 |
603 if (fx + modelResolution < int(modelStart) || | 603 if (fx + int(modelResolution) < int(modelStart) || |
604 fx > int(modelEnd)) continue; | 604 fx > int(modelEnd)) continue; |
605 | 605 |
606 int rx0 = v->getXForFrame((fx + int(modelStart)) * srRatio); | 606 int rx0 = v->getXForFrame(int((fx + int(modelStart)) * srRatio)); |
607 int rx1 = v->getXForFrame((fx + int(modelStart) + int(modelResolution) + 1) * srRatio); | 607 int rx1 = v->getXForFrame(int((fx + int(modelStart) + int(modelResolution) + 1) * srRatio)); |
608 | 608 |
609 int rw = rx1 - rx0; | 609 int rw = rx1 - rx0; |
610 if (rw < 1) rw = 1; | 610 if (rw < 1) rw = 1; |
611 | 611 |
612 bool showLabel = (rw > 10 && | 612 bool showLabel = (rw > 10 && |
671 } | 671 } |
672 | 672 |
673 void | 673 void |
674 Colour3DPlotLayer::paintDense(View *v, QPainter &paint, QRect rect) const | 674 Colour3DPlotLayer::paintDense(View *v, QPainter &paint, QRect rect) const |
675 { | 675 { |
676 long startFrame = v->getStartFrame(); | |
677 int zoomLevel = v->getZoomLevel(); | |
678 | |
679 size_t modelStart = m_model->getStartFrame(); | 676 size_t modelStart = m_model->getStartFrame(); |
680 size_t modelEnd = m_model->getEndFrame(); | |
681 size_t modelResolution = m_model->getResolution(); | 677 size_t modelResolution = m_model->getResolution(); |
682 | 678 |
683 float srRatio = | 679 float srRatio = |
684 float(v->getViewManager()->getMainModelSampleRate()) / | 680 float(v->getViewManager()->getMainModelSampleRate()) / |
685 float(m_model->getSampleRate()); | 681 float(m_model->getSampleRate()); |
693 | 689 |
694 QImage img(w, h, QImage::Format_RGB32); | 690 QImage img(w, h, QImage::Format_RGB32); |
695 | 691 |
696 for (int x = x0; x < x1; ++x) { | 692 for (int x = x0; x < x1; ++x) { |
697 | 693 |
698 long xf = v->getFrameForX(x) / srRatio; | 694 long xf = long(v->getFrameForX(x) / srRatio); |
699 if (xf < 0) { | 695 if (xf < 0) { |
700 for (int y = 0; y < h; ++y) { | 696 for (int y = 0; y < h; ++y) { |
701 img.setPixel(x - x0, y, m_cache->color(0)); | 697 img.setPixel(x - x0, y, m_cache->color(0)); |
702 } | 698 } |
703 continue; | 699 continue; |
721 int max = 0; | 717 int max = 0; |
722 | 718 |
723 for (int sx = sx0i; sx <= sx1i; ++sx) { | 719 for (int sx = sx0i; sx <= sx1i; ++sx) { |
724 | 720 |
725 int scx = 0; | 721 int scx = 0; |
726 if (sx > m_cacheStart) scx = sx - m_cacheStart; | 722 if (sx > int(m_cacheStart)) scx = sx - int(m_cacheStart); |
727 | 723 |
728 if (scx < 0 || scx >= m_cache->width()) continue; | 724 if (scx < 0 || scx >= m_cache->width()) continue; |
729 | 725 |
730 for (int sy = sy0i; sy <= sy1i; ++sy) { | 726 for (int sy = sy0i; sy <= sy1i; ++sy) { |
731 | 727 |