wolfhece._overlays

Overlay and panel classes extracted from PyDraw.py.

These classes provide on-canvas HUD overlays and floating control panels for the WolfMapViewer.

Author: HECE - University of Liege, Pierre Archambeau Date: 2024

Copyright (c) 2024 University of Liege. All rights reserved.

This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.

Module Contents

class wolfhece._overlays.HillshadePanel(mapviewer: wolfhece.PyDraw.WolfMapViewer)[source]

Bases: wx.Frame

Inheritance diagram of wolfhece._overlays.HillshadePanel

Persistent panel for hillshade / sun-lighting controls.

Provides live sliders for altitude, azimuth, intensity, checkboxes for enable and multi-directional mode, and a sunrise animation button.

_ANIM_INTERVAL_MS = 33[source]
_ANIM_SPEED_DEG_S = 30.0[source]
mapviewer[source]
_panel[source]
_chk_enable[source]
_alt[source]
_az[source]
_int[source]
_chk_multi[source]
_chk_sync[source]
_z_exag[source]
_spec[source]
_gloss[source]
_hl[source]
_anim_speed[source]
_btn_apply[source]
_btn_anim[source]
_btn_natural[source]
_btn_pseudo[source]
_btn_save[source]
_timer[source]
_on_change(event)[source]

Called on Enter key, Apply button, or checkbox — push to mapviewer.

_on_toggle_anim(event)[source]
_apply_preset(altitude, azimuth, intensity, z_exag, multidirectional, specular=0.0, glossiness=0.5, highlight=1.0)[source]

Apply a preset and sync all controls.

_on_preset_natural(event)[source]

Standard cartographic hillshade: NW light, moderate settings.

_on_preset_pseudoscopic(event)[source]

Pseudoscopic illusion: SE light + strong Z exaggeration.

_on_timer(event)[source]
_on_close(event)[source]
_on_sync_toggle(event)[source]

Toggle synchronised / per-array mode.

_on_save(event)[source]

Persist material params to sidecar files.

refresh_from_params()[source]

Refresh spin controls from the active material params source.

class wolfhece._overlays.HillshadeOverlay(mapviewer: wolfhece.PyDraw.WolfMapViewer)[source]

On-canvas HUD for interactive hillshade control.

Draws an azimuth ring and altitude bar in the bottom-right corner of the GL canvas. Responds to mouse drag on these widgets.

Only active while the HillshadePanel is open.

_MARGIN = 20[source]
_RING_RADIUS = 45[source]
_BAR_WIDTH = 14[source]
_MINI_BAR_WIDTH = 10[source]
_GAP = 18[source]
_MINI_GAP = 8[source]
_BG_RGBA = (0.1, 0.1, 0.1, 0.5)[source]
_OUTLINE_RGBA = (0.8, 0.8, 0.8, 0.8)[source]
_SUN_RGBA = (1.0, 0.9, 0.2, 0.9)[source]
_SUN_FILL_RGBA = (1.0, 0.9, 0.2, 0.4)[source]
_SPEC_RGBA = (0.9, 0.9, 1.0, 0.9)[source]
_SPEC_FILL = (0.7, 0.7, 1.0, 0.4)[source]
_ROUGH_RGBA = (0.6, 0.85, 0.6, 0.9)[source]
_ROUGH_FILL = (0.4, 0.7, 0.4, 0.4)[source]
_METAL_RGBA = (0.9, 0.7, 0.3, 0.9)[source]
_METAL_FILL = (0.8, 0.6, 0.2, 0.4)[source]
mapviewer[source]
_dragging: str | None = None[source]
_ring_center()[source]
_bar_rect()[source]

Return (x0, y_bottom, x1, y_top) for the altitude bar.

_mini_bar_rect(index)[source]

Return (x0, y0, x1, y1) for mini bar index (0=S, 1=R, 2=M).

Mini bars sit to the left of the altitude bar.

_wx_to_gl(wx_x, wx_y)[source]
hit_test(wx_x, wx_y)[source]

Return 'azimuth', 'altitude', 'specular', 'glossiness', 'highlight', or None.

on_drag(wx_x, wx_y)[source]

Update the hillshade parameter corresponding to _dragging.

_sync_panel()[source]

Push current mapviewer values back into the HillshadePanel controls.

handle_wheel(rotation, delta, ctrl, shift)[source]

Handle mouse wheel when hillshade panel is open.

Returns True if the event was consumed.

draw()[source]

Draw azimuth ring + altitude bar as a pixel-space HUD.

