From b1a35d4697a80be42e94a9dc0b46e75c3d1962f5 Mon Sep 17 00:00:00 2001 From: danielhrisca Date: Wed, 11 Sep 2024 10:35:24 +0300 Subject: [PATCH] make sure to have a visible region --- src/asammdf/gui/widgets/plot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/asammdf/gui/widgets/plot.py b/src/asammdf/gui/widgets/plot.py index e5714c8c1..35edf4d2b 100644 --- a/src/asammdf/gui/widgets/plot.py +++ b/src/asammdf/gui/widgets/plot.py @@ -4692,15 +4692,17 @@ def keyPressEvent(self, event): self.region.sigRegionChanged.connect(self.range_modified_handler) self.region.sigRegionChangeFinished.connect(self.range_modified_finished_handler) start, stop = self.viewbox.viewRange()[0] + view_range = abs(stop - start) start, stop = ( start + 0.1 * (stop - start), stop - 0.1 * (stop - start), ) - self.region.setRegion((start, stop)) - if self.cursor1 is not None: + if self.cursor1 is not None and abs(self.cursor1.value() - stop) >= 0.1 * view_range: self.cursor1.hide() self.region.setRegion(tuple(sorted((self.cursor1.value(), stop)))) + else: + self.region.setRegion((start, stop)) else: self.region_lock = None