From 1c8ce6bfa7a3d0f43d1b6b062dbe6dd8d9641831 Mon Sep 17 00:00:00 2001 From: RaghavaAlajangi Date: Thu, 2 Oct 2025 14:44:27 +0200 Subject: [PATCH 1/4] fix: cache selected event using dataslot id in quickview --- dcscope/gui/quick_view/qv_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dcscope/gui/quick_view/qv_main.py b/dcscope/gui/quick_view/qv_main.py index 62959e5..87b089c 100644 --- a/dcscope/gui/quick_view/qv_main.py +++ b/dcscope/gui/quick_view/qv_main.py @@ -871,7 +871,7 @@ def show_event(self, event): # dataset ds = self.rtdc_ds self._dataset_event_plot_indices_cache[ - id(self.rtdc_ds.hparent)] = event + self.slot.identifier] = int(event) event_count = ds.config["experiment"]["event count"] if event_count == 0: # nothing to do @@ -1019,7 +1019,7 @@ def show_rtdc(self, rtdc_ds, slot): self.spinBox_event.setMaximum(event_count) self.spinBox_event.setToolTip("total: {}".format(event_count)) cur_value = self._dataset_event_plot_indices_cache.get( - id(rtdc_ds), 0) + 1 + self.slot.identifier, 0) + 1 self.spinBox_event.setValue(cur_value) self.spinBox_event.blockSignals(False) From 19531be9196d00e61156ee77fe3746e53dbd3162 Mon Sep 17 00:00:00 2001 From: RaghavaAlajangi Date: Mon, 6 Oct 2025 14:50:34 +0200 Subject: [PATCH 2/4] fix: cache selected event per dataset in QuickView --- CHANGELOG | 2 + tests/test_gui_quickview.py | 83 +++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 150bd0e..9e2f91d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +2.22.3 + - fix: cache selected event per dataset in QuickView (#196) 2.22.2 - fix: error message dialog limited to traceback length of three - fix: copy error text to clipboard did not work in error message dialog diff --git a/tests/test_gui_quickview.py b/tests/test_gui_quickview.py index 66aba65..5ab439c 100644 --- a/tests/test_gui_quickview.py +++ b/tests/test_gui_quickview.py @@ -1117,3 +1117,86 @@ def test_select_x_y_axis_based_on_unavailable_feature_name_issue_206(qtbot): # Since the feature is not available in dataset-2, it should be set # to "deform" (first option in default choice) assert qv.comboBox_y.currentData() == "deform", "Check manual selection" + + +def test_cache_selected_event_using_dataslot_issue_196(qtbot): + """Event selection should be cached when switching between datasets""" + + mw = DCscope() + qtbot.addWidget(mw) + + # add dataslots + path1 = datapath / "calibration_beads_47.rtdc" + path2 = datapath / "blood_rbc_qpi_data.rtdc" + mw.add_dataslot(paths=[path1, path2]) + + assert len(mw.pipeline.slot_ids) == 2, "we added that" + assert len(mw.pipeline.filter_ids) == 1, "automatically added" + + # Get the slot_id of the first data slot + slot_id1 = mw.pipeline.slot_ids[0] + filt_id = mw.pipeline.filter_ids[0] + + # activate dataslot-1 + em1 = mw.block_matrix.get_widget(slot_id1, filt_id) + qtbot.mouseClick(em1, QtCore.Qt.MouseButton.LeftButton, + QtCore.Qt.KeyboardModifier.ShiftModifier) + + em1 = mw.block_matrix.get_widget(slot_id1, filt_id) + qtbot.mouseClick(em1, QtCore.Qt.MouseButton.LeftButton) + + # did that work? + assert mw.toolButton_quick_view.isChecked() + + # selected events + slot1_event = 3 + slot2_event = 6 + + # Get QuickView instance + qv = mw.widget_quick_view + + # Open plot (settings) tool of QuickView + plot_tool = qv.toolButton_settings + qtbot.mouseClick(plot_tool, QtCore.Qt.MouseButton.LeftButton) + + # select an event index in slot1 + qv.show_event(slot1_event) + + # check whether event 4 is saved in cache dict + assert qv._dataset_event_plot_indices_cache["Dataslot_1"] == slot1_event + + # Do we have the correct event shown? + assert qv.spinBox_event.value()-1 == slot1_event + + # Get the slot_id the second data slot + slot_id2 = mw.pipeline.slot_ids[1] + # Activate data slot-2 + em2 = mw.block_matrix.get_widget(slot_id2, filt_id) + qtbot.mouseClick(em2, QtCore.Qt.MouseButton.LeftButton, + QtCore.Qt.KeyboardModifier.ShiftModifier) + + em2 = mw.block_matrix.get_widget(slot_id2, filt_id) + qtbot.mouseClick(em2, QtCore.Qt.MouseButton.LeftButton) + + # select an event index in slot2 + qv.show_event(slot2_event) + + # Do we have the correct event shown? + assert qv.spinBox_event.value()-1 == slot2_event + + # check whether slot2_event is exists in cache dict + assert qv._dataset_event_plot_indices_cache["Dataslot_2"] == slot2_event + + # now switch back to slot1 and check event + em1 = mw.block_matrix.get_widget(slot_id1, filt_id) + qtbot.mouseClick(em1, QtCore.Qt.MouseButton.LeftButton, + QtCore.Qt.KeyboardModifier.ShiftModifier) + + em1 = mw.block_matrix.get_widget(slot_id1, filt_id) + qtbot.mouseClick(em2, QtCore.Qt.MouseButton.LeftButton) + + # Do we still have the correct event shown? + assert qv.spinBox_event.value()-1 == slot1_event + + # check whether slot1_event is still exists in cache dict + assert qv._dataset_event_plot_indices_cache["Dataslot_1"] == slot1_event From 4f0db34c70fadb28f0b8437c4357dbdee9605a51 Mon Sep 17 00:00:00 2001 From: RaghavaAlajangi Date: Mon, 13 Oct 2025 15:28:25 +0200 Subject: [PATCH 3/4] fix: replace slot.identifier with rtdc_ds.hparent --- dcscope/gui/quick_view/qv_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dcscope/gui/quick_view/qv_main.py b/dcscope/gui/quick_view/qv_main.py index 87b089c..c88f74e 100644 --- a/dcscope/gui/quick_view/qv_main.py +++ b/dcscope/gui/quick_view/qv_main.py @@ -871,7 +871,7 @@ def show_event(self, event): # dataset ds = self.rtdc_ds self._dataset_event_plot_indices_cache[ - self.slot.identifier] = int(event) + id(self.rtdc_ds.hparent)] = int(event) event_count = ds.config["experiment"]["event count"] if event_count == 0: # nothing to do @@ -1019,7 +1019,7 @@ def show_rtdc(self, rtdc_ds, slot): self.spinBox_event.setMaximum(event_count) self.spinBox_event.setToolTip("total: {}".format(event_count)) cur_value = self._dataset_event_plot_indices_cache.get( - self.slot.identifier, 0) + 1 + id(self.rtdc_ds.hparent), 0) + 1 self.spinBox_event.setValue(cur_value) self.spinBox_event.blockSignals(False) From 5091317693ca3b2c1259cdeb2e131c4f58c3b39b Mon Sep 17 00:00:00 2001 From: RaghavaAlajangi Date: Mon, 13 Oct 2025 15:29:02 +0200 Subject: [PATCH 4/4] fix: update cache checks for selected events using dataset ids --- tests/test_gui_quickview.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_gui_quickview.py b/tests/test_gui_quickview.py index 5ab439c..58b700b 100644 --- a/tests/test_gui_quickview.py +++ b/tests/test_gui_quickview.py @@ -1146,6 +1146,7 @@ def test_cache_selected_event_using_dataslot_issue_196(qtbot): qtbot.mouseClick(em1, QtCore.Qt.MouseButton.LeftButton) # did that work? + assert mw.pipeline.is_element_active(slot_id1, filt_id) assert mw.toolButton_quick_view.isChecked() # selected events @@ -1162,8 +1163,11 @@ def test_cache_selected_event_using_dataslot_issue_196(qtbot): # select an event index in slot1 qv.show_event(slot1_event) + # Get the id of the current dataset + ds_id1 = id(qv.rtdc_ds.hparent) + # check whether event 4 is saved in cache dict - assert qv._dataset_event_plot_indices_cache["Dataslot_1"] == slot1_event + assert qv._dataset_event_plot_indices_cache[ds_id1] == slot1_event # Do we have the correct event shown? assert qv.spinBox_event.value()-1 == slot1_event @@ -1178,14 +1182,18 @@ def test_cache_selected_event_using_dataslot_issue_196(qtbot): em2 = mw.block_matrix.get_widget(slot_id2, filt_id) qtbot.mouseClick(em2, QtCore.Qt.MouseButton.LeftButton) + # did that work? + assert mw.pipeline.is_element_active(slot_id2, filt_id) + # select an event index in slot2 qv.show_event(slot2_event) # Do we have the correct event shown? assert qv.spinBox_event.value()-1 == slot2_event + ds_id2 = id(qv.rtdc_ds.hparent) # check whether slot2_event is exists in cache dict - assert qv._dataset_event_plot_indices_cache["Dataslot_2"] == slot2_event + assert qv._dataset_event_plot_indices_cache[ds_id2] == slot2_event # now switch back to slot1 and check event em1 = mw.block_matrix.get_widget(slot_id1, filt_id) @@ -1198,5 +1206,6 @@ def test_cache_selected_event_using_dataslot_issue_196(qtbot): # Do we still have the correct event shown? assert qv.spinBox_event.value()-1 == slot1_event - # check whether slot1_event is still exists in cache dict - assert qv._dataset_event_plot_indices_cache["Dataslot_1"] == slot1_event + # check whether slot1_event, slot1_even2 are still exists in cache dict + assert qv._dataset_event_plot_indices_cache[ds_id1] == slot1_event + assert qv._dataset_event_plot_indices_cache[ds_id2] == slot2_event