33 from python_qt_binding.QtWidgets
import QAbstractItemView, QTableWidgetSelectionRange
35 from .table_widget
import TableWidget
37 HEADERS = [
'Score',
'X',
'Theta']
41 """This widget displays a sorted list of all the trajectories in tabular format."""
43 def __init__(self, parent, selection_callback):
44 TableWidget.__init__(self, HEADERS)
45 self.
table.setSelectionBehavior(QAbstractItemView.SelectRows)
57 self.
table.resize(self.size())
58 self.
table.setRowCount(len(evaluation.twists))
61 self.
sorted_twists = sorted(enumerate(evaluation.twists), key=
lambda x: (x[1].total < 0, x[1].total))
64 for row_index, (original_index, twist)
in enumerate(self.
sorted_twists):
65 self.
setValue(row_index, 0,
'%5.2f' % twist.total)
66 self.
setValue(row_index, 1,
'%.2f' % twist.traj.velocity.x)
67 self.
setValue(row_index, 2,
'%.2f' % twist.traj.velocity.theta)
82 self.
table.setRangeSelected(QTableWidgetSelectionRange(0, 0,
83 self.
table.rowCount() - 1, self.
table.columnCount() - 1
87 for index
in selected:
94 for index
in self.
table.selectedIndexes():
107 new_selected.remove(selection)
109 new_selected.append(selection)