wolfhece._asset_manager

Asset-chart and interactive-transform companion object for WolfMapViewer.

All pie / bar / curve chart CRUD logic and the asset-transform drag / snap machinery live here. WolfMapViewer holds a single instance as self._assets and exposes one-line delegators for every public method so that external callers and the retrocompatibility test remain unaffected.

Design notes

  • AssetManager owns all mutable transform state (8 attrs) and the snap grid cache (2 attrs) — none of these were ever part of the public API.

  • Viewer-level settings (snap_grid_unit, snap_grid_round_base) remain properties on WolfMapViewer; AssetManager reads them via self._viewer.

  • wx parent for dialogs is always self._viewer.

  • Three event-hook methods (on_left_down, on_left_up, on_end_action) let the viewer delegate its mouse / action events with a single call rather than scattering attribute access.

Module Contents

class wolfhece._asset_manager.AssetManager(viewer: wolfhece.PyDraw.WolfMapViewer)[source]

Companion object that owns chart CRUD and asset-transform state.

Instantiated once as viewer._assets = AssetManager(viewer) inside WolfMapViewer.__init__.

_viewer[source]
transform_controller = None[source]
transform_editor = None[source]
drag_handle: str | None = None[source]
drag_start_xy: tuple[float, float] | None = None[source]
drag_start_bounds: tuple[float, float, float, float] | None = None[source]
cursor_key: str = ''[source]
direct_pan: bool = False[source]
editor_refresh_pending: bool = False[source]
_snap_grid_origin: tuple[float, float] | None = None[source]
_snap_grid_origin_signature: tuple[float, float] | None = None[source]
on_left_down(x: float, y: float) bool[source]

Handle left-mouse-down in transform asset bounds mode.

Returns True if the event was consumed (no further processing needed by the caller).

on_left_up(x: float, y: float) None[source]

Flush pending editor refresh, reset drag state, update cursor.

on_end_action() None[source]

Reset transform state when a viewer action ends.

add_pie_asset(values: Sequence[float], x: float, y: float, radius: float, id: str = 'pie_chart', labels: Sequence[str] = None, colors: Sequence[tuple] = None, ToCheck: bool = True, return_controller: bool = False, open_editor: bool = False, **kwargs) Zones | PieZonesController[source]

Create and add a world-space pie chart with persistent controller.

_bind_pie_controller_to_zones(controller: wolfhece.assets.pie.PieZonesController, zones: Zones | None) None[source]

Attach pie controller metadata to the Zones object.

_iter_pie_controllers() list[wolfhece.assets.pie.PieZonesController][source]

Collect pie controllers from the viewer’s vector objects.

_get_pie_controller(pie_id: str) PieZonesController | None[source]
OnCreatePieChart(event: wx.Event) None[source]

Create a new editable pie chart and open the full wx editor.

OnEditPieChart(event: wx.Event) None[source]

Open pie editor for an existing controller.

OnLoadPieChartJSON(event: wx.Event) None[source]

Load an editable pie chart from JSON and attach it to the viewer.

add_bar_asset(values: Sequence[float], x: float, y: float, width: float, height: float, id: str = 'bar_chart', labels: Sequence[str] = None, colors: Sequence[tuple] = None, orientation: str = 'horizontal', ToCheck: bool = True, return_controller: bool = False, open_editor: bool = False, **kwargs) Zones | BarZonesController[source]

Create and add a world-space bar chart with persistent controller.

_bind_bar_controller_to_zones(controller: wolfhece.assets.bar.BarZonesController, zones: Zones | None) None[source]
_iter_bar_controllers() list[wolfhece.assets.bar.BarZonesController][source]
_get_bar_controller(bar_id: str) BarZonesController | None[source]
OnCreateBarChart(event: wx.Event) None[source]
OnEditBarChart(event: wx.Event) None[source]
OnLoadBarChartJSON(event: wx.Event) None[source]
add_curve_asset(curves: Sequence, id: str = 'curve_plot', labels: Sequence[str] = None, colors: Sequence[tuple] = None, canvas_origin: tuple[float, float] = (0.0, 0.0), canvas_size: tuple[float, float] = (100.0, 100.0), area_fraction: tuple[float, float, float, float] = (0.1, 0.1, 0.8, 0.3), ToCheck: bool = True, return_controller: bool = False, open_editor: bool = False, **kwargs) Zones | CurveZonesController[source]

Create and add a world-space curve chart with persistent controller.

_bind_curve_controller_to_zones(controller: wolfhece.assets.curve.CurveZonesController, zones: Zones | None) None[source]
_iter_curve_controllers() list[wolfhece.assets.curve.CurveZonesController][source]
_get_curve_controller(curve_id: str) CurveZonesController | None[source]
OnCreateCurveChart(event: wx.Event) None[source]
OnEditCurveChart(event: wx.Event) None[source]
OnLoadCurveChartJSON(event: wx.Event) None[source]
add_boxplot_asset(series, *, id: str = 'boxplot', canvas_origin: tuple = (0.0, 0.0), canvas_size: tuple = (100.0, 80.0), area_fraction: tuple = (0.1, 0.08, 0.92, 0.88), open_editor: bool = False, return_controller: bool = False, **kwargs)[source]
_bind_boxplot_controller_to_zones(controller: wolfhece.assets.boxplot.BoxplotZonesController, zones: Zones | None) None[source]
_iter_boxplot_controllers() list[wolfhece.assets.boxplot.BoxplotZonesController][source]
_get_boxplot_controller(boxplot_id: str) BoxplotZonesController | None[source]
OnCreateBoxplot(event: wx.Event) None[source]
OnEditBoxplot(event: wx.Event) None[source]
OnLoadBoxplotJSON(event: wx.Event) None[source]
_get_asset_transform_bounds()[source]
static _compute_asset_handles(bounds)[source]
_asset_handle_hit_test(x: float, y: float)[source]
static _cursor_for_asset_handle(handle: str | None) int[source]
_set_asset_transform_cursor(handle: str | None) None[source]
_update_asset_transform_cursor(x: float, y: float) None[source]
static _nice_step(raw_step: float) float[source]

Round a raw spacing to a readable 1-2-5 × 10ⁿ step.

_ensure_snap_grid_origin() tuple[float, float][source]

Return a stable world origin for snapping, initialized once.

_adaptive_snap_step_from_span(span: float, target_divisions: float = 20.0) float[source]

Compute zoom-adaptive step as power-of-two multiple of base unit.

_asset_transform_snap_steps() tuple[float, float][source]

Return adaptive grid steps as nested multiples of base snap unit.

_asset_transform_snap_origin() tuple[float, float][source]
static _snap_value(v: float, step: float, origin: float = 0.0) float[source]
_snap_xy_on_grid(x: float, y: float, do_snap: bool = True) tuple[float, float][source]

Snap point coordinates using the current grid.

_apply_asset_transform_drag(x: float, y: float, *, keep_ratio: bool = False, resize_from_center: bool = False, do_snap: bool = True) bool[source]