_draw_azimuth_ring(math, glColor4f, glLineWidth, glBegin, glEnd, glVertex2f, GL_TRIANGLE_FAN, GL_LINE_LOOP, GL_LINES)[source]
_draw_altitude_bar(glColor4f, glLineWidth, glBegin, glEnd, glVertex2f, GL_LINE_LOOP, GL_LINES, GL_QUADS)[source]
_draw_mini_bars(glColor4f, glLineWidth, glBegin, glEnd, glVertex2f, GL_LINE_LOOP, GL_LINES, GL_QUADS)[source]

Draw the three S / R / M mini-bars.

class wolfhece._overlays._ToolButton(icon: str, label: str, *, action: str | None = None, is_toggle: bool = False, callback=None)[source]

Descriptor for one toolbar button.

icon[source]
label[source]
action = None[source]
is_toggle = False[source]
callback = None[source]
SEPARATOR = None[source]
class wolfhece._overlays.CutFillOverlay(mapviewer: wolfhece.PyDraw.WolfMapViewer)[source]

Two side-by-side pie-chart HUDs showing cut/fill earthwork volumes.

The Zoom pie covers only the cells currently visible in the viewport; the Global pie covers the entire active array. Both measure the signed difference z_ref z_current:

  • Cut (orange): cells where the terrain was lowered (ref > current).

  • Fill (teal): cells where the terrain was raised (ref < current).

The overlay is visible only when the sculpt or profile brush is active and a reference snapshot has been frozen. It is placed at the bottom-right corner, automatically pushed above the hillshade overlay when that one is also on screen.

_GLOBAL_THROTTLE_S: float = 0.4[source]
PIE_R = 65[source]
CARD_PAD = 10[source]
TITLE_H = 15[source]
VALUE_H = 36[source]
GAP = 14[source]
MARGIN_X = 16[source]
MARGIN_Y = 16[source]
HS_MARGIN = 12[source]
property CARD_W[source]
property CARD_H[source]
BG_RGBA = (0.06, 0.06, 0.06, 0.62)[source]
OUTLINE_RGBA = (0.7, 0.7, 0.7, 0.65)[source]
CUT_RGBA = (1.0, 0.52, 0.12, 0.88)[source]
CUT_FILL = (1.0, 0.52, 0.12, 0.38)[source]
FILL_RGBA = (0.18, 0.8, 0.88, 0.88)[source]
FILL_FILL = (0.18, 0.8, 0.88, 0.38)[source]
ZERO_RGBA = (0.35, 0.35, 0.35, 0.55)[source]
TITLE_RGBA = (0.88, 0.88, 0.88, 1.0)[source]
CUT_TEXT = (1.0, 0.65, 0.3, 1.0)[source]
FILL_TEXT = (0.3, 0.9, 0.95, 1.0)[source]
enabled: bool = True[source]
mapviewer[source]
_g_cut: float = 0.0[source]
_g_fill: float = 0.0[source]
_z_cut: float = 0.0[source]
_z_fill: float = 0.0[source]
_dirty: bool = True[source]
_zoom_dirty: bool = True[source]
_last_viewport: tuple = ()[source]
_last_global_t: float = -1000000000.0[source]
_last_zoom_t: float = -1000000000.0[source]
invalidate() None[source]

Mark both caches dirty. Call after each brush stroke.

force_recompute() None[source]

Bypass throttle and recompute global immediately.

Call when brushing ends so the final tally is always accurate.

_get_brush_info()[source]

Return (ref_array, live_data, dx, dy, nullvalue) or None.

Pulls from whichever brush (sculpt or profile) is currently active.

_recompute_global() None[source]
_compute_zoom()[source]

Return (cut_m3, fill_m3) restricted to the current viewport.

static _vol_str(v: float) str[source]
_card_bottom_y() float[source]

Bottom-left y (GL pixels) for the cards, avoiding the hillshade.

_centers()[source]

Return (cx1, cx2, cy) — disc centres for Zoom / Global pies.

static _draw_disc_sector(math, glColor4f, glBegin, glEnd, glVertex2f, GL_TRIANGLE_FAN, cx, cy, r, a_start, a_end, color, n=72)[source]

Draw a filled pie sector from a_start to a_end (CCW radians).

draw() None[source]

Draw both cut/fill pie chart cards in GL pixel space.

Called every repaint from WolfMapViewer.Paint().

_draw_card(cx, cy, cut, fill, title, math, glColor4f, glLineWidth, glBegin, glEnd, glVertex2f, GL_TRIANGLE_FAN, GL_LINE_LOOP, GL_LINES)[source]

Draw the background rect and pie disc for one card.

_draw_text_card(cx, cy, cut, fill, title, tr, px_mvp, vp, math)[source]

Draw the text labels for one pie card using pixel-space MVP.

