Map Mode Internals¶
Context¶
Map mode stitches multiple FOVs into a single composite view and introduces spatial navigation challenges for plugins that assume per-FOV coordinates.
Key Decisions¶
VirtualMapLayerrenders stitched tiles by reusing existing single-FOV rendering paths.- Map mode is gated behind
ENABLE_MAP_MODE; single-FOV behavior is fully preserved when disabled. - FOV-local coordinates are resolved into stitched-map pixels for selection and navigation without mutating underlying data tables.
- A dedicated stitched-tile cache (keyed by channel and overlay state) avoids stale renders.
Coordinate Systems¶
| System | Description |
|---|---|
| FOV-local pixels | Pixel coordinates within a single FOV image |
| Stitched-canvas pixels | Pixel coordinates in the full stitched map canvas |
| Physical µm | Real-world coordinates from the map descriptor |
Conversion helpers:
resolve_cell_map_position()— FOV-local → stitched-canvasmap_bounds()→ physical µm bounds of the full mapbase_pixel_size_um()→ µm per pixel at base resolution
Tile Rendering¶
VirtualMapLayer.render()is called with the current viewport._collect_visible_tiles()returns tiles whose bounding boxes intersect the viewport.- Each tile is rendered via
render_fov_to_array()usingchannel_settingsfrom the marker profile (no UI widget reads). - Tiles are stitched onto the canvas via
_allocate_canvas()+_blit_tile().
The uncached-tile budget¶
The cap is on uncached tiles only — already-cached tiles always render, however many there are, because drawing them costs nothing but a memcpy. The budget exists to stop a single frame pulling hundreds of TIFFs off a slow network filesystem at once.
- The base budget is read from the viewer as
_map_render_tile_limit(default 80), so it can be lowered at runtime on a slow machine:viewer._map_render_tile_limit = 40. - The effective budget is
_map_render_tile_limit × max(1, downsample_factor). It scales with the downsample factor deliberately: a fully zoomed-out view (ds ≥ 8) is cheap per tile and needs to show every FOV rather than cut off the edges of the map. - When the uncached set exceeds the budget, tiles are sorted by squared distance from the viewport centre and truncated, so what survives is the region the user is actually looking at.
Plugin Map-Mode Hooks¶
All plugins inherit from PluginBase, which provides two lifecycle hooks:
on_map_mode_activate()— Called when map mode is enabled. Plugins should disable FOV-scope filters.on_map_mode_deactivate()— Called when map mode is disabled. Plugins restore normal behavior.
The active FOV is retrieved via get_active_fov(), which returns None in map mode to prevent stale widget reads.
Known Fixes¶
- Missing bounds offset (v0.3.1):
_export_map_roi_workernow appliesmap_bounds()origin offset to canvas-pixel → µm conversion. - Render suppression at startup:
_suspend_display_updatesprevents burst renders duringload_widget_states.