X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=3df87e540b986b0e08b1242c9139950f65f12a5b;hp=aac6333addd032c0adb85886c60f2fdf9b48a248;hb=b3f44329f5846bfb800ee53c15c65b2395d3ba0c;hpb=7f4038d6abbe86e8a8c511df188293a704064167 diff --git a/pv/view/view.cpp b/pv/view/view.cpp index aac6333a..3df87e54 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -50,14 +50,14 @@ #include "pv/session.hpp" #include "pv/data/logic.hpp" -#include "pv/data/logicsnapshot.hpp" +#include "pv/data/logicsegment.hpp" #include "pv/util.hpp" using boost::shared_lock; using boost::shared_mutex; using pv::data::SignalData; -using pv::data::Snapshot; +using pv::data::Segment; using pv::util::format_time; using std::back_inserter; @@ -104,7 +104,7 @@ View::View(Session &session, QWidget *parent) : tick_period_(0.0), tick_prefix_(0), show_cursors_(false), - cursors_(*this), + cursors_(new CursorPair(*this)), hover_point_(-1, -1) { connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), @@ -121,9 +121,9 @@ View::View(Session &session, QWidget *parent) : connect(&session_, SIGNAL(frame_ended()), this, SLOT(data_updated())); - connect(cursors_.first().get(), SIGNAL(time_changed()), + connect(cursors_->first().get(), SIGNAL(time_changed()), this, SLOT(marker_time_changed())); - connect(cursors_.second().get(), SIGNAL(time_changed()), + connect(cursors_->second().get(), SIGNAL(time_changed()), this, SLOT(marker_time_changed())); connect(header_, SIGNAL(signals_moved()), @@ -195,6 +195,14 @@ const Viewport* View::viewport() const return viewport_; } +vector< shared_ptr > View::time_items() const +{ + vector< shared_ptr > items; + items.push_back(cursors_->first()); + items.push_back(cursors_->second()); + return items; +} + double View::scale() const { return scale_; @@ -263,7 +271,10 @@ void View::zoom_one_to_one() double samplerate = 0.0; for (const shared_ptr d : visible_data) { assert(d); - samplerate = max(samplerate, d->samplerate()); + const vector< shared_ptr > segments = + d->segments(); + for (const shared_ptr &s : segments) + samplerate = max(samplerate, s->samplerate()); } if (samplerate == 0.0) @@ -311,12 +322,12 @@ pair View::get_time_extents() const const set< shared_ptr > visible_data = get_visible_data(); for (const shared_ptr d : visible_data) { - double samplerate = d->samplerate(); - samplerate = (samplerate <= 0.0) ? 1.0 : samplerate; + const vector< shared_ptr > segments = + d->segments(); + for (const shared_ptr &s : segments) { + double samplerate = s->samplerate(); + samplerate = (samplerate <= 0.0) ? 1.0 : 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 + @@ -346,18 +357,13 @@ void View::show_cursors(bool show) void View::centre_cursors() { const double time_width = scale_ * viewport_->width(); - cursors_.first()->set_time(offset_ + time_width * 0.4); - cursors_.second()->set_time(offset_ + time_width * 0.6); + cursors_->first()->set_time(offset_ + time_width * 0.4); + cursors_->second()->set_time(offset_ + time_width * 0.6); cursorheader_->update(); viewport_->update(); } -CursorPair& View::cursors() -{ - return cursors_; -} - -const CursorPair& View::cursors() const +std::shared_ptr View::cursors() const { return cursors_; } @@ -499,16 +505,16 @@ void View::update_layout() update_scroll(); } -void View::paint_label(QPainter &p, int right, bool hover) +void View::paint_label(QPainter &p, const QRect &rect, bool hover) { (void)p; - (void)right; + (void)rect; (void)hover; } -QRectF View::label_rect(int right) +QRectF View::label_rect(const QRectF &rect) { - (void)right; + (void)rect; return QRectF(); }