From: Soeren Apel Date: Wed, 30 May 2018 15:55:32 +0000 (+0200) Subject: Fix #956 by adding the missing final sample to the range X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f8a8811b634642c792342c5e69cd1a11231cce9f;p=pulseview.git Fix #956 by adding the missing final sample to the range --- diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index 8a055729..655954a4 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -407,7 +407,7 @@ void AnalogSignal::paint_trace(QPainter &p, p.setPen(base_->color()); - const int64_t points_count = end - start; + const int64_t points_count = end - start + 1; QPointF *points = new QPointF[points_count]; QPointF *point = points; @@ -420,7 +420,7 @@ void AnalogSignal::paint_trace(QPainter &p, segment->get_samples(start, start + sample_count, sample_block); const int w = 2; - for (int64_t sample = start; sample != end; sample++, block_sample++) { + for (int64_t sample = start; sample <= end; sample++, block_sample++) { if (block_sample == TracePaintBlockSize) { block_sample = 0; @@ -428,8 +428,7 @@ void AnalogSignal::paint_trace(QPainter &p, segment->get_samples(sample, sample + sample_count, sample_block); } - const float x = (sample / samples_per_pixel - - pixels_offset) + left; + const float x = left + (sample / samples_per_pixel - pixels_offset); *point++ = QPointF(x, y - sample_block[block_sample] * scale_);