35 from python_qt_binding
import QT_BINDING
36 from python_qt_binding.QtCore
import qDebug
41 from .plot_widget
import PlotWidget
43 from .data_plot
import DataPlot
50 self.setObjectName(
'Plot')
56 initial_topics=self._args.topics, start_paused=self._args.start_paused)
60 self._data_plot.set_autoscale(x=
False)
61 self._data_plot.set_autoscale(y=DataPlot.SCALE_EXTEND | DataPlot.SCALE_VISIBLE)
62 self._data_plot.set_xlim([0, 10.0])
64 self._widget.switch_data_plot_widget(self.
_data_plot)
65 if context.serial_number() > 1:
66 self._widget.setWindowTitle(
67 self._widget.windowTitle() + (
' (%d)' % context.serial_number()))
68 context.add_widget(self.
_widget)
71 parser = argparse.ArgumentParser(prog=
'rqt_plot', add_help=
False)
72 Plot.add_arguments(parser)
73 args = parser.parse_args(argv)
81 for sub_t
in [x
for x
in t.split(
',')
if x]:
84 base = sub_t[:sub_t.find(
':')]
88 parser.error(
"%s must contain a topic and field name" % sub_t)
89 base = base[:base.rfind(
'/')]
92 fields = sub_t.split(
':')[1:]
93 c_topics.extend([
"%s/%s" % (base, f)
for f
in fields
if f])
95 c_topics.append(sub_t)
98 c_topics = [rosgraph.names.script_resolve_name(
'rqt_plot', n)
for n
in c_topics]
99 if type(c_topics) == list:
100 topic_list.extend(c_topics)
102 topic_list.append(c_topics)
103 args.topics = topic_list
109 group = parser.add_argument_group(
'Options for rqt_plot plugin')
110 group.add_argument(
'-P',
'--pause', action=
'store_true', dest=
'start_paused',
111 help=
'Start in paused state')
112 group.add_argument(
'-e',
'--empty', action=
'store_true', dest=
'start_empty',
113 help=
'Start without restoring previous topics')
114 group.add_argument(
'topics', nargs=
'*', default=[], help=
'Topics to plot')
117 self._widget.setWindowTitle(self._data_plot.getTitle())
118 if self._context.serial_number() > 1:
119 self._widget.setWindowTitle(
120 self._widget.windowTitle() + (
' (%d)' % self._context.serial_number()))
123 self._data_plot.save_settings(plugin_settings, instance_settings)
124 instance_settings.set_value(
'autoscroll', self._widget.autoscroll_checkbox.isChecked())
125 instance_settings.set_value(
'topics', pack(self._widget._rosdata.keys()))
128 autoscroll = instance_settings.value(
'autoscroll',
True)
in [
True,
'true']
129 self._widget.autoscroll_checkbox.setChecked(autoscroll)
130 self._data_plot.autoscroll(autoscroll)
134 if len(self._widget._rosdata.keys()) == 0
and not self._args.start_empty:
135 topics = unpack(instance_settings.value(
'topics', []))
138 self._widget.add_topic(topic)
140 self._data_plot.restore_settings(plugin_settings, instance_settings)
143 self._data_plot.doSettingsDialog()
147 self._widget.clean_up_subscribers()
def __init__(self, context)
def save_settings(self, plugin_settings, instance_settings)
def _parse_args(self, argv)
def shutdown_plugin(self)
def add_arguments(parser)
def restore_settings(self, plugin_settings, instance_settings)
def trigger_configuration(self)