From 642b092f4160be570c7a6af3815b57569bec73d4 Mon Sep 17 00:00:00 2001 From: James Crake-Merani Date: Thu, 17 Oct 2024 10:37:15 +0100 Subject: [PATCH 1/3] Dodgy avoidance of exception. --- src/sas/qtgui/Plotting/Plotter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sas/qtgui/Plotting/Plotter.py b/src/sas/qtgui/Plotting/Plotter.py index 9d347d757f..fb03218d96 100644 --- a/src/sas/qtgui/Plotting/Plotter.py +++ b/src/sas/qtgui/Plotting/Plotter.py @@ -531,10 +531,7 @@ def onAddText(self): # MPL style names styles = ['normal', 'italic', 'oblique'] # QFont::Style maps directly onto the above - try: - mpl_font.set_style(styles[extra_font.style()]) - except: - pass + mpl_font.set_style(styles[extra_font.style().value]) if len(extra_text) > 0: new_text = self.ax.text(pos_x, From 4534e469ab513fe2dffb60c12e7499a7c6379ae2 Mon Sep 17 00:00:00 2001 From: James Crake-Merani Date: Thu, 17 Oct 2024 11:07:33 +0100 Subject: [PATCH 2/3] Posistion should be updated even on right clicks. --- src/sas/qtgui/Plotting/Plotter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sas/qtgui/Plotting/Plotter.py b/src/sas/qtgui/Plotting/Plotter.py index fb03218d96..2e74f7a28c 100644 --- a/src/sas/qtgui/Plotting/Plotter.py +++ b/src/sas/qtgui/Plotting/Plotter.py @@ -916,6 +916,11 @@ def onMplMouseDown(self, event): """ Left button down and ready to drag """ + try: + self.x_click = float(event.xdata) # / size_x + self.y_click = float(event.ydata) # / size_y + except: + self.position = None # Check that the LEFT button was pressed if event.button != 1: return @@ -927,11 +932,6 @@ def onMplMouseDown(self, event): return if event.inaxes is None: return - try: - self.x_click = float(event.xdata) # / size_x - self.y_click = float(event.ydata) # / size_y - except: - self.position = None x_str = GuiUtils.formatNumber(self.x_click) y_str = GuiUtils.formatNumber(self.y_click) From 50bbddff40180b97f71b9795648a9fe8c77287c0 Mon Sep 17 00:00:00 2001 From: James Crake-Merani Date: Fri, 18 Oct 2024 09:21:30 +0100 Subject: [PATCH 3/3] Added some comments. --- src/sas/qtgui/Plotting/Plotter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sas/qtgui/Plotting/Plotter.py b/src/sas/qtgui/Plotting/Plotter.py index 2e74f7a28c..1f7ffa3399 100644 --- a/src/sas/qtgui/Plotting/Plotter.py +++ b/src/sas/qtgui/Plotting/Plotter.py @@ -531,7 +531,9 @@ def onAddText(self): # MPL style names styles = ['normal', 'italic', 'oblique'] # QFont::Style maps directly onto the above - mpl_font.set_style(styles[extra_font.style().value]) + # Get an index of the font style which we can then lookup in the styles list. + font_index = extra_font.style().value + mpl_font.set_style(styles[font_index]) if len(extra_text) > 0: new_text = self.ax.text(pos_x, @@ -916,6 +918,8 @@ def onMplMouseDown(self, event): """ Left button down and ready to drag """ + # Before checking if this mouse click is a left click, we need to update the position of the mouse regardless as + # this may be needed by other events (e.g. adding text) try: self.x_click = float(event.xdata) # / size_x self.y_click = float(event.ydata) # / size_y