mirror of git://sigrok.org/pulseview
Flesh out segment display mode handling
This commit is contained in:
parent
7daebd054e
commit
341d9a7975
|
@ -960,14 +960,14 @@ void Session::free_unused_memory()
|
|||
|
||||
void Session::signal_new_segment()
|
||||
{
|
||||
int new_segment_id = 1;
|
||||
int new_segment_id = 0;
|
||||
|
||||
if ((cur_logic_segment_ != nullptr) || !cur_analog_segments_.empty()) {
|
||||
|
||||
// Determine new frame/segment number, assuming that all
|
||||
// signals have the same number of frames/segments
|
||||
if (cur_logic_segment_) {
|
||||
new_segment_id = logic_data_->get_segment_count();
|
||||
new_segment_id = logic_data_->get_segment_count() - 1;
|
||||
} else {
|
||||
shared_ptr<sigrok::Channel> any_channel =
|
||||
(*cur_analog_segments_.begin()).first;
|
||||
|
@ -978,7 +978,7 @@ void Session::signal_new_segment()
|
|||
shared_ptr<data::Analog> data(base->analog_data());
|
||||
assert(data);
|
||||
|
||||
new_segment_id = data->get_segment_count();
|
||||
new_segment_id = data->get_segment_count() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ Q_SIGNALS:
|
|||
|
||||
void trigger_event(util::Timestamp location);
|
||||
|
||||
void new_segment(int new_frame_id);
|
||||
void new_segment(int new_segment_id);
|
||||
|
||||
void data_received();
|
||||
|
||||
|
|
|
@ -662,7 +662,7 @@ shared_ptr<pv::data::AnalogSegment> AnalogSignal::get_analog_segment_to_paint()
|
|||
try {
|
||||
segment = segments.at(current_segment_);
|
||||
} catch (out_of_range) {
|
||||
qDebug() << "Current analog segment out of range for signal" << base_->name();
|
||||
qDebug() << "Current analog segment out of range for signal" << base_->name() << ":" << current_segment_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -685,7 +685,7 @@ shared_ptr<pv::data::LogicSegment> AnalogSignal::get_logic_segment_to_paint() co
|
|||
try {
|
||||
segment = segments.at(current_segment_);
|
||||
} catch (out_of_range) {
|
||||
qDebug() << "Current logic segment out of range for signal" << base_->name();
|
||||
qDebug() << "Current logic segment out of range for signal" << base_->name() << ":" << current_segment_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ shared_ptr<pv::data::LogicSegment> LogicSignal::get_logic_segment_to_paint() con
|
|||
try {
|
||||
segment = segments.at(current_segment_);
|
||||
} catch (out_of_range) {
|
||||
qDebug() << "Current logic segment out of range for signal" << base_->name();
|
||||
qDebug() << "Current logic segment out of range for signal" << base_->name() << ":" << current_segment_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,10 +89,15 @@ StandardBar::StandardBar(Session &session, QWidget *parent,
|
|||
segment_selector_->hide();
|
||||
connect(&session_, SIGNAL(new_segment(int)),
|
||||
this, SLOT(on_new_segment(int)));
|
||||
|
||||
connect(segment_selector_, SIGNAL(valueChanged(int)),
|
||||
view_, SLOT(on_segment_changed(int)));
|
||||
this, SLOT(on_segment_selected(int)));
|
||||
connect(view_, SIGNAL(segment_changed(int)),
|
||||
this, SLOT(on_segment_changed(int)));
|
||||
|
||||
connect(this, SIGNAL(segment_selected(int)),
|
||||
view_, SLOT(on_segment_changed(int)));
|
||||
|
||||
connect(view_, SIGNAL(segment_display_mode_changed(bool)),
|
||||
this, SLOT(on_segment_display_mode_changed(bool)));
|
||||
|
||||
|
@ -196,7 +201,7 @@ void StandardBar::on_new_segment(int new_segment_id)
|
|||
{
|
||||
if (new_segment_id > 1) {
|
||||
show_multi_segment_ui(true);
|
||||
segment_selector_->setMaximum(new_segment_id);
|
||||
segment_selector_->setMaximum(new_segment_id + 1);
|
||||
} else
|
||||
show_multi_segment_ui(false);
|
||||
}
|
||||
|
@ -205,7 +210,21 @@ void StandardBar::on_segment_changed(int segment_id)
|
|||
{
|
||||
// This is called when the current segment was changed
|
||||
// by other parts of the UI, e.g. the view itself
|
||||
segment_selector_->setValue(segment_id);
|
||||
|
||||
// We need to adjust the value by 1 because internally, segments
|
||||
// start at 0 while they start with 1 for the spinbox
|
||||
segment_selector_->setValue(segment_id + 1);
|
||||
|
||||
segment_selected(segment_id);
|
||||
}
|
||||
|
||||
void StandardBar::on_segment_selected(int ui_segment_id)
|
||||
{
|
||||
// This is called when the user selected a segment using the spin box
|
||||
|
||||
// We need to adjust the value by 1 because internally, segments
|
||||
// start at 0 while they start with 1 for the spinbox
|
||||
segment_selected(ui_segment_id - 1);
|
||||
}
|
||||
|
||||
void StandardBar::on_segment_display_mode_changed(bool segment_selectable)
|
||||
|
|
|
@ -75,6 +75,9 @@ protected:
|
|||
|
||||
QSpinBox *segment_selector_;
|
||||
|
||||
Q_SIGNALS:
|
||||
void segment_selected(int segment_id);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void on_actionViewZoomIn_triggered();
|
||||
|
||||
|
@ -90,6 +93,7 @@ protected Q_SLOTS:
|
|||
|
||||
void on_new_segment(int new_segment_id);
|
||||
void on_segment_changed(int segment_id);
|
||||
void on_segment_selected(int ui_segment_id);
|
||||
void on_segment_display_mode_changed(bool segment_selectable);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1420,7 +1420,7 @@ void View::on_segment_changed(int segment)
|
|||
switch (segment_display_mode_) {
|
||||
case Trace::ShowLastSegmentOnly:
|
||||
case Trace::ShowSingleSegmentOnly:
|
||||
current_segment_ = segment - 1;
|
||||
current_segment_ = segment;
|
||||
for (shared_ptr<Signal> signal : signals_)
|
||||
signal->set_current_segment(current_segment_);
|
||||
viewport_->update();
|
||||
|
|
Loading…
Reference in New Issue