]> sigrok.org Git - pulseview.git/commitdiff
Fixed signal ends to cover screen
authorJoel Holdsworth <redacted>
Sat, 7 Jul 2012 07:16:07 +0000 (08:16 +0100)
committerJoel Holdsworth <redacted>
Mon, 3 Sep 2012 12:59:06 +0000 (13:59 +0100)
logicdatasnapshot.cpp
logicsignal.cpp

index 032d9c81e464f2dd3311fd31a076a83073aa34a1..e29a866e5fea444b735e5219835c1278b746bef5 100644 (file)
@@ -65,7 +65,7 @@ void LogicDataSnapshot::get_subsampled_edges(
        bool last_sample = get_sample(start) & sig_mask;
        edges.push_back(pair<int64_t, bool>(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<int64_t, bool>(end - 1,
-               get_sample(end - 1) & sig_mask));
+       edges.push_back(pair<int64_t, bool>(end,
+               get_sample(end) & sig_mask));
 }
index 486c002d7a1ed1179e9979377a4195d15f816c76..79a27ddd05c97996cc6f7332b3b6b3a7ab4e4058 100644 (file)
@@ -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