Add an extra sample to the logic edges so that the end sample is visible
authorJoel Holdsworth <joel@airwebreathe.org.uk>
Sat, 25 Jan 2014 09:51:11 +0000 (09:51 +0000)
committerBert Vermeulen <bert@biot.com>
Sat, 25 Jan 2014 11:54:10 +0000 (12:54 +0100)
pv/data/logicsnapshot.cpp
pv/view/logicsignal.cpp
test/data/logicsnapshot.cpp

index 177c66279bf0a1fa079f82b3da0d22a8f537ee86..f203e8b674fb57fb37c556edc593c5e1798873a8 100644 (file)
@@ -366,8 +366,10 @@ void LogicSnapshot::get_subsampled_edges(
        }
 
        // Add the final state
-       edges.push_back(pair<int64_t, bool>(end,
-               get_sample(end) & sig_mask));
+       const bool end_sample = get_sample(end) & sig_mask;
+       if (last_sample != end_sample)
+               edges.push_back(pair<int64_t, bool>(end, end_sample));
+       edges.push_back(pair<int64_t, bool>(end + 1, end_sample));
 }
 
 uint64_t LogicSnapshot::get_subsample(int level, uint64_t offset) const
index cf75bc28c1636d229bde2a498762e0fdf78638fe..65ecae53724be4394418472ac84dd9c0f7fe567f 100644 (file)
@@ -167,7 +167,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right)
        delete[] edge_lines;
 
        // Paint the caps
-       const unsigned int max_cap_line_count = (edges.size() - 1);
+       const unsigned int max_cap_line_count = edges.size();
        QLineF *const cap_lines = new QLineF[max_cap_line_count];
 
        p.setPen(HighColour);
index ba89c607a111a8d8f23b4e97ed0b47b8cd46b3a8..5fc17213ba1ca06e2a2d5d0b84686ee0b60957a3 100644 (file)
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(Basic)
        BOOST_CHECK_EQUAL(edges[0].first, 0);
        BOOST_CHECK_EQUAL(edges[1].first, 8);
        BOOST_CHECK_EQUAL(edges[2].first, 16);
-       BOOST_CHECK_EQUAL(edges[3].first, 255);
+       BOOST_CHECK_EQUAL(edges[3].first, 256);
 
        // Test a subset at high zoom
        edges.clear();
@@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(Basic)
        BOOST_CHECK_EQUAL(edges[0].first, 6);
        BOOST_CHECK_EQUAL(edges[1].first, 8);
        BOOST_CHECK_EQUAL(edges[2].first, 16);
-       BOOST_CHECK_EQUAL(edges[3].first, 17);
+       BOOST_CHECK_EQUAL(edges[3].first, 18);
 }
 
 BOOST_AUTO_TEST_CASE(LargeData)
@@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE(LargeData)
                BOOST_CHECK_EQUAL(edges[i].second, i & 1);
        }
 
-       BOOST_CHECK_EQUAL(edges[31].first, 999999);
+       BOOST_CHECK_EQUAL(edges[31].first, 1000000);
 
        // Check in very low zoom case
        edges.clear();
@@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(LongPulses)
                BOOST_CHECK_EQUAL(edges[i*2+1].second, false);
        }
 
-       BOOST_CHECK_EQUAL(edges.back().first, Length-1);
+       BOOST_CHECK_EQUAL(edges.back().first, Length);
        BOOST_CHECK_EQUAL(edges.back().second, false);
 
        //----- Test get_subsampled_edges at a simplified scale -----//
@@ -418,7 +418,7 @@ BOOST_AUTO_TEST_CASE(LongPulses)
                BOOST_CHECK_EQUAL(edges[i+1].second, false);
        }
 
-       BOOST_CHECK_EQUAL(edges.back().first, Length-1);
+       BOOST_CHECK_EQUAL(edges.back().first, Length);
        BOOST_CHECK_EQUAL(edges.back().second, false);
 }