wolfhece._viewer_plugin_handlers

Per-action mouse handlers for WolfMapViewer.

Rationale

On_Mouse_Right_Down and On_Mouse_Motion were monolithic catch-all chains of if/elif blocks — one branch per action. This module extracts those branches into individual handler functions and exposes two dispatch tables:

  • ACTION_RDOWN_HANDLERS — called on right mouse-button press.

  • ACTION_MOTION_HANDLERS — called on mouse motion while an action is active.

Usage (in WolfMapViewer):

ctx = MouseContext(x, y, x_snap, y_snap, x_pixel=0, y_pixel=0,
                   keyboard=KeyboardSnapshot(alt=alt, ctrl=ctrl, shift=shift))
if self.action in ACTION_RDOWN_HANDLERS:
    ACTION_RDOWN_HANDLERS[self.action](self, ctx)

Adding a new action

  1. Write _rdown_<action>(viewer, ctx) and/or _motion_<action>(viewer, ctx).

  2. Register in ACTION_RDOWN_HANDLERS / ACTION_MOTION_HANDLERS.

  3. Add an ActionKind entry to _action_kind.py if not yet present.

Each handler receives the viewer (WolfMapViewer) and a MouseContext. Handlers must NOT import WolfMapViewer at module level to avoid circular imports — use TYPE_CHECKING for type hints only.

Module Contents

class wolfhece._viewer_plugin_handlers.KeyboardSnapshot[source]

Keyboard state snapshot — covers both polled and event-driven contexts.

When embedded in a MouseContext (polled at mouse-event time):

key_code = 0, is_down = True, held contains all non-modifier keys currently pressed.

When built from a wx.KeyEvent (key-down / key-up):

key_code = triggering key, is_down = True/False, held = empty frozenset (not polled for key events).

ctrl: bool = False[source]
shift: bool = False[source]
alt: bool = False[source]
key_code: int = 0[source]
is_down: bool = True[source]
held: frozenset[source]
is_key_down(key_code: int) bool[source]

Return True if key_code is currently held.

class wolfhece._viewer_plugin_handlers.MouseContext[source]

Preprocessed mouse event data passed to every action handler.

All coordinates are in world space (map units, not pixels). Keyboard modifier state is accessible via the keyboard attribute or the convenience properties alt, ctrl, shift.

x: float[source]
y: float[source]
x_snap: float[source]
y_snap: float[source]
x_pixel: int[source]
y_pixel: int[source]
keyboard: KeyboardSnapshot[source]
left_down: bool = False[source]
middle_down: bool = False[source]
right_down: bool = False[source]
pressure: float = 1.0[source]
wheel_rotation: int = 0[source]
wheel_delta: int = 120[source]
property alt: bool[source]

Alt key held (delegates to keyboard.alt).

property ctrl: bool[source]

Ctrl key held (delegates to keyboard.ctrl).

property shift: bool[source]

Shift key held (delegates to keyboard.shift).

wolfhece._viewer_plugin_handlers._RightDownHandler[source]
wolfhece._viewer_plugin_handlers._LeftDownHandler[source]
wolfhece._viewer_plugin_handlers._KeyHandler[source]
wolfhece._viewer_plugin_handlers._PaintHandler[source]
wolfhece._viewer_plugin_handlers._rdown_move_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Right-click handler for MOVE_VECTOR.

First click records the start position; second click commits the move. Shift constrains vertical movement to zero; Alt constrains horizontal.

wolfhece._viewer_plugin_handlers._rdown_rotate_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Right-click handler for ROTATE_VECTOR.

First click sets the rotation centre; second click commits the rotation. Shift+click sets a discrete rotation step; Shift+Ctrl+click clears it.

