double samplerate() const;
void set_samplerate(double samplerate);
- double get_start_time() const;
-
virtual std::vector< std::shared_ptr<Snapshot> > snapshots() const = 0;
virtual void clear() = 0;
virtual uint64_t get_max_sample_count() const = 0;
protected:
- double start_time_;
double samplerate_;
};
const double pixels_offset = pp.pixels_offset();
const double samplerate = data_->samplerate();
- const double start_time = data_->get_start_time();
+ const double start_time = snapshot->start_time();
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * pp.scale();
const double start = samplerate * (pp.offset() - start_time);
samplerate = 1.0;
const double pixels_offset = pp.pixels_offset();
- const double start_time = data_->get_start_time();
+ const double start_time = snapshot->start_time();
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * pp.scale();
const double start = samplerate * (pp.offset() - start_time);
using boost::shared_mutex;
using pv::data::SignalData;
+using pv::data::Snapshot;
using pv::util::format_time;
using std::back_inserter;
pair<double, double> View::get_time_extents() const
{
- const set< shared_ptr<SignalData> > visible_data = get_visible_data();
- if (visible_data.empty())
- return make_pair(0.0, 0.0);
-
double left_time = DBL_MAX, right_time = DBL_MIN;
+ const set< shared_ptr<SignalData> > visible_data = get_visible_data();
for (const shared_ptr<SignalData> d : visible_data)
{
- const double start_time = d->get_start_time();
double samplerate = d->samplerate();
samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
- left_time = min(left_time, start_time);
- right_time = max(right_time, start_time +
- d->get_max_sample_count() / samplerate);
+ const vector< shared_ptr<Snapshot> > snapshots =
+ d->snapshots();
+ for (const shared_ptr<Snapshot> &s : snapshots) {
+ const double start_time = s->start_time();
+ left_time = min(left_time, start_time);
+ right_time = max(right_time, start_time +
+ d->get_max_sample_count() / samplerate);
+ }
}
+ if (left_time == DBL_MAX && right_time == DBL_MIN)
+ return make_pair(0.0, 0.0);
+
assert(left_time < right_time);
return make_pair(left_time, right_time);
}