Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mlautman authored Oct 23, 2018
1 parent f776eea commit dbf4075
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 77 deletions.
6 changes: 4 additions & 2 deletions src/rqt_console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class Console(Plugin):

def __init__(self, context):
"""
:param context: plugin context hook to enable adding widgets as a ROS_GUI pane, ''PluginContext''
:param context: plugin context hook to enable adding widgets as a ROS_GUI pane,
''PluginContext''
"""
super(Console, self).__init__(context)
self.setObjectName('Console')
Expand All @@ -67,7 +68,8 @@ def __init__(self, context):

self._widget = ConsoleWidget(self._proxy_model, self._rospack)
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
self._widget.setWindowTitle(
self._widget.windowTitle() + (' (%d)' % context.serial_number()))
context.add_widget(self._widget)

# queue to store incoming data which get flushed periodically to the model
Expand Down
3 changes: 2 additions & 1 deletion src/rqt_console/console_settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def __init__(self, topics, rospack):
:param limit: displayed in the message buffer size spin box, ''int''
"""
super(ConsoleSettingsDialog, self).__init__()
ui_file = os.path.join(rospack.get_path('rqt_console'), 'resource', 'console_settings_dialog.ui')
ui_file = os.path.join(
rospack.get_path('rqt_console'), 'resource', 'console_settings_dialog.ui')
loadUi(ui_file, self)
for topic in topics:
self.topic_combo.addItem(topic[0] + ' (' + topic[1] + ')', topic[0])
Expand Down
169 changes: 123 additions & 46 deletions src/rqt_console/console_widget.py

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/rqt_console/filters/custom_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ class CustomFilterWidget(QWidget):

def __init__(self, parentfilter, rospack, item_providers):
super(CustomFilterWidget, self).__init__()
ui_file = os.path.join(rospack.get_path('rqt_console'), 'resource/filters', 'custom_filter_widget.ui')
ui_file = os.path.join(
rospack.get_path('rqt_console'), 'resource/filters', 'custom_filter_widget.ui')
loadUi(ui_file, self)
self.setObjectName('CustomFilterWidget')
self._parentfilter = parentfilter # When data is changed it is stored in the parent filter

# keep color for highlighted items even when not active
for list_widget in [self.severity_list, self.node_list, self.topic_list]:
active_color = list_widget.palette().brush(QPalette.Active, QPalette.Highlight).color().name()
list_widget.setStyleSheet('QListWidget:item:selected:!active { background: %s; }' % active_color)
active_color = list_widget.palette().brush(
QPalette.Active, QPalette.Highlight).color().name()
list_widget.setStyleSheet(
'QListWidget:item:selected:!active { background: %s; }' % active_color)

# Text Filter Initialization
self.text_edit.textChanged.connect(self.handle_text_changed)
Expand Down
6 changes: 4 additions & 2 deletions src/rqt_console/filters/filter_wrapper_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
class FilterWrapperWidget(QWidget):

"""
Wraps the other filter widgets to provide enable check box, delete button control and uniform labeling
Wraps the other filter widgets to provide enable check box, delete button control and uniform
labeling
"""

def __init__(self, widget, filter_name):
Expand All @@ -51,7 +52,8 @@ def __init__(self, widget, filter_name):
"""
super(FilterWrapperWidget, self).__init__()
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('rqt_console'), 'resource/filters', 'filter_wrapper_widget.ui')
ui_file = os.path.join(
rp.get_path('rqt_console'), 'resource/filters', 'filter_wrapper_widget.ui')
loadUi(ui_file, self)
self.setObjectName('FilterWrapperWidget')
self.delete_button.setIcon(QIcon.fromTheme('list-remove'))
Expand Down
9 changes: 6 additions & 3 deletions src/rqt_console/filters/list_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def __init__(self, parentfilter, rospack, item_provider):
:param item_provider: a function designed to provide a list or dict
"""
super(ListFilterWidget, self).__init__()
ui_file = os.path.join(rospack.get_path('rqt_console'), 'resource/filters', 'list_filter_widget.ui')
ui_file = os.path.join(
rospack.get_path('rqt_console'), 'resource/filters', 'list_filter_widget.ui')
loadUi(ui_file, self)
self.setObjectName('ListFilterWidget')
self._parentfilter = parentfilter # When data is changed we need to store it in the parent filter
# When data is changed we need to store it in the parent filter
self._parentfilter = parentfilter

# keep color for highlighted items even when not active
active_color = self.palette().brush(QPalette.Active, QPalette.Highlight).color().name()
Expand Down Expand Up @@ -98,7 +100,8 @@ def repopulate(self):
item = new_items[key]
if item not in self._display_list:
self.list_widget.addItem(item)
self.list_widget.item(self.list_widget.count() - 1).setData(Qt.UserRole, key)
self.list_widget.item(
self.list_widget.count() - 1).setData(Qt.UserRole, key)
else:
for item in new_items:
if item not in self._display_list:
Expand Down
3 changes: 2 additions & 1 deletion src/rqt_console/filters/text_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __init__(self, parentfilter, rospack):
:param parentfilter: buddy filter were data is stored, ''TimeFilter''
"""
super(TextFilterWidget, self).__init__()
ui_file = os.path.join(rospack.get_path('rqt_console'), 'resource/filters', 'text_filter_widget.ui')
ui_file = os.path.join(
rospack.get_path('rqt_console'), 'resource/filters', 'text_filter_widget.ui')
loadUi(ui_file, self)
self.setObjectName('TextFilterWidget')
self._parentfilter = parentfilter # When data is changed it is stored in the parent filter
Expand Down
4 changes: 2 additions & 2 deletions src/rqt_console/filters/time_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def has_filter(self):
def test_message(self, message):
"""
Tests if the message matches the filter.
If _stop_time_enabled is true then the message's time value must be between the dates provided
to be considered a match
If _stop_time_enabled is true then the message's time value must be between the dates
provided to be considered a match
If _stop_time_enabled is false then the time must simply be after _start_time
:param message: the message to be tested against the filters, ''Message''
:returns: True if the message matches, ''bool''
Expand Down
15 changes: 10 additions & 5 deletions src/rqt_console/filters/time_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def __init__(self, parentfilter, rospack, time_range_provider):
the min and max time to be displayed, ''list of tuple''
"""
super(TimeFilterWidget, self).__init__()
ui_file = os.path.join(rospack.get_path('rqt_console'), 'resource/filters', 'time_filter_widget.ui')
ui_file = os.path.join(
rospack.get_path('rqt_console'), 'resource/filters', 'time_filter_widget.ui')
loadUi(ui_file, self)
self.setObjectName('TimeFilterWidget')
self._parentfilter = parentfilter # When data is changed it is stored in the parent filter
Expand Down Expand Up @@ -98,8 +99,10 @@ def save_settings(self, settings):
Saves the settings for this filter to an ini file.
:param settings: used to write the settings to an ini file ''qt_gui.settings.Settings''
"""
settings.set_value('start_time', self._parentfilter._start_time.toString('hh:mm:ss.zzz (yyyy-MM-dd)'))
settings.set_value('stop_time', self._parentfilter._stop_time.toString('hh:mm:ss.zzz (yyyy-MM-dd)'))
settings.set_value(
'start_time', self._parentfilter._start_time.toString('hh:mm:ss.zzz (yyyy-MM-dd)'))
settings.set_value(
'stop_time', self._parentfilter._stop_time.toString('hh:mm:ss.zzz (yyyy-MM-dd)'))
settings.set_value('stop_time_enabled', self._parentfilter._stop_time_enabled)

def restore_settings(self, settings):
Expand All @@ -109,11 +112,13 @@ def restore_settings(self, settings):
"""
self.handle_stop_enabled_changed(settings.value('stop_time_enabled') in [True, 'true'])
if settings.contains('start_time'):
self.handle_start_changed(QDateTime.fromString(settings.value('start_time'), 'hh:mm:ss.zzz (yyyy-MM-dd)'))
self.handle_start_changed(
QDateTime.fromString(settings.value('start_time'), 'hh:mm:ss.zzz (yyyy-MM-dd)'))
else:
self.handle_start_changed(QDateTime(datetime.now()))
if settings.contains('stop_time'):
self.handle_stop_changed(QDateTime.fromString(settings.value('stop_time'), 'hh:mm:ss.zzz (yyyy-MM-dd)'))
self.handle_stop_changed(
QDateTime.fromString(settings.value('stop_time'), 'hh:mm:ss.zzz (yyyy-MM-dd)'))
else:
self.handle_stop_changed(QDateTime(datetime.now()))

