X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Fanalogsignal.cpp;h=efde2941d9137041b0c3fcfa9b882d3d882c0ff8;hb=e71eb81c946c3524e01eaef9781ccbf170143d0c;hp=5b6d8a50ca3ac4e24d96d5892a73b7a155ecffdc;hpb=f3d66e52ed6b454ea7a0662d5e6367e230116a2b;p=pulseview.git diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 5b6d8a50..efde2941 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -28,7 +28,7 @@ #include "pv/data/analogsegment.hpp" #include "pv/view/view.hpp" -#include +#include using std::max; using std::make_pair; @@ -77,23 +77,18 @@ shared_ptr AnalogSignal::analog_data() const return data_; } -void AnalogSignal::set_scale(float scale) -{ - scale_ = scale; -} - std::pair AnalogSignal::v_extents() const { return make_pair(-NominalHeight / 2, NominalHeight / 2); } -void AnalogSignal::paint_back(QPainter &p, const RowItemPaintParams &pp) +void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (channel_->enabled()) paint_axis(p, pp, get_visual_y()); } -void AnalogSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) +void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { assert(data_); assert(owner_); @@ -113,15 +108,15 @@ void AnalogSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) const double pixels_offset = pp.pixels_offset(); const double samplerate = segment->samplerate(); - const double start_time = segment->start_time(); + const pv::util::Timestamp& 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(); + const pv::util::Timestamp start = samplerate * (pp.offset() - start_time); + const pv::util::Timestamp end = start + samples_per_pixel * pp.width(); - const int64_t start_sample = min(max((int64_t)floor(start), + const int64_t start_sample = min(max(floor(start).convert_to(), (int64_t)0), last_sample); - const int64_t end_sample = min(max((int64_t)ceil(end) + 1, + const int64_t end_sample = min(max((ceil(end) + 1).convert_to(), (int64_t)0), last_sample); if (samples_per_pixel < EnvelopeThreshold) @@ -181,7 +176,7 @@ void AnalogSignal::paint_envelope(QPainter &p, QRectF *const rects = new QRectF[e.length]; QRectF *rect = rects; - for(uint64_t sample = 0; sample < e.length-1; sample++) { + for (uint64_t sample = 0; sample < e.length-1; sample++) { const float x = ((e.scale * sample + e.start) / samples_per_pixel - pixels_offset) + left; const AnalogSegment::EnvelopeSample *const s = @@ -193,9 +188,9 @@ void AnalogSignal::paint_envelope(QPainter &p, const float t = y - min(s->min, (s+1)->max) * scale_; float h = b - t; - if(h >= 0.0f && h <= 1.0f) + if (h >= 0.0f && h <= 1.0f) h = 1.0f; - if(h <= 0.0f && h >= -1.0f) + if (h <= 0.0f && h >= -1.0f) h = -1.0f; *rect++ = QRectF(x, t, 1.0f, h);