X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecodetrace.cpp;h=5ca665e0dff947f17ebbcbd0a5a77aa8802d1b98;hp=138ba0a14263fc92e0ce09cb74232f227d0b0c22;hb=be9e7b4bb29b6594ec2b64442748ab135b684bf8;hpb=c3a740dd5d095eb1cdf42e00df4d5a5c480ac5b3 diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 138ba0a1..5ca665e0 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -53,14 +53,16 @@ extern "C" { #include #include +using boost::shared_lock; +using boost::shared_mutex; using std::dynamic_pointer_cast; using std::list; using std::lock_guard; using std::make_pair; using std::max; +using std::make_pair; using std::map; using std::min; -using std::mutex; using std::pair; using std::shared_ptr; using std::tie; @@ -154,10 +156,20 @@ const std::shared_ptr& DecodeTrace::decoder() const return _decoder_stack; } +pair DecodeTrace::v_extents() const +{ + /// @todo Replace this with an implementation that knows the true + /// height of the trace + QFontMetrics m(QApplication::font()); + const int text_height = m.boundingRect(QRect(), 0, "Tg").height(); + const int row_height = (text_height * 6) / 4; + return make_pair(-row_height / 2, row_height * 7 / 2); +} + void DecodeTrace::paint_back(QPainter &p, int left, int right) { Trace::paint_back(p, left, right); - paint_axis(p, get_y(), left, right); + paint_axis(p, get_visual_y(), left, right); } void DecodeTrace::paint_mid(QPainter &p, int left, int right) @@ -179,7 +191,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) } // Iterate through the rows - int y = get_y(); + int y = get_visual_y(); pair sample_range = get_sample_range(left, right); assert(_decoder_stack); @@ -224,7 +236,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) for (size_t i = 0; i < _visible_rows.size(); i++) { - const int y = i * _row_height + get_y(); + const int y = i * _row_height + get_visual_y(); p.setPen(QPen(Qt::NoPen)); p.setBrush(QApplication::palette().brush(QPalette::WindowText)); @@ -431,7 +443,7 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, void DecodeTrace::draw_error(QPainter &p, const QString &message, int left, int right) { - const int y = get_y(); + const int y = get_visual_y(); p.setPen(ErrorBgColour.darker()); p.setBrush(ErrorBgColour); @@ -487,7 +499,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, if (sample_count == samples_decoded) return; - const int y = get_y(); + const int y = get_visual_y(); tie(pixels_offset, samples_per_pixel) = get_pixels_offset_samples_per_pixel(); @@ -550,7 +562,8 @@ int DecodeTrace::get_row_at_point(const QPoint &point) if (!_row_height) return -1; - const int row = (point.y() - get_y() + _row_height / 2) / _row_height; + const int row = (point.y() - get_visual_y() + _row_height / 2) / + _row_height; if (row < 0 || row >= (int)_visible_rows.size()) return -1; @@ -618,8 +631,9 @@ void DecodeTrace::hover_point_changed() // decode trace, not below. hp.setX(hp.x() - (text_size.width() / 2) - padding); - hp.setY(get_y() - (_row_height / 2) + (hover_row * _row_height) - - _row_height - text_size.height()); + hp.setY(get_visual_y() - (_row_height / 2) + + (hover_row * _row_height) - + _row_height - text_size.height()); QToolTip::showText(view->viewport()->mapToGlobal(hp), ann); } @@ -696,7 +710,7 @@ QComboBox* DecodeTrace::create_channel_selector( { assert(dec); - lock_guard lock(_session.signals_mutex()); + shared_lock lock(_session.signals_mutex()); const vector< shared_ptr > &sigs(_session.signals()); assert(_decoder_stack); @@ -731,7 +745,7 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec map > channel_map; - lock_guard lock(_session.signals_mutex()); + shared_lock lock(_session.signals_mutex()); const vector< shared_ptr > &sigs(_session.signals()); for (const ChannelSelector &s : _channel_selectors)