class wolfhece._overlays.ToolbarOverlay(mapviewer: wolfhece.PyDraw.WolfMapViewer)[source]

On-canvas contextual toolbar that appears in the top-left corner.

Shows a small indicator (three dots) when collapsed. Expands vertically on hover to show tool buttons relevant to the currently active object type (vectors, arrays, point clouds, cross-sections, tiles).

Toggled completely on/off with the T key.

_INDICATOR_X = 12[source]
_INDICATOR_Y_TOP = 16[source]
_INDICATOR_DOT_R = 3[source]
_INDICATOR_DOT_GAP = 8[source]
_INDICATOR_HIT_W = 28[source]
_INDICATOR_HIT_H = 40[source]
_BTN_SIZE = 30[source]
_BTN_GAP = 3[source]
_BAR_PADDING = 6[source]
_BAR_LEFT = 8[source]
_COLLAPSE_DELAY_MS = 600[source]
_BG = (0.1, 0.1, 0.12, 0.75)[source]
_BG_HOVER = (0.25, 0.25, 0.3, 0.85)[source]
_BG_ACTIVE = (0.15, 0.45, 0.8, 0.9)[source]
_BORDER = (0.55, 0.55, 0.6, 0.8)[source]
_TEXT = (0.95, 0.95, 0.95, 1.0)[source]
_TEXT_ACTIVE = (1.0, 1.0, 1.0, 1.0)[source]
_SEP_COLOR = (0.45, 0.45, 0.5, 0.6)[source]
_DOT_COLOR = (0.7, 0.7, 0.75, 0.8)[source]
_TOOLTIP_BG = (0.08, 0.08, 0.1, 0.9)[source]
_TOOLTIP_TEXT = (0.95, 0.93, 0.8, 1.0)[source]
_BUTTONS_VECTOR: list[source]
_BUTTONS_ARRAY: list[source]
_BUTTONS_CLOUD: list[source]
_BUTTONS_CS: list[source]
_BUTTONS_TILE: list[source]
mapviewer[source]
_expanded = False[source]
_hover_btn: int | None = None[source]
_text_renderer = None[source]
_collapse_timer = None[source]
_last_context: str | None = None[source]
_cached_buttons: list | None = None[source]
_detect_context() str[source]

Return a context key based on the selected object in the tree.

Multiple active_* attributes can be non-None simultaneously, so they cannot be used to decide which button set to show. The selected_object (tree selection) is the authoritative source.

_get_buttons() list | None[source]

Return the button list for the current context (cached).

_canvas_size()[source]
static _wx_to_gl(wx_x, wx_y, h)[source]
_indicator_rect_gl()[source]

GL rect (x0, y0, x1, y1) of the 3-dot indicator zone.

_bar_geometry()[source]

Return (x0, y_top, y_bot, bar_w, btn_rects) for expanded bar.

btn_rects is a list of (bx0, by0, bx1, by1) in GL coords, one per non-separator button.

is_inside(wx_x, wx_y) bool[source]

True if the wx point is over the indicator or the expanded bar.

hit_test(wx_x, wx_y) int | None[source]

Return button index if wx point is over a button, else None.

on_mouse_move(wx_x, wx_y) bool[source]

Track hover. Returns True if the event should be consumed.

on_click(wx_x, wx_y) bool[source]

Handle a left click. Returns True if consumed.

_start_collapse_timer()[source]
_stop_collapse_timer()[source]
_on_collapse()[source]
_tb_add_zone()[source]
_tb_add_vector()[source]
_tb_create_parallel()[source]
_tb_select_all()[source]
_tb_reset_selection()[source]
_tb_dilate()[source]
_tb_erode()[source]
_tb_mask_inside()[source]
_tb_mask_outside()[source]
_tb_open_sculpt()[source]
_tb_sculpt_mode(mode_value: str) None[source]

Open the sculpt panel, set brush mode, and activate sculpting.

_tb_sculpt_smooth()[source]
_tb_sculpt_raise()[source]
_tb_sculpt_lower()[source]
_tb_sculpt_flatten()[source]
_tb_sculpt_noise()[source]
_tb_open_profile()[source]

Open (or raise) the floating ProfilePanel.

draw()[source]

Draw the toolbar overlay. Called from WolfMapViewer.Paint().

_draw_indicator(w, h, glColor4f, glPointSize, glBegin, glEnd, glVertex2f, GL_POINTS)[source]

Draw three small dots in the top-left corner.

_draw_expanded(w, h, glBegin, glEnd, glVertex2f, glColor4f, glLineWidth, glPointSize, GL_QUADS, GL_LINES, GL_POINTS)[source]

