]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/decodetrace.cpp
Begin PD multisegment support
[pulseview.git] / pv / views / trace / decodetrace.cpp
index 9529c50a72650958ce7f0b3abdc93b67a01a6f21..bc309a738d8d82ee6f0341c3d301ec5a0119c0e9 100644 (file)
@@ -146,6 +146,8 @@ DecodeTrace::DecodeTrace(pv::Session &session,
 
        connect(decode_signal_.get(), SIGNAL(new_annotations()),
                this, SLOT(on_new_annotations()));
+       connect(decode_signal_.get(), SIGNAL(decode_reset()),
+               this, SLOT(on_decode_reset()));
        connect(decode_signal_.get(), SIGNAL(decode_finished()),
                this, SLOT(on_decode_finished()));
        connect(decode_signal_.get(), SIGNAL(channels_updated()),
@@ -605,11 +607,11 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, int right
 
        double samples_per_pixel, pixels_offset;
 
-       const int64_t sample_count = decode_signal_->get_working_sample_count();
+       const int64_t sample_count = decode_signal_->get_working_sample_count(current_segment_);
        if (sample_count == 0)
                return;
 
-       const int64_t samples_decoded = decode_signal_->get_decoded_sample_count();
+       const int64_t samples_decoded = decode_signal_->get_decoded_sample_count(current_segment_);
        if (sample_count == samples_decoded)
                return;
 
@@ -710,15 +712,13 @@ const QString DecodeTrace::get_annotation_at_point(const QPoint &point)
                QString() : annotations[0].annotations().front();
 }
 
-void DecodeTrace::hover_point_changed()
+void DecodeTrace::hover_point_changed(const QPoint &hp)
 {
        assert(owner_);
 
        const View *const view = owner_->view();
        assert(view);
 
-       QPoint hp = view->hover_point();
-
        if (hp.x() == 0) {
                QToolTip::hideText();
                return;
@@ -746,13 +746,14 @@ void DecodeTrace::hover_point_changed()
        // If it did, the tool tip would constantly hide and re-appear.
        // We also push it up by one row so that it appears above the
        // decode trace, not below.
-       hp.setX(hp.x() - (text_size.width() / 2) - padding);
+       QPoint p = hp;
+       p.setX(hp.x() - (text_size.width() / 2) - padding);
 
-       hp.setY(get_visual_y() - (row_height_ / 2) +
+       p.setY(get_visual_y() - (row_height_ / 2) +
                (hover_row * row_height_) -
                row_height_ - text_size.height() - padding);
 
-       QToolTip::showText(view->viewport()->mapToGlobal(hp), ann);
+       QToolTip::showText(view->viewport()->mapToGlobal(p), ann);
 }
 
 void DecodeTrace::create_decoder_form(int index,
@@ -890,6 +891,15 @@ void DecodeTrace::on_delayed_trace_update()
                owner_->row_item_appearance_changed(false, true);
 }
 
+void DecodeTrace::on_decode_reset()
+{
+       visible_rows_.clear();
+       max_visible_rows_ = 0;
+
+       if (owner_)
+               owner_->row_item_appearance_changed(false, true);
+}
+
 void DecodeTrace::on_decode_finished()
 {
        if (owner_)
@@ -950,6 +960,10 @@ void DecodeTrace::on_delete_decoder(int index)
 {
        decode_signal_->remove_decoder(index);
 
+       // Force re-calculation of the trace height, see paint_mid()
+       max_visible_rows_ = 0;
+       owner_->extents_changed(false, true);
+
        // Update the popup
        create_popup_form();
 }
@@ -961,6 +975,12 @@ void DecodeTrace::on_show_hide_decoder(int index)
        assert(index < (int)decoder_forms_.size());
        decoder_forms_[index]->set_decoder_visible(state);
 
+       if (!state) {
+               // Force re-calculation of the trace height, see paint_mid()
+               max_visible_rows_ = 0;
+               owner_->extents_changed(false, true);
+       }
+
        if (owner_)
                owner_->row_item_appearance_changed(false, true);
 }