From 175af7f6871d4b1a64a39e19e780927f08e25340 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 3 May 2023 03:46:28 +0800 Subject: [PATCH] cabana: display the actual signal time on the track line (#28080) Display the actual signal time on the track line old-commit-hash: 50e6c43efd346860c61c8aa053518499c831a624 --- tools/cabana/chart/chart.cc | 8 ++++++-- tools/cabana/chart/tiplabel.cc | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/cabana/chart/chart.cc b/tools/cabana/chart/chart.cc index 23ea21f4f..1d61d543d 100644 --- a/tools/cabana/chart/chart.cc +++ b/tools/cabana/chart/chart.cc @@ -534,8 +534,8 @@ void ChartView::showTip(double sec) { } tooltip_x = chart()->mapToPosition({sec, 0}).x(); - qreal x = tooltip_x; - QStringList text_list(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3)); + qreal x = -1; + QStringList text_list; for (auto &s : sigs) { if (s.series->isVisible()) { QString value = "--"; @@ -553,7 +553,11 @@ void ChartView::showTip(double sec) { .arg(s.series->color().name(), name, value, min, max); } } + if (x < 0) { + x = tooltip_x; + } QPoint pt(x, chart()->plotArea().top()); + text_list.push_front(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3)); QString text = "

" % text_list.join("
") % "

"; tip_label.showText(pt, text, this, visible_rect); viewport()->update(); diff --git a/tools/cabana/chart/tiplabel.cc b/tools/cabana/chart/tiplabel.cc index 37c00834c..f34d7e8df 100644 --- a/tools/cabana/chart/tiplabel.cc +++ b/tools/cabana/chart/tiplabel.cc @@ -30,9 +30,9 @@ void TipLabel::showText(const QPoint &pt, const QString &text, QWidget *w, const if (!text.isEmpty()) { QSize extra(1, 1); resize(sizeHint() + extra); - QPoint tip_pos(pt.x() + 12, rect.top() + 2); + QPoint tip_pos(pt.x() + 8, rect.top() + 2); if (tip_pos.x() + size().width() >= rect.right()) { - tip_pos.rx() = pt.x() - size().width() - 12; + tip_pos.rx() = pt.x() - size().width() - 8; } if (rect.contains({tip_pos, size()})) { move(w->mapToGlobal(tip_pos));