From c5bc16ded9125e22cb2286daf3de3b018a3976fe Mon Sep 17 00:00:00 2001 From: trainman419 Date: Wed, 4 Jun 2014 11:08:13 -0700 Subject: [PATCH] Switch button usage per #231 --- rqt_plot/resource/plot.ui | 2 +- rqt_plot/src/rqt_plot/plot_widget.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/rqt_plot/resource/plot.ui b/rqt_plot/resource/plot.ui index 06972e35..8419a72f 100644 --- a/rqt_plot/resource/plot.ui +++ b/rqt_plot/resource/plot.ui @@ -131,7 +131,7 @@ - remove all topics + clear plot diff --git a/rqt_plot/src/rqt_plot/plot_widget.py b/rqt_plot/src/rqt_plot/plot_widget.py index 0a54dd56..6faef7fc 100644 --- a/rqt_plot/src/rqt_plot/plot_widget.py +++ b/rqt_plot/src/rqt_plot/plot_widget.py @@ -167,7 +167,7 @@ def on_autoscroll_checkbox_clicked(self, checked): @Slot() def on_clear_button_clicked(self): - self.clean_up_subscribers() + self.clear_plot() def update_plot(self): if self.data_plot is not None: @@ -188,6 +188,7 @@ def _subscribed_topics_changed(self): if not self.pause_button.isChecked(): # if pause button is not pressed, enable timer based on subscribed topics self.enable_timer(self._rosdata) + self.data_plot.redraw() def _update_remove_topic_menu(self): def make_remove_topic_function(x): @@ -199,6 +200,11 @@ def make_remove_topic_function(x): action.triggered.connect(make_remove_topic_function(topic_name)) self._remove_topic_menu.addAction(action) + if len(self._rosdata) > 1: + all_action = QAction('All', self._remove_topic_menu) + all_action.triggered.connect(self.clean_up_subscribers) + self._remove_topic_menu.addAction(all_action) + self.remove_topic_button.setMenu(self._remove_topic_menu) def add_topic(self, topic_name): @@ -223,6 +229,11 @@ def remove_topic(self, topic_name): self._subscribed_topics_changed() + def clear_plot(self): + for topic_name, _ in self._rosdata.items(): + self.data_plot.clear_values(topic_name) + self.data_plot.redraw() + def clean_up_subscribers(self): for topic_name, rosdata in self._rosdata.items(): rosdata.close()