cabana: display the actual signal time on the track line (#28080)

Display the actual signal time on the track line
pull/28086/head
Dean Lee 2 years ago committed by GitHub
parent a16730a9c4
commit 50e6c43efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      tools/cabana/chart/chart.cc
  2. 4
      tools/cabana/chart/tiplabel.cc

@ -534,8 +534,8 @@ void ChartView::showTip(double sec) {
} }
tooltip_x = chart()->mapToPosition({sec, 0}).x(); tooltip_x = chart()->mapToPosition({sec, 0}).x();
qreal x = tooltip_x; qreal x = -1;
QStringList text_list(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3)); QStringList text_list;
for (auto &s : sigs) { for (auto &s : sigs) {
if (s.series->isVisible()) { if (s.series->isVisible()) {
QString value = "--"; QString value = "--";
@ -553,7 +553,11 @@ void ChartView::showTip(double sec) {
.arg(s.series->color().name(), name, value, min, max); .arg(s.series->color().name(), name, value, min, max);
} }
} }
if (x < 0) {
x = tooltip_x;
}
QPoint pt(x, chart()->plotArea().top()); QPoint pt(x, chart()->plotArea().top());
text_list.push_front(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3));
QString text = "<p style='white-space:pre'>" % text_list.join("<br />") % "</p>"; QString text = "<p style='white-space:pre'>" % text_list.join("<br />") % "</p>";
tip_label.showText(pt, text, this, visible_rect); tip_label.showText(pt, text, this, visible_rect);
viewport()->update(); viewport()->update();

@ -30,9 +30,9 @@ void TipLabel::showText(const QPoint &pt, const QString &text, QWidget *w, const
if (!text.isEmpty()) { if (!text.isEmpty()) {
QSize extra(1, 1); QSize extra(1, 1);
resize(sizeHint() + extra); 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()) { 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()})) { if (rect.contains({tip_pos, size()})) {
move(w->mapToGlobal(tip_pos)); move(w->mapToGlobal(tip_pos));

Loading…
Cancel
Save