updateIndex method
void
updateIndex(
- SpatialIndex<
InteractiveOverlayImage> index, - Op<
InteractiveOverlayImage> op, - InteractiveOverlayImage? getItem()
override
Updates the spatial index based on the operation.
getItem allows retrieving the current state of an item by key (useful for Move ops).
Implementation
@override
void updateIndex(
SpatialIndex<InteractiveOverlayImage> index,
Op<InteractiveOverlayImage> op,
InteractiveOverlayImage? Function(Key) getItem,
) {
switch (op) {
case AddOverlayOp(:final overlay):
index.add(overlay.key!, overlay, getBounds(overlay));
case RemoveOverlayOp(:final key):
index.remove(key);
case UpdateOverlayOp(:final newOverlay):
index.add(newOverlay.key!, newOverlay, getBounds(newOverlay));
case MoveCornerOverlayOp(:final key):
final item = getItem(key);
if (item != null) index.add(key, item, getBounds(item));
}
}