diff --git a/robot_log_visualizer/plotter/matplotlib_viewer_canvas.py b/robot_log_visualizer/plotter/matplotlib_viewer_canvas.py index 92a385a..dc50957 100644 --- a/robot_log_visualizer/plotter/matplotlib_viewer_canvas.py +++ b/robot_log_visualizer/plotter/matplotlib_viewer_canvas.py @@ -39,7 +39,7 @@ def __init__(self, parent, signal_provider, period): # start the vertical line animation (self.vertical_line,) = self.axes.plot([], [], "-", lw=1, c="k") - self.periond_in_ms = int(period * 1000) + self.period_in_ms = int(period * 1000) # active paths self.active_paths = {} @@ -48,7 +48,7 @@ def __init__(self, parent, signal_provider, period): self.fig, self.update_vertical_line, init_func=self.init_vertical_line, - interval=self.periond_in_ms, + interval=self.period_in_ms, blit=True, ) @@ -64,6 +64,12 @@ def quit_animation(self): if self.vertical_line_anim: self.vertical_line_anim._stop() + def pause_animation(self): + self.vertical_line_anim.pause() + + def resume_animation(self): + self.vertical_line_anim.resume() + def update_plots(self, paths, legends): for path, legend in zip(paths, legends): path_string = "/".join(path) @@ -108,7 +114,7 @@ def update_plots(self, paths, legends): self.fig, self.update_vertical_line, init_func=self.init_vertical_line, - interval=self.periond_in_ms, + interval=self.period_in_ms, blit=True, ) diff --git a/robot_log_visualizer/ui/gui.py b/robot_log_visualizer/ui/gui.py index e3428d4..fdc77a7 100644 --- a/robot_log_visualizer/ui/gui.py +++ b/robot_log_visualizer/ui/gui.py @@ -476,6 +476,13 @@ def textLogTreeWidget_on_click(self): self.text_logger.highlight_cell(self.find_text_log_index(path)) def plotTabBar_currentChanged(self, index): + # pause all the animations except the one that is selected, this is done to avoid the overhead of the animations + for i in range(len(self.plot_items)): + if i != index: + self.plot_items[i].canvas.pause_animation() + else: + self.plot_items[i].canvas.resume_animation() + # clear the selection to prepare a new one self.ui.variableTreeWidget.clearSelection() for active_path_str in self.plot_items[index].canvas.active_paths.keys():