Skip to content

Commit

Permalink
Switch button usage per ros-visualization#231
Browse files Browse the repository at this point in the history
  • Loading branch information
trainman419 committed Jun 4, 2014
1 parent bc0b6ea commit c5bc16d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rqt_plot/resource/plot.ui
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>remove all topics</string>
<string>clear plot</string>
</property>
<property name="iconSize">
<size>
Expand Down
13 changes: 12 additions & 1 deletion rqt_plot/src/rqt_plot/plot_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit c5bc16d

Please sign in to comment.