]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/decodetrace.cpp
DecodeSignal: Add and use inclusive/exclusive sample count variant
[pulseview.git] / pv / views / trace / decodetrace.cpp
index c2f3cebe5b7b40c14b23ca8e922a2faebdcb1a0c..a65b4d9771ebc4c04530cf25afcecf4ff69e5c5c 100644 (file)
@@ -53,7 +53,6 @@ extern "C" {
 #include <pv/widgets/decodermenu.hpp>
 
 using std::abs;
-using std::all_of;
 using std::make_pair;
 using std::max;
 using std::min;
@@ -177,8 +176,13 @@ void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
 
        // Iterate through the rows
        int y = get_visual_y();
-       pair<uint64_t, uint64_t> sample_range = get_sample_range(
-               pp.left(), pp.right());
+       pair<uint64_t, uint64_t> sample_range = get_sample_range(pp.left(), pp.right());
+
+       // Just because the view says we see a certain sample range it
+       // doesn't mean we have this many decoded samples, too, so crop
+       // the range to what has been decoded already
+       sample_range.second = min((int64_t)sample_range.second,
+               decode_signal_->get_decoded_sample_count(current_segment_, false));
 
        const vector<Row> rows = decode_signal_->visible_rows();
 
@@ -256,6 +260,9 @@ void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp)
                p.setPen(QApplication::palette().color(QPalette::WindowText));
                p.drawText(r, f, h);
        }
+
+       if (show_hover_marker_)
+               paint_hover_marker(p);
 }
 
 void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
@@ -578,7 +585,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, int right
        if (sample_count == 0)
                return;
 
-       const int64_t samples_decoded = decode_signal_->get_decoded_sample_count(current_segment_);
+       const int64_t samples_decoded = decode_signal_->get_decoded_sample_count(current_segment_, true);
        if (sample_count == samples_decoded)
                return;
 
@@ -709,6 +716,8 @@ const QString DecodeTrace::get_annotation_at_point(const QPoint &point)
 
 void DecodeTrace::hover_point_changed(const QPoint &hp)
 {
+       Trace::hover_point_changed(hp);
+
        assert(owner_);
 
        const View *const view = owner_->view();