X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=e43522577e9c985e3808d5cf5edce5b5c4365017;hb=8914fe790fb677c56194a3ae4da06ba671fca78a;hp=e0c49c20ad4b2f60b4e9ea1b16c69420318321ba;hpb=ff008de665c7990d5f3408f918ff090d8e6c60b2;p=pulseview.git diff --git a/pv/view/view.cpp b/pv/view/view.cpp index e0c49c2..e435225 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -50,17 +50,16 @@ #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; using std::deque; using std::dynamic_pointer_cast; using std::list; @@ -104,7 +103,8 @@ View::View(Session &session, QWidget *parent) : tick_period_(0.0), tick_prefix_(0), show_cursors_(false), - cursors_(*this), + cursors_(new CursorPair(*this)), + next_flag_text_('A'), hover_point_(-1, -1) { connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), @@ -121,11 +121,6 @@ View::View(Session &session, QWidget *parent) : connect(&session_, SIGNAL(frame_ended()), this, SLOT(data_updated())); - connect(cursors_.first().get(), SIGNAL(time_changed()), - this, SLOT(marker_time_changed())); - connect(cursors_.second().get(), SIGNAL(time_changed()), - this, SLOT(marker_time_changed())); - connect(header_, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); @@ -195,6 +190,16 @@ const Viewport* View::viewport() const return viewport_; } +vector< shared_ptr > View::time_items() const +{ + const vector> f(flags()); + vector> items(f.begin(), f.end()); + items.push_back(cursors_); + items.push_back(cursors_->first()); + items.push_back(cursors_->second()); + return items; +} + double View::scale() const { return scale_; @@ -263,9 +268,9 @@ void View::zoom_one_to_one() double samplerate = 0.0; for (const shared_ptr d : visible_data) { assert(d); - const vector< shared_ptr > snapshots = - d->snapshots(); - for (const shared_ptr &s : snapshots) + const vector< shared_ptr > segments = + d->segments(); + for (const shared_ptr &s : segments) samplerate = max(samplerate, s->samplerate()); } @@ -314,9 +319,9 @@ pair View::get_time_extents() const const set< shared_ptr > visible_data = get_visible_data(); for (const shared_ptr d : visible_data) { - const vector< shared_ptr > snapshots = - d->snapshots(); - for (const shared_ptr &s : snapshots) { + const vector< shared_ptr > segments = + d->segments(); + for (const shared_ptr &s : segments) { double samplerate = s->samplerate(); samplerate = (samplerate <= 0.0) ? 1.0 : samplerate; @@ -349,20 +354,41 @@ 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() +std::shared_ptr View::cursors() const { return cursors_; } -const CursorPair& View::cursors() const +void View::add_flag(double time) { - return cursors_; + flags_.push_back(shared_ptr(new Flag(*this, time, + QString("%1").arg(next_flag_text_)))); + next_flag_text_ = (next_flag_text_ >= 'Z') ? 'A' : + (next_flag_text_ + 1); + time_item_appearance_changed(true, true); +} + +void View::remove_flag(std::shared_ptr flag) +{ + flags_.remove(flag); + time_item_appearance_changed(true, true); +} + +vector< std::shared_ptr > View::flags() const +{ + vector< std::shared_ptr > flags(flags_.begin(), flags_.end()); + stable_sort(flags.begin(), flags.end(), + [](const shared_ptr &a, const shared_ptr &b) { + return a->time() < b->time(); + }); + + return flags; } const QPoint& View::hover_point() const @@ -479,11 +505,11 @@ void View::update_scroll() // Set the vertical scrollbar verticalScrollBar()->setPageStep(areaSize.height()); + verticalScrollBar()->setSingleStep(areaSize.height() / 8); const pair extents = v_extents(); - const int extra_scroll_height = (extents.second - extents.first) / 4; - verticalScrollBar()->setRange(extents.first - extra_scroll_height, - extents.first + extra_scroll_height); + verticalScrollBar()->setRange(extents.first - (areaSize.height() / 2), + extents.second - (areaSize.height() / 2)); } void View::update_layout() @@ -502,16 +528,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(); } @@ -603,7 +629,7 @@ void View::resizeEvent(QResizeEvent*) update_layout(); } -void View::appearance_changed(bool label, bool content) +void View::row_item_appearance_changed(bool label, bool content) { if (label) header_->update(); @@ -611,11 +637,19 @@ void View::appearance_changed(bool label, bool content) viewport_->update(); } +void View::time_item_appearance_changed(bool label, bool content) +{ + if (label) + cursorheader_->update(); + if (content) + viewport_->update(); +} + void View::extents_changed(bool horz, bool vert) { sticky_events_ |= - (horz ? SelectableItemHExtentsChanged : 0) | - (vert ? SelectableItemVExtentsChanged : 0); + (horz ? RowItemHExtentsChanged : 0) | + (vert ? RowItemVExtentsChanged : 0); lazy_event_handler_.start(); } @@ -724,12 +758,6 @@ void View::data_updated() viewport_->update(); } -void View::marker_time_changed() -{ - cursorheader_->update(); - viewport_->update(); -} - void View::on_signals_moved() { update_scroll(); @@ -738,9 +766,9 @@ void View::on_signals_moved() void View::process_sticky_events() { - if (sticky_events_ & SelectableItemHExtentsChanged) + if (sticky_events_ & RowItemHExtentsChanged) update_layout(); - if (sticky_events_ & SelectableItemVExtentsChanged) + if (sticky_events_ & RowItemVExtentsChanged) restack_all_row_items(); // Clear the sticky events