Skip to content

Commit

Permalink
seperate toggle_waterfalls into two functions #REF793
Browse files Browse the repository at this point in the history
  • Loading branch information
MialLewis committed Jun 17, 2022
1 parent 31b46eb commit 8ba7b3c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mslice/plotting/plot_window/cut_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def setup_connections(self, plot_window):
plot_window.action_gen_script.triggered.connect(self.generate_script)
plot_window.action_gen_script_clipboard.triggered.connect(lambda: self.generate_script(clipboard=True))
plot_window.action_waterfall.triggered.connect(self.toggle_waterfall)
plot_window.waterfall_x_edt.editingFinished.connect(self.toggle_waterfall)
plot_window.waterfall_y_edt.editingFinished.connect(self.toggle_waterfall)
plot_window.waterfall_x_edt.editingFinished.connect(self.update_waterfall)
plot_window.waterfall_y_edt.editingFinished.connect(self.update_waterfall)
plot_window.waterfall_x_edt.editingFinished.connect(plot_window.lose_waterfall_x_edt_focus)
plot_window.waterfall_y_edt.editingFinished.connect(plot_window.lose_waterfall_y_edt_focus)
plot_window.action_aluminium.triggered.connect(
Expand Down Expand Up @@ -442,13 +442,16 @@ def get_line_visible(self, line_index: int) -> bool:
return line_visible

def toggle_waterfall(self):
self._datum_dirty = True
self.update_bragg_peaks(refresh=True)
self.update_waterfall()

def update_waterfall(self):
if self.waterfall:
self._apply_offset(self.plot_window.waterfall_x, self.plot_window.waterfall_y)
else:
self._apply_offset(0., 0.)

self._datum_dirty = True
self.update_bragg_peaks(refresh=True)
self._canvas.draw()

def _cache_line(self, line):
Expand Down Expand Up @@ -492,8 +495,8 @@ def on_newplot(self, ax, plot_over):
if line not in self._waterfall_cache:
self._waterfall_cache[line] = [line.get_xdata(), line.get_ydata()]
new_line = True
if new_line and num_lines > 1:
self.toggle_waterfall()
if new_line and num_lines > 1 and self.plot_window.waterfall:
self.update_waterfall()

self._datum_dirty = True
self.update_bragg_peaks(refresh=True)
Expand Down

0 comments on commit 8ba7b3c

Please sign in to comment.