| 58 | } |
| 59 | |
| 60 | void SidepanelReplay::updateTableModel(const AbsBehaviorTree& locaded_tree) |
| 61 | { |
| 62 | _table_model->setColumnCount(4); |
| 63 | _table_model->setRowCount(0); |
| 64 | |
| 65 | const size_t transitions_count = _transitions.size(); |
| 66 | |
| 67 | auto createStatusItem = [](NodeStatus status) -> QStandardItem* |
| 68 | { |
| 69 | QStandardItem* item = nullptr; |
| 70 | switch (status) |
| 71 | { |
| 72 | case NodeStatus::SUCCESS:{ |
| 73 | item = new QStandardItem("SUCCESS"); |
| 74 | item->setBackground(QColor::fromRgb(22, 255, 22)); |
| 75 | } break; |
| 76 | case NodeStatus::FAILURE:{ |
| 77 | item = new QStandardItem("FAILURE"); |
| 78 | item->setBackground(QColor::fromRgb(255, 22, 22)); |
| 79 | } break; |
| 80 | case NodeStatus::RUNNING:{ |
| 81 | item = new QStandardItem("RUNNING"); |
| 82 | item->setBackground(QColor::fromRgb(250, 160, 20)); |
| 83 | } break; |
| 84 | case NodeStatus::IDLE:{ |
| 85 | item = new QStandardItem("IDLE"); |
| 86 | item->setBackground(QColor::fromRgb(222, 222, 222)); |
| 87 | } break; |
| 88 | } |
| 89 | item->setForeground(QColor::fromRgb(0, 0, 0)); |
| 90 | return item; |
| 91 | }; |
| 92 | |
| 93 | if( transitions_count > 0) |
| 94 | { |
| 95 | double previous_timestamp = 0; |
| 96 | const double first_timestamp = _transitions.front().timestamp; |
| 97 | |
| 98 | for(size_t row=0; row < transitions_count; row++) |
| 99 | { |
| 100 | auto& trans = _transitions[row]; |
| 101 | auto node = locaded_tree.node( trans.index ); |
| 102 | |
| 103 | QString timestamp; |
| 104 | timestamp.sprintf("%.3f", trans.timestamp - first_timestamp); |
| 105 | |
| 106 | auto timestamp_item = new QStandardItem( timestamp ); |
| 107 | timestamp.sprintf("absolute time: %.3f", trans.timestamp); |
| 108 | timestamp_item->setToolTip( timestamp ); |
| 109 | |
| 110 | if( (trans.timestamp - previous_timestamp) >= 0.001 || row == transitions_count-1) |
| 111 | { |
| 112 | _timepoint.push_back( {trans.timestamp, row} ); |
| 113 | previous_timestamp = trans.timestamp; |
| 114 | |
| 115 | auto font = timestamp_item->font(); |
| 116 | font.setBold(true); |
| 117 | timestamp_item->setFont(font); |