commit
52ba79e425
88 changed files with 2823 additions and 1644 deletions
@ -1 +1 @@ |
||||
Subproject commit d70d215de6c584f671272d2de2f46a4f778e9f14 |
||||
Subproject commit 4f5502c8657813ccb538e9575ca1a7b258b17af9 |
@ -1 +1 @@ |
||||
Subproject commit 14eb9de2d923235a485abbc9b5e8d33c03a06278 |
||||
Subproject commit 3c81860270e918d1a08f14a833522fd798aa39ca |
@ -0,0 +1,4 @@ |
||||
#!/usr/bin/bash |
||||
set -e |
||||
|
||||
RUBYOPT="-W0" irqtop -d1 -R |
@ -0,0 +1,70 @@ |
||||
#!/usr/bin/env python3 |
||||
import time |
||||
import random |
||||
import unittest |
||||
import subprocess |
||||
|
||||
from panda import Panda |
||||
from system.hardware import TICI |
||||
from system.hardware.tici.hardware import Tici |
||||
from system.hardware.tici.amplifier import Amplifier |
||||
|
||||
|
||||
class TestAmplifier(unittest.TestCase): |
||||
|
||||
@classmethod |
||||
def setUpClass(cls): |
||||
if not TICI: |
||||
raise unittest.SkipTest |
||||
|
||||
def setUp(self): |
||||
# clear dmesg |
||||
subprocess.check_call("sudo dmesg -C", shell=True) |
||||
|
||||
self.panda = Panda() |
||||
self.panda.reset() |
||||
|
||||
def tearDown(self): |
||||
self.panda.reset(reconnect=False) |
||||
|
||||
def _check_for_i2c_errors(self, expected): |
||||
dmesg = subprocess.check_output("dmesg", shell=True, encoding='utf8') |
||||
i2c_lines = [l for l in dmesg.strip().splitlines() if 'i2c_geni a88000.i2c' in l] |
||||
i2c_str = '\n'.join(i2c_lines) |
||||
if not expected: |
||||
assert len(i2c_lines) == 0 |
||||
else: |
||||
assert "i2c error :-107" in i2c_str or "Bus arbitration lost" in i2c_str |
||||
|
||||
def test_init(self): |
||||
amp = Amplifier(debug=True) |
||||
r = amp.initialize_configuration(Tici().model) |
||||
assert r |
||||
self._check_for_i2c_errors(False) |
||||
|
||||
def test_shutdown(self): |
||||
amp = Amplifier(debug=True) |
||||
for _ in range(10): |
||||
r = amp.set_global_shutdown(True) |
||||
r = amp.set_global_shutdown(False) |
||||
assert r |
||||
self._check_for_i2c_errors(False) |
||||
|
||||
def test_init_while_siren_play(self): |
||||
for _ in range(5): |
||||
self.panda.set_siren(False) |
||||
time.sleep(0.1) |
||||
|
||||
self.panda.set_siren(True) |
||||
time.sleep(random.randint(0, 5)) |
||||
|
||||
amp = Amplifier(debug=True) |
||||
r = amp.initialize_configuration(Tici().model) |
||||
assert r |
||||
|
||||
# make sure we're a good test |
||||
self._check_for_i2c_errors(True) |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
unittest.main() |
@ -1,7 +1,7 @@ |
||||
moc_* |
||||
*.moc |
||||
|
||||
_cabana |
||||
cabana |
||||
settings |
||||
dbc/car_fingerprint_to_dbc.json |
||||
tests/_test_cabana |
||||
tests/test_cabana |
||||
|
@ -1,4 +0,0 @@ |
||||
#!/bin/sh |
||||
cd "$(dirname "$0")" |
||||
export LD_LIBRARY_PATH="../../opendbc/can:$LD_LIBRARY_PATH" |
||||
exec ./_cabana "$@" |
@ -0,0 +1,751 @@ |
||||
#include "tools/cabana/chart/chart.h" |
||||
|
||||
#include <QActionGroup> |
||||
#include <QApplication> |
||||
#include <QDrag> |
||||
#include <QGraphicsLayout> |
||||
#include <QGraphicsDropShadowEffect> |
||||
#include <QGraphicsOpacityEffect> |
||||
#include <QMenu> |
||||
#include <QMimeData> |
||||
#include <QOpenGLWidget> |
||||
#include <QPropertyAnimation> |
||||
#include <QRubberBand> |
||||
#include <QtMath> |
||||
|
||||
#include "tools/cabana/chart/chartswidget.h" |
||||
|
||||
static inline bool xLessThan(const QPointF &p, float x) { return p.x() < x; } |
||||
|
||||
ChartView::ChartView(const std::pair<double, double> &x_range, ChartsWidget *parent) : charts_widget(parent), tip_label(this), QChartView(nullptr, parent) { |
||||
series_type = (SeriesType)settings.chart_series_type; |
||||
QChart *chart = new QChart(); |
||||
chart->setBackgroundVisible(false); |
||||
axis_x = new QValueAxis(this); |
||||
axis_y = new QValueAxis(this); |
||||
chart->addAxis(axis_x, Qt::AlignBottom); |
||||
chart->addAxis(axis_y, Qt::AlignLeft); |
||||
chart->legend()->layout()->setContentsMargins(0, 0, 0, 0); |
||||
chart->legend()->setShowToolTips(true); |
||||
chart->setMargins({0, 0, 0, 0}); |
||||
|
||||
axis_x->setRange(x_range.first, x_range.second); |
||||
setChart(chart); |
||||
|
||||
createToolButtons(); |
||||
// TODO: enable zoomIn/seekTo in live streaming mode.
|
||||
setRubberBand(can->liveStreaming() ? QChartView::NoRubberBand : QChartView::HorizontalRubberBand); |
||||
setMouseTracking(true); |
||||
setTheme(settings.theme == DARK_THEME ? QChart::QChart::ChartThemeDark : QChart::ChartThemeLight); |
||||
|
||||
QObject::connect(axis_y, &QValueAxis::rangeChanged, [this]() { resetChartCache(); }); |
||||
QObject::connect(axis_y, &QAbstractAxis::titleTextChanged, [this]() { resetChartCache(); }); |
||||
|
||||
QObject::connect(dbc(), &DBCManager::signalRemoved, this, &ChartView::signalRemoved); |
||||
QObject::connect(dbc(), &DBCManager::signalUpdated, this, &ChartView::signalUpdated); |
||||
QObject::connect(dbc(), &DBCManager::msgRemoved, this, &ChartView::msgRemoved); |
||||
QObject::connect(dbc(), &DBCManager::msgUpdated, this, &ChartView::msgUpdated); |
||||
} |
||||
|
||||
void ChartView::createToolButtons() { |
||||
move_icon = new QGraphicsPixmapItem(utils::icon("grip-horizontal"), chart()); |
||||
move_icon->setToolTip(tr("Drag and drop to move chart")); |
||||
|
||||
QToolButton *remove_btn = new ToolButton("x", tr("Remove Chart")); |
||||
close_btn_proxy = new QGraphicsProxyWidget(chart()); |
||||
close_btn_proxy->setWidget(remove_btn); |
||||
close_btn_proxy->setZValue(chart()->zValue() + 11); |
||||
|
||||
// series types
|
||||
QMenu *menu = new QMenu(this); |
||||
auto change_series_group = new QActionGroup(menu); |
||||
change_series_group->setExclusive(true); |
||||
QStringList types{tr("Line"), tr("Step Line"), tr("Scatter")}; |
||||
for (int i = 0; i < types.size(); ++i) { |
||||
QAction *act = new QAction(types[i], change_series_group); |
||||
act->setData(i); |
||||
act->setCheckable(true); |
||||
act->setChecked(i == (int)series_type); |
||||
menu->addAction(act); |
||||
} |
||||
menu->addSeparator(); |
||||
menu->addAction(tr("Manage Signals"), this, &ChartView::manageSignals); |
||||
split_chart_act = menu->addAction(tr("Split Chart"), [this]() { charts_widget->splitChart(this); }); |
||||
|
||||
QToolButton *manage_btn = new ToolButton("list", ""); |
||||
manage_btn->setMenu(menu); |
||||
manage_btn->setPopupMode(QToolButton::InstantPopup); |
||||
manage_btn->setStyleSheet("QToolButton::menu-indicator { image: none; }"); |
||||
manage_btn_proxy = new QGraphicsProxyWidget(chart()); |
||||
manage_btn_proxy->setWidget(manage_btn); |
||||
manage_btn_proxy->setZValue(chart()->zValue() + 11); |
||||
|
||||
QObject::connect(remove_btn, &QToolButton::clicked, [this]() { charts_widget->removeChart(this); }); |
||||
QObject::connect(change_series_group, &QActionGroup::triggered, [this](QAction *action) { |
||||
setSeriesType((SeriesType)action->data().toInt()); |
||||
}); |
||||
} |
||||
|
||||
QSize ChartView::sizeHint() const { |
||||
return {CHART_MIN_WIDTH, settings.chart_height}; |
||||
} |
||||
|
||||
void ChartView::setTheme(QChart::ChartTheme theme) { |
||||
chart()->setTheme(theme); |
||||
if (theme == QChart::ChartThemeDark) { |
||||
axis_x->setTitleBrush(palette().text()); |
||||
axis_x->setLabelsBrush(palette().text()); |
||||
axis_y->setTitleBrush(palette().text()); |
||||
axis_y->setLabelsBrush(palette().text()); |
||||
chart()->legend()->setLabelColor(palette().color(QPalette::Text)); |
||||
} |
||||
for (auto &s : sigs) { |
||||
s.series->setColor(getColor(s.sig)); |
||||
} |
||||
} |
||||
|
||||
void ChartView::addSignal(const MessageId &msg_id, const cabana::Signal *sig) { |
||||
if (hasSignal(msg_id, sig)) return; |
||||
|
||||
QXYSeries *series = createSeries(series_type, getColor(sig)); |
||||
sigs.push_back({.msg_id = msg_id, .sig = sig, .series = series}); |
||||
updateSeries(sig); |
||||
updateSeriesPoints(); |
||||
updateTitle(); |
||||
emit charts_widget->seriesChanged(); |
||||
} |
||||
|
||||
bool ChartView::hasSignal(const MessageId &msg_id, const cabana::Signal *sig) const { |
||||
return std::any_of(sigs.begin(), sigs.end(), [&](auto &s) { return s.msg_id == msg_id && s.sig == sig; }); |
||||
} |
||||
|
||||
void ChartView::removeIf(std::function<bool(const SigItem &s)> predicate) { |
||||
int prev_size = sigs.size(); |
||||
for (auto it = sigs.begin(); it != sigs.end(); /**/) { |
||||
if (predicate(*it)) { |
||||
chart()->removeSeries(it->series); |
||||
it->series->deleteLater(); |
||||
it = sigs.erase(it); |
||||
} else { |
||||
++it; |
||||
} |
||||
} |
||||
if (sigs.empty()) { |
||||
charts_widget->removeChart(this); |
||||
} else if (sigs.size() != prev_size) { |
||||
emit charts_widget->seriesChanged(); |
||||
updateAxisY(); |
||||
resetChartCache(); |
||||
} |
||||
} |
||||
|
||||
void ChartView::signalUpdated(const cabana::Signal *sig) { |
||||
if (std::any_of(sigs.begin(), sigs.end(), [=](auto &s) { return s.sig == sig; })) { |
||||
updateTitle(); |
||||
updateSeries(sig); |
||||
} |
||||
} |
||||
|
||||
void ChartView::msgUpdated(MessageId id) { |
||||
if (std::any_of(sigs.begin(), sigs.end(), [=](auto &s) { return s.msg_id == id; })) |
||||
updateTitle(); |
||||
} |
||||
|
||||
void ChartView::manageSignals() { |
||||
SignalSelector dlg(tr("Mange Chart"), this); |
||||
for (auto &s : sigs) { |
||||
dlg.addSelected(s.msg_id, s.sig); |
||||
} |
||||
if (dlg.exec() == QDialog::Accepted) { |
||||
auto items = dlg.seletedItems(); |
||||
for (auto s : items) { |
||||
addSignal(s->msg_id, s->sig); |
||||
} |
||||
removeIf([&](auto &s) { |
||||
return std::none_of(items.cbegin(), items.cend(), [&](auto &it) { return s.msg_id == it->msg_id && s.sig == it->sig; }); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
void ChartView::resizeEvent(QResizeEvent *event) { |
||||
qreal left, top, right, bottom; |
||||
chart()->layout()->getContentsMargins(&left, &top, &right, &bottom); |
||||
move_icon->setPos(left, top); |
||||
close_btn_proxy->setPos(rect().right() - right - close_btn_proxy->size().width(), top); |
||||
int x = close_btn_proxy->pos().x() - manage_btn_proxy->size().width() - style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
||||
manage_btn_proxy->setPos(x, top); |
||||
if (align_to > 0) { |
||||
updatePlotArea(align_to, true); |
||||
} |
||||
QChartView::resizeEvent(event); |
||||
} |
||||
|
||||
void ChartView::updatePlotArea(int left_pos, bool force) { |
||||
if (align_to != left_pos || force) { |
||||
align_to = left_pos; |
||||
|
||||
qreal left, top, right, bottom; |
||||
chart()->layout()->getContentsMargins(&left, &top, &right, &bottom); |
||||
chart()->legend()->setGeometry({move_icon->sceneBoundingRect().topRight(), manage_btn_proxy->sceneBoundingRect().bottomLeft()}); |
||||
QSizeF x_label_size = QFontMetrics(axis_x->labelsFont()).size(Qt::TextSingleLine, QString::number(axis_x->max(), 'f', 2)); |
||||
x_label_size += QSizeF{5, 5}; |
||||
int adjust_top = chart()->legend()->geometry().height() + style()->pixelMetric(QStyle::PM_LayoutTopMargin); |
||||
chart()->setPlotArea(rect().adjusted(align_to + left, adjust_top + top, -x_label_size.width() / 2 - right, -x_label_size.height() - bottom)); |
||||
chart()->layout()->invalidate(); |
||||
resetChartCache(); |
||||
} |
||||
} |
||||
|
||||
void ChartView::updateTitle() { |
||||
for (QLegendMarker *marker : chart()->legend()->markers()) { |
||||
QObject::connect(marker, &QLegendMarker::clicked, this, &ChartView::handleMarkerClicked, Qt::UniqueConnection); |
||||
} |
||||
for (auto &s : sigs) { |
||||
auto decoration = s.series->isVisible() ? "none" : "line-through"; |
||||
s.series->setName(QString("<span style=\"text-decoration:%1\"><b>%2</b> <font color=\"gray\">%3 %4</font></span>").arg(decoration, s.sig->name, msgName(s.msg_id), s.msg_id.toString())); |
||||
} |
||||
split_chart_act->setEnabled(sigs.size() > 1); |
||||
resetChartCache(); |
||||
} |
||||
|
||||
void ChartView::updatePlot(double cur, double min, double max) { |
||||
cur_sec = cur; |
||||
if (min != axis_x->min() || max != axis_x->max()) { |
||||
axis_x->setRange(min, max); |
||||
updateAxisY(); |
||||
updateSeriesPoints(); |
||||
// update tooltip
|
||||
if (tooltip_x >= 0) { |
||||
showTip(chart()->mapToValue({tooltip_x, 0}).x()); |
||||
} |
||||
resetChartCache(); |
||||
} |
||||
viewport()->update(); |
||||
} |
||||
|
||||
void ChartView::updateSeriesPoints() { |
||||
// Show points when zoomed in enough
|
||||
for (auto &s : sigs) { |
||||
auto begin = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->min(), xLessThan); |
||||
auto end = std::lower_bound(begin, s.vals.end(), axis_x->max(), xLessThan); |
||||
if (begin != end) { |
||||
int num_points = std::max<int>((end - begin), 1); |
||||
QPointF right_pt = end == s.vals.end() ? s.vals.back() : *end; |
||||
double pixels_per_point = (chart()->mapToPosition(right_pt).x() - chart()->mapToPosition(*begin).x()) / num_points; |
||||
|
||||
if (series_type == SeriesType::Scatter) { |
||||
qreal size = std::clamp(pixels_per_point / 2.0, 2.0, 8.0); |
||||
if (s.series->useOpenGL()) { |
||||
size *= devicePixelRatioF(); |
||||
} |
||||
((QScatterSeries *)s.series)->setMarkerSize(size); |
||||
} else { |
||||
s.series->setPointsVisible(pixels_per_point > 20); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ChartView::updateSeries(const cabana::Signal *sig) { |
||||
for (auto &s : sigs) { |
||||
if (!sig || s.sig == sig) { |
||||
if (!can->liveStreaming()) { |
||||
s.vals.clear(); |
||||
s.step_vals.clear(); |
||||
s.last_value_mono_time = 0; |
||||
} |
||||
s.series->setColor(getColor(s.sig)); |
||||
|
||||
const auto &msgs = can->events().at(s.msg_id); |
||||
auto first = std::upper_bound(msgs.cbegin(), msgs.cend(), CanEvent{.mono_time = s.last_value_mono_time}); |
||||
int new_size = std::max<int>(s.vals.size() + std::distance(first, msgs.cend()), settings.max_cached_minutes * 60 * 100); |
||||
if (s.vals.capacity() <= new_size) { |
||||
s.vals.reserve(new_size * 2); |
||||
s.step_vals.reserve(new_size * 4); |
||||
} |
||||
|
||||
const double route_start_time = can->routeStartTime(); |
||||
for (auto end = msgs.cend(); first != end; ++first) { |
||||
double value = get_raw_value(first->dat, first->size, *s.sig); |
||||
double ts = first->mono_time / 1e9 - route_start_time; // seconds
|
||||
s.vals.append({ts, value}); |
||||
if (!s.step_vals.empty()) { |
||||
s.step_vals.append({ts, s.step_vals.back().y()}); |
||||
} |
||||
s.step_vals.append({ts, value}); |
||||
s.last_value_mono_time = first->mono_time; |
||||
} |
||||
if (!can->liveStreaming()) { |
||||
s.segment_tree.build(s.vals); |
||||
} |
||||
s.series->replace(series_type == SeriesType::StepLine ? s.step_vals : s.vals); |
||||
} |
||||
} |
||||
updateAxisY(); |
||||
// invoke resetChartCache in ui thread
|
||||
QMetaObject::invokeMethod(this, &ChartView::resetChartCache, Qt::QueuedConnection); |
||||
} |
||||
|
||||
// auto zoom on yaxis
|
||||
void ChartView::updateAxisY() { |
||||
if (sigs.isEmpty()) return; |
||||
|
||||
double min = std::numeric_limits<double>::max(); |
||||
double max = std::numeric_limits<double>::lowest(); |
||||
QString unit = sigs[0].sig->unit; |
||||
|
||||
for (auto &s : sigs) { |
||||
if (!s.series->isVisible()) continue; |
||||
|
||||
// Only show unit when all signals have the same unit
|
||||
if (unit != s.sig->unit) { |
||||
unit.clear(); |
||||
} |
||||
|
||||
auto first = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->min(), xLessThan); |
||||
auto last = std::lower_bound(first, s.vals.end(), axis_x->max(), xLessThan); |
||||
s.min = std::numeric_limits<double>::max(); |
||||
s.max = std::numeric_limits<double>::lowest(); |
||||
if (can->liveStreaming()) { |
||||
for (auto it = first; it != last; ++it) { |
||||
if (it->y() < s.min) s.min = it->y(); |
||||
if (it->y() > s.max) s.max = it->y(); |
||||
} |
||||
} else { |
||||
auto [min_y, max_y] = s.segment_tree.minmax(std::distance(s.vals.begin(), first), std::distance(s.vals.begin(), last)); |
||||
s.min = min_y; |
||||
s.max = max_y; |
||||
} |
||||
min = std::min(min, s.min); |
||||
max = std::max(max, s.max); |
||||
} |
||||
if (min == std::numeric_limits<double>::max()) min = 0; |
||||
if (max == std::numeric_limits<double>::lowest()) max = 0; |
||||
|
||||
if (axis_y->titleText() != unit) { |
||||
axis_y->setTitleText(unit); |
||||
y_label_width = 0; // recalc width
|
||||
} |
||||
|
||||
double delta = std::abs(max - min) < 1e-3 ? 1 : (max - min) * 0.05; |
||||
auto [min_y, max_y, tick_count] = getNiceAxisNumbers(min - delta, max + delta, axis_y->tickCount()); |
||||
if (min_y != axis_y->min() || max_y != axis_y->max() || y_label_width == 0) { |
||||
axis_y->setRange(min_y, max_y); |
||||
axis_y->setTickCount(tick_count); |
||||
|
||||
int n = qMax(int(-qFloor(std::log10((max_y - min_y) / (tick_count - 1)))), 0) + 1; |
||||
int max_label_width = 0; |
||||
QFontMetrics fm(axis_y->labelsFont()); |
||||
for (int i = 0; i < tick_count; i++) { |
||||
qreal value = min_y + (i * (max_y - min_y) / (tick_count - 1)); |
||||
max_label_width = std::max(max_label_width, fm.width(QString::number(value, 'f', n))); |
||||
} |
||||
|
||||
int title_spacing = unit.isEmpty() ? 0 : QFontMetrics(axis_y->titleFont()).size(Qt::TextSingleLine, unit).height(); |
||||
y_label_width = title_spacing + max_label_width + 15; |
||||
axis_y->setLabelFormat(QString("%.%1f").arg(n)); |
||||
emit axisYLabelWidthChanged(y_label_width); |
||||
} |
||||
} |
||||
|
||||
std::tuple<double, double, int> ChartView::getNiceAxisNumbers(qreal min, qreal max, int tick_count) { |
||||
qreal range = niceNumber((max - min), true); // range with ceiling
|
||||
qreal step = niceNumber(range / (tick_count - 1), false); |
||||
min = qFloor(min / step); |
||||
max = qCeil(max / step); |
||||
tick_count = int(max - min) + 1; |
||||
return {min * step, max * step, tick_count}; |
||||
} |
||||
|
||||
// nice numbers can be expressed as form of 1*10^n, 2* 10^n or 5*10^n
|
||||
qreal ChartView::niceNumber(qreal x, bool ceiling) { |
||||
qreal z = qPow(10, qFloor(std::log10(x))); //find corresponding number of the form of 10^n than is smaller than x
|
||||
qreal q = x / z; //q<10 && q>=1;
|
||||
if (ceiling) { |
||||
if (q <= 1.0) q = 1; |
||||
else if (q <= 2.0) q = 2; |
||||
else if (q <= 5.0) q = 5; |
||||
else q = 10; |
||||
} else { |
||||
if (q < 1.5) q = 1; |
||||
else if (q < 3.0) q = 2; |
||||
else if (q < 7.0) q = 5; |
||||
else q = 10; |
||||
} |
||||
return q * z; |
||||
} |
||||
|
||||
void ChartView::leaveEvent(QEvent *event) { |
||||
if (tip_label.isVisible()) { |
||||
charts_widget->showValueTip(-1); |
||||
} |
||||
QChartView::leaveEvent(event); |
||||
} |
||||
|
||||
QPixmap getBlankShadowPixmap(const QSize &size, int extent) { |
||||
QGraphicsDropShadowEffect *e = new QGraphicsDropShadowEffect; |
||||
e->setColor(QColor(40, 40, 40, 245)); |
||||
e->setOffset(0, 2); |
||||
e->setBlurRadius(10); |
||||
|
||||
QGraphicsScene scene; |
||||
QGraphicsPixmapItem item; |
||||
QPixmap src(size); |
||||
src.fill(Qt::white); |
||||
item.setPixmap(src); |
||||
item.setGraphicsEffect(e); |
||||
scene.addItem(&item); |
||||
QImage target(src.size() + QSize(extent * 2, extent * 2), QImage::Format_ARGB32); |
||||
target.fill(Qt::transparent); |
||||
QPainter p(&target); |
||||
scene.render(&p, QRectF(), QRectF(-extent, -extent, src.width() + extent * 2, src.height() + extent * 2)); |
||||
return QPixmap::fromImage(target); |
||||
} |
||||
|
||||
static QPixmap getDropPixmap(const QPixmap &src) { |
||||
static QPixmap shadow_px; |
||||
const int extent = 10; |
||||
if (shadow_px.size() != src.size() + QSize(extent * 2, extent * 2)) { |
||||
shadow_px = getBlankShadowPixmap(src.size(), extent); |
||||
} |
||||
QPixmap px = shadow_px; |
||||
QPainter p(&px); |
||||
int delta_w = px.width() - src.width(); |
||||
int delta_h = px.height() - src.height(); |
||||
p.drawPixmap(QPoint(delta_w / 2, delta_h / 2), src); |
||||
p.setCompositionMode(QPainter::CompositionMode_DestinationIn); |
||||
p.fillRect(delta_w / 2, delta_h / 2, src.width(), src.height(), QColor(0, 0, 0, 200)); |
||||
return px; |
||||
} |
||||
|
||||
void ChartView::mousePressEvent(QMouseEvent *event) { |
||||
if (event->button() == Qt::LeftButton && move_icon->sceneBoundingRect().contains(event->pos())) { |
||||
QMimeData *mimeData = new QMimeData; |
||||
mimeData->setData(CHART_MIME_TYPE, QByteArray::number((qulonglong)this)); |
||||
QPixmap px = grab().scaledToWidth(CHART_MIN_WIDTH, Qt::SmoothTransformation); |
||||
QDrag *drag = new QDrag(this); |
||||
drag->setMimeData(mimeData); |
||||
drag->setPixmap(getDropPixmap(px)); |
||||
drag->setHotSpot(-QPoint(5, 5)); |
||||
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction); |
||||
charts_widget->stopAutoScroll(); |
||||
} else if (event->button() == Qt::LeftButton && QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) { |
||||
if (!can->liveStreaming()) { |
||||
// Save current playback state when scrubbing
|
||||
resume_after_scrub = !can->isPaused(); |
||||
if (resume_after_scrub) { |
||||
can->pause(true); |
||||
} |
||||
is_scrubbing = true; |
||||
} |
||||
} else { |
||||
QChartView::mousePressEvent(event); |
||||
} |
||||
} |
||||
|
||||
void ChartView::mouseReleaseEvent(QMouseEvent *event) { |
||||
auto rubber = findChild<QRubberBand *>(); |
||||
if (event->button() == Qt::LeftButton && rubber && rubber->isVisible()) { |
||||
rubber->hide(); |
||||
QRectF rect = rubber->geometry().normalized(); |
||||
double min = chart()->mapToValue(rect.topLeft()).x(); |
||||
double max = chart()->mapToValue(rect.bottomRight()).x(); |
||||
|
||||
// Prevent zooming/seeking past the end of the route
|
||||
min = std::clamp(min, 0., can->totalSeconds()); |
||||
max = std::clamp(max, 0., can->totalSeconds()); |
||||
|
||||
if (rubber->width() <= 0) { |
||||
// no rubber dragged, seek to mouse position
|
||||
can->seekTo(min); |
||||
} else if (rubber->width() > 10) { |
||||
charts_widget->zoom_undo_stack->push(new ZoomCommand(charts_widget, {min, max})); |
||||
} else { |
||||
viewport()->update(); |
||||
} |
||||
event->accept(); |
||||
} else if (!can->liveStreaming() && event->button() == Qt::RightButton) { |
||||
charts_widget->zoom_undo_stack->undo(); |
||||
event->accept(); |
||||
} else { |
||||
QGraphicsView::mouseReleaseEvent(event); |
||||
} |
||||
|
||||
// Resume playback if we were scrubbing
|
||||
is_scrubbing = false; |
||||
if (resume_after_scrub) { |
||||
can->pause(false); |
||||
resume_after_scrub = false; |
||||
} |
||||
} |
||||
|
||||
void ChartView::mouseMoveEvent(QMouseEvent *ev) { |
||||
const auto plot_area = chart()->plotArea(); |
||||
// Scrubbing
|
||||
if (is_scrubbing && QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) { |
||||
if (plot_area.contains(ev->pos())) { |
||||
can->seekTo(std::clamp(chart()->mapToValue(ev->pos()).x(), 0., can->totalSeconds())); |
||||
} |
||||
} |
||||
|
||||
auto rubber = findChild<QRubberBand *>(); |
||||
bool is_zooming = rubber && rubber->isVisible(); |
||||
clearTrackPoints(); |
||||
|
||||
if (!is_zooming && plot_area.contains(ev->pos())) { |
||||
const double sec = chart()->mapToValue(ev->pos()).x(); |
||||
charts_widget->showValueTip(sec); |
||||
} else if (tip_label.isVisible()) { |
||||
charts_widget->showValueTip(-1); |
||||
} |
||||
|
||||
QChartView::mouseMoveEvent(ev); |
||||
if (is_zooming) { |
||||
QRect rubber_rect = rubber->geometry(); |
||||
rubber_rect.setLeft(std::max(rubber_rect.left(), (int)plot_area.left())); |
||||
rubber_rect.setRight(std::min(rubber_rect.right(), (int)plot_area.right())); |
||||
if (rubber_rect != rubber->geometry()) { |
||||
rubber->setGeometry(rubber_rect); |
||||
} |
||||
viewport()->update(); |
||||
} |
||||
} |
||||
|
||||
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)); |
||||
for (auto &s : sigs) { |
||||
if (s.series->isVisible()) { |
||||
QString value = "--"; |
||||
// use reverse iterator to find last item <= sec.
|
||||
auto it = std::lower_bound(s.vals.rbegin(), s.vals.rend(), sec, [](auto &p, double x) { return p.x() > x; }); |
||||
if (it != s.vals.rend() && it->x() >= axis_x->min()) { |
||||
value = QString::number(it->y()); |
||||
s.track_pt = *it; |
||||
x = std::max(x, chart()->mapToPosition(*it).x()); |
||||
} |
||||
QString name = sigs.size() > 1 ? s.sig->name + ": " : ""; |
||||
QString min = s.min == std::numeric_limits<double>::max() ? "--" : QString::number(s.min); |
||||
QString max = s.max == std::numeric_limits<double>::lowest() ? "--" : QString::number(s.max); |
||||
text_list << QString("<span style=\"color:%1;\">■ </span>%2<b>%3</b> (%4, %5)") |
||||
.arg(s.series->color().name(), name, value, min, max); |
||||
} |
||||
} |
||||
QPointF tooltip_pt(x, chart()->plotArea().top()); |
||||
int plot_right = mapToGlobal(chart()->plotArea().topRight().toPoint()).x(); |
||||
tip_label.showText(mapToGlobal(tooltip_pt.toPoint()), "<p style='white-space:pre'>" + text_list.join("<br />") + "</p>", plot_right); |
||||
viewport()->update(); |
||||
} |
||||
|
||||
void ChartView::hideTip() { |
||||
clearTrackPoints(); |
||||
tooltip_x = -1; |
||||
tip_label.hide(); |
||||
viewport()->update(); |
||||
} |
||||
|
||||
void ChartView::dragEnterEvent(QDragEnterEvent *event) { |
||||
if (event->mimeData()->hasFormat(CHART_MIME_TYPE)) { |
||||
drawDropIndicator(event->source() != this); |
||||
event->acceptProposedAction(); |
||||
} |
||||
} |
||||
|
||||
void ChartView::dragMoveEvent(QDragMoveEvent *event) { |
||||
if (event->mimeData()->hasFormat(CHART_MIME_TYPE)) { |
||||
event->setDropAction(event->source() == this ? Qt::MoveAction : Qt::CopyAction); |
||||
event->accept(); |
||||
} |
||||
charts_widget->startAutoScroll(); |
||||
} |
||||
|
||||
void ChartView::dropEvent(QDropEvent *event) { |
||||
if (event->mimeData()->hasFormat(CHART_MIME_TYPE)) { |
||||
if (event->source() != this) { |
||||
ChartView *source_chart = (ChartView *)event->source(); |
||||
for (auto &s : source_chart->sigs) { |
||||
source_chart->chart()->removeSeries(s.series); |
||||
addSeries(s.series); |
||||
} |
||||
sigs.append(source_chart->sigs); |
||||
updateAxisY(); |
||||
updateTitle(); |
||||
startAnimation(); |
||||
|
||||
source_chart->sigs.clear(); |
||||
charts_widget->removeChart(source_chart); |
||||
event->acceptProposedAction(); |
||||
} |
||||
can_drop = false; |
||||
} |
||||
} |
||||
|
||||
void ChartView::resetChartCache() { |
||||
chart_pixmap = QPixmap(); |
||||
viewport()->update(); |
||||
} |
||||
|
||||
void ChartView::startAnimation() { |
||||
QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this); |
||||
viewport()->setGraphicsEffect(eff); |
||||
QPropertyAnimation *a = new QPropertyAnimation(eff, "opacity"); |
||||
a->setDuration(250); |
||||
a->setStartValue(0.3); |
||||
a->setEndValue(1); |
||||
a->setEasingCurve(QEasingCurve::InBack); |
||||
a->start(QPropertyAnimation::DeleteWhenStopped); |
||||
} |
||||
|
||||
void ChartView::paintEvent(QPaintEvent *event) { |
||||
if (!can->liveStreaming()) { |
||||
if (chart_pixmap.isNull()) { |
||||
const qreal dpr = viewport()->devicePixelRatioF(); |
||||
chart_pixmap = QPixmap(viewport()->size() * dpr); |
||||
chart_pixmap.setDevicePixelRatio(dpr); |
||||
QPainter p(&chart_pixmap); |
||||
p.setRenderHints(QPainter::Antialiasing); |
||||
drawBackground(&p, viewport()->rect()); |
||||
scene()->setSceneRect(viewport()->rect()); |
||||
scene()->render(&p); |
||||
} |
||||
|
||||
QPainter painter(viewport()); |
||||
painter.setRenderHints(QPainter::Antialiasing); |
||||
painter.drawPixmap(QPoint(), chart_pixmap); |
||||
if (can_drop) { |
||||
painter.setPen(QPen(palette().color(QPalette::Highlight), 4)); |
||||
painter.drawRect(viewport()->rect()); |
||||
} |
||||
QRectF exposed_rect = mapToScene(event->region().boundingRect()).boundingRect(); |
||||
drawForeground(&painter, exposed_rect); |
||||
} else { |
||||
QChartView::paintEvent(event); |
||||
} |
||||
} |
||||
|
||||
void ChartView::drawBackground(QPainter *painter, const QRectF &rect) { |
||||
painter->fillRect(rect, palette().color(QPalette::Base)); |
||||
} |
||||
|
||||
void ChartView::drawForeground(QPainter *painter, const QRectF &rect) { |
||||
// draw time line
|
||||
qreal x = chart()->mapToPosition(QPointF{cur_sec, 0}).x(); |
||||
x = std::clamp(x, chart()->plotArea().left(), chart()->plotArea().right()); |
||||
qreal y1 = chart()->plotArea().top() - 2; |
||||
qreal y2 = chart()->plotArea().bottom() + 2; |
||||
painter->setPen(QPen(chart()->titleBrush().color(), 2)); |
||||
painter->drawLine(QPointF{x, y1}, QPointF{x, y2}); |
||||
|
||||
// draw track points
|
||||
painter->setPen(Qt::NoPen); |
||||
qreal track_line_x = -1; |
||||
for (auto &s : sigs) { |
||||
if (!s.track_pt.isNull() && s.series->isVisible()) { |
||||
painter->setBrush(s.series->color().darker(125)); |
||||
QPointF pos = chart()->mapToPosition(s.track_pt); |
||||
painter->drawEllipse(pos, 5.5, 5.5); |
||||
track_line_x = std::max(track_line_x, pos.x()); |
||||
} |
||||
} |
||||
if (track_line_x > 0) { |
||||
painter->setPen(QPen(Qt::darkGray, 1, Qt::DashLine)); |
||||
painter->drawLine(QPointF{track_line_x, y1}, QPointF{track_line_x, y2}); |
||||
} |
||||
|
||||
// paint points. OpenGL mode lacks certain features (such as showing points)
|
||||
painter->setPen(Qt::NoPen); |
||||
for (auto &s : sigs) { |
||||
if (s.series->useOpenGL() && s.series->isVisible() && s.series->pointsVisible()) { |
||||
auto first = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->min(), xLessThan); |
||||
auto last = std::lower_bound(first, s.vals.end(), axis_x->max(), xLessThan); |
||||
painter->setBrush(s.series->color()); |
||||
for (auto it = first; it != last; ++it) { |
||||
painter->drawEllipse(chart()->mapToPosition(*it), 4, 4); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// paint zoom range
|
||||
auto rubber = findChild<QRubberBand *>(); |
||||
if (rubber && rubber->isVisible() && rubber->width() > 1) { |
||||
painter->setPen(Qt::white); |
||||
auto rubber_rect = rubber->geometry().normalized(); |
||||
for (const auto &pt : {rubber_rect.bottomLeft(), rubber_rect.bottomRight()}) { |
||||
QString sec = QString::number(chart()->mapToValue(pt).x(), 'f', 1); |
||||
// ChartAxisElement's padding is 4 (https://codebrowser.dev/qt5/qtcharts/src/charts/axis/chartaxiselement_p.h.html)
|
||||
auto r = painter->fontMetrics().boundingRect(sec).adjusted(-6, -4, 6, 4); |
||||
pt == rubber_rect.bottomLeft() ? r.moveTopRight(pt + QPoint{0, 2}) : r.moveTopLeft(pt + QPoint{0, 2}); |
||||
painter->fillRect(r, Qt::gray); |
||||
painter->drawText(r, Qt::AlignCenter, sec); |
||||
} |
||||
} |
||||
} |
||||
|
||||
QXYSeries *ChartView::createSeries(SeriesType type, QColor color) { |
||||
QXYSeries *series = nullptr; |
||||
if (type == SeriesType::Line) { |
||||
series = new QLineSeries(this); |
||||
chart()->legend()->setMarkerShape(QLegend::MarkerShapeRectangle); |
||||
} else if (type == SeriesType::StepLine) { |
||||
series = new QLineSeries(this); |
||||
chart()->legend()->setMarkerShape(QLegend::MarkerShapeFromSeries); |
||||
} else { |
||||
series = new QScatterSeries(this); |
||||
chart()->legend()->setMarkerShape(QLegend::MarkerShapeCircle); |
||||
} |
||||
series->setColor(color); |
||||
// TODO: Due to a bug in CameraWidget the camera frames
|
||||
// are drawn instead of the graphs on MacOS. Re-enable OpenGL when fixed
|
||||
#ifndef __APPLE__ |
||||
series->setUseOpenGL(true); |
||||
// Qt doesn't properly apply device pixel ratio in OpenGL mode
|
||||
QPen pen = series->pen(); |
||||
pen.setWidthF(2.0 * devicePixelRatioF()); |
||||
series->setPen(pen); |
||||
#endif |
||||
addSeries(series); |
||||
return series; |
||||
} |
||||
|
||||
void ChartView::addSeries(QXYSeries *series) { |
||||
chart()->addSeries(series); |
||||
series->attachAxis(axis_x); |
||||
series->attachAxis(axis_y); |
||||
|
||||
// disables the delivery of mouse events to the opengl widget.
|
||||
// this enables the user to select the zoom area when the mouse press on the data point.
|
||||
auto glwidget = findChild<QOpenGLWidget *>(); |
||||
if (glwidget && !glwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) { |
||||
glwidget->setAttribute(Qt::WA_TransparentForMouseEvents); |
||||
} |
||||
} |
||||
|
||||
void ChartView::setSeriesType(SeriesType type) { |
||||
if (type != series_type) { |
||||
series_type = type; |
||||
for (auto &s : sigs) { |
||||
chart()->removeSeries(s.series); |
||||
s.series->deleteLater(); |
||||
} |
||||
for (auto &s : sigs) { |
||||
auto series = createSeries(series_type, getColor(s.sig)); |
||||
series->replace(series_type == SeriesType::StepLine ? s.step_vals : s.vals); |
||||
s.series = series; |
||||
} |
||||
updateSeriesPoints(); |
||||
updateTitle(); |
||||
} |
||||
} |
||||
|
||||
void ChartView::handleMarkerClicked() { |
||||
auto marker = qobject_cast<QLegendMarker *>(sender()); |
||||
Q_ASSERT(marker); |
||||
if (sigs.size() > 1) { |
||||
auto series = marker->series(); |
||||
series->setVisible(!series->isVisible()); |
||||
marker->setVisible(true); |
||||
updateAxisY(); |
||||
updateTitle(); |
||||
} |
||||
} |
@ -0,0 +1,109 @@ |
||||
#pragma once |
||||
|
||||
#include <QGraphicsPixmapItem> |
||||
#include <QGraphicsProxyWidget> |
||||
#include <QtCharts/QChartView> |
||||
#include <QtCharts/QLegendMarker> |
||||
#include <QtCharts/QLineSeries> |
||||
#include <QtCharts/QScatterSeries> |
||||
#include <QtCharts/QValueAxis> |
||||
using namespace QtCharts; |
||||
|
||||
#include "tools/cabana/chart/tiplabel.h" |
||||
#include "tools/cabana/dbc/dbcmanager.h" |
||||
#include "tools/cabana/streams/abstractstream.h" |
||||
|
||||
enum class SeriesType { |
||||
Line = 0, |
||||
StepLine, |
||||
Scatter |
||||
}; |
||||
|
||||
class ChartsWidget; |
||||
class ChartView : public QChartView { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
ChartView(const std::pair<double, double> &x_range, ChartsWidget *parent = nullptr); |
||||
void addSignal(const MessageId &msg_id, const cabana::Signal *sig); |
||||
bool hasSignal(const MessageId &msg_id, const cabana::Signal *sig) const; |
||||
void updateSeries(const cabana::Signal *sig = nullptr); |
||||
void updatePlot(double cur, double min, double max); |
||||
void setSeriesType(SeriesType type); |
||||
void updatePlotArea(int left, bool force = false); |
||||
void showTip(double sec); |
||||
void hideTip(); |
||||
void startAnimation(); |
||||
|
||||
struct SigItem { |
||||
MessageId msg_id; |
||||
const cabana::Signal *sig = nullptr; |
||||
QXYSeries *series = nullptr; |
||||
QVector<QPointF> vals; |
||||
QVector<QPointF> step_vals; |
||||
uint64_t last_value_mono_time = 0; |
||||
QPointF track_pt{}; |
||||
SegmentTree segment_tree; |
||||
double min = 0; |
||||
double max = 0; |
||||
}; |
||||
|
||||
signals: |
||||
void axisYLabelWidthChanged(int w); |
||||
|
||||
private slots: |
||||
void signalUpdated(const cabana::Signal *sig); |
||||
void manageSignals(); |
||||
void handleMarkerClicked(); |
||||
void msgUpdated(MessageId id); |
||||
void msgRemoved(MessageId id) { removeIf([=](auto &s) { return s.msg_id == id; }); } |
||||
void signalRemoved(const cabana::Signal *sig) { removeIf([=](auto &s) { return s.sig == sig; }); } |
||||
|
||||
private: |
||||
void createToolButtons(); |
||||
void addSeries(QXYSeries *series); |
||||
void mousePressEvent(QMouseEvent *event) override; |
||||
void mouseReleaseEvent(QMouseEvent *event) override; |
||||
void mouseMoveEvent(QMouseEvent *ev) override; |
||||
void dragEnterEvent(QDragEnterEvent *event) override; |
||||
void dragLeaveEvent(QDragLeaveEvent *event) override { drawDropIndicator(false); } |
||||
void dragMoveEvent(QDragMoveEvent *event) override; |
||||
void dropEvent(QDropEvent *event) override; |
||||
void leaveEvent(QEvent *event) override; |
||||
void resizeEvent(QResizeEvent *event) override; |
||||
QSize sizeHint() const override; |
||||
void updateAxisY(); |
||||
void updateTitle(); |
||||
void resetChartCache(); |
||||
void setTheme(QChart::ChartTheme theme); |
||||
void paintEvent(QPaintEvent *event) override; |
||||
void drawForeground(QPainter *painter, const QRectF &rect) override; |
||||
void drawBackground(QPainter *painter, const QRectF &rect) override; |
||||
void drawDropIndicator(bool draw) { if (std::exchange(can_drop, draw) != can_drop) viewport()->update(); } |
||||
std::tuple<double, double, int> getNiceAxisNumbers(qreal min, qreal max, int tick_count); |
||||
qreal niceNumber(qreal x, bool ceiling); |
||||
QXYSeries *createSeries(SeriesType type, QColor color); |
||||
void updateSeriesPoints(); |
||||
void removeIf(std::function<bool(const SigItem &)> predicate); |
||||
inline void clearTrackPoints() { for (auto &s : sigs) s.track_pt = {}; } |
||||
|
||||
int y_label_width = 0; |
||||
int align_to = 0; |
||||
QValueAxis *axis_x; |
||||
QValueAxis *axis_y; |
||||
QAction *split_chart_act; |
||||
QGraphicsPixmapItem *move_icon; |
||||
QGraphicsProxyWidget *close_btn_proxy; |
||||
QGraphicsProxyWidget *manage_btn_proxy; |
||||
TipLabel tip_label; |
||||
QList<SigItem> sigs; |
||||
double cur_sec = 0; |
||||
SeriesType series_type = SeriesType::Line; |
||||
bool is_scrubbing = false; |
||||
bool resume_after_scrub = false; |
||||
QPixmap chart_pixmap; |
||||
bool can_drop = false; |
||||
double tooltip_x = -1; |
||||
ChartsWidget *charts_widget; |
||||
friend class ChartsWidget; |
||||
}; |
@ -0,0 +1,514 @@ |
||||
#include "tools/cabana/chart/chartswidget.h" |
||||
|
||||
#include <QApplication> |
||||
#include <QFutureSynchronizer> |
||||
#include <QMenu> |
||||
#include <QScrollBar> |
||||
#include <QToolBar> |
||||
#include <QtConcurrent> |
||||
|
||||
#include "tools/cabana/chart/chart.h" |
||||
|
||||
const int MAX_COLUMN_COUNT = 4; |
||||
const int CHART_SPACING = 10; |
||||
|
||||
ChartsWidget::ChartsWidget(QWidget *parent) : align_timer(this), auto_scroll_timer(this), QFrame(parent) { |
||||
setFrameStyle(QFrame::StyledPanel | QFrame::Plain); |
||||
QVBoxLayout *main_layout = new QVBoxLayout(this); |
||||
main_layout->setContentsMargins(0, 0, 0, 0); |
||||
main_layout->setSpacing(0); |
||||
|
||||
// toolbar
|
||||
QToolBar *toolbar = new QToolBar(tr("Charts"), this); |
||||
int icon_size = style()->pixelMetric(QStyle::PM_SmallIconSize); |
||||
toolbar->setIconSize({icon_size, icon_size}); |
||||
|
||||
auto new_plot_btn = new ToolButton("file-plus", tr("New Chart")); |
||||
auto new_tab_btn = new ToolButton("window-stack", tr("New Tab")); |
||||
toolbar->addWidget(new_plot_btn); |
||||
toolbar->addWidget(new_tab_btn); |
||||
toolbar->addWidget(title_label = new QLabel()); |
||||
title_label->setContentsMargins(0, 0, style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0); |
||||
|
||||
QMenu *menu = new QMenu(this); |
||||
for (int i = 0; i < MAX_COLUMN_COUNT; ++i) { |
||||
menu->addAction(tr("%1").arg(i + 1), [=]() { setColumnCount(i + 1); }); |
||||
} |
||||
columns_action = toolbar->addAction(""); |
||||
columns_action->setMenu(menu); |
||||
qobject_cast<QToolButton*>(toolbar->widgetForAction(columns_action))->setPopupMode(QToolButton::InstantPopup); |
||||
|
||||
QLabel *stretch_label = new QLabel(this); |
||||
stretch_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
||||
toolbar->addWidget(stretch_label); |
||||
|
||||
range_lb_action = toolbar->addWidget(range_lb = new QLabel(this)); |
||||
range_slider = new LogSlider(1000, Qt::Horizontal, this); |
||||
range_slider->setMaximumWidth(200); |
||||
range_slider->setToolTip(tr("Set the chart range")); |
||||
range_slider->setRange(1, settings.max_cached_minutes * 60); |
||||
range_slider->setSingleStep(1); |
||||
range_slider->setPageStep(60); // 1 min
|
||||
range_slider_action = toolbar->addWidget(range_slider); |
||||
|
||||
// zoom controls
|
||||
zoom_undo_stack = new QUndoStack(this); |
||||
toolbar->addAction(undo_zoom_action = zoom_undo_stack->createUndoAction(this)); |
||||
undo_zoom_action->setIcon(utils::icon("arrow-counterclockwise")); |
||||
toolbar->addAction(redo_zoom_action = zoom_undo_stack->createRedoAction(this)); |
||||
redo_zoom_action->setIcon(utils::icon("arrow-clockwise")); |
||||
reset_zoom_action = toolbar->addWidget(reset_zoom_btn = new ToolButton("zoom-out", tr("Reset Zoom"))); |
||||
reset_zoom_btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
||||
|
||||
toolbar->addWidget(remove_all_btn = new ToolButton("x", tr("Remove all charts"))); |
||||
toolbar->addWidget(dock_btn = new ToolButton("")); |
||||
main_layout->addWidget(toolbar); |
||||
|
||||
// tabbar
|
||||
tabbar = new QTabBar(this); |
||||
tabbar->setAutoHide(true); |
||||
tabbar->setExpanding(false); |
||||
tabbar->setDrawBase(true); |
||||
tabbar->setAcceptDrops(true); |
||||
tabbar->setChangeCurrentOnDrag(true); |
||||
tabbar->setTabsClosable(true); |
||||
tabbar->setUsesScrollButtons(true); |
||||
main_layout->addWidget(tabbar); |
||||
|
||||
// charts
|
||||
charts_container = new ChartsContainer(this); |
||||
|
||||
charts_scroll = new QScrollArea(this); |
||||
charts_scroll->setFrameStyle(QFrame::NoFrame); |
||||
charts_scroll->setWidgetResizable(true); |
||||
charts_scroll->setWidget(charts_container); |
||||
charts_scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
main_layout->addWidget(charts_scroll); |
||||
|
||||
// init settings
|
||||
current_theme = settings.theme; |
||||
column_count = std::clamp(settings.chart_column_count, 1, MAX_COLUMN_COUNT); |
||||
max_chart_range = std::clamp(settings.chart_range, 1, settings.max_cached_minutes * 60); |
||||
display_range = {0, max_chart_range}; |
||||
range_slider->setValue(max_chart_range); |
||||
updateToolBar(); |
||||
|
||||
align_timer.setSingleShot(true); |
||||
QObject::connect(&align_timer, &QTimer::timeout, this, &ChartsWidget::alignCharts); |
||||
QObject::connect(&auto_scroll_timer, &QTimer::timeout, this, &ChartsWidget::doAutoScroll); |
||||
QObject::connect(dbc(), &DBCManager::DBCFileChanged, this, &ChartsWidget::removeAll); |
||||
QObject::connect(can, &AbstractStream::eventsMerged, this, &ChartsWidget::eventsMerged); |
||||
QObject::connect(can, &AbstractStream::updated, this, &ChartsWidget::updateState); |
||||
QObject::connect(range_slider, &QSlider::valueChanged, this, &ChartsWidget::setMaxChartRange); |
||||
QObject::connect(new_plot_btn, &QToolButton::clicked, this, &ChartsWidget::newChart); |
||||
QObject::connect(remove_all_btn, &QToolButton::clicked, this, &ChartsWidget::removeAll); |
||||
QObject::connect(reset_zoom_btn, &QToolButton::clicked, this, &ChartsWidget::zoomReset); |
||||
QObject::connect(&settings, &Settings::changed, this, &ChartsWidget::settingChanged); |
||||
QObject::connect(new_tab_btn, &QToolButton::clicked, this, &ChartsWidget::newTab); |
||||
QObject::connect(tabbar, &QTabBar::tabCloseRequested, this, &ChartsWidget::removeTab); |
||||
QObject::connect(tabbar, &QTabBar::currentChanged, [this](int index) { |
||||
if (index != -1) updateLayout(true); |
||||
}); |
||||
QObject::connect(dock_btn, &QToolButton::clicked, [this]() { |
||||
emit dock(!docking); |
||||
docking = !docking; |
||||
updateToolBar(); |
||||
}); |
||||
|
||||
newTab(); |
||||
setWhatsThis(tr(R"( |
||||
<b>Chart view</b><br /> |
||||
<!-- TODO: add descprition here --> |
||||
)")); |
||||
} |
||||
|
||||
void ChartsWidget::newTab() { |
||||
static int tab_unique_id = 0; |
||||
int idx = tabbar->addTab(""); |
||||
tabbar->setTabData(idx, tab_unique_id++); |
||||
for (int i = 0; i < tabbar->count(); ++i) { |
||||
tabbar->setTabText(i, QString("Tab %1").arg(i + 1)); |
||||
} |
||||
tabbar->setCurrentIndex(idx); |
||||
} |
||||
|
||||
void ChartsWidget::removeTab(int index) { |
||||
int id = tabbar->tabData(index).toInt(); |
||||
for (auto &c : tab_charts[id]) { |
||||
removeChart(c); |
||||
} |
||||
tab_charts.erase(id); |
||||
tabbar->removeTab(index); |
||||
} |
||||
|
||||
void ChartsWidget::eventsMerged() { |
||||
QFutureSynchronizer<void> future_synchronizer; |
||||
for (auto c : charts) { |
||||
future_synchronizer.addFuture(QtConcurrent::run(c, &ChartView::updateSeries, nullptr)); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::setZoom(double min, double max) { |
||||
zoomed_range = {min, max}; |
||||
is_zoomed = zoomed_range != display_range; |
||||
updateToolBar(); |
||||
updateState(); |
||||
emit rangeChanged(min, max, is_zoomed); |
||||
} |
||||
|
||||
void ChartsWidget::zoomReset() { |
||||
setZoom(display_range.first, display_range.second); |
||||
zoom_undo_stack->clear(); |
||||
} |
||||
|
||||
void ChartsWidget::showValueTip(double sec) { |
||||
const QRect visible_rect(-charts_container->pos(), charts_scroll->viewport()->size()); |
||||
for (auto c : currentCharts()) { |
||||
if (sec >= 0 && visible_rect.contains(QRect(c->mapTo(charts_container, QPoint(0, 0)), c->size()))) { |
||||
c->showTip(sec); |
||||
} else { |
||||
c->hideTip(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::updateState() { |
||||
if (charts.isEmpty()) return; |
||||
|
||||
const double cur_sec = can->currentSec(); |
||||
if (!is_zoomed) { |
||||
double pos = (cur_sec - display_range.first) / std::max<float>(1.0, max_chart_range); |
||||
if (pos < 0 || pos > 0.8) { |
||||
display_range.first = std::max(0.0, cur_sec - max_chart_range * 0.1); |
||||
} |
||||
double max_sec = std::min(std::floor(display_range.first + max_chart_range), can->lastEventSecond()); |
||||
display_range.first = std::max(0.0, max_sec - max_chart_range); |
||||
display_range.second = display_range.first + max_chart_range; |
||||
} else if (cur_sec < zoomed_range.first || cur_sec >= zoomed_range.second) { |
||||
// loop in zoomed range
|
||||
can->seekTo(zoomed_range.first); |
||||
} |
||||
|
||||
const auto &range = is_zoomed ? zoomed_range : display_range; |
||||
for (auto c : charts) { |
||||
c->updatePlot(cur_sec, range.first, range.second); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::setMaxChartRange(int value) { |
||||
max_chart_range = settings.chart_range = range_slider->value(); |
||||
updateToolBar(); |
||||
updateState(); |
||||
} |
||||
|
||||
void ChartsWidget::updateToolBar() { |
||||
title_label->setText(tr("Charts: %1").arg(charts.size())); |
||||
columns_action->setText(tr("Column: %1").arg(column_count)); |
||||
range_lb->setText(utils::formatSeconds(max_chart_range)); |
||||
range_lb_action->setVisible(!is_zoomed); |
||||
range_slider_action->setVisible(!is_zoomed); |
||||
undo_zoom_action->setVisible(is_zoomed); |
||||
redo_zoom_action->setVisible(is_zoomed); |
||||
reset_zoom_action->setVisible(is_zoomed); |
||||
reset_zoom_btn->setText(is_zoomed ? tr("%1-%2").arg(zoomed_range.first, 0, 'f', 1).arg(zoomed_range.second, 0, 'f', 1) : ""); |
||||
remove_all_btn->setEnabled(!charts.isEmpty()); |
||||
dock_btn->setIcon(docking ? "arrow-up-right-square" : "arrow-down-left-square"); |
||||
dock_btn->setToolTip(docking ? tr("Undock charts") : tr("Dock charts")); |
||||
} |
||||
|
||||
void ChartsWidget::settingChanged() { |
||||
if (std::exchange(current_theme, settings.theme) != current_theme) { |
||||
undo_zoom_action->setIcon(utils::icon("arrow-counterclockwise")); |
||||
redo_zoom_action->setIcon(utils::icon("arrow-clockwise")); |
||||
auto theme = settings.theme == DARK_THEME ? QChart::QChart::ChartThemeDark : QChart::ChartThemeLight; |
||||
for (auto c : charts) { |
||||
c->setTheme(theme); |
||||
} |
||||
} |
||||
range_slider->setRange(1, settings.max_cached_minutes * 60); |
||||
for (auto c : charts) { |
||||
c->setFixedHeight(settings.chart_height); |
||||
c->setSeriesType((SeriesType)settings.chart_series_type); |
||||
c->resetChartCache(); |
||||
} |
||||
} |
||||
|
||||
ChartView *ChartsWidget::findChart(const MessageId &id, const cabana::Signal *sig) { |
||||
for (auto c : charts) |
||||
if (c->hasSignal(id, sig)) return c; |
||||
return nullptr; |
||||
} |
||||
|
||||
ChartView *ChartsWidget::createChart() { |
||||
auto chart = new ChartView(is_zoomed ? zoomed_range : display_range, this); |
||||
chart->setFixedHeight(settings.chart_height); |
||||
chart->setMinimumWidth(CHART_MIN_WIDTH); |
||||
chart->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
||||
QObject::connect(chart, &ChartView::axisYLabelWidthChanged, &align_timer, qOverload<>(&QTimer::start)); |
||||
charts.push_front(chart); |
||||
currentCharts().push_front(chart); |
||||
updateLayout(true); |
||||
updateToolBar(); |
||||
return chart; |
||||
} |
||||
|
||||
void ChartsWidget::showChart(const MessageId &id, const cabana::Signal *sig, bool show, bool merge) { |
||||
ChartView *chart = findChart(id, sig); |
||||
if (show && !chart) { |
||||
chart = merge && currentCharts().size() > 0 ? currentCharts().front() : createChart(); |
||||
chart->addSignal(id, sig); |
||||
} else if (!show && chart) { |
||||
chart->removeIf([&](auto &s) { return s.msg_id == id && s.sig == sig; }); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::splitChart(ChartView *src_chart) { |
||||
if (src_chart->sigs.size() > 1) { |
||||
for (auto it = src_chart->sigs.begin() + 1; it != src_chart->sigs.end(); /**/) { |
||||
auto c = createChart(); |
||||
src_chart->chart()->removeSeries(it->series); |
||||
c->addSeries(it->series); |
||||
c->sigs.push_back(*it); |
||||
c->updateAxisY(); |
||||
c->updateTitle(); |
||||
it = src_chart->sigs.erase(it); |
||||
} |
||||
src_chart->updateAxisY(); |
||||
src_chart->updateTitle(); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::setColumnCount(int n) { |
||||
n = std::clamp(n, 1, MAX_COLUMN_COUNT); |
||||
if (column_count != n) { |
||||
column_count = settings.chart_column_count = n; |
||||
updateToolBar(); |
||||
updateLayout(); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::updateLayout(bool force) { |
||||
auto charts_layout = charts_container->charts_layout; |
||||
int n = MAX_COLUMN_COUNT; |
||||
for (; n > 1; --n) { |
||||
if ((n * CHART_MIN_WIDTH + (n - 1) * charts_layout->spacing()) < charts_layout->geometry().width()) break; |
||||
} |
||||
|
||||
bool show_column_cb = n > 1; |
||||
columns_action->setVisible(show_column_cb); |
||||
|
||||
n = std::min(column_count, n); |
||||
auto ¤t_charts = currentCharts(); |
||||
if ((current_charts.size() != charts_layout->count() || n != current_column_count) || force) { |
||||
current_column_count = n; |
||||
charts_container->setUpdatesEnabled(false); |
||||
for (auto c : charts) { |
||||
c->setVisible(false); |
||||
} |
||||
for (int i = 0; i < current_charts.size(); ++i) { |
||||
charts_layout->addWidget(current_charts[i], i / n, i % n); |
||||
current_charts[i]->setVisible(true); |
||||
} |
||||
charts_container->setUpdatesEnabled(true); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::startAutoScroll() { |
||||
auto_scroll_timer.start(50); |
||||
} |
||||
|
||||
void ChartsWidget::stopAutoScroll() { |
||||
auto_scroll_timer.stop(); |
||||
auto_scroll_count = 0; |
||||
} |
||||
|
||||
void ChartsWidget::doAutoScroll() { |
||||
QScrollBar *scroll = charts_scroll->verticalScrollBar(); |
||||
if (auto_scroll_count < scroll->pageStep()) { |
||||
++auto_scroll_count; |
||||
} |
||||
|
||||
int value = scroll->value(); |
||||
QPoint pos = charts_scroll->viewport()->mapFromGlobal(QCursor::pos()); |
||||
QRect area = charts_scroll->viewport()->rect(); |
||||
|
||||
if (pos.y() - area.top() < settings.chart_height / 2) { |
||||
scroll->setValue(value - auto_scroll_count); |
||||
} else if (area.bottom() - pos.y() < settings.chart_height / 2) { |
||||
scroll->setValue(value + auto_scroll_count); |
||||
} |
||||
bool vertical_unchanged = value == scroll->value(); |
||||
if (vertical_unchanged) { |
||||
stopAutoScroll(); |
||||
} else { |
||||
// mouseMoveEvent to updates the drag-selection rectangle
|
||||
const QPoint globalPos = charts_scroll->viewport()->mapToGlobal(pos); |
||||
const QPoint windowPos = charts_scroll->window()->mapFromGlobal(globalPos); |
||||
QMouseEvent mm(QEvent::MouseMove, pos, windowPos, globalPos, |
||||
Qt::NoButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt); |
||||
QApplication::sendEvent(charts_scroll->viewport(), &mm); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::resizeEvent(QResizeEvent *event) { |
||||
QWidget::resizeEvent(event); |
||||
updateLayout(); |
||||
} |
||||
|
||||
void ChartsWidget::newChart() { |
||||
SignalSelector dlg(tr("New Chart"), this); |
||||
if (dlg.exec() == QDialog::Accepted) { |
||||
auto items = dlg.seletedItems(); |
||||
if (!items.isEmpty()) { |
||||
auto c = createChart(); |
||||
for (auto it : items) { |
||||
c->addSignal(it->msg_id, it->sig); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::removeChart(ChartView *chart) { |
||||
charts.removeOne(chart); |
||||
chart->deleteLater(); |
||||
for (auto &[_, list] : tab_charts) { |
||||
list.removeOne(chart); |
||||
} |
||||
updateToolBar(); |
||||
updateLayout(true); |
||||
alignCharts(); |
||||
emit seriesChanged(); |
||||
} |
||||
|
||||
void ChartsWidget::removeAll() { |
||||
if (!charts.isEmpty()) { |
||||
for (auto c : charts) { |
||||
c->deleteLater(); |
||||
} |
||||
charts.clear(); |
||||
tab_charts.clear(); |
||||
updateToolBar(); |
||||
emit seriesChanged(); |
||||
} |
||||
while (tabbar->count() > 1) { |
||||
tabbar->removeTab(1); |
||||
} |
||||
} |
||||
|
||||
void ChartsWidget::alignCharts() { |
||||
int plot_left = 0; |
||||
for (auto c : charts) { |
||||
plot_left = std::max(plot_left, c->y_label_width); |
||||
} |
||||
plot_left = std::max((plot_left / 10) * 10 + 10, 50); |
||||
for (auto c : charts) { |
||||
c->updatePlotArea(plot_left); |
||||
} |
||||
} |
||||
|
||||
bool ChartsWidget::eventFilter(QObject *obj, QEvent *event) { |
||||
if (obj != this && event->type() == QEvent::Close) { |
||||
emit dock_btn->clicked(); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
bool ChartsWidget::event(QEvent *event) { |
||||
bool back_button = false; |
||||
switch (event->type()) { |
||||
case QEvent::MouseButtonPress: { |
||||
QMouseEvent *ev = static_cast<QMouseEvent *>(event); |
||||
back_button = ev->button() == Qt::BackButton; |
||||
break; |
||||
} |
||||
case QEvent::NativeGesture: { |
||||
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent *>(event); |
||||
back_button = (ev->value() == 180); |
||||
break; |
||||
} |
||||
case QEvent::WindowActivate: |
||||
case QEvent::WindowDeactivate: |
||||
case QEvent::FocusIn: |
||||
case QEvent::FocusOut: |
||||
case QEvent::Leave: |
||||
showValueTip(-1); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
if (back_button) { |
||||
zoom_undo_stack->undo(); |
||||
return true; |
||||
} |
||||
return QFrame::event(event); |
||||
} |
||||
|
||||
// ChartsContainer
|
||||
|
||||
ChartsContainer::ChartsContainer(ChartsWidget *parent) : charts_widget(parent), QWidget(parent) { |
||||
setAcceptDrops(true); |
||||
QVBoxLayout *charts_main_layout = new QVBoxLayout(this); |
||||
charts_main_layout->setContentsMargins(0, 10, 0, 0); |
||||
charts_layout = new QGridLayout(); |
||||
charts_layout->setSpacing(CHART_SPACING); |
||||
charts_main_layout->addLayout(charts_layout); |
||||
charts_main_layout->addStretch(0); |
||||
} |
||||
|
||||
void ChartsContainer::dragEnterEvent(QDragEnterEvent *event) { |
||||
if (event->mimeData()->hasFormat(CHART_MIME_TYPE)) { |
||||
event->acceptProposedAction(); |
||||
drawDropIndicator(event->pos()); |
||||
} |
||||
} |
||||
|
||||
void ChartsContainer::dropEvent(QDropEvent *event) { |
||||
if (event->mimeData()->hasFormat(CHART_MIME_TYPE)) { |
||||
auto w = getDropAfter(event->pos()); |
||||
auto chart = qobject_cast<ChartView *>(event->source()); |
||||
if (w != chart) { |
||||
for (auto &[_, list] : charts_widget->tab_charts) { |
||||
list.removeOne(chart); |
||||
} |
||||
int to = w ? charts_widget->currentCharts().indexOf(w) + 1 : 0; |
||||
charts_widget->currentCharts().insert(to, chart); |
||||
charts_widget->updateLayout(true); |
||||
event->acceptProposedAction(); |
||||
chart->startAnimation(); |
||||
} |
||||
drawDropIndicator({}); |
||||
} |
||||
} |
||||
|
||||
void ChartsContainer::paintEvent(QPaintEvent *ev) { |
||||
if (!drop_indictor_pos.isNull() && !childAt(drop_indictor_pos)) { |
||||
QRect r; |
||||
if (auto insert_after = getDropAfter(drop_indictor_pos)) { |
||||
QRect area = insert_after->geometry(); |
||||
r = QRect(area.left(), area.bottom() + 1, area.width(), CHART_SPACING); |
||||
} else { |
||||
r = geometry(); |
||||
r.setHeight(CHART_SPACING); |
||||
} |
||||
|
||||
const int margin = (CHART_SPACING - 2) / 2; |
||||
QPainterPath path; |
||||
path.addPolygon(QPolygonF({r.topLeft(), QPointF(r.left() + CHART_SPACING, r.top() + r.height() / 2), r.bottomLeft()})); |
||||
path.addPolygon(QPolygonF({r.topRight(), QPointF(r.right() - CHART_SPACING, r.top() + r.height() / 2), r.bottomRight()})); |
||||
|
||||
QPainter p(this); |
||||
p.setRenderHint(QPainter::Antialiasing); |
||||
p.fillPath(path, palette().highlight()); |
||||
p.fillRect(r.adjusted(2, margin, -2, -margin), palette().highlight()); |
||||
} |
||||
} |
||||
|
||||
ChartView *ChartsContainer::getDropAfter(const QPoint &pos) const { |
||||
auto it = std::find_if(charts_widget->currentCharts().crbegin(), charts_widget->currentCharts().crend(), [&pos](auto c) { |
||||
auto area = c->geometry(); |
||||
return pos.x() >= area.left() && pos.x() <= area.right() && pos.y() >= area.bottom(); |
||||
}); |
||||
return it == charts_widget->currentCharts().crend() ? nullptr : *it; |
||||
} |
@ -0,0 +1,126 @@ |
||||
#pragma once |
||||
|
||||
#include <QGridLayout> |
||||
#include <QLabel> |
||||
#include <QScrollArea> |
||||
#include <QTabBar> |
||||
#include <QTimer> |
||||
#include <QUndoCommand> |
||||
#include <QUndoStack> |
||||
|
||||
#include "tools/cabana/chart/signalselector.h" |
||||
#include "tools/cabana/dbc/dbcmanager.h" |
||||
#include "tools/cabana/streams/abstractstream.h" |
||||
|
||||
const int CHART_MIN_WIDTH = 300; |
||||
const QString CHART_MIME_TYPE = "application/x-cabanachartview"; |
||||
|
||||
class ChartView; |
||||
class ChartsWidget; |
||||
|
||||
class ChartsContainer : public QWidget { |
||||
public: |
||||
ChartsContainer(ChartsWidget *parent); |
||||
void dragEnterEvent(QDragEnterEvent *event) override; |
||||
void dropEvent(QDropEvent *event) override; |
||||
void dragLeaveEvent(QDragLeaveEvent *event) override { drawDropIndicator({}); } |
||||
void drawDropIndicator(const QPoint &pt) { drop_indictor_pos = pt; update(); } |
||||
void paintEvent(QPaintEvent *ev) override; |
||||
ChartView *getDropAfter(const QPoint &pos) const; |
||||
|
||||
QGridLayout *charts_layout; |
||||
ChartsWidget *charts_widget; |
||||
QPoint drop_indictor_pos; |
||||
}; |
||||
|
||||
class ChartsWidget : public QFrame { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
ChartsWidget(QWidget *parent = nullptr); |
||||
void showChart(const MessageId &id, const cabana::Signal *sig, bool show, bool merge); |
||||
inline bool hasSignal(const MessageId &id, const cabana::Signal *sig) { return findChart(id, sig) != nullptr; } |
||||
|
||||
public slots: |
||||
void setColumnCount(int n); |
||||
void removeAll(); |
||||
void setZoom(double min, double max); |
||||
|
||||
signals: |
||||
void dock(bool floating); |
||||
void rangeChanged(double min, double max, bool is_zommed); |
||||
void seriesChanged(); |
||||
|
||||
private: |
||||
void resizeEvent(QResizeEvent *event) override; |
||||
bool event(QEvent *event) override; |
||||
void alignCharts(); |
||||
void newChart(); |
||||
ChartView *createChart(); |
||||
void removeChart(ChartView *chart); |
||||
void splitChart(ChartView *chart); |
||||
void eventsMerged(); |
||||
void updateState(); |
||||
void zoomReset(); |
||||
void startAutoScroll(); |
||||
void stopAutoScroll(); |
||||
void doAutoScroll(); |
||||
void updateToolBar(); |
||||
void setMaxChartRange(int value); |
||||
void updateLayout(bool force = false); |
||||
void settingChanged(); |
||||
void showValueTip(double sec); |
||||
bool eventFilter(QObject *obj, QEvent *event) override; |
||||
void newTab(); |
||||
void removeTab(int index); |
||||
inline QList<ChartView *> ¤tCharts() { return tab_charts[tabbar->tabData(tabbar->currentIndex()).toInt()]; } |
||||
ChartView *findChart(const MessageId &id, const cabana::Signal *sig); |
||||
|
||||
QLabel *title_label; |
||||
QLabel *range_lb; |
||||
LogSlider *range_slider; |
||||
QAction *range_lb_action; |
||||
QAction *range_slider_action; |
||||
bool docking = true; |
||||
ToolButton *dock_btn; |
||||
|
||||
QAction *undo_zoom_action; |
||||
QAction *redo_zoom_action; |
||||
QAction *reset_zoom_action; |
||||
ToolButton *reset_zoom_btn; |
||||
QUndoStack *zoom_undo_stack; |
||||
|
||||
ToolButton *remove_all_btn; |
||||
QList<ChartView *> charts; |
||||
std::unordered_map<int, QList<ChartView *>> tab_charts; |
||||
QTabBar *tabbar; |
||||
ChartsContainer *charts_container; |
||||
QScrollArea *charts_scroll; |
||||
uint32_t max_chart_range = 0; |
||||
bool is_zoomed = false; |
||||
std::pair<double, double> display_range; |
||||
std::pair<double, double> zoomed_range; |
||||
QAction *columns_action; |
||||
int column_count = 1; |
||||
int current_column_count = 0; |
||||
int auto_scroll_count = 0; |
||||
QTimer auto_scroll_timer; |
||||
QTimer align_timer; |
||||
int current_theme = 0; |
||||
friend class ZoomCommand; |
||||
friend class ChartView; |
||||
friend class ChartsContainer; |
||||
}; |
||||
|
||||
class ZoomCommand : public QUndoCommand { |
||||
public: |
||||
ZoomCommand(ChartsWidget *charts, std::pair<double, double> range) : charts(charts), range(range), QUndoCommand() { |
||||
prev_range = charts->is_zoomed ? charts->zoomed_range : charts->display_range; |
||||
setText(QObject::tr("Zoom to %1-%2").arg(range.first, 0, 'f', 1).arg(range.second, 0, 'f', 1)); |
||||
} |
||||
void undo() override { charts->setZoom(prev_range.first, prev_range.second); } |
||||
void redo() override { charts->setZoom(range.first, range.second); } |
||||
ChartsWidget *charts; |
||||
std::pair<double, double> prev_range, range; |
||||
}; |
||||
|
@ -0,0 +1,108 @@ |
||||
#include "tools/cabana/chart/signalselector.h" |
||||
|
||||
#include <QCompleter> |
||||
#include <QDialogButtonBox> |
||||
#include <QGridLayout> |
||||
#include <QLabel> |
||||
#include <QLineEdit> |
||||
#include <QPushButton> |
||||
#include <QVBoxLayout> |
||||
|
||||
#include "tools/cabana/streams/abstractstream.h" |
||||
|
||||
SignalSelector::SignalSelector(QString title, QWidget *parent) : QDialog(parent) { |
||||
setWindowTitle(title); |
||||
QGridLayout *main_layout = new QGridLayout(this); |
||||
|
||||
// left column
|
||||
main_layout->addWidget(new QLabel(tr("Available Signals")), 0, 0); |
||||
main_layout->addWidget(msgs_combo = new QComboBox(this), 1, 0); |
||||
msgs_combo->setEditable(true); |
||||
msgs_combo->lineEdit()->setPlaceholderText(tr("Select a msg...")); |
||||
msgs_combo->setInsertPolicy(QComboBox::NoInsert); |
||||
msgs_combo->completer()->setCompletionMode(QCompleter::PopupCompletion); |
||||
msgs_combo->completer()->setFilterMode(Qt::MatchContains); |
||||
|
||||
main_layout->addWidget(available_list = new QListWidget(this), 2, 0); |
||||
|
||||
// buttons
|
||||
QVBoxLayout *btn_layout = new QVBoxLayout(); |
||||
QPushButton *add_btn = new QPushButton(utils::icon("chevron-right"), "", this); |
||||
add_btn->setEnabled(false); |
||||
QPushButton *remove_btn = new QPushButton(utils::icon("chevron-left"), "", this); |
||||
remove_btn->setEnabled(false); |
||||
btn_layout->addStretch(0); |
||||
btn_layout->addWidget(add_btn); |
||||
btn_layout->addWidget(remove_btn); |
||||
btn_layout->addStretch(0); |
||||
main_layout->addLayout(btn_layout, 0, 1, 3, 1); |
||||
|
||||
// right column
|
||||
main_layout->addWidget(new QLabel(tr("Selected Signals")), 0, 2); |
||||
main_layout->addWidget(selected_list = new QListWidget(this), 1, 2, 2, 1); |
||||
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
||||
main_layout->addWidget(buttonBox, 3, 2); |
||||
|
||||
for (auto it = can->last_msgs.cbegin(); it != can->last_msgs.cend(); ++it) { |
||||
if (auto m = dbc()->msg(it.key())) { |
||||
msgs_combo->addItem(QString("%1 (%2)").arg(m->name).arg(it.key().toString()), QVariant::fromValue(it.key())); |
||||
} |
||||
} |
||||
msgs_combo->model()->sort(0); |
||||
msgs_combo->setCurrentIndex(-1); |
||||
|
||||
QObject::connect(msgs_combo, qOverload<int>(&QComboBox::currentIndexChanged), this, &SignalSelector::updateAvailableList); |
||||
QObject::connect(available_list, &QListWidget::currentRowChanged, [=](int row) { add_btn->setEnabled(row != -1); }); |
||||
QObject::connect(selected_list, &QListWidget::currentRowChanged, [=](int row) { remove_btn->setEnabled(row != -1); }); |
||||
QObject::connect(available_list, &QListWidget::itemDoubleClicked, this, &SignalSelector::add); |
||||
QObject::connect(selected_list, &QListWidget::itemDoubleClicked, this, &SignalSelector::remove); |
||||
QObject::connect(add_btn, &QPushButton::clicked, [this]() { if (auto item = available_list->currentItem()) add(item); }); |
||||
QObject::connect(remove_btn, &QPushButton::clicked, [this]() { if (auto item = selected_list->currentItem()) remove(item); }); |
||||
QObject::connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
||||
QObject::connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
||||
} |
||||
|
||||
void SignalSelector::add(QListWidgetItem *item) { |
||||
auto it = (ListItem *)item; |
||||
addItemToList(selected_list, it->msg_id, it->sig, true); |
||||
delete item; |
||||
} |
||||
|
||||
void SignalSelector::remove(QListWidgetItem *item) { |
||||
auto it = (ListItem *)item; |
||||
if (it->msg_id == msgs_combo->currentData().value<MessageId>()) { |
||||
addItemToList(available_list, it->msg_id, it->sig); |
||||
} |
||||
delete item; |
||||
} |
||||
|
||||
void SignalSelector::updateAvailableList(int index) { |
||||
if (index == -1) return; |
||||
available_list->clear(); |
||||
MessageId msg_id = msgs_combo->itemData(index).value<MessageId>(); |
||||
auto selected_items = seletedItems(); |
||||
for (auto s : dbc()->msg(msg_id)->getSignals()) { |
||||
bool is_selected = std::any_of(selected_items.begin(), selected_items.end(), [=, sig = s](auto it) { return it->msg_id == msg_id && it->sig == sig; }); |
||||
if (!is_selected) { |
||||
addItemToList(available_list, msg_id, s); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void SignalSelector::addItemToList(QListWidget *parent, const MessageId id, const cabana::Signal *sig, bool show_msg_name) { |
||||
QString text = QString("<span style=\"color:%0;\">■ </span> %1").arg(getColor(sig).name(), sig->name); |
||||
if (show_msg_name) text += QString(" <font color=\"gray\">%0 %1</font>").arg(msgName(id), id.toString()); |
||||
|
||||
QLabel *label = new QLabel(text); |
||||
label->setContentsMargins(5, 0, 5, 0); |
||||
auto new_item = new ListItem(id, sig, parent); |
||||
new_item->setSizeHint(label->sizeHint()); |
||||
parent->setItemWidget(new_item, label); |
||||
} |
||||
|
||||
QList<SignalSelector::ListItem *> SignalSelector::seletedItems() { |
||||
QList<SignalSelector::ListItem *> ret; |
||||
for (int i = 0; i < selected_list->count(); ++i) ret.push_back((ListItem *)selected_list->item(i)); |
||||
return ret; |
||||
} |
@ -0,0 +1,30 @@ |
||||
#pragma once |
||||
|
||||
#include <QComboBox> |
||||
#include <QDialog> |
||||
#include <QListWidget> |
||||
|
||||
#include "tools/cabana/dbc/dbcmanager.h" |
||||
|
||||
class SignalSelector : public QDialog { |
||||
public: |
||||
struct ListItem : public QListWidgetItem { |
||||
ListItem(const MessageId &msg_id, const cabana::Signal *sig, QListWidget *parent) : msg_id(msg_id), sig(sig), QListWidgetItem(parent) {} |
||||
MessageId msg_id; |
||||
const cabana::Signal *sig; |
||||
}; |
||||
|
||||
SignalSelector(QString title, QWidget *parent); |
||||
QList<ListItem *> seletedItems(); |
||||
inline void addSelected(const MessageId &id, const cabana::Signal *sig) { addItemToList(selected_list, id, sig, true); } |
||||
|
||||
private: |
||||
void updateAvailableList(int index); |
||||
void addItemToList(QListWidget *parent, const MessageId id, const cabana::Signal *sig, bool show_msg_name = false); |
||||
void add(QListWidgetItem *item); |
||||
void remove(QListWidgetItem *item); |
||||
|
||||
QComboBox *msgs_combo; |
||||
QListWidget *available_list; |
||||
QListWidget *selected_list; |
||||
}; |
@ -0,0 +1,46 @@ |
||||
#include "tools/cabana/chart/tiplabel.h" |
||||
|
||||
#include <QApplication> |
||||
#include <QStylePainter> |
||||
#include <QToolTip> |
||||
|
||||
#include "tools/cabana/settings.h" |
||||
|
||||
TipLabel::TipLabel(QWidget *parent) : QLabel(parent, Qt::ToolTip | Qt::FramelessWindowHint) { |
||||
setForegroundRole(QPalette::ToolTipText); |
||||
setBackgroundRole(QPalette::ToolTipBase); |
||||
auto palette = QToolTip::palette(); |
||||
if (settings.theme != DARK_THEME) { |
||||
palette.setColor(QPalette::ToolTipBase, QApplication::palette().color(QPalette::Base)); |
||||
palette.setColor(QPalette::ToolTipText, QRgb(0x404044)); // same color as chart label brush
|
||||
} |
||||
setPalette(palette); |
||||
ensurePolished(); |
||||
setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this)); |
||||
setAttribute(Qt::WA_ShowWithoutActivating); |
||||
setTextFormat(Qt::RichText); |
||||
setVisible(false); |
||||
} |
||||
|
||||
void TipLabel::showText(const QPoint &pt, const QString &text, int right_edge) { |
||||
setText(text); |
||||
if (!text.isEmpty()) { |
||||
QSize extra(1, 1); |
||||
resize(sizeHint() + extra); |
||||
QPoint tip_pos(pt.x() + 12, pt.y()); |
||||
if (tip_pos.x() + size().width() >= right_edge) { |
||||
tip_pos.rx() = pt.x() - size().width() - 12; |
||||
} |
||||
move(tip_pos); |
||||
} |
||||
setVisible(!text.isEmpty()); |
||||
} |
||||
|
||||
void TipLabel::paintEvent(QPaintEvent *ev) { |
||||
QStylePainter p(this); |
||||
QStyleOptionFrame opt; |
||||
opt.init(this); |
||||
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); |
||||
p.end(); |
||||
QLabel::paintEvent(ev); |
||||
} |
@ -0,0 +1,10 @@ |
||||
#pragma once |
||||
|
||||
#include <QLabel> |
||||
|
||||
class TipLabel : public QLabel { |
||||
public: |
||||
TipLabel(QWidget *parent = nullptr); |
||||
void showText(const QPoint &pt, const QString &sec, int right_edge); |
||||
void paintEvent(QPaintEvent *ev) override; |
||||
}; |
File diff suppressed because it is too large
Load Diff
@ -1,188 +0,0 @@ |
||||
#pragma once |
||||
|
||||
#include <QGridLayout> |
||||
#include <QLabel> |
||||
#include <QListWidget> |
||||
#include <QGraphicsPixmapItem> |
||||
#include <QGraphicsProxyWidget> |
||||
#include <QStack> |
||||
#include <QTimer> |
||||
#include <QtCharts/QChartView> |
||||
#include <QtCharts/QLegendMarker> |
||||
#include <QtCharts/QLineSeries> |
||||
#include <QtCharts/QScatterSeries> |
||||
#include <QtCharts/QValueAxis> |
||||
|
||||
#include "tools/cabana/dbc/dbcmanager.h" |
||||
#include "tools/cabana/streams/abstractstream.h" |
||||
using namespace QtCharts; |
||||
|
||||
const int CHART_MIN_WIDTH = 300; |
||||
|
||||
enum class SeriesType { |
||||
Line = 0, |
||||
StepLine, |
||||
Scatter |
||||
}; |
||||
|
||||
class ChartView : public QChartView { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
ChartView(QWidget *parent = nullptr); |
||||
void addSeries(const MessageId &msg_id, const cabana::Signal *sig); |
||||
bool hasSeries(const MessageId &msg_id, const cabana::Signal *sig) const; |
||||
void updateSeries(const cabana::Signal *sig = nullptr); |
||||
void updatePlot(double cur, double min, double max); |
||||
void setSeriesType(SeriesType type); |
||||
void updatePlotArea(int left); |
||||
|
||||
struct SigItem { |
||||
MessageId msg_id; |
||||
const cabana::Signal *sig = nullptr; |
||||
QXYSeries *series = nullptr; |
||||
QVector<QPointF> vals; |
||||
QVector<QPointF> step_vals; |
||||
uint64_t last_value_mono_time = 0; |
||||
QPointF track_pt{}; |
||||
SegmentTree segment_tree; |
||||
double min = 0; |
||||
double max = 0; |
||||
}; |
||||
|
||||
signals: |
||||
void seriesRemoved(const MessageId &id, const cabana::Signal *sig); |
||||
void seriesAdded(const MessageId &id, const cabana::Signal *sig); |
||||
void zoomIn(double min, double max); |
||||
void zoomUndo(); |
||||
void remove(); |
||||
void axisYLabelWidthChanged(int w); |
||||
|
||||
private slots: |
||||
void signalUpdated(const cabana::Signal *sig); |
||||
void manageSeries(); |
||||
void handleMarkerClicked(); |
||||
void msgUpdated(MessageId id); |
||||
void msgRemoved(MessageId id) { removeIf([=](auto &s) { return s.msg_id == id; }); } |
||||
void signalRemoved(const cabana::Signal *sig) { removeIf([=](auto &s) { return s.sig == sig; }); } |
||||
|
||||
private: |
||||
void createToolButtons(); |
||||
void mousePressEvent(QMouseEvent *event) override; |
||||
void mouseReleaseEvent(QMouseEvent *event) override; |
||||
void mouseMoveEvent(QMouseEvent *ev) override; |
||||
void dragMoveEvent(QDragMoveEvent *event) override; |
||||
void dropEvent(QDropEvent *event) override; |
||||
void leaveEvent(QEvent *event) override; |
||||
void resizeEvent(QResizeEvent *event) override; |
||||
QSize sizeHint() const override { return {CHART_MIN_WIDTH, settings.chart_height}; } |
||||
void updateAxisY(); |
||||
void updateTitle(); |
||||
void drawForeground(QPainter *painter, const QRectF &rect) override; |
||||
std::tuple<double, double, int> getNiceAxisNumbers(qreal min, qreal max, int tick_count); |
||||
qreal niceNumber(qreal x, bool ceiling); |
||||
QXYSeries *createSeries(SeriesType type, QColor color); |
||||
void updateSeriesPoints(); |
||||
void removeIf(std::function<bool(const SigItem &)> predicate); |
||||
inline void clearTrackPoints() { for (auto &s : sigs) s.track_pt = {}; } |
||||
|
||||
int y_label_width = 0; |
||||
int align_to = 0; |
||||
QValueAxis *axis_x; |
||||
QValueAxis *axis_y; |
||||
QGraphicsPixmapItem *move_icon; |
||||
QGraphicsProxyWidget *close_btn_proxy; |
||||
QGraphicsProxyWidget *manage_btn_proxy; |
||||
QGraphicsRectItem *background; |
||||
QList<SigItem> sigs; |
||||
double cur_sec = 0; |
||||
const QString mime_type = "application/x-cabanachartview"; |
||||
SeriesType series_type = SeriesType::Line; |
||||
bool is_scrubbing = false; |
||||
bool resume_after_scrub = false; |
||||
friend class ChartsWidget; |
||||
}; |
||||
|
||||
class ChartsWidget : public QFrame { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
ChartsWidget(QWidget *parent = nullptr); |
||||
void showChart(const MessageId &id, const cabana::Signal *sig, bool show, bool merge); |
||||
inline bool hasSignal(const MessageId &id, const cabana::Signal *sig) { return findChart(id, sig) != nullptr; } |
||||
|
||||
public slots: |
||||
void setColumnCount(int n); |
||||
void removeAll(); |
||||
|
||||
signals: |
||||
void dock(bool floating); |
||||
void rangeChanged(double min, double max, bool is_zommed); |
||||
void seriesChanged(); |
||||
|
||||
private: |
||||
void resizeEvent(QResizeEvent *event) override; |
||||
bool event(QEvent *event) override; |
||||
void alignCharts(); |
||||
void newChart(); |
||||
ChartView *createChart(); |
||||
void removeChart(ChartView *chart); |
||||
void eventsMerged(); |
||||
void updateState(); |
||||
void zoomIn(double min, double max); |
||||
void zoomReset(); |
||||
void zoomUndo(); |
||||
void setZoom(double min, double max); |
||||
void updateToolBar(); |
||||
void setMaxChartRange(int value); |
||||
void updateLayout(); |
||||
void settingChanged(); |
||||
bool eventFilter(QObject *obj, QEvent *event) override; |
||||
ChartView *findChart(const MessageId &id, const cabana::Signal *sig); |
||||
|
||||
QLabel *title_label; |
||||
QLabel *range_lb; |
||||
LogSlider *range_slider; |
||||
QAction *range_lb_action; |
||||
QAction *range_slider_action; |
||||
bool docking = true; |
||||
QAction *dock_btn; |
||||
QAction *undo_zoom_action; |
||||
QAction *reset_zoom_action; |
||||
QAction *remove_all_btn; |
||||
QGridLayout *charts_layout; |
||||
QList<ChartView *> charts; |
||||
uint32_t max_chart_range = 0; |
||||
bool is_zoomed = false; |
||||
std::pair<double, double> display_range; |
||||
std::pair<double, double> zoomed_range; |
||||
QStack<QPair<double, double>> zoom_stack; |
||||
bool use_dark_theme = false; |
||||
QAction *columns_action; |
||||
int column_count = 1; |
||||
int current_column_count = 0; |
||||
QTimer align_timer; |
||||
}; |
||||
|
||||
class SeriesSelector : public QDialog { |
||||
public: |
||||
struct ListItem : public QListWidgetItem { |
||||
ListItem(const MessageId &msg_id, const cabana::Signal *sig, QListWidget *parent) : msg_id(msg_id), sig(sig), QListWidgetItem(parent) {} |
||||
MessageId msg_id; |
||||
const cabana::Signal *sig; |
||||
}; |
||||
|
||||
SeriesSelector(QString title, QWidget *parent); |
||||
QList<ListItem *> seletedItems(); |
||||
inline void addSelected(const MessageId &id, const cabana::Signal *sig) { addItemToList(selected_list, id, sig, true); } |
||||
|
||||
private: |
||||
void updateAvailableList(int index); |
||||
void addItemToList(QListWidget *parent, const MessageId id, const cabana::Signal *sig, bool show_msg_name = false); |
||||
void add(QListWidgetItem *item); |
||||
void remove(QListWidgetItem *item); |
||||
|
||||
QComboBox *msgs_combo; |
||||
QListWidget *available_list; |
||||
QListWidget *selected_list; |
||||
}; |
@ -1,4 +0,0 @@ |
||||
#!/bin/sh |
||||
cd "$(dirname "$0")" |
||||
export LD_LIBRARY_PATH="../../../opendbc/can:$LD_LIBRARY_PATH" |
||||
exec ./_test_cabana "$1" |
@ -0,0 +1,100 @@ |
||||
<?xml version='1.0' encoding='UTF-8'?> |
||||
<root> |
||||
<tabbed_widget parent="main_window" name="Main Window"> |
||||
<Tab containers="1" tab_name="SOF / EOF"> |
||||
<Container> |
||||
<DockSplitter orientation="-" sizes="0.500885;0.499115" count="2"> |
||||
<DockArea name="..."> |
||||
<plot flip_x="false" mode="TimeSeries" style="Lines" flip_y="false"> |
||||
<range right="780.030468" bottom="35000000.000000" top="65000000.000000" left="0.108134"/> |
||||
<limitY max="6.5e+07" min="3.5e+07"/> |
||||
<curve color="#1f77b4" name="/driverEncodeIdx/timestampSof"> |
||||
<transform alias="/driverEncodeIdx/timestampSof[Derivative]" name="Derivative"> |
||||
<options lineEdit="1.0" radioChecked="radioCustom"/> |
||||
</transform> |
||||
</curve> |
||||
<curve color="#d62728" name="/roadEncodeIdx/timestampSof"> |
||||
<transform alias="/roadEncodeIdx/timestampSof[Derivative]" name="Derivative"> |
||||
<options lineEdit="1.0" radioChecked="radioCustom"/> |
||||
</transform> |
||||
</curve> |
||||
<curve color="#1ac938" name="/wideRoadEncodeIdx/timestampSof"> |
||||
<transform alias="/wideRoadEncodeIdx/timestampSof[Derivative]" name="Derivative"> |
||||
<options lineEdit="1.0" radioChecked="radioCustom"/> |
||||
</transform> |
||||
</curve> |
||||
</plot> |
||||
</DockArea> |
||||
<DockArea name="..."> |
||||
<plot flip_x="false" mode="TimeSeries" style="Lines" flip_y="false"> |
||||
<range right="780.030468" bottom="35000000.000000" top="65000000.000000" left="0.108134"/> |
||||
<limitY max="6.5e+07" min="3.5e+07"/> |
||||
<curve color="#f14cc1" name="/driverEncodeIdx/timestampEof"> |
||||
<transform alias="/driverEncodeIdx/timestampEof[Derivative]" name="Derivative"> |
||||
<options lineEdit="1.0" radioChecked="radioCustom"/> |
||||
</transform> |
||||
</curve> |
||||
<curve color="#9467bd" name="/roadEncodeIdx/timestampEof"> |
||||
<transform alias="/roadEncodeIdx/timestampEof[Derivative]" name="Derivative"> |
||||
<options lineEdit="1.0" radioChecked="radioCustom"/> |
||||
</transform> |
||||
</curve> |
||||
<curve color="#17becf" name="/wideRoadEncodeIdx/timestampEof"> |
||||
<transform alias="/wideRoadEncodeIdx/timestampEof[Derivative]" name="Derivative"> |
||||
<options lineEdit="1.0" radioChecked="radioCustom"/> |
||||
</transform> |
||||
</curve> |
||||
</plot> |
||||
</DockArea> |
||||
</DockSplitter> |
||||
</Container> |
||||
</Tab> |
||||
<Tab containers="1" tab_name="model timings"> |
||||
<Container> |
||||
<DockSplitter orientation="-" sizes="0.5;0.5" count="2"> |
||||
<DockArea name="..."> |
||||
<plot flip_x="false" mode="TimeSeries" style="Lines" flip_y="false"> |
||||
<range right="780.030468" bottom="0.018421" top="0.030813" left="0.108134"/> |
||||
<limitY/> |
||||
<curve color="#ff7f0e" name="/modelV2/modelExecutionTime"/> |
||||
</plot> |
||||
</DockArea> |
||||
<DockArea name="..."> |
||||
<plot flip_x="false" mode="TimeSeries" style="Lines" flip_y="false"> |
||||
<range right="780.030468" bottom="-0.100000" top="0.100000" left="0.108134"/> |
||||
<limitY/> |
||||
<curve color="#f14cc1" name="/modelV2/frameDropPerc"/> |
||||
</plot> |
||||
</DockArea> |
||||
</DockSplitter> |
||||
</Container> |
||||
</Tab> |
||||
<Tab containers="1" tab_name="sensor info"> |
||||
<Container> |
||||
<DockSplitter orientation="-" sizes="1" count="1"> |
||||
<DockArea name="..."> |
||||
<plot flip_x="false" mode="TimeSeries" style="Lines" flip_y="false"> |
||||
<range right="780.030468" bottom="1.900000" top="2.100000" left="0.108134"/> |
||||
<limitY/> |
||||
<curve color="#bcbd22" name="/driverCameraState/sensor"/> |
||||
<curve color="#1f77b4" name="/roadCameraState/sensor"/> |
||||
<curve color="#d62728" name="/wideRoadCameraState/sensor"/> |
||||
</plot> |
||||
</DockArea> |
||||
</DockSplitter> |
||||
</Container> |
||||
</Tab> |
||||
<currentTabIndex index="0"/> |
||||
</tabbed_widget> |
||||
<use_relative_time_offset enabled="1"/> |
||||
<!-- - - - - - - - - - - - - - - --> |
||||
<!-- - - - - - - - - - - - - - - --> |
||||
<Plugins> |
||||
<plugin ID="DataLoad Rlog"/> |
||||
<plugin ID="Cereal Subscriber"/> |
||||
</Plugins> |
||||
<customMathEquations/> |
||||
<snippets/> |
||||
<!-- - - - - - - - - - - - - - - --> |
||||
</root> |
||||
|
@ -0,0 +1,44 @@ |
||||
<?xml version='1.0' encoding='UTF-8'?> |
||||
<root> |
||||
<tabbed_widget name="Main Window" parent="main_window"> |
||||
<Tab containers="1" tab_name="tab1"> |
||||
<Container> |
||||
<DockSplitter orientation="-" sizes="0.333333;0.333333;0.333333" count="3"> |
||||
<DockArea name="..."> |
||||
<plot style="Lines" flip_x="false" flip_y="false" mode="TimeSeries"> |
||||
<range right="134.825489" top="4402341.574525" bottom="-107369.555525" left="0.000000"/> |
||||
<limitY/> |
||||
<curve name="/gpsLocationExternal/accuracy" color="#1f77b4"/> |
||||
</plot> |
||||
</DockArea> |
||||
<DockArea name="..."> |
||||
<plot style="Lines" flip_x="false" flip_y="false" mode="TimeSeries"> |
||||
<range right="134.825489" top="1.025000" bottom="-0.025000" left="0.000000"/> |
||||
<limitY/> |
||||
<curve name="/gpsLocationExternal/flags" color="#d62728"/> |
||||
</plot> |
||||
</DockArea> |
||||
<DockArea name="..."> |
||||
<plot style="Lines" flip_x="false" flip_y="false" mode="TimeSeries"> |
||||
<range right="134.825489" top="6.150000" bottom="-0.150000" left="0.000000"/> |
||||
<limitY/> |
||||
<curve name="/ubloxGnss/measurementReport/numMeas" color="#1ac938"/> |
||||
</plot> |
||||
</DockArea> |
||||
</DockSplitter> |
||||
</Container> |
||||
</Tab> |
||||
<currentTabIndex index="0"/> |
||||
</tabbed_widget> |
||||
<use_relative_time_offset enabled="1"/> |
||||
<!-- - - - - - - - - - - - - - - --> |
||||
<!-- - - - - - - - - - - - - - - --> |
||||
<Plugins> |
||||
<plugin ID="DataLoad Rlog"/> |
||||
<plugin ID="Cereal Subscriber"/> |
||||
</Plugins> |
||||
<customMathEquations/> |
||||
<snippets/> |
||||
<!-- - - - - - - - - - - - - - - --> |
||||
</root> |
||||
|
Loading…
Reference in new issue