projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Finalize segment decoding
[pulseview.git]
/
pv
/
views
/
trace
/
decodetrace.cpp
diff --git
a/pv/views/trace/decodetrace.cpp
b/pv/views/trace/decodetrace.cpp
index f4ab55ffa3ee1cbca8246873057ce67b4b8e264b..88fa97fbc0b6f36cee3083892be919ba24260e09 100644
(file)
--- a/
pv/views/trace/decodetrace.cpp
+++ b/
pv/views/trace/decodetrace.cpp
@@
-56,14
+56,11
@@
extern "C" {
using std::all_of;
using std::make_pair;
using std::max;
using std::all_of;
using std::make_pair;
using std::max;
-using std::map;
using std::min;
using std::out_of_range;
using std::pair;
using std::shared_ptr;
using std::min;
using std::out_of_range;
using std::pair;
using std::shared_ptr;
-using std::make_shared;
using std::tie;
using std::tie;
-using std::unordered_set;
using std::vector;
using pv::data::decode::Annotation;
using std::vector;
using pv::data::decode::Annotation;
@@
-149,6
+146,10
@@
DecodeTrace::DecodeTrace(pv::Session &session,
connect(decode_signal_.get(), SIGNAL(new_annotations()),
this, SLOT(on_new_annotations()));
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()),
this, SLOT(on_channels_updated()));
connect(decode_signal_.get(), SIGNAL(channels_updated()),
this, SLOT(on_channels_updated()));
@@
-235,7
+236,7
@@
void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
vector<Annotation> annotations;
decode_signal_->get_annotation_subset(annotations, row,
vector<Annotation> annotations;
decode_signal_->get_annotation_subset(annotations, row,
- sample_range.first, sample_range.second);
+
current_segment_,
sample_range.first, sample_range.second);
if (!annotations.empty()) {
draw_annotations(annotations, p, annotation_height, pp, y,
base_colour, row_title_width);
if (!annotations.empty()) {
draw_annotations(annotations, p, annotation_height, pp, y,
base_colour, row_title_width);
@@
-249,11
+250,13
@@
void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
// Draw the hatching
draw_unresolved_period(p, annotation_height, pp.left(), pp.right());
// Draw the hatching
draw_unresolved_period(p, annotation_height, pp.left(), pp.right());
- if ((int)visible_rows_.size() > max_visible_rows_)
-
owner_->extents_changed(false, true
);
+ if ((int)visible_rows_.size() > max_visible_rows_)
{
+
max_visible_rows_ = (int)visible_rows_.size(
);
- // Update the maximum row count if needed
- max_visible_rows_ = max(max_visible_rows_, (int)visible_rows_.size());
+ // Call order is important, otherwise the lazy event handler won't work
+ owner_->extents_changed(false, true);
+ owner_->row_item_appearance_changed(false, true);
+ }
}
void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp)
}
void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp)
@@
-604,11
+607,11
@@
void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, int right
double samples_per_pixel, pixels_offset;
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;
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;
if (sample_count == samples_decoded)
return;
@@
-703,20
+706,24
@@
const QString DecodeTrace::get_annotation_at_point(const QPoint &point)
vector<pv::data::decode::Annotation> annotations;
decode_signal_->get_annotation_subset(annotations, visible_rows_[row],
vector<pv::data::decode::Annotation> annotations;
decode_signal_->get_annotation_subset(annotations, visible_rows_[row],
- sample_range.first, sample_range.second);
+
current_segment_,
sample_range.first, sample_range.second);
return (annotations.empty()) ?
QString() : annotations[0].annotations().front();
}
return (annotations.empty()) ?
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);
{
assert(owner_);
const View *const view = owner_->view();
assert(view);
- QPoint hp = view->hover_point();
+ if (hp.x() == 0) {
+ QToolTip::hideText();
+ return;
+ }
+
QString ann = get_annotation_at_point(hp);
assert(view);
QString ann = get_annotation_at_point(hp);
assert(view);
@@
-739,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.
// 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);
-
h
p.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);
(hover_row * row_height_) -
row_height_ - text_size.height() - padding);
- QToolTip::showText(view->viewport()->mapToGlobal(
h
p), ann);
+ QToolTip::showText(view->viewport()->mapToGlobal(p), ann);
}
void DecodeTrace::create_decoder_form(int index,
}
void DecodeTrace::create_decoder_form(int index,
@@
-883,6
+891,21
@@
void DecodeTrace::on_delayed_trace_update()
owner_->row_item_appearance_changed(false, true);
}
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_)
+ owner_->row_item_appearance_changed(false, true);
+}
+
void DecodeTrace::delete_pressed()
{
on_delete();
void DecodeTrace::delete_pressed()
{
on_delete();
@@
-937,6
+960,10
@@
void DecodeTrace::on_delete_decoder(int index)
{
decode_signal_->remove_decoder(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();
}
// Update the popup
create_popup_form();
}
@@
-948,6
+975,12
@@
void DecodeTrace::on_show_hide_decoder(int index)
assert(index < (int)decoder_forms_.size());
decoder_forms_[index]->set_decoder_visible(state);
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);
}
if (owner_)
owner_->row_item_appearance_changed(false, true);
}