Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1121:d930ff725f64 spectrogram-minor-refactor
Wiring through the magnitude range updates
author | Chris Cannam |
---|---|
date | Fri, 22 Jul 2016 12:17:55 +0100 |
parents | 64709d4d09ef |
children | 94370157b265 |
comparison
equal
deleted
inserted
replaced
1120:65cdaf8d6b50 | 1121:d930ff725f64 |
---|---|
1383 { | 1383 { |
1384 #ifdef DEBUG_SPECTROGRAM | 1384 #ifdef DEBUG_SPECTROGRAM |
1385 cerr << "SpectrogramLayer::invalidateMagnitudes called" << endl; | 1385 cerr << "SpectrogramLayer::invalidateMagnitudes called" << endl; |
1386 #endif | 1386 #endif |
1387 m_viewMags.clear(); | 1387 m_viewMags.clear(); |
1388 for (vector<MagnitudeRange>::iterator i = m_columnMags.begin(); | 1388 /*!!! for (vector<MagnitudeRange>::iterator i = m_columnMags.begin(); |
1389 i != m_columnMags.end(); ++i) { | 1389 i != m_columnMags.end(); ++i) { |
1390 *i = MagnitudeRange(); | 1390 *i = MagnitudeRange(); |
1391 } | 1391 } |
1392 } | 1392 */ |
1393 | 1393 } |
1394 /*!!! | |
1394 bool | 1395 bool |
1395 SpectrogramLayer::updateViewMagnitudes(LayerGeometryProvider *v) const | 1396 SpectrogramLayer::updateViewMagnitudes(LayerGeometryProvider *v) const |
1396 { | 1397 { |
1397 MagnitudeRange mag; | 1398 MagnitudeRange mag; |
1398 | 1399 |
1432 if (!mag.isSet()) return false; | 1433 if (!mag.isSet()) return false; |
1433 if (mag == m_viewMags[v->getId()]) return false; | 1434 if (mag == m_viewMags[v->getId()]) return false; |
1434 m_viewMags[v->getId()] = mag; | 1435 m_viewMags[v->getId()] = mag; |
1435 return true; | 1436 return true; |
1436 } | 1437 } |
1437 | 1438 */ |
1438 void | 1439 void |
1439 SpectrogramLayer::setSynchronousPainting(bool synchronous) | 1440 SpectrogramLayer::setSynchronousPainting(bool synchronous) |
1440 { | 1441 { |
1441 m_synchronous = synchronous; | 1442 m_synchronous = synchronous; |
1442 } | 1443 } |
1485 } | 1486 } |
1486 | 1487 |
1487 void | 1488 void |
1488 SpectrogramLayer::paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const | 1489 SpectrogramLayer::paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const |
1489 { | 1490 { |
1490 static int depth = 0; | |
1491 | |
1492 Colour3DPlotRenderer *renderer = getRenderer(v); | 1491 Colour3DPlotRenderer *renderer = getRenderer(v); |
1493 | 1492 |
1493 Colour3DPlotRenderer::RenderResult result; | |
1494 | |
1494 if (m_synchronous) { | 1495 if (m_synchronous) { |
1495 (void)renderer->render(v, paint, rect); | 1496 |
1496 return; | 1497 result = renderer->render(v, paint, rect); |
1497 } | 1498 |
1498 | 1499 } else { |
1499 ++depth; | 1500 |
1500 cerr << "paint depth " << depth << endl; | 1501 result = renderer->renderTimeConstrained(v, paint, rect); |
1501 | 1502 |
1502 (void)renderer->renderTimeConstrained(v, paint, rect); | 1503 cerr << "mag range in this paint: " << result.range.getMin() << " -> " |
1503 | 1504 << result.range.getMax() << endl; |
1504 //!!! + mag range | 1505 |
1505 | 1506 //!!! |
1506 QRect uncached = renderer->getLargestUncachedRect(); | 1507 |
1507 if (uncached.width() > 0) { | 1508 QRect uncached = renderer->getLargestUncachedRect(v); |
1508 cerr << "updating rect at " << uncached.x() << " width " | 1509 if (uncached.width() > 0) { |
1509 << uncached.width() << endl; | 1510 cerr << "updating rect at " << uncached.x() << " width " |
1510 v->updatePaintRect(uncached); | 1511 << uncached.width() << endl; |
1511 } | 1512 v->updatePaintRect(uncached); |
1512 | 1513 } |
1513 cerr << "exiting paint depth " << depth << endl; | 1514 } |
1514 --depth; | 1515 |
1516 //!!! at the mo this measures the range of the whole thing, not | |
1517 //!!! just the view - need to reset it when view extents change | |
1518 | |
1519 m_viewMags[v->getId()].sample(result.range); | |
1520 | |
1521 cerr << "mag range in this view: " | |
1522 << m_viewMags[v->getId()].getMin() | |
1523 << " -> " | |
1524 << m_viewMags[v->getId()].getMax() | |
1525 << endl; | |
1526 | |
1515 } | 1527 } |
1516 | 1528 |
1517 void | 1529 void |
1518 SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const | 1530 SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const |
1519 { | 1531 { |