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

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

parent 7299e61a
No related branches found
No related tags found
No related merge requests found
...@@ -623,25 +623,35 @@ class ExploUim: ...@@ -623,25 +623,35 @@ class ExploUim:
if not is_numeric_dtype(self.stab_timeseries["value"]): if not is_numeric_dtype(self.stab_timeseries["value"]):
self.stab_timeseries["value"] = self.stab_timeseries["value_int"] self.stab_timeseries["value"] = self.stab_timeseries["value_int"]
# Get the main windows view box # If the regions are not yet placed, it means that this function is executed for stabilization window's
main_range = self.plot_item.getViewBox().viewRange() # initialization --> use view box of the main window's plot
if self.stab_region_left.getRegion() == (0, 1):
# Place the 2 (right/left) regions # Get the main windows view box
x_min = main_range[0][0] main_range = self.plot_item.getViewBox().viewRange()
x_max = main_range[0][1]
x_1_third = x_min + ((x_max - x_min) / 3) # Place the 2 (right/left) regions
x_2_third = x_min + 2 * ((x_max - x_min) / 3) x_min = main_range[0][0]
self.stab_region_left.setRegion([x_min, x_1_third]) x_max = main_range[0][1]
self.stab_region_right.setRegion([x_2_third, x_max]) x_1_third = x_min + ((x_max - x_min) / 3)
x_2_third = x_min + 2 * ((x_max - x_min) / 3)
# Re-calculate the position of the left/right means self.stab_region_left.setRegion([x_min, x_1_third])
self.__update_region_characteristics__(self.stab_region_left, "left") self.stab_region_right.setRegion([x_2_third, x_max])
self.__update_region_characteristics__(self.stab_region_right, "right")
# Re-calculate the position of the left/right means
# X range is the same as main window's plot X range self.__update_region_characteristics__(self.stab_region_left, "left")
self.stab_plot_item.getViewBox().setRange(xRange=(main_range[0][0], main_range[0][1]), self.__update_region_characteristics__(self.stab_region_right, "right")
yRange=(main_range[1][0], main_range[1][1]),
padding=0) # X range is the same as main window's plot X range
self.stab_plot_item.getViewBox().setXRange(min=main_range[0][0],
max=main_range[0][1],
padding=0)
# Otherwise, the function is executed due to a variable change --> keep current viewbox and regions settings.
else:
pass
self.stab_plot_item.getViewBox().setYRange(min=self.stab_timeseries["value"].min(),
max=self.stab_timeseries["value"].max(),
padding=0)
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()
......
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