From f9d0cd0139d371e5d3d32ec8d89ee10d22e74804 Mon Sep 17 00:00:00 2001
From: kienle <kienle@passcal.nmt.edu>
Date: Thu, 31 Aug 2023 15:22:07 -0600
Subject: [PATCH] Fix SOH message not being brought to front

---
 .../plotting_widget/plotting_widget.py        | 22 ++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
index 63757ee0e..aa830071b 100755
--- a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+++ b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
@@ -223,6 +223,12 @@ class PlottingWidget(QtWidgets.QScrollArea):
         ruler_text: the current text shown above the ruler
         """
         self.ruler_text: Optional[matplotlib.text.Text] = None
+        """
+        button_press_picked_a_point: whether a button press event triggered a
+        pick event. Used to fix a bug where picking a point on the SOH plot of
+        an RT130 data set does not bring the SOH messages dialog to the front.
+        """
+        self.is_button_press_event_triggered_pick_event: bool = False
 
         self.set_colors('B')
 
@@ -296,6 +302,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
         + If the chan_data has key 'logIdx', raise the Search Messages dialog,
             focus SOH tab, roll to the corresponding line.
         """
+        self.is_button_press_event_triggered_pick_event = True
         artist = event.artist
         ax = artist.axes
 
@@ -380,9 +387,18 @@ class PlottingWidget(QtWidgets.QScrollArea):
                 w.on_ctrl_cmd_click(xdata)
             w.draw()
 
-        self.parent.show()
-        self.parent.activateWindow()
-        self.parent.raise_()
+        if (not self.is_button_press_event_triggered_pick_event or
+                modifiers == QtCore.Qt.ShiftModifier):
+            # Bring the main window to the front only if no point was picked.
+            # In logpeek and qpeek, zooming is always done, event if a point is
+            # picked, so we replicate that here.
+            self.parent.show()
+            self.parent.activateWindow()
+            self.parent.raise_()
+        else:
+            # Reset the flag checking if this button press event triggered a
+            # pick event.
+            self.is_button_press_event_triggered_pick_event = False
 
     def on_ctrl_cmd_click(self, xdata):
         """
-- 
GitLab