X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Flogicsignal.cpp;h=4a8939d14eadaa6f298aa5f1e682c783685f9ffb;hp=22b39bbbcfaa49f907696c005fb991508e3cb3eb;hb=3b84fd6d59b10053d5ffba90f8e66324f49841a3;hpb=ddfda54df6070f6188663d9cc17b7cafeb30cc40 diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 22b39bbb..4a8939d1 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -31,10 +31,10 @@ #include "logicsignal.hpp" #include "view.hpp" -#include +#include #include #include -#include +#include #include #include @@ -145,63 +145,52 @@ std::pair LogicSignal::v_extents() const return make_pair(-SignalHeight - SignalMargin, SignalMargin); } -void LogicSignal::paint_back(QPainter &p, int left, int right) +void LogicSignal::paint_back(QPainter &p, const RowItemPaintParams &pp) { if (channel_->enabled()) - paint_axis(p, get_visual_y(), left, right); + paint_axis(p, pp, get_visual_y()); } -void LogicSignal::paint_mid(QPainter &p, int left, int right) +void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) { - using pv::view::View; - QLineF *line; vector< pair > edges; assert(channel_); assert(data_); - assert(right >= left); assert(owner_); const int y = get_visual_y(); - const View *const view = owner_->view(); - assert(view); - - const double scale = view->scale(); - assert(scale > 0); - - const double offset = view->offset(); - if (!channel_->enabled()) return; const float high_offset = y - SignalHeight + 0.5f; const float low_offset = y + 0.5f; - const deque< shared_ptr > &snapshots = - data_->get_snapshots(); - if (snapshots.empty()) + const deque< shared_ptr > &segments = + data_->logic_segments(); + if (segments.empty()) return; - const shared_ptr &snapshot = - snapshots.front(); + const shared_ptr &segment = + segments.front(); - double samplerate = data_->samplerate(); + double samplerate = segment->samplerate(); // Show sample rate as 1Hz when it is unknown if (samplerate == 0.0) samplerate = 1.0; - const double pixels_offset = offset / scale; - const double start_time = data_->get_start_time(); - const int64_t last_sample = snapshot->get_sample_count() - 1; - const double samples_per_pixel = samplerate * scale; - const double start = samplerate * (offset - start_time); - const double end = start + samples_per_pixel * (right - left); + const double pixels_offset = pp.pixels_offset(); + const double start_time = segment->start_time(); + const int64_t last_sample = segment->get_sample_count() - 1; + const double samples_per_pixel = samplerate * pp.scale(); + const double start = samplerate * (pp.offset() - start_time); + const double end = start + samples_per_pixel * pp.width(); - snapshot->get_subsampled_edges(edges, + segment->get_subsampled_edges(edges, min(max((int64_t)floor(start), (int64_t)0), last_sample), min(max((int64_t)ceil(end), (int64_t)0), last_sample), samples_per_pixel / Oversampling, channel_->index()); @@ -214,7 +203,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) for (auto i = edges.cbegin() + 1; i != edges.cend() - 1; i++) { const float x = ((*i).first / samples_per_pixel - - pixels_offset) + left; + pixels_offset) + pp.left(); *line++ = QLineF(x, high_offset, x, low_offset); } @@ -228,18 +217,16 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) p.setPen(HighColour); paint_caps(p, cap_lines, edges, true, samples_per_pixel, - pixels_offset, left, high_offset); + pixels_offset, pp.left(), high_offset); p.setPen(LowColour); paint_caps(p, cap_lines, edges, false, samples_per_pixel, - pixels_offset, left, low_offset); + pixels_offset, pp.left(), low_offset); delete[] cap_lines; } -void LogicSignal::paint_fore(QPainter &p, int left, int right) +void LogicSignal::paint_fore(QPainter &p, const RowItemPaintParams &pp) { - (void)left; - // Draw the trigger marker if (!trigger_match_) return; @@ -259,15 +246,15 @@ void LogicSignal::paint_fore(QPainter &p, int left, int right) if (!pixmap) continue; - const int pad = TriggerMarkerPadding; + const float pad = TriggerMarkerPadding - 0.5f; const QSize size = pixmap->size(); const QPoint point( - right - size.width() - pad * 2, + pp.right() - size.width() - pad * 2, y - (SignalHeight + size.height()) / 2); - p.setPen(QPen(Qt::NoPen)); + p.setPen(QPen(TriggerMarkerBackgroundColour.darker())); p.setBrush(TriggerMarkerBackgroundColour); - p.drawRoundedRect(QRect(point, size).adjusted( + p.drawRoundedRect(QRectF(point, size).adjusted( -pad, -pad, pad, pad), pad, pad); p.drawPixmap(point, *pixmap);