Expand Down
19 changes: 12 additions & 7 deletions src/rqt_console/message_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def data(self, index, role=None):

# colorize severity label
if role == Qt.ForegroundRole and column == 'severity':
assert msg.severity in MessageDataModel.severity_colors, 'Unknown severity type: %s' % msg.severity
assert msg.severity in MessageDataModel.severity_colors, \
'Unknown severity type: %s' % msg.severity
return MessageDataModel.severity_colors[msg.severity]

if role == Qt.ToolTipRole and column != 'severity':
Expand All @@ -120,7 +121,8 @@ def data(self, index, role=None):
else:
data = getattr(msg, column)
# <font> tag enables word wrap by forcing rich text
return '<font>' + data + '<br/><br/>' + self.tr('Right click for menu.') + '</font>'
return '<font>' + data + '<br/><br/>' + \
self.tr('Right click for menu.') + '</font>'

def headerData(self, section, orientation, role=None):
if role is None:
Expand All @@ -135,7 +137,9 @@ def headerData(self, section, orientation, role=None):
if section == 0:
return self.tr('Sort the rows by serial number in descendig order')
else:
return self.tr('Sorting the table by a column other then the serial number slows down the interaction especially when recording high frequency data')
return self.tr(
'Sorting the table by a column other then the serial number slows down the '
'interaction especially when recording high frequency data')

