pipeworks_mud_mapper.callbacks.map_callbacks
Map visualization and interaction callbacks.
This module handles:
Rendering the flattened map when zone data or visibility filter changes
Selecting rooms when clicked on the map
The map displays all Z-levels on a single 2D plane with visual differentiation:
z=-1 (Down): Black filled circles (smallest)
z=0 (Ground): Blue filled circles (largest)
z=+1 (Up): White circles with black border (medium)
Component Dependencies
Inputs:
current-zone-data: Zone data for renderingz-level-filter: List of visible Z-levels (checklist)selected-room: Currently selected roommap-graph: Click events on the map
Outputs:
map-graph: Updated Plotly figureselected-room: Room ID from click
Click Selection with Stacked Rooms
When rooms overlap (same X,Y, different Z), ground level (z=0) receives clicks first due to render order. To select a lower-level room:
Uncheck higher levels in the z-level-filter
Click the now-visible lower-level room
Re-check levels when done
See also
-, -
Functions
|
Update the map figure when zone data, visibility, or selection changes. |
|
Select a room when clicked, or unselect if clicking the same room again. |
|
Adjust the X-axis visual offset via +/- buttons. |
|
Adjust the Y-axis visual offset via +/- buttons. |
Module Contents
- pipeworks_mud_mapper.callbacks.map_callbacks.update_map_with_rooms(zone_data, visible_z_levels, selected_room, visual_offset_x, visual_offset_y)[source]
Update the map figure when zone data, visibility, or selection changes.
Re-renders the Plotly figure with rooms from all visible Z-levels, displayed on a single 2D plane with visual differentiation by level.
- Parameters:
zone_data (
dict | None) – Current zone data containing rooms, or None if no zone loaded.visible_z_levels (
list[int]) – List of Z-levels to display, from the filter checklist. Default is all levels: [-1, 0, 1]. Empty list shows base map only.selected_room (
str | None) – Currently selected room ID, or None. Selected room is highlighted in red regardless of its Z-level.visual_offset_x (
float | None) – X-axis scale factor for Z-level visual offset. Controls horizontal separation of stacked rooms.visual_offset_y (
float | None) – Y-axis scale factor for Z-level visual offset. Controls vertical separation of stacked rooms.
- Returns:
dict– Plotly figure dictionary for the map graph.Rendering Behavior------------------- Rooms are rendered in Z-order (
z=-1 first,z=+1 second,z=0 last)- Ground level (z=0) appears on topandreceives clicks first- Exit lines only connect rooms on the same Z-levelVertical exits (up/down) are shown as
"U/D"labels near stacked rooms
- Cross-zone exits are shown as triangle markers near the source room- Hover text includes Z-level information for each room
- Return type:
Any
Examples
Show all levels (default):
>>> figure = update_map_with_rooms(zone_data, [-1, 0, 1], None, 1.0)
Show only ground level:
>>> figure = update_map_with_rooms(zone_data, [0], None, 1.0)
Hide ground to select a basement room:
>>> figure = update_map_with_rooms(zone_data, [-1, 1], "cellar", 1.0)
- pipeworks_mud_mapper.callbacks.map_callbacks.handle_map_click(click_data, zone_data, current_selection)[source]
Select a room when clicked, or unselect if clicking the same room again.
Extracts the room ID from the clicked point’s text field and validates that it exists in the current zone. Clicking on an already-selected room toggles the selection off.
- Parameters:
click_data (
dict | None) – Plotly click event data containing information about the clicked point, or None if no click occurred.zone_data (
dict | None) – Current zone data containing rooms dictionary.current_selection (
str | None) – Currently selected room ID, used for toggle behavior.
- Returns:
str | None | no_update– Room ID if a new room was clicked, None if the same room was clicked again (toggle off), or no_update if the click was on a non-room element like an exit line.Click Handling Details----------------------- Room ID is stored in the ``text`field` ofScatter points- Clicking an already-selected room clears the selection (toggle)- Clicks on exit lines return no_update (hoverinfo=``”skip”``)- Invalid room IDs (not in zone_data) return no_updateStacked Room Selection----------------------When rooms are stacked (same X,Y,different Z),the topmost visibleroom receives the click. Duetorender order- If z=0 is visible,ground-level room gets the click- If z=0 is hidden but z=+1 visible,upper-level room gets the click- If only z=-1 is visible,lower-level room gets the clickTo select a specific stacked room,use the z-level-filtertohidethe levels above it.
- Return type:
Any
Examples
Click data structure from Plotly:
>>> click_data = { ... "points": [{ ... "x": 0, ... "y": 0, ... "text": "spawn", # Room ID ... "curveNumber": 2, ... }] ... } >>> handle_map_click(click_data, zone_data, None) 'spawn'
Click same room again to unselect:
>>> handle_map_click(click_data, zone_data, "spawn") None