From 2797fa44708f13e31dbcd8f192e2f63115c647f8 Mon Sep 17 00:00:00 2001 From: MAKOMO Date: Thu, 26 Sep 2024 13:33:36 +0200 Subject: [PATCH] preserve the zoom state on marking the CHARGE event without modifying the navigation stack --- src/artisanlib/canvas.py | 18 ++++++++---------- wiki/ReleaseHistory.md | 3 +++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/artisanlib/canvas.py b/src/artisanlib/canvas.py index e11a807b6..48ad59db0 100644 --- a/src/artisanlib/canvas.py +++ b/src/artisanlib/canvas.py @@ -6301,7 +6301,7 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:Optiona return -1 #format X axis labels - def xaxistosm(self,redraw:bool = True, min_time:Optional[float] = None, max_time:Optional[float] = None) -> None: + def xaxistosm(self,redraw:bool = True, min_time:Optional[float] = None, max_time:Optional[float] = None, set_xlim:bool = True) -> None: if self.ax is None: return try: @@ -6322,7 +6322,8 @@ def xaxistosm(self,redraw:bool = True, min_time:Optional[float] = None, max_time endtime = endofx + starttime - self.ax.set_xlim(startofx,endtime) + if set_xlim: + self.ax.set_xlim(startofx,endtime) if self.xgrid != 0: @@ -12829,9 +12830,10 @@ def markChargeTrigger(self) -> None: # if noaction is True, the button event action is not triggered @pyqtSlot(bool) def markCharge(self, noaction:bool = False) -> None: + zoomed_in: bool = False # True if zoomed in; in that case we prevent xaxistoxm to reset the x-axis limits (set_xlim) try: - if self.aw.ntb._nav_stack(): # pylint: disable=protected-access # if ZOOMED in we push state on stack - self.aw.ntb.push_current() # remember current canvas ZOOM/POSITION on stack + if self.aw.ntb._nav_stack(): # pylint: disable=protected-access + zoomed_in = True except Exception: # pylint: disable=broad-except pass removed = False @@ -12864,7 +12866,7 @@ def markCharge(self, noaction:bool = False) -> None: del self.l_annotations_dict[0] self.timeindex[0] = -1 removed = True - self.xaxistosm(redraw=False) + self.xaxistosm(redraw=False, set_xlim=not zoomed_in) elif not self.aw.buttonCHARGE.isFlat(): if self.device == 18 and self.aw.simulator is None: #manual mode tx,et,bt = self.aw.ser.NONE() @@ -12909,7 +12911,7 @@ def markCharge(self, noaction:bool = False) -> None: self.endofx = self.resetmaxtime except Exception: # pylint: disable=broad-except pass - self.xaxistosm(redraw=False) # need to fix uneven x-axis labels like -0:13 + self.xaxistosm(redraw=False, set_xlim=not zoomed_in) # need to fix uneven x-axis labels like -0:13 if self.BTcurve or self.ETcurve: temp = (self.temp2[self.timeindex[0]] if self.BTcurve else self.temp1[self.timeindex[0]]) @@ -12979,10 +12981,6 @@ def markCharge(self, noaction:bool = False) -> None: if self.roastpropertiesAutoOpenFlag: self.aw.openPropertiesSignal.emit() self.aw.onMarkMoveToNext(self.aw.buttonCHARGE) - try: - self.aw.ntb._update_view() # type:ignore[has-type] # pylint: disable=protected-access # recallcanvas ZOOM/POSITION from stack - except Exception: # pylint: disable=broad-except - pass # called via markTPSignal (queued), triggered by external device # does directly call markTP() diff --git a/wiki/ReleaseHistory.md b/wiki/ReleaseHistory.md index c3ad9d184..55d30e50a 100644 --- a/wiki/ReleaseHistory.md +++ b/wiki/ReleaseHistory.md @@ -22,6 +22,7 @@ v3.0.3 - reduce the size of builds by removing unnecessary files - removes the optional delay on reads from serial MODBUS - adds optional delay after connect before sending requests to serial MODBUS to allow to wait for Arduino slaves to complete reboot ([Issue #1694](../../../issues/1694)) + - limits the visible length of long popup lists in Devices and Statistics Dialog * FIXES - updates Cropster XLS importer ([Issue #1685](../../../issues/1685)) @@ -30,6 +31,8 @@ v3.0.3 - fixes a regression which prevented loading settings written (slightly broken) by Artisan v3.0 ([Discussion #1692](../../../discussions/1692)) - fixes a regression communicating with some serial MODBUS devices resulting from a more strict protocol interpretation by the underlying MODBUS pymodbus lib 3.7 introduced in Artisan v3.0.2, by adding a 'strict' flag (default off) to the serial MODBUS configuration ([Issue #1694](../../../issues/1694)) - removes incorrectly reconstructed custom events outside of the CHARGE to DROP period on quitting the designer ([Discussion #1696](../../../discussions/1696)) + - makes validation of numeric configuration input more robust ([Issue #1700](../../../issues/1700)) + - ensures that splitter state in Comparator is properly reset on Factory Reset