Skip to content
Snippets Groups Projects

Correct clicking data point for info

Merged Lan Dam requested to merge i134_mass_pos_not_show_datapoint_info into master
2 files
+ 69
53
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -12,9 +12,9 @@ from PySide6.QtWidgets import QWidget, QApplication, QTextBrowser
from sohstationviewer.conf import constants
from sohstationviewer.view.util.color import set_color_mode
from sohstationviewer.view.util.functions import (
get_total_miny_maxy, get_index_from_time
)
from sohstationviewer.view.plotting.plotting_widget.plotting_widget_helper \
import get_index_from_data_picked, get_total_miny_maxy
from sohstationviewer.view.plotting.plotting_widget.plotting_axes import (
PlottingAxes
)
@@ -222,6 +222,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')
@@ -295,11 +301,16 @@ 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
if isinstance(artist, pl.Line2D):
ax = artist.axes
chan_id = ax.chan
chan_data = self.plotting_data1[chan_id]
try:
chan_data = self.plotting_data1[chan_id]
except KeyError:
# in case of mass position
chan_data = self.plotting_data2[chan_id]
# list of x values of the plot
x_list = artist.get_xdata()
# list of y values of the plot
@@ -312,14 +323,12 @@ class PlottingWidget(QtWidgets.QScrollArea):
clicked_time = x_list[click_plot_index]
clicked_val = y_list[click_plot_index]
list_idx, section_idx = get_index_from_time(
real_idx = get_index_from_data_picked(
chan_data, clicked_time, clicked_val)
if list_idx is None:
if real_idx is None:
display_tracking_info(self.tracking_box, "Point not found.")
return
clicked_data = chan_data['data'][list_idx][section_idx]
clicked_data = chan_data['data'][0][real_idx]
if hasattr(ax, 'unit_bw'):
clicked_data = ax.unit_bw.format(clicked_data)
formatted_clicked_time = format_time(
@@ -333,7 +342,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
# For Reftek, need to hightlight the corresponding
# SOH message line based on the log_idx of the clicked point
self.parent.search_message_dialog.show()
clicked_log_idx = chan_data['logIdx'][0][section_idx]
clicked_log_idx = chan_data['logIdx'][0][real_idx]
try:
self.parent.search_message_dialog. \
show_log_entry_from_data_index(clicked_log_idx)
@@ -397,9 +406,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):
"""
Loading