Skip to content
Snippets Groups Projects
Commit cb8efaff authored by Lan Dam's avatar Lan Dam
Browse files

add context menu and call SelectChannelToShowDialog so user can decide which...

add context menu and call SelectChannelToShowDialog so user can decide which channels to be displayed
parent 7b4b30ed
No related branches found
No related tags found
1 merge request!261Feature for users to hide/show and reorder channels
...@@ -21,6 +21,9 @@ from sohstationviewer.conf import constants as const ...@@ -21,6 +21,9 @@ from sohstationviewer.conf import constants as const
from sohstationviewer.database.extract_data import get_chan_plot_info from sohstationviewer.database.extract_data import get_chan_plot_info
from sohstationviewer.view.select_channels_to_show_dialog import \
SelectChanelsToShowDialog
class MultiThreadedPlottingWidget(PlottingWidget): class MultiThreadedPlottingWidget(PlottingWidget):
finished = QtCore.Signal() finished = QtCore.Signal()
...@@ -70,7 +73,6 @@ class MultiThreadedPlottingWidget(PlottingWidget): ...@@ -70,7 +73,6 @@ class MultiThreadedPlottingWidget(PlottingWidget):
:param is_waveform: True if this is a WaveformWidget, otherwise False :param is_waveform: True if this is a WaveformWidget, otherwise False
""" """
self.zoom_marker1_shown = False self.zoom_marker1_shown = False
self.data_set_id = data_set_id
self.processing_log = [] # [(message, type)] self.processing_log = [] # [(message, type)]
self.gaps = d_obj.gaps[data_set_id] self.gaps = d_obj.gaps[data_set_id]
self.gap_bar = None self.gap_bar = None
...@@ -125,6 +127,7 @@ class MultiThreadedPlottingWidget(PlottingWidget): ...@@ -125,6 +127,7 @@ class MultiThreadedPlottingWidget(PlottingWidget):
chan_order, list(plotting_data.keys())) chan_order, list(plotting_data.keys()))
chan_order = remove_not_found_chans( chan_order = remove_not_found_chans(
chan_order, list(plotting_data.keys()), self.processing_log) chan_order, list(plotting_data.keys()), self.processing_log)
self.pref_order = chan_order
not_plot_chans = [] not_plot_chans = []
for chan_id in chan_order: for chan_id in chan_order:
...@@ -178,6 +181,9 @@ class MultiThreadedPlottingWidget(PlottingWidget): ...@@ -178,6 +181,9 @@ class MultiThreadedPlottingWidget(PlottingWidget):
for chan_id in chan_order: for chan_id in chan_order:
if 'chan_db_info' not in plotting_data[chan_id]: if 'chan_db_info' not in plotting_data[chan_id]:
continue continue
if ('show' in plotting_data[chan_id] and
not plotting_data[chan_id]['show']):
continue
channel_processor = PlottingChannelProcessor( channel_processor = PlottingChannelProcessor(
plotting_data[chan_id], chan_id, plotting_data[chan_id], chan_id,
self.min_x, self.max_x, self.min_x, self.max_x,
...@@ -205,6 +211,11 @@ class MultiThreadedPlottingWidget(PlottingWidget): ...@@ -205,6 +211,11 @@ class MultiThreadedPlottingWidget(PlottingWidget):
:param time_ticks_total: max number of tick to show on time bar :param time_ticks_total: max number of tick to show on time bar
:param pref_order: order of channels to be plotted :param pref_order: order of channels to be plotted
""" """
self.data_object = d_obj
self.data_set_id = data_set_id
self.start_tm = start_tm
self.end_tm = end_tm
self.time_ticks_total = time_ticks_total
self.pref_order = pref_order self.pref_order = pref_order
if not self.is_working: if not self.is_working:
self.reset_widget() self.reset_widget()
...@@ -341,3 +352,7 @@ class MultiThreadedPlottingWidget(PlottingWidget): ...@@ -341,3 +352,7 @@ class MultiThreadedPlottingWidget(PlottingWidget):
f'{self.name} plot stopped', LogType.INFO) f'{self.name} plot stopped', LogType.INFO)
self.is_working = False self.is_working = False
self.stopped.emit() self.stopped.emit()
def select_channels_to_show(self):
win = SelectChanelsToShowDialog(self)
win.exec()
...@@ -81,6 +81,10 @@ class SOHWidget(MultiThreadedPlottingWidget): ...@@ -81,6 +81,10 @@ class SOHWidget(MultiThreadedPlottingWidget):
return return
context_menu = QtWidgets.QMenu(self) context_menu = QtWidgets.QMenu(self)
select_channels_to_show_action = context_menu.addAction(
"Select Channels to show")
select_channels_to_show_action.triggered.connect(
self.select_channels_to_show)
try: try:
add_edit_chan_action = context_menu.addAction(add_edit_action_str) add_edit_chan_action = context_menu.addAction(add_edit_action_str)
add_edit_chan_action.triggered.connect(self.add_edit_channel) add_edit_chan_action.triggered.connect(self.add_edit_channel)
...@@ -106,7 +110,6 @@ class SOHWidget(MultiThreadedPlottingWidget): ...@@ -106,7 +110,6 @@ class SOHWidget(MultiThreadedPlottingWidget):
:param end_tm: requested end time to read :param end_tm: requested end time to read
:param time_ticks_total: max number of tick to show on time bar :param time_ticks_total: max number of tick to show on time bar
""" """
self.data_object = d_obj
self.plotting_data1 = ( self.plotting_data1 = (
d_obj.soh_data[data_set_id] if data_set_id else {}) d_obj.soh_data[data_set_id] if data_set_id else {})
self.plotting_data2 = ( self.plotting_data2 = (
......
...@@ -16,6 +16,20 @@ class WaveformWidget(MultiThreadedPlottingWidget): ...@@ -16,6 +16,20 @@ class WaveformWidget(MultiThreadedPlottingWidget):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
MultiThreadedPlottingWidget.__init__(self, *args, **kwargs) MultiThreadedPlottingWidget.__init__(self, *args, **kwargs)
def contextMenuEvent(self, event):
"""
Create menu showing up when right click mouse to add/edit channel
"""
context_menu = QtWidgets.QMenu(self)
select_channels_to_show_action = context_menu.addAction(
"Select Channels to show")
select_channels_to_show_action.triggered.connect(
self.select_channels_to_show)
context_menu.exec_(self.mapToGlobal(event.pos()))
self.curr_ax = None # to make sure curr_ax is clear
def init_plot(self, d_obj: GeneralData, def init_plot(self, d_obj: GeneralData,
data_set_id: Union[str, Tuple[str, str]], data_set_id: Union[str, Tuple[str, str]],
start_tm: float, end_tm: float, time_ticks_total: int): start_tm: float, end_tm: float, time_ticks_total: int):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment