comparison layer/SpectrogramLayer.cpp @ 1122:94370157b265 spectrogram-minor-refactor

Fixes and debug output for mag range calculations
author Chris Cannam
date Fri, 22 Jul 2016 13:56:24 +0100
parents d930ff725f64
children 343887ac6766
comparison
equal deleted inserted replaced
1121:d930ff725f64 1122:94370157b265
1489 SpectrogramLayer::paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const 1489 SpectrogramLayer::paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
1490 { 1490 {
1491 Colour3DPlotRenderer *renderer = getRenderer(v); 1491 Colour3DPlotRenderer *renderer = getRenderer(v);
1492 1492
1493 Colour3DPlotRenderer::RenderResult result; 1493 Colour3DPlotRenderer::RenderResult result;
1494 MagnitudeRange magRange;
1495 int viewId = v->getId();
1496
1497 if (!renderer->geometryChanged(v)) {
1498 cerr << "geometry unchanged, extending view mag range" << endl;
1499 magRange = m_viewMags[viewId];
1500 } else {
1501 cerr << "geometry changed!! creating new view mag range" << endl;
1502 }
1494 1503
1495 if (m_synchronous) { 1504 if (m_synchronous) {
1496 1505
1497 result = renderer->render(v, paint, rect); 1506 result = renderer->render(v, paint, rect);
1498 1507
1499 } else { 1508 } else {
1500 1509
1501 result = renderer->renderTimeConstrained(v, paint, rect); 1510 result = renderer->renderTimeConstrained(v, paint, rect);
1502 1511
1503 cerr << "mag range in this paint: " << result.range.getMin() << " -> " 1512 cerr << "rect width from this paint: " << result.rendered.width()
1513 << ", mag range in this paint: " << result.range.getMin() << " -> "
1504 << result.range.getMax() << endl; 1514 << result.range.getMax() << endl;
1505 1515
1506 //!!! 1516 //!!!
1507 1517
1508 QRect uncached = renderer->getLargestUncachedRect(v); 1518 QRect uncached = renderer->getLargestUncachedRect(v);
1511 << uncached.width() << endl; 1521 << uncached.width() << endl;
1512 v->updatePaintRect(uncached); 1522 v->updatePaintRect(uncached);
1513 } 1523 }
1514 } 1524 }
1515 1525
1516 //!!! at the mo this measures the range of the whole thing, not 1526 magRange.sample(result.range);
1517 //!!! just the view - need to reset it when view extents change 1527
1518 1528 if (magRange.isSet()) {
1519 m_viewMags[v->getId()].sample(result.range); 1529 if (m_viewMags[viewId] == magRange) {
1530 cerr << "mag range unchanged" << endl;
1531 } else {
1532 cerr << "mag range changed!!" << endl;
1533 m_viewMags[viewId] = magRange;
1534 }
1535 }
1520 1536
1521 cerr << "mag range in this view: " 1537 cerr << "mag range in this view: "
1522 << m_viewMags[v->getId()].getMin() 1538 << m_viewMags[viewId].getMin()
1523 << " -> " 1539 << " -> "
1524 << m_viewMags[v->getId()].getMax() 1540 << m_viewMags[viewId].getMax()
1525 << endl; 1541 << endl;
1526
1527 } 1542 }
1528 1543
1529 void 1544 void
1530 SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const 1545 SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
1531 { 1546 {