From: Joel Holdsworth Date: Sat, 7 Jul 2012 07:16:07 +0000 (+0100) Subject: Fixed signal ends to cover screen X-Git-Tag: pulseview-0.1.0~326 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=652010ea57ca43952d626f33ebf84fb01a663ed4;ds=inline Fixed signal ends to cover screen --- diff --git a/logicdatasnapshot.cpp b/logicdatasnapshot.cpp index 032d9c81..e29a866e 100644 --- a/logicdatasnapshot.cpp +++ b/logicdatasnapshot.cpp @@ -65,7 +65,7 @@ void LogicDataSnapshot::get_subsampled_edges( bool last_sample = get_sample(start) & sig_mask; edges.push_back(pair(start, last_sample)); - for(int64_t i = start + 1; i < end - 1; i++) + for(int64_t i = start + 1; i < end; i++) { const bool sample = get_sample(i) & sig_mask; @@ -89,6 +89,6 @@ void LogicDataSnapshot::get_subsampled_edges( } // Add the final state - edges.push_back(pair(end - 1, - get_sample(end - 1) & sig_mask)); + edges.push_back(pair(end, + get_sample(end) & sig_mask)); } diff --git a/logicsignal.cpp b/logicsignal.cpp index 486c002d..79a27ddd 100644 --- a/logicsignal.cpp +++ b/logicsignal.cpp @@ -86,16 +86,16 @@ void LogicSignal::paint(QGLWidget &widget, const QRect &rect, const double pixels_offset = offset / scale; const double samplerate = _data->get_samplerate(); const double start_time = _data->get_start_time(); - const int64_t last_sample = (int64_t)snapshot->get_sample_count() - 1; + const int64_t last_sample = snapshot->get_sample_count() - 1; const double samples_per_pixel = samplerate * scale; - const int64_t start = min(max((int64_t)(samplerate * (offset - start_time)), - (int64_t)0), last_sample); - const int64_t end = min((int64_t)(start + samples_per_pixel * rect.width()), - last_sample); + const double start = samplerate * (offset - start_time); + const double end = start + samples_per_pixel * rect.width(); const int64_t quantization_length = 1LL << (int64_t)floorf( - max(logf(samples_per_pixel / Log2), 0.0f)); + max(logf((float)samples_per_pixel) / Log2, 0.0f)); - snapshot->get_subsampled_edges(edges, start, end, + snapshot->get_subsampled_edges(edges, + min(max((int64_t)floor(start), (int64_t)0), last_sample), + min(max((int64_t)ceil(end), (int64_t)0), last_sample), quantization_length, _probe_index); // Paint the edges