cabana: sort events based on priority (#27809)

* sort events based on priority

* cleanup for pr

* pr cleanup 2

* pr cleanup 3
pull/27832/head
Justin Newberry 2 years ago committed by GitHub
parent d551a4c18e
commit f8d9263eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      tools/cabana/videowidget.cc

@ -19,6 +19,20 @@ static const QColor timeline_colors[] = {
[(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) {
setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
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) {
timer.callOnTimeout([this]() {
timeline = can->getTimeline();
std::sort(timeline.begin(), timeline.end(), sortTimelineBasedOnEventPriority);
update();
});
setMouseTracking(true);
@ -189,6 +205,7 @@ void Slider::paintEvent(QPaintEvent *ev) {
p.fillRect(r, timeline_colors[(int)TimelineType::None]);
double min = minimum() / 1000.0;
double max = maximum() / 1000.0;
for (auto [begin, end, type] : timeline) {
if (begin > max || end < min)
continue;

Loading…
Cancel
Save