Skip to content

Commit

Permalink
cabana: fill rows with Qt::BDiagPattern if messag size is incorrect (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored and pull[bot] committed Nov 17, 2023
1 parent 252efc0 commit fe06eb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions tools/cabana/binaryview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ void BinaryViewModel::refresh() {
row_count = can->lastMessage(msg_id).dat.size();
items.resize(row_count * column_count);
}
int valid_rows = std::min(can->lastMessage(msg_id).dat.size(), row_count);
for (int i = 0; i < valid_rows * column_count; ++i) {
items[i].valid = true;
}
endResetModel();
updateState();
}
Expand Down Expand Up @@ -307,9 +311,6 @@ void BinaryViewModel::updateState() {
items[i * column_count + 8].val = toHex(binary[i]);
items[i * column_count + 8].bg_color = last_msg.colors[i];
}
for (int i = binary.size() * column_count; i < items.size(); ++i) {
items[i].val = "-";
}

for (int i = 0; i < items.size(); ++i) {
if (i >= prev_items.size() || prev_items[i].val != items[i].val || prev_items[i].bg_color != items[i].bg_color) {
Expand Down Expand Up @@ -376,6 +377,9 @@ void BinaryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
}
}

if (!item->valid) {
painter->fillRect(option.rect, QBrush(Qt::darkGray, Qt::BDiagPattern));
}
painter->drawText(option.rect, Qt::AlignCenter, item->val);
if (item->is_msb || item->is_lsb) {
painter->setFont(small_font);
Expand Down
3 changes: 2 additions & 1 deletion tools/cabana/binaryview.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class BinaryViewModel : public QAbstractTableModel {
QColor bg_color = QColor(102, 86, 169, 0);
bool is_msb = false;
bool is_lsb = false;
QString val = "-";
QString val;
QList<const cabana::Signal *> sigs;
bool valid = false;
};
std::vector<Item> items;

Expand Down

0 comments on commit fe06eb5

Please sign in to comment.