// Stop any currently running capture session
session_.stop_capture();
- // Get sample rate
- double samplerate = 0.0;
-
- for (const shared_ptr<pv::data::SignalData> d : session_.get_data()) {
- assert(d);
- const vector< shared_ptr<pv::data::Segment> > segments =
- d->segments();
- for (const shared_ptr<pv::data::Segment> &s : segments)
- samplerate = std::max(samplerate, s->samplerate());
- }
-
- if (samplerate == 0.0)
- samplerate = 1;
-
// Verify that the cursors are active and fetch their values
if (!view_->cursors()->enabled()) {
show_session_error(tr("Missing Cursors"), tr("You need to set the " \
return;
}
+ const double samplerate = session_.get_samplerate();
+
const pv::util::Timestamp& start_time = view_->cursors()->first()->time();
const pv::util::Timestamp& end_time = view_->cursors()->second()->time();
return data;
}
+double Session::get_samplerate() const
+{
+ double samplerate = 0.0;
+
+ for (const shared_ptr<pv::data::SignalData> d : get_data()) {
+ assert(d);
+ const vector< shared_ptr<pv::data::Segment> > segments =
+ d->segments();
+ for (const shared_ptr<pv::data::Segment> &s : segments)
+ samplerate = std::max(samplerate, s->samplerate());
+ }
+
+ // If there is no sample rate given we use samples as unit
+ if (samplerate == 0.0)
+ samplerate = 1.0;
+
+ return samplerate;
+}
+
const unordered_set< shared_ptr<view::Signal> > Session::signals() const
{
shared_lock<shared_mutex> lock(signals_mutex_);
std::set< std::shared_ptr<data::SignalData> > get_data() const;
+ double get_samplerate() const;
+
const std::unordered_set< std::shared_ptr<view::Signal> >
signals() const;
if (visible_data.empty())
return;
- double samplerate = 0.0;
- for (const shared_ptr<SignalData> d : visible_data) {
- assert(d);
- const vector< shared_ptr<Segment> > segments =
- d->segments();
- for (const shared_ptr<Segment> &s : segments)
- samplerate = max(samplerate, s->samplerate());
- }
-
- if (samplerate == 0.0)
- return;
-
assert(viewport_);
const int w = viewport_->width();
if (w <= 0)
return;
- set_zoom(1.0 / samplerate, w / 2);
+ set_zoom(1.0 / session_.get_samplerate(), w / 2);
}
void View::set_scale_offset(double scale, const Timestamp& offset)