#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
+#include <QDebug>
#include <QFormLayout>
#include <QGridLayout>
#include <QLabel>
using std::make_pair;
using std::min;
using std::numeric_limits;
+using std::out_of_range;
using std::pair;
using std::placeholders::_1;
using std::shared_ptr;
if (segments.empty())
return;
- const shared_ptr<pv::data::AnalogSegment> &segment =
- segments.front();
+ shared_ptr<pv::data::AnalogSegment> segment;
+ try {
+ segment = segments.at(current_segment_);
+ } catch (out_of_range) {
+ qDebug() << "Current analog segment out of range for signal" << base_->name();
+ return;
+ }
const double pixels_offset = pp.pixels_offset();
const double samplerate = max(1.0, segment->samplerate());
if (segments.empty())
return;
- const shared_ptr<pv::data::LogicSegment> &segment =
- segments.front();
+ shared_ptr<pv::data::LogicSegment> segment;
+ try {
+ segment = segments.at(current_segment_);
+ } catch (out_of_range) {
+ qDebug() << "Current logic segment out of range for signal" << base_->name();
+ return;
+ }
double samplerate = segment->samplerate();
using std::make_pair;
using std::min;
using std::none_of;
+using std::out_of_range;
using std::pair;
using std::shared_ptr;
using std::vector;
if (segments.empty())
return;
- const shared_ptr<pv::data::LogicSegment> &segment = segments.front();
+ shared_ptr<pv::data::LogicSegment> segment;
+ try {
+ segment = segments.at(current_segment_);
+ } catch (out_of_range) {
+ qDebug() << "Current logic segment out of range for signal" << base_->name();
+ return;
+ }
double samplerate = segment->samplerate();
#define PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP
#include <QCache>
+#include <QDebug>
#include <QSpinBox>
#include "signal.hpp"
shared_ptr<data::SignalBase> channel) :
Trace(channel),
session_(session),
- name_widget_(nullptr)
+ name_widget_(nullptr),
+ current_segment_(0)
{
assert(base_);
return base_;
}
+void Signal::set_current_segment(const int segment)
+{
+ current_segment_ = segment;
+}
+
+int Signal::get_current_segment() const
+{
+ return current_segment_;
+}
+
void Signal::save_settings(QSettings &settings) const
{
(void)settings;
shared_ptr<data::SignalBase> base() const;
+ void set_current_segment(const int segment);
+
+ int get_current_segment() const;
+
virtual void save_settings(QSettings &settings) const;
virtual void restore_settings(QSettings &settings);
pv::Session &session_;
QComboBox *name_widget_;
+
+ /// The ID of the currently displayed segment
+ int current_segment_;
};
} // namespace trace
action_view_show_cursors_->setText(tr("Show &Cursors"));
segment_selector_->setMinimum(1);
+ segment_selector_->hide();
connect(&session_, SIGNAL(frame_ended()),
this, SLOT(on_segment_added()));
+ connect(segment_selector_, SIGNAL(valueChanged(int)),
+ view_, SLOT(on_segment_changed(int)));
connect(view_, SIGNAL(always_zoom_to_fit_changed(bool)),
this, SLOT(on_always_zoom_to_fit_changed(bool)));
}
}
+void View::on_segment_changed(int segment)
+{
+ current_segment_ = segment - 1;
+
+ for (shared_ptr<Signal> signal : signals_)
+ signal->set_current_segment(current_segment_);
+
+ viewport_->update();
+}
+
void View::perform_delayed_view_update()
{
if (always_zoom_to_fit_) {
void signals_changed();
void capture_state_updated(int state);
+ void on_segment_changed(int segment);
+
virtual void perform_delayed_view_update();
void process_sticky_events();
vector< shared_ptr<DecodeTrace> > decode_traces_;
#endif
+ /// The ID of the currently displayed segment
+ int current_segment_;
+
/// The view time scale in seconds per pixel.
double scale_;