From 7989252b3ded6c46d6d98d2a064d03d9c32d71c2 Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Mon, 27 Jan 2025 15:42:48 -0500 Subject: [PATCH 1/3] docs(streamlines): Remove some outdated & inaccurate comments --- src/density_plots.py | 2 +- src/fields_plots.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/density_plots.py b/src/density_plots.py index dabe82f..2e0088c 100644 --- a/src/density_plots.py +++ b/src/density_plots.py @@ -937,7 +937,7 @@ def setZmaxChanged(self, *args): self.parent.SetPlotParam('set_v_max', self.setZmaxVar.get()) def TxtEnter(self, e): - streamlines.streamlines_callback(self, update_plot=True) # not updating plots because FieldsCallback forces an update no matter what + streamlines.streamlines_callback(self, update_plot=True) self.FieldsCallback() self.GammaCallback() diff --git a/src/fields_plots.py b/src/fields_plots.py index 10f590c..31d0c70 100644 --- a/src/fields_plots.py +++ b/src/fields_plots.py @@ -1508,7 +1508,7 @@ def Selector(self): self.parent.SetPlotParam('show_z', self.ShowZVar.get()) def TxtEnter(self, e): - streamlines.streamlines_callback(self, update_plot=False) # not updating plots because FieldsCallback forces an update no matter what + streamlines.streamlines_callback(self, update_plot=False) self.FieldsCallback() self.GammaCallback() From 9822a9182178d3bbf1177d3cfcab4a5541119c6c Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Mon, 27 Jan 2025 15:45:46 -0500 Subject: [PATCH 2/3] fix(streamlines): force a redraw of streamplots when turned on Before this change when the user was zoomed into a section of the domain and turned on the streamlines it would overlay the streamlines for the full domain onto the zoomed in section. This change fixes that so that only the streamlines in the zoomed section are plotted. Fixes #47 Co-authored-by: Patrick Crumley --- src/streamlines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/streamlines.py b/src/streamlines.py index fc1ae9d..80605da 100644 --- a/src/streamlines.py +++ b/src/streamlines.py @@ -106,7 +106,7 @@ def __show_streamline_handler(settings, panel): """ # Write value to the settings dictionary settings.parent.SetPlotParam( - "show_streamlines", settings.show_streamlines.get(), update_plot=False + "show_streamlines", settings.show_streamlines.get(), update_plot=False, NeedsRedraw=True ) # Either create the streamlines or remove them depending on the state of the checkbox if settings.parent.GetPlotParam("show_streamlines"): From bb0f2ba5a475cc51883d9a88b9de8514ef9f8952 Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Mon, 27 Jan 2025 15:51:55 -0500 Subject: [PATCH 3/3] perf(streamlines): Remove duplicate plotting of streamlines In a few places the streamlines would be computed and plotted multiple times. I've removed those cases so that the streamlines will only be computed and plotted once. This should result in a noticeable speedup in plotting streamlines. --- src/streamlines.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/streamlines.py b/src/streamlines.py index 80605da..2cf3a7a 100644 --- a/src/streamlines.py +++ b/src/streamlines.py @@ -108,10 +108,9 @@ def __show_streamline_handler(settings, panel): settings.parent.SetPlotParam( "show_streamlines", settings.show_streamlines.get(), update_plot=False, NeedsRedraw=True ) - # Either create the streamlines or remove them depending on the state of the checkbox - if settings.parent.GetPlotParam("show_streamlines"): - draw_streamlines(panel) - else: + + # Remove streamlines if the checkbox is unchecked + if not settings.parent.GetPlotParam("show_streamlines"): remove_streamlines(panel) # Update everything @@ -129,7 +128,9 @@ def streamlines_callback(settings, update_plot=True): update_plot = False # Handle streamline stride - if settings.streamlines_stride.get() != settings.streamlines_stride: + if settings.streamlines_stride.get() != settings.parent.plot_param_dict['streamlines_stride']: + settings.parent.plot_param_dict['streamlines_stride'] = settings.streamlines_stride.get() + settings.parent.SetPlotParam( "streamlines_stride", settings.streamlines_stride.get(), @@ -137,7 +138,9 @@ def streamlines_callback(settings, update_plot=True): ) # Handle streamline density - if settings.streamlines_density.get() != settings.streamlines_density: + if settings.streamlines_density.get() != settings.parent.plot_param_dict['streamlines_density']: + settings.parent.plot_param_dict['streamlines_density'] = settings.streamlines_density.get() + settings.parent.SetPlotParam( "streamlines_density", settings.streamlines_density.get(), @@ -145,7 +148,9 @@ def streamlines_callback(settings, update_plot=True): ) # Handle streamline color - if settings.streamlines_color.get() != settings.streamlines_color: + if settings.streamlines_color.get() != settings.parent.plot_param_dict['streamlines_color']: + settings.parent.plot_param_dict['streamlines_color'] = settings.streamlines_color.get() + settings.parent.SetPlotParam( "streamlines_color", settings.streamlines_color.get(),