]> sigrok.org Git - pulseview.git/blobdiff - pv/view/analogsignal.cpp
Add a spin box widget for timestamp values
[pulseview.git] / pv / view / analogsignal.cpp
index 5b6d8a50ca3ac4e24d96d5892a73b7a155ecffdc..8e541dac1672da902233105215f49d0c4c271c01 100644 (file)
@@ -28,7 +28,7 @@
 #include "pv/data/analogsegment.hpp"
 #include "pv/view/view.hpp"
 
-#include <libsigrok/libsigrok.hpp>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 using std::max;
 using std::make_pair;
@@ -87,13 +87,13 @@ std::pair<int, int> 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 +113,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>(),
                (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>(),
                (int64_t)0), last_sample);
 
        if (samples_per_pixel < EnvelopeThreshold)
@@ -181,7 +181,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 +193,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);