Skip to content

Commit

Permalink
Store rqt_plot range to restore it at next launch
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentrou committed Apr 2, 2014
1 parent de34443 commit e0d5024
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rqt_plot/src/rqt_plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def save_settings(self, plugin_settings, instance_settings):
instance_settings.set_value('plot_type', self._plot_type_index)
instance_settings.set_value('autoscroll', self._widget.autoscroll_checkbox.isChecked())
instance_settings.set_value('topics', pack(self._widget._rosdata.keys()))
if self._plot_type_index == 0:
instance_settings.set_value('state', pack(self._widget.get_range()))

def restore_settings(self, plugin_settings, instance_settings):
self._widget.autoscroll_checkbox.setChecked(instance_settings.value('autoscroll', True) in [True, 'true'])
Expand All @@ -178,6 +180,8 @@ def restore_settings(self, plugin_settings, instance_settings):
if topics:
for topic in topics:
self._widget.add_topic(topic)
if self._plot_type_index == 0:
self._widget.set_range(unpack(instance_settings.value('state', ([0, 1], [0, 1]))))

def trigger_configuration(self):
dialog = SimpleSettingsDialog(title='Plot Options')
Expand Down
6 changes: 6 additions & 0 deletions rqt_plot/src/rqt_plot/plot_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,9 @@ def enable_timer(self, enabled=True):
self._update_plot_timer.start(self._redraw_interval)
else:
self._update_plot_timer.stop()

def get_range(self):
return self.data_plot.get_range()

def set_range(self, range):
return self.data_plot.set_range(range)
7 changes: 7 additions & 0 deletions rqt_plot/src/rqt_plot/pyqtgraph_data_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ def redraw(self):

self._plot_widget.setXRange(x_max - x_delta, x_max, padding=0)

def get_range(self):
return self._plot_widget.viewRange()

def set_range(self, range):
x, y = range
self._plot_widget.setXRange(x[0], x[1], padding=0)
self._plot_widget.setYRange(y[0], y[1], padding=0)

0 comments on commit e0d5024

Please sign in to comment.