Signal: Added scale_handle_offset, scale_handle_dragged and scale_handle_released
[pulseview.git] / pv / view / logicsignal.cpp
index 58eaac9317c3694625d0757eb5cf2264ea9a5918..573d1b780645dd4304295f1543f66f0fb76f4835 100644 (file)
@@ -105,12 +105,12 @@ LogicSignal::LogicSignal(
        Signal(session, channel),
        device_(device),
        data_(data),
-       trigger_none_(NULL),
-       trigger_rising_(NULL),
-       trigger_high_(NULL),
-       trigger_falling_(NULL),
-       trigger_low_(NULL),
-       trigger_change_(NULL)
+       trigger_none_(nullptr),
+       trigger_rising_(nullptr),
+       trigger_high_(nullptr),
+       trigger_falling_(nullptr),
+       trigger_low_(nullptr),
+       trigger_change_(nullptr)
 {
        shared_ptr<Trigger> trigger;
 
@@ -150,6 +150,16 @@ std::pair<int, int> LogicSignal::v_extents() const
        return make_pair(-SignalHeight - SignalMargin, SignalMargin);
 }
 
+int LogicSignal::scale_handle_offset() const
+{
+       return SignalHeight;
+}
+
+void LogicSignal::scale_handle_dragged(int offset)
+{
+       (void)offset;
+}
+
 void LogicSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
 {
        if (channel_->enabled())
@@ -189,15 +199,18 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
                samplerate = 1.0;
 
        const double pixels_offset = pp.pixels_offset();
-       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(floor(start).convert_to<int64_t>(),
+               (int64_t)0), last_sample);
+       const uint64_t end_sample = min(max(ceil(end).convert_to<int64_t>(),
+               (int64_t)0), last_sample);
 
-       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),
+       segment->get_subsampled_edges(edges, start_sample, end_sample,
                samples_per_pixel / Oversampling, channel_->index());
        assert(edges.size() >= 2);
 
@@ -417,7 +430,7 @@ void LogicSignal::modify_trigger()
        if (trigger) {
                for (auto stage : trigger->stages()) {
                        const auto &matches = stage->matches();
-                       if (std::none_of(begin(matches), end(matches),
+                       if (std::none_of(matches.begin(), matches.end(),
                            [&](shared_ptr<TriggerMatch> match) {
                                        return match->channel() != channel_; }))
                                continue;