# END Required implementations of QAbstractTableModel functions

Expand Down Expand Up @@ -217,7 +221,8 @@ def get_selected_text(self, rowlist):
def get_time_range(self, rowlist):
"""
:param rowlist: a list of row indexes, ''list''
:returns: a tuple of min and max times in a rowlist in '(unix timestamp).(fraction of second)' format, ''tuple(str,str)''
:returns: a tuple of min and max times in a rowlist in
'(unix timestamp).(fraction of second)' format, ''tuple(str,str)''
"""
min_ = float("inf")
max_ = float("-inf")
Expand All @@ -230,19 +235,19 @@ def get_time_range(self, rowlist):
return min_, max_

def get_unique_nodes(self):
nodes = set([])
nodes = set()
for message in self._messages:
nodes.add(message.node)
return nodes

def get_unique_severities(self):
severities = set([])
severities = set()
for message in self._messages:
severities.add(message.severity)
return severities

def get_unique_topics(self):
topics = set([])
topics = set()
for message in self._messages:
for topic in message.topics:
topics.add(topic)
Expand Down
4 changes: 3 additions & 1 deletion src/rqt_console/message_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def __getitem__(self, key):

def __delitem__(self, key):
if isinstance(key, slice):
assert key.step is None or key.step == 1, 'MessageList.__delitem__ not implemented for slices with step argument different than 1'
assert key.step is None or key.step == 1, \
'MessageList.__delitem__ not implemented for slices with step argument ' \
'different than 1'
del self._messages[len(self._messages) - key.stop:len(self._messages) - key.start]
else:
del self._messages[len(self._messages) - key - 1]
Expand Down
12 changes: 8 additions & 4 deletions src/rqt_console/message_proxy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def setSourceModel(self, source_model):

def filterAcceptsRow(self, sourcerow, sourceparent):
"""
returns: True if the row does not match any exclude filter AND (_show_highlighted_only is False OR it matches any highlight filter), ''bool''
returns: True if the row does not match any exclude filter AND (_show_highlighted_only is
False OR it matches any highlight filter), ''bool''
"""
msg = self._source_model._messages[sourcerow]
if self._exclude_filters.test_message(msg):
Expand All @@ -81,7 +82,8 @@ def filterAcceptsRow(self, sourcerow, sourceparent):
if self._highlight_filters.count_enabled_filters() > 0:
highlighted = self._highlight_filters.test_message(msg, default=True)
if self._show_highlighted_only and not highlighted:
# hide messages which are not highlighted when only highlightes messages should be visible
# hide messages which are not highlighted when only highlightes messages
# should be visible
return False

# update message state
Expand Down Expand Up @@ -117,9 +119,11 @@ def handle_highlight_filters_changed(self):
else:
self.invalidateFilter()
if qVersion().startswith('4.'):
self.dataChanged.emit(self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1))
self.dataChanged.emit(
self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1))
else:
self.dataChanged.emit(self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1), [])
self.dataChanged.emit(
self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1), [])

def add_exclude_filter(self, newfilter):
self._exclude_filters.append(newfilter)
Expand Down

0 comments on commit dbf4075

Please sign in to comment.