Draw the full expanded toolbar.

_draw_button_icon(btn, bx0, by0, bx1, by1, is_active, w, h)[source]

Draw the icon from the texture atlas, centred in the button.

_draw_separators(buttons, btn_rects, x0, bar_w, glColor4f, glLineWidth, glBegin, glEnd, glVertex2f, GL_LINES)[source]

Draw horizontal separator lines between button groups.

_draw_tooltip(text, btn_rect, w, h, glColor4f, glBegin, glEnd, glVertex2f, GL_QUADS)[source]

Draw a tooltip to the right of a button.

class wolfhece._overlays.PaletteOverlay(mapviewer: wolfhece.PyDraw.WolfMapViewer)[source]

On-canvas HUD for interactive colour-palette editing.

Draws a horizontal gradient bar at the top of the GL canvas showing the active array’s palette. Triangular cursors mark the values at each colour stop and can be dragged to reshape the palette.

Only active while toggled on (key K).

_MARGIN = 20[source]
_BAR_HEIGHT = 24[source]
_CURSOR_H = 12[source]
_LABEL_FONT_SIZE = 11[source]
_LABEL_GAP = 4[source]
_MIN_CURSOR_SEP = 3[source]
_HANDLE_W = 10[source]
_BG_RGBA = (0.12, 0.12, 0.12, 0.55)[source]
_OUTLINE_RGBA = (0.8, 0.8, 0.8, 0.8)[source]
_CURSOR_RGBA = (1.0, 1.0, 1.0, 0.9)[source]
_CURSOR_ACTIVE_RGBA = (1.0, 0.85, 0.0, 1.0)[source]
_LABEL_COLOR = (0.95, 0.93, 0.8, 1.0)[source]
_LABEL_BG = (0.08, 0.08, 0.1, 0.9)[source]
mapviewer[source]
_dragging: int | None = None[source]
_hover: int | None = None[source]
_hover_gl_x: float | None = None[source]
_text_renderer = None[source]
_get_palette_owner()[source]

Return the selected object that owns a palette, or None.

Returns a WolfArray or Wolfresults_2D picked from mapviewer.selected_object.

_get_palette()[source]

Return the active array’s or active 2D result’s palette, or None.

_iter_underlying_arrays()[source]

Yield every WolfArray that backs the current palette owner.

For a plain WolfArray owner, yields just that single array. For a WolfArrayMB owner, yields the parent and every sub-block. For a Wolfresults_2D owner, yields the _current WolfArray of every block via iter_current_arrays().

_bar_rect()[source]

Return (x0, y_bottom, x1, y_top) for the gradient bar.

_value_to_x(val, pal, x0, x1)[source]

Map a palette value to a pixel x-coordinate.

_x_to_value(px_x, pal, x0, x1)[source]

Map a pixel x-coordinate back to a palette value.

_wx_to_gl(wx_x, wx_y)[source]
is_inside(wx_x, wx_y)[source]

Return True if the wx position is inside the overlay zone.

on_mouse_move(wx_x, wx_y)[source]

Track hover position. Returns True if mouse is over the bar.

hit_test(wx_x, wx_y)[source]

Return cursor index, -1 (min handle), -2 (max handle), or None.

on_drag(wx_x, wx_y)[source]

Update palette values based on drag position.

draw()[source]

Draw the palette bar + cursors + labels as a pixel-space HUD.

_draw_gradient_bar(pal, x0, y0, x1, y1, glColor4f, glColor3f, glBegin, glEnd, glVertex2f, GL_QUADS)[source]

Draw the colour gradient (or piecewise-constant blocks).

_draw_cursors(pal, x0, y0, x1, y1, glColor4f, glBegin, glEnd, glVertex2f, GL_TRIANGLES)[source]

Draw triangular cursors below the bar for each colour stop.

_draw_labels(pal, x0, y0, x1, y1, w, h)[source]

Draw min/max value labels with tooltip-style background.

_draw_hover_value(pal, x0, y0, x1, y1, w, h, glColor4f, glLineWidth, glBegin, glEnd, glVertex2f, GL_LINES)[source]

Draw a vertical hair-line + tooltip-style value label at hover.

on_double_click(wx_x, wx_y)[source]

Open a dialog to type an exact value for the clicked cursor.

on_right_click(wx_x, wx_y)[source]

Show context menu if click is inside the overlay area.

_PRESETS: dict[source]
_apply_preset(key: str)[source]

Apply a domain-specific preset palette to the active array.

_apply_model_file(filename: str)[source]

Load a .pal file from wolfhece/models/ into the active palette.

_apply_palette_change()[source]

Rebuild palette internals + invalidate GPU cache + refresh.