X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Flogicsignal.cpp;h=63d15314cdcf23470261f72a82dafedde51619e3;hp=b20e5f06bf457b2b7710085aa39addbe0cab3757;hb=30bb6ca0a51a601c3bee8f53ccbbc7479aebf2d5;hpb=60d9b99a32e551cffd2b537d3e157d578a761c9b diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index b20e5f06..63d15314 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -25,6 +25,7 @@ #include +#include #include #include @@ -59,9 +60,6 @@ using sigrok::TriggerMatchType; namespace pv { namespace view { -const int LogicSignal::SignalHeight = 30; -const int LogicSignal::SignalMargin = 10; - const float LogicSignal::Oversampling = 2.0f; const QColor LogicSignal::EdgeColour(0x80, 0x80, 0x80); @@ -103,6 +101,7 @@ LogicSignal::LogicSignal( shared_ptr channel, shared_ptr data) : Signal(session, channel), + signal_height_(QFontMetrics(QApplication::font()).height() * 2), device_(device), data_(data), trigger_none_(nullptr), @@ -147,7 +146,21 @@ void LogicSignal::set_logic_data(std::shared_ptr data) std::pair LogicSignal::v_extents() const { - return make_pair(-SignalHeight - SignalMargin, SignalMargin); + const int signal_margin = + QFontMetrics(QApplication::font()).height() / 2; + return make_pair(-signal_height_ - signal_margin, signal_margin); +} + +int LogicSignal::scale_handle_offset() const +{ + return -signal_height_; +} + +void LogicSignal::scale_handle_dragged(int offset) +{ + const int font_height = QFontMetrics(QApplication::font()).height(); + const int units = (-offset / font_height); + signal_height_ = ((units < 1) ? 1 : units) * font_height; } void LogicSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) @@ -171,7 +184,7 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) if (!channel_->enabled()) return; - const float high_offset = y - SignalHeight + 0.5f; + const float high_offset = y - signal_height_ + 0.5f; const float low_offset = y + 0.5f; const deque< shared_ptr > &segments = @@ -236,7 +249,7 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) void LogicSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp) { // Draw the trigger marker - if (!trigger_match_) + if (!trigger_match_ || !channel_->enabled()) return; const int y = get_visual_y(); @@ -258,7 +271,7 @@ void LogicSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp) const QSize size = pixmap->size(); const QPoint point( pp.right() - size.width() - pad * 2, - y - (SignalHeight + size.height()) / 2); + y - (signal_height_ + size.height()) / 2); p.setPen(QPen(TriggerMarkerBackgroundColour.darker())); p.setBrush(TriggerMarkerBackgroundColour); @@ -420,7 +433,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 match) { return match->channel() != channel_; })) continue; @@ -434,8 +447,15 @@ void LogicSignal::modify_trigger() } } - if (trigger_match_) - new_trigger->add_stage()->add_match(channel_, trigger_match_); + if (trigger_match_) { + // Until we can let the user decide how to group trigger matches + // into stages, put all of the matches into a single stage -- + // most devices only support a single trigger stage. + if (new_trigger->stages().empty()) + new_trigger->add_stage(); + + new_trigger->stages().back()->add_match(channel_, trigger_match_); + } session_.session()->set_trigger( new_trigger->stages().empty() ? nullptr : new_trigger);