def wait(self): array_data = self._arrayreq.wait() # We can't make this assertion, because the array request might be expanded # with a halo so that the QGraphicsItem can display edges on tile borders. # assert array_data.shape == (self.rect.width(), self.rect.height()) def create(): # Construct the path items # This *could* be done outside of this create() function (and thus outside of the main thread), # but (1) that seems to cause crashes on shutdown, # and (2) performance gets worse, not better. path_items = generate_path_items_for_labels( self._layer.pen_table, self._layer.default_pen, array_data, None) # All SegmentationEdgesItem(s) associated with this layer will share a common pen table. # They react immediately when the pen table is updated. graphics_item = SegmentationEdgesItem(path_items, self._layer.pen_table, self._layer.default_pen, self._is_clickable) # When the item is clicked, the layer is notified. graphics_item.edgeClicked.connect(self._layer.handle_edge_clicked) graphics_item.edgeSwiped.connect(self._layer.handle_edge_swiped) return graphics_item # We're probably running in a non-main thread right now, # but we're only allowed to create QGraphicsItemObjects in the main thread. return execute_in_main_thread(create)
def wait(self): array_data = self._arrayreq.wait() # We can't make this assertion, because the array request might be expanded # with a halo so that the QGraphicsItem can display edges on tile borders. #assert array_data.shape == (self.rect.width(), self.rect.height()) def create(): # Construct the path items # This *could* be done outside of this create() function (and thus outside of the main thread), # but (1) that seems to cause crashes on shutdown, # and (2) performance gets worse, not better. path_items = generate_path_items_for_labels(self._layer.pen_table, array_data, None) # All SegmentationEdgesItem(s) associated with this layer will share a common pen table. # They react immediately when the pen table is updated. graphics_item = SegmentationEdgesItem(path_items, self._layer.pen_table) # When the item is clicked, the layer is notified. graphics_item.edgeClicked.connect( self._layer.handle_edge_clicked ) return graphics_item # We're probably running in a non-main thread right now, # but we're only allowed to create QGraphicsItemObjects in the main thread. return execute_in_main_thread(create)
def wait(self): array_data = self._arrayreq.wait() # Here's where we would do something with the data... assert array_data.shape == (self.rect.width(), self.rect.height()) return execute_in_main_thread(DummyItem, QRectF(self.rect))
def f(): print("in thread:", threading.current_thread().name) result = execute_in_main_thread(g) print("Result was:", result)
def f(): print "in thread:", threading.current_thread().name result = execute_in_main_thread(g) print "Result was:", result