cabana: highlight dowloaded segments (#30459)

highlight dowloaded segments
old-commit-hash: 86a5ac383e
testing-closet
Dean Lee 1 year ago committed by GitHub
parent a10dbffbf8
commit 13d0f243ff
  1. 20
      tools/cabana/videowidget.cc
  2. 1
      tools/cabana/videowidget.h

@ -14,7 +14,6 @@
#include <QtConcurrent> #include <QtConcurrent>
#include "tools/cabana/streams/replaystream.h" #include "tools/cabana/streams/replaystream.h"
#include "tools/cabana/util.h"
const int MIN_VIDEO_HEIGHT = 100; const int MIN_VIDEO_HEIGHT = 100;
const int THUMBNAIL_MARGIN = 3; const int THUMBNAIL_MARGIN = 3;
@ -290,12 +289,23 @@ void Slider::paintEvent(QPaintEvent *ev) {
double min = minimum() / factor; double min = minimum() / factor;
double max = maximum() / factor; double max = maximum() / factor;
for (auto [begin, end, type] : qobject_cast<ReplayStream *>(can)->getReplay()->getTimeline()) { auto fillRange = [&](double begin, double end, const QColor &color) {
if (begin > max || end < min) if (begin > max || end < min) return;
continue;
r.setLeft(((std::max(min, begin) - min) / (max - min)) * width()); r.setLeft(((std::max(min, begin) - min) / (max - min)) * width());
r.setRight(((std::min(max, end) - min) / (max - min)) * width()); r.setRight(((std::min(max, end) - min) / (max - min)) * width());
p.fillRect(r, timeline_colors[(int)type]); p.fillRect(r, color);
};
const auto replay = qobject_cast<ReplayStream *>(can)->getReplay();
for (auto [begin, end, type] : replay->getTimeline()) {
fillRange(begin, end, timeline_colors[(int)type]);
}
QColor empty_color = palette().color(QPalette::Window);
empty_color.setAlpha(160);
for (const auto &[n, seg] : replay->segments()) {
if (!(seg && seg->isLoaded()))
fillRange(n * 60.0, (n + 1) * 60.0, empty_color);
} }
QStyleOptionSlider opt; QStyleOptionSlider opt;

@ -8,7 +8,6 @@
#include <QFrame> #include <QFrame>
#include <QSlider> #include <QSlider>
#include <QTabBar> #include <QTabBar>
#include <QToolButton>
#include "selfdrive/ui/qt/widgets/cameraview.h" #include "selfdrive/ui/qt/widgets/cameraview.h"
#include "tools/cabana/util.h" #include "tools/cabana/util.h"

Loading…
Cancel
Save