cabana: sort events based on priority (#27809)

* sort events based on priority

* cleanup for pr

* pr cleanup 2

* pr cleanup 3
old-commit-hash: f8d9263eae
beeps
Justin Newberry 2 years ago committed by GitHub
parent faf3860d5a
commit 447a7bf9b1
  1. 17
      tools/cabana/videowidget.cc

@ -19,6 +19,20 @@ static const QColor timeline_colors[] = {
[(int)TimelineType::AlertCritical] = QColor(199, 0, 57), [(int)TimelineType::AlertCritical] = QColor(199, 0, 57),
}; };
bool sortTimelineBasedOnEventPriority(const std::tuple<int, int, TimelineType> &left, const std::tuple<int, int, TimelineType> &right){
const static std::map<TimelineType, int> timelinePriority = {
{ TimelineType::None, 0 },
{ TimelineType::Engaged, 10 },
{ TimelineType::AlertInfo, 20 },
{ TimelineType::AlertWarning, 30 },
{ TimelineType::AlertCritical, 40 },
{ TimelineType::UserFlag, 35 }
};
return timelinePriority.at(std::get<2>(left)) < timelinePriority.at(std::get<2>(right));
}
VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) { VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) {
setFrameStyle(QFrame::StyledPanel | QFrame::Plain); setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
auto main_layout = new QVBoxLayout(this); auto main_layout = new QVBoxLayout(this);
@ -129,6 +143,8 @@ void VideoWidget::updatePlayBtnState() {
Slider::Slider(QWidget *parent) : timer(this), thumbnail_label(this), QSlider(Qt::Horizontal, parent) { Slider::Slider(QWidget *parent) : timer(this), thumbnail_label(this), QSlider(Qt::Horizontal, parent) {
timer.callOnTimeout([this]() { timer.callOnTimeout([this]() {
timeline = can->getTimeline(); timeline = can->getTimeline();
std::sort(timeline.begin(), timeline.end(), sortTimelineBasedOnEventPriority);
update(); update();
}); });
setMouseTracking(true); setMouseTracking(true);
@ -189,6 +205,7 @@ void Slider::paintEvent(QPaintEvent *ev) {
p.fillRect(r, timeline_colors[(int)TimelineType::None]); p.fillRect(r, timeline_colors[(int)TimelineType::None]);
double min = minimum() / 1000.0; double min = minimum() / 1000.0;
double max = maximum() / 1000.0; double max = maximum() / 1000.0;
for (auto [begin, end, type] : timeline) { for (auto [begin, end, type] : timeline) {
if (begin > max || end < min) if (begin > max || end < min)
continue; continue;

Loading…
Cancel
Save