Skip to content
Snippets Groups Projects
Commit f00f0f68 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

Stab. Keep window's view box when changing variable.

parent e2415a7a
No related branches found
No related tags found
No related merge requests found
...@@ -637,22 +637,23 @@ class ExploUim: ...@@ -637,22 +637,23 @@ class ExploUim:
self.stab_region_left.setRegion([x_min, x_1_third]) self.stab_region_left.setRegion([x_min, x_1_third])
self.stab_region_right.setRegion([x_2_third, x_max]) self.stab_region_right.setRegion([x_2_third, x_max])
# Re-calculate the position of the left/right means
self.__update_region_characteristics__(self.stab_region_left, "left")
self.__update_region_characteristics__(self.stab_region_right, "right")
# X range is the same as main window's plot X range # X range is the same as main window's plot X range
self.stab_plot_item.getViewBox().disableAutoRange()
self.stab_plot_item.getViewBox().setXRange(min=main_range[0][0], self.stab_plot_item.getViewBox().setXRange(min=main_range[0][0],
max=main_range[0][1], max=main_range[0][1],
padding=0) padding=0)
# Otherwise, the function is executed due to a variable change --> keep current viewbox and regions settings. # Otherwise, the function is executed due to a variable change --> keep current viewbox and regions settings.
else: else:
pass pass
self.stab_plot_item.getViewBox().setYRange(min=self.stab_timeseries["value"].min(), self.stab_plot_item.getViewBox().setYRange(min=self.stab_timeseries["value"].min(),
max=self.stab_timeseries["value"].max(), max=self.stab_timeseries["value"].max(),
padding=0) padding=0)
# Re-calculate the position of the left/right means
self.__update_region_characteristics__(self.stab_region_left, "left")
self.__update_region_characteristics__(self.stab_region_right, "right")
def __update_region_characteristics__(self, region: pg.LinearRegionItem, side: str): def __update_region_characteristics__(self, region: pg.LinearRegionItem, side: str):
df = self.stab_timeseries.copy() df = self.stab_timeseries.copy()
...@@ -666,8 +667,23 @@ class ExploUim: ...@@ -666,8 +667,23 @@ class ExploUim:
# Compute x_value's average and standard deviation over the selected region. # Compute x_value's average and standard deviation over the selected region.
mean = inside_values.mean() mean = inside_values.mean()
sd = inside_values.std() sd = inside_values.std()
# Hide InfiniteLines if it is not possible to calculate any region's average.
if math.isnan(mean): if math.isnan(mean):
self.stab_high_hline.hide()
self.stab_low_hline.hide()
self.stab_high_vline.hide()
self.stab_low_vline.hide()
self.stab_left_mean_line.hide()
self.stab_right_mean_line.hide()
return return
else:
self.stab_high_hline.show()
self.stab_low_hline.show()
self.stab_high_vline.show()
self.stab_low_vline.show()
self.stab_left_mean_line.show()
self.stab_right_mean_line.show()
# Update UI's text zones # Update UI's text zones
getattr(self.stab_window.ui, "stab_lineedit_"+side+"_mean").setText("{:.3f}".format(mean)) getattr(self.stab_window.ui, "stab_lineedit_"+side+"_mean").setText("{:.3f}".format(mean))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment