From e4f8bc347d397477f5ee1974f5fcf0bbfd46a1f5 Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Thu, 6 Jun 2024 14:29:31 +0200 Subject: [PATCH] prepare rectangular selection --- src/View/Tools/PamhyrPlot.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/View/Tools/PamhyrPlot.py b/src/View/Tools/PamhyrPlot.py index 843be242..45118fe1 100644 --- a/src/View/Tools/PamhyrPlot.py +++ b/src/View/Tools/PamhyrPlot.py @@ -17,6 +17,7 @@ # -*- coding: utf-8 -*- import matplotlib.colors as mplcolors +from matplotlib.widgets import RectangleSelector from matplotlib import ticker from tools import timestamp_to_old_pamhyr_date @@ -100,6 +101,14 @@ class PamhyrPlot(APlot): self._highlight_data_update = False self._current_data = None #: Current data identifier self._current_data_update = False + self._rect_select = RectangleSelector(ax=self.canvas.axes, + onselect=self.rect_select_callback, + useblit=True, + button=[1, 3], # don't use middle button + minspanx=1.0, + minspany=1.0, + spancoords='pixels', + interactive=False) @property def canvas(self): @@ -231,3 +240,10 @@ class PamhyrPlot(APlot): def onclick(self, event): return + + def rect_select_callback(self, eclick, erelease): + 'eclick and erelease are the press and release events' + x1, y1 = eclick.xdata, eclick.ydata + x2, y2 = erelease.xdata, erelease.ydata + print("(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2)) + return