Mercurial > hg > svgui
changeset 1549:9a5eede01869
Use x + width() instead of QRect::right(), which doesn't return what we need and leaves us a pixel short; also subtract the resolution from the start frame to avoid scrolling scraggy single-pixel lines when we should be drawing nice fat ones
author | Chris Cannam |
---|---|
date | Thu, 31 Oct 2019 15:32:01 +0000 |
parents | bd6af89982d7 |
children | e95cefd4aa81 |
files | layer/TimeInstantLayer.cpp |
diffstat | 1 files changed, 43 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/TimeInstantLayer.cpp Thu Oct 17 14:44:22 2019 +0100 +++ b/layer/TimeInstantLayer.cpp Thu Oct 31 15:32:01 2019 +0000 @@ -321,11 +321,20 @@ // Profiler profiler("TimeInstantLayer::paint", true); - int x0 = rect.left(), x1 = rect.right(); + int x0 = rect.left(); + int x1 = x0 + rect.width(); - sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t resolution = model->getResolution(); + + sv_frame_t frame0 = v->getFrameForX(x0) - resolution; sv_frame_t frame1 = v->getFrameForX(x1); +#ifdef DEBUG_TIME_INSTANT_LAYER + SVCERR << "TimeInstantLayer[" << this << "]::paint: x0 = " + << x0 << ", x1 = " << x1 << ", frame0 = " << frame0 + << ", frame1 = " << frame1 << endl; +#endif + int overspill = 0; if (m_plotStyle == PlotSegmentation) { // We need to start painting at the prior point, so we can @@ -334,7 +343,13 @@ } EventVector points(model->getEventsWithin(frame0, frame1 - frame0, - overspill)); + overspill)); + +#ifdef DEBUG_TIME_INSTANT_LAYER + SVCERR << "TimeInstantLayer[" << this << "]::paint: have " << points.size() + << " point(s) with overspill = " << overspill << " from model " + << getModel() << endl; +#endif bool odd = false; if (m_plotStyle == PlotSegmentation && !points.empty()) { @@ -364,9 +379,6 @@ oddBrushColour.setAlpha(100); } -// SVDEBUG << "TimeInstantLayer::paint: resolution is " -// << model->getResolution() << " frames" << endl; - QPoint localPos; sv_frame_t illuminateFrame = -1; @@ -388,8 +400,18 @@ ++j; int x = v->getXForFrame(p.getFrame()); + +#ifdef DEBUG_TIME_INSTANT_LAYER + SVCERR << "point frame = " << p.getFrame() << " -> x = " << x << endl; +#endif + if (x == prevX && m_plotStyle == PlotInstants && - p.getFrame() != illuminateFrame) continue; + p.getFrame() != illuminateFrame) { +#ifdef DEBUG_TIME_INSTANT_LAYER + SVCERR << "(skipping)" << endl; +#endif + continue; + } int iw = v->getXForFrame(p.getFrame() + model->getResolution()) - x; if (iw < 2) { @@ -410,6 +432,10 @@ paint.setPen(brushColour); } +#ifdef DEBUG_TIME_INSTANT_LAYER + SVCERR << "m_plotStyle = " << m_plotStyle << ", iw = " << iw << endl; +#endif + if (m_plotStyle == PlotInstants) { if (iw > 1) { paint.drawRect(x, 0, iw - 1, v->getPaintHeight() - 1); @@ -516,7 +542,11 @@ } void -TimeInstantLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) +TimeInstantLayer::drawEnd(LayerGeometryProvider *, QMouseEvent * +#ifdef DEBUG_TIME_INSTANT_LAYER + e +#endif + ) { #ifdef DEBUG_TIME_INSTANT_LAYER cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << endl; @@ -623,7 +653,11 @@ } void -TimeInstantLayer::editEnd(LayerGeometryProvider *, QMouseEvent *) +TimeInstantLayer::editEnd(LayerGeometryProvider *, QMouseEvent * +#ifdef DEBUG_TIME_INSTANT_LAYER + e +#endif + ) { #ifdef DEBUG_TIME_INSTANT_LAYER cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << endl;