class GlueController(QtWidgets.QMainWindow): def __init__(self, session, parent=None): super(GlueController, self).__init__(parent=parent) self.layer_widget = LayerTreeWidget() self.layer_widget.set_checkable(False) self.layer_widget.setup(session.data_collection) self.setCentralWidget(self.layer_widget) self.tbar = EditSubsetModeToolBar() self.addToolBar(self.tbar) self.layer_widget.bind_selection_to_edit_subset()
def test_apply_roi_single(self): # Regression test for a bug that caused mode.update to be called # multiple times and resulted in all other viewers receiving many # messages regarding subset updates (this occurred when multiple) # datasets were present. layer_tree = LayerTreeWidget(session=self.session) layer_tree.set_checkable(False) layer_tree.setup(self.data_collection) layer_tree.bind_selection_to_edit_subset() class Client(HubListener): def __init__(self, *args, **kwargs): super(Client, self).__init__(*args, **kwargs) self.count = Counter() def ping(self, message): self.count[message.sender] += 1 def register_to_hub(self, hub): hub.subscribe(self, SubsetUpdateMessage, handler=self.ping) d1 = Data(a=[[1, 2], [3, 4]], label='d1') d2 = Data(b=[[1, 2], [3, 4]], label='d2') d3 = Data(c=[[1, 2], [3, 4]], label='d3') d4 = Data(d=[[1, 2], [3, 4]], label='d4') self.data_collection.append(d1) self.data_collection.append(d2) self.data_collection.append(d3) self.data_collection.append(d4) client = Client() client.register_to_hub(self.hub) self.viewer.add_data(d1) self.viewer.add_data(d3) roi = XRangeROI(2.5, 3.5) self.viewer.apply_roi(roi) for subset in client.count: assert client.count[subset] == 1