wolfhece._viewer_plugin_handlers._rdown_move_triangles(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Right-click handler for MOVE_TRIANGLES.

First click records the start; second click commits the move. Shift constrains vertical movement; Alt constrains horizontal.

wolfhece._viewer_plugin_handlers._rdown_rotate_triangles(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Right-click handler for ROTATE_TRIANGLES.

First click sets the rotation centre; second click commits the rotation. Shift+click sets a discrete step; Shift+Ctrl+click clears it.

wolfhece._viewer_plugin_handlers._rdown_move_zone(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Right-click handler for MOVE_ZONE.

First click records the start; second click commits the move.

Note

The shift/alt constraints set delta_x/delta_y local variables that are not forwarded to zone.move() — this matches the original behaviour (preserved intentionally).

wolfhece._viewer_plugin_handlers._rdown_rotate_zone(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Right-click handler for ROTATE_ZONE.

First click sets the rotation centre; second click commits the rotation.

wolfhece._viewer_plugin_handlers._rdown_add_points_to_cloud(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Shift: remove nearest vertex. Ctrl: remove last vertex. Else: add snapped vertex.

wolfhece._viewer_plugin_handlers._rdown_move_point_in_cloud(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

First click picks nearest vertex; second click commits the final position.

wolfhece._viewer_plugin_handlers._rdown_plot_alaro_xy(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_distance_along_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_pie_center(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_bar_position(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_curve_origin(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_landmap(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_municipality(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_a_picture(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_bridge(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_weir(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_bridge_gltf(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Delegate to PyDraw._bridge_gltf_dialog() which owns the wx dialogs.

wolfhece._viewer_plugin_handlers._rdown_plot_cross_section(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_set_1d_profile(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Delegate to PyDraw._set_1d_profile_rdown() which owns the notebook/wx logic.

wolfhece._viewer_plugin_handlers._rdown_select_nearest_profile(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Delegate to PyDraw._select_nearest_profile_rdown() which owns the notebook/wx logic.

wolfhece._viewer_plugin_handlers._rdown_select_active_tile(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_select_active_image_tile(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_catchment_lidaxe(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_pick_path_lidaxe(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_select_active_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Handler inspects v.action to differentiate inside/outside and single/all-zone.

wolfhece._viewer_plugin_handlers._rdown_select_node(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_select_by_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_laz_tmp_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_create_polygon_tiles(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_capture_vertices(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Update the trailing preview vertex, append a new one, optionally sample Z.

wolfhece._viewer_plugin_handlers._rdown_offset_scale_image(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

First click records start; second click commits the image offset.

wolfhece._viewer_plugin_handlers._rdown_dynamic_parallel(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]
wolfhece._viewer_plugin_handlers._rdown_modify_vertices(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

First click picks nearest vertex; second click confirms (optionally samples Z).

wolfhece._viewer_plugin_handlers._rdown_insert_vertices(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

First click inserts vertex at nearest edge; second click confirms.

wolfhece._viewer_plugin_handlers._motion_move_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Motion handler for MOVE_VECTOR — live preview while the start is set.

wolfhece._viewer_plugin_handlers._motion_rotate_vector(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Motion handler for ROTATE_VECTOR — live preview while centre is set.

wolfhece._viewer_plugin_handlers._motion_move_triangles(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Motion handler for MOVE_TRIANGLES — live preview while start is set.

wolfhece._viewer_plugin_handlers._motion_rotate_triangles(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Motion handler for ROTATE_TRIANGLES — live preview while centre is set.

wolfhece._viewer_plugin_handlers._motion_move_zone(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Motion handler for MOVE_ZONE — live preview while start is set.

wolfhece._viewer_plugin_handlers._motion_rotate_zone(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Motion handler for ROTATE_ZONE — live preview while centre is set.

wolfhece._viewer_plugin_handlers._motion_move_point_in_cloud(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Live preview for MOVE_POINT_IN_CLOUD while vertex is picked.

wolfhece._viewer_plugin_handlers._motion_dynamic_parallel(v: wolfhece.PyDraw.WolfMapViewer, ctx: MouseContext) None[source]

Recompute the parallel line on every mouse-move (no coords needed).

wolfhece._viewer_plugin_handlers.ACTION_RDOWN_HANDLERS: dict[wolfhece._action_kind.ActionKind, _RightDownHandler][source]
wolfhece._viewer_plugin_handlers.ACTION_MOTION_HANDLERS: dict[wolfhece._action_kind.ActionKind, _RightDownHandler][source]