Skip to content

Commit

Permalink
Fix #1003. Use updated nionutils which fixes filtered list model sele…
Browse files Browse the repository at this point in the history
…ction issue. Test.
  • Loading branch information
cmeyer committed Feb 9, 2024
1 parent 840ae70 commit 3b0af5c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions nion/swift/test/Workspace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,42 @@ def test_dragging_header_to_swap_works(self):
self.assertEqual(document_controller.workspace_controller.display_panels[0].display_item.data_item, data_item2)
self.assertEqual(document_controller.workspace_controller.display_panels[1].display_item.data_item, data_item1)

def test_display_panel_selection_updates_properly_with_data_panel_filter(self):
# this tests a failure where 2nd processing action would replace the source display item with something else.
with TestContext.create_memory_context() as test_context:
document_controller = test_context.create_document_controller()
document_controller.display_items_model._ttt = "ONE"
document_controller.filtered_display_items_model._ttt = "TWO"
document_model = document_controller.document_model
workspace_2x2 = document_controller.workspace_controller.new_workspace(*get_layout("2x2"))
document_controller.workspace_controller.change_workspace(workspace_2x2)
root_canvas_item = document_controller.workspace_controller.image_row.children[0]._root_canvas_item()
root_canvas_item.layout_immediate(Geometry.IntSize(width=640, height=480))
data_item1 = DataItem.DataItem(numpy.zeros((256), numpy.double))
data_item2 = DataItem.DataItem(numpy.zeros((256), numpy.double))
data_item1.title = "aaa"
data_item2.title = "bbb"
document_model.append_data_item(data_item1)
document_model.append_data_item(data_item2)
display_item2 = document_model.get_display_item_for_data_item(data_item2)
document_controller.workspace_controller.display_panels[0].set_display_item(display_item2)
document_controller.workspace_controller.display_panels[0].request_focus()
# error only occurred with filter enabled
document_controller.filter_controller.text_filter_changed("bbb")
self.assertEqual(2, len(document_model.display_items))
document_controller.perform_action(DocumentController.GaussianFilterAction())
self.assertEqual(3, len(document_model.display_items))
self.assertEqual(document_controller.workspace_controller.display_panels[0].display_item, display_item2)
self.assertEqual(document_controller.workspace_controller.display_panels[1].display_item, document_model.display_items[2])
document_controller.workspace_controller.display_panels[1].request_focus()
self.assertEqual(document_controller.workspace_controller.display_panels[0].display_item, display_item2)
self.assertEqual(document_controller.workspace_controller.display_panels[1].display_item, document_model.display_items[2])
document_controller.perform_action(DocumentController.FFTAction())
self.assertEqual(4, len(document_model.display_items))
self.assertEqual(document_controller.workspace_controller.display_panels[0].display_item, display_item2)
self.assertEqual(document_controller.workspace_controller.display_panels[1].display_item, document_model.display_items[2])
self.assertEqual(document_controller.workspace_controller.display_panels[2].display_item, document_model.display_items[3])

def test_clicking_in_header_selects_and_focuses_display_panel(self):
with TestContext.create_memory_context() as test_context:
document_controller = test_context.create_document_controller()
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[metadata]
name = nionswift
version = 16.10.0
# requires nionutils 0.4.11 or later for list model selection fix
author = Nion Software
author_email = swift@nion.com
description = Nion Swift: Scientific Image Processing.
Expand Down

0 comments on commit 3b0af5c

Please sign in to comment.