From: Joel Holdsworth Date: Sat, 29 Nov 2014 18:48:06 +0000 (+0000) Subject: SignalData: Moved start_time into Snapshot X-Git-Tag: pulseview-0.3.0~395 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7f4038d6abbe86e8a8c511df188293a704064167;p=pulseview.git SignalData: Moved start_time into Snapshot --- diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index bb2818bb..e5a75877 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -263,7 +263,7 @@ void DecoderStack::begin_decode() snapshot_ = snapshots.front(); // Get the samplerate and start time - start_time_ = data->get_start_time(); + start_time_ = snapshot_->start_time(); samplerate_ = data->samplerate(); if (samplerate_ == 0.0) samplerate_ = 1.0; diff --git a/pv/data/signaldata.cpp b/pv/data/signaldata.cpp index 42409b82..ceeef0b4 100644 --- a/pv/data/signaldata.cpp +++ b/pv/data/signaldata.cpp @@ -24,7 +24,6 @@ namespace pv { namespace data { SignalData::SignalData() : - start_time_(0), samplerate_(0) { } @@ -40,10 +39,5 @@ void SignalData::set_samplerate(double samplerate) clear(); } -double SignalData::get_start_time() const -{ - return start_time_; -} - } // namespace data } // namespace pv diff --git a/pv/data/signaldata.hpp b/pv/data/signaldata.hpp index 35b1305f..7d67add1 100644 --- a/pv/data/signaldata.hpp +++ b/pv/data/signaldata.hpp @@ -40,8 +40,6 @@ public: double samplerate() const; void set_samplerate(double samplerate); - double get_start_time() const; - virtual std::vector< std::shared_ptr > snapshots() const = 0; virtual void clear() = 0; @@ -49,7 +47,6 @@ public: virtual uint64_t get_max_sample_count() const = 0; protected: - double start_time_; double samplerate_; }; diff --git a/pv/data/snapshot.cpp b/pv/data/snapshot.cpp index 58da4dbd..6e1235d2 100644 --- a/pv/data/snapshot.cpp +++ b/pv/data/snapshot.cpp @@ -32,6 +32,7 @@ namespace data { Snapshot::Snapshot(unsigned int unit_size) : sample_count_(0), + start_time_(0), capacity_(0), unit_size_(unit_size) { @@ -50,6 +51,11 @@ uint64_t Snapshot::get_sample_count() const return sample_count_; } +double Snapshot::start_time() const +{ + return start_time_; +} + unsigned int Snapshot::unit_size() const { return unit_size_; diff --git a/pv/data/snapshot.hpp b/pv/data/snapshot.hpp index 29d0eed4..b9dacc7e 100644 --- a/pv/data/snapshot.hpp +++ b/pv/data/snapshot.hpp @@ -37,6 +37,8 @@ public: uint64_t get_sample_count() const; + double start_time() const; + unsigned int unit_size() const; /** @@ -73,6 +75,7 @@ protected: mutable std::recursive_mutex mutex_; std::vector data_; uint64_t sample_count_; + double start_time_; uint64_t capacity_; unsigned int unit_size_; }; diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index c4d31cb6..382d1e35 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -113,7 +113,7 @@ void AnalogSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) 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); diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 79f8457a..48316f8b 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -184,7 +184,7 @@ void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) 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); diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 5877c22d..aac6333a 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -57,6 +57,7 @@ using boost::shared_lock; using boost::shared_mutex; using pv::data::SignalData; +using pv::data::Snapshot; using pv::util::format_time; using std::back_inserter; @@ -306,22 +307,26 @@ set< shared_ptr > View::get_visible_data() const pair View::get_time_extents() const { - const set< shared_ptr > 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 > visible_data = get_visible_data(); for (const shared_ptr 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 > snapshots = + d->snapshots(); + for (const shared_ptr &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); }