wolfhece._asset_manager ======================= .. py:module:: wolfhece._asset_manager .. autoapi-nested-parse:: 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 --------------- .. py:class:: AssetManager(viewer: wolfhece.PyDraw.WolfMapViewer) Companion object that owns chart CRUD and asset-transform state. Instantiated once as ``viewer._assets = AssetManager(viewer)`` inside ``WolfMapViewer.__init__``. .. py:attribute:: _viewer .. py:attribute:: transform_controller :value: None .. py:attribute:: transform_editor :value: None .. py:attribute:: drag_handle :type: str | None :value: None .. py:attribute:: drag_start_xy :type: tuple[float, float] | None :value: None .. py:attribute:: drag_start_bounds :type: tuple[float, float, float, float] | None :value: None .. py:attribute:: cursor_key :type: str :value: '' .. py:attribute:: direct_pan :type: bool :value: False .. py:attribute:: editor_refresh_pending :type: bool :value: False .. py:attribute:: _snap_grid_origin :type: tuple[float, float] | None :value: None .. py:attribute:: _snap_grid_origin_signature :type: tuple[float, float] | None :value: None .. py:method:: on_left_down(x: float, y: float) -> bool Handle left-mouse-down in *transform asset bounds* mode. Returns ``True`` if the event was consumed (no further processing needed by the caller). .. py:method:: on_left_up(x: float, y: float) -> None Flush pending editor refresh, reset drag state, update cursor. .. py:method:: on_end_action() -> None Reset transform state when a viewer action ends. .. py:method:: 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 Create and add a world-space pie chart with persistent controller. .. py:method:: _bind_pie_controller_to_zones(controller: wolfhece.assets.pie.PieZonesController, zones: Zones | None) -> None Attach pie controller metadata to the Zones object. .. py:method:: _iter_pie_controllers() -> list[wolfhece.assets.pie.PieZonesController] Collect pie controllers from the viewer's vector objects. .. py:method:: _get_pie_controller(pie_id: str) -> PieZonesController | None .. py:method:: OnCreatePieChart(event: wx.Event) -> None Create a new editable pie chart and open the full wx editor. .. py:method:: OnEditPieChart(event: wx.Event) -> None Open pie editor for an existing controller. .. py:method:: OnLoadPieChartJSON(event: wx.Event) -> None Load an editable pie chart from JSON and attach it to the viewer. .. py:method:: 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 Create and add a world-space bar chart with persistent controller. .. py:method:: _bind_bar_controller_to_zones(controller: wolfhece.assets.bar.BarZonesController, zones: Zones | None) -> None .. py:method:: _iter_bar_controllers() -> list[wolfhece.assets.bar.BarZonesController] .. py:method:: _get_bar_controller(bar_id: str) -> BarZonesController | None .. py:method:: OnCreateBarChart(event: wx.Event) -> None .. py:method:: OnEditBarChart(event: wx.Event) -> None .. py:method:: OnLoadBarChartJSON(event: wx.Event) -> None .. py:method:: 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 Create and add a world-space curve chart with persistent controller. .. py:method:: _bind_curve_controller_to_zones(controller: wolfhece.assets.curve.CurveZonesController, zones: Zones | None) -> None .. py:method:: _iter_curve_controllers() -> list[wolfhece.assets.curve.CurveZonesController] .. py:method:: _get_curve_controller(curve_id: str) -> CurveZonesController | None .. py:method:: OnCreateCurveChart(event: wx.Event) -> None .. py:method:: OnEditCurveChart(event: wx.Event) -> None .. py:method:: OnLoadCurveChartJSON(event: wx.Event) -> None .. py:method:: 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) .. py:method:: _bind_boxplot_controller_to_zones(controller: wolfhece.assets.boxplot.BoxplotZonesController, zones: Zones | None) -> None .. py:method:: _iter_boxplot_controllers() -> list[wolfhece.assets.boxplot.BoxplotZonesController] .. py:method:: _get_boxplot_controller(boxplot_id: str) -> BoxplotZonesController | None .. py:method:: OnCreateBoxplot(event: wx.Event) -> None .. py:method:: OnEditBoxplot(event: wx.Event) -> None .. py:method:: OnLoadBoxplotJSON(event: wx.Event) -> None .. py:method:: _get_asset_transform_bounds() .. py:method:: _compute_asset_handles(bounds) :staticmethod: .. py:method:: _asset_handle_hit_test(x: float, y: float) .. py:method:: _cursor_for_asset_handle(handle: str | None) -> int :staticmethod: .. py:method:: _set_asset_transform_cursor(handle: str | None) -> None .. py:method:: _update_asset_transform_cursor(x: float, y: float) -> None .. py:method:: _nice_step(raw_step: float) -> float :staticmethod: Round a raw spacing to a readable 1-2-5 × 10ⁿ step. .. py:method:: _ensure_snap_grid_origin() -> tuple[float, float] Return a stable world origin for snapping, initialized once. .. py:method:: _adaptive_snap_step_from_span(span: float, target_divisions: float = 20.0) -> float Compute zoom-adaptive step as power-of-two multiple of base unit. .. py:method:: _asset_transform_snap_steps() -> tuple[float, float] Return adaptive grid steps as nested multiples of base snap unit. .. py:method:: _asset_transform_snap_origin() -> tuple[float, float] .. py:method:: _snap_value(v: float, step: float, origin: float = 0.0) -> float :staticmethod: .. py:method:: _snap_xy_on_grid(x: float, y: float, do_snap: bool = True) -> tuple[float, float] Snap point coordinates using the current grid. .. py:method:: _apply_asset_transform_drag(x: float, y: float, *, keep_ratio: bool = False, resize_from_center: bool = False, do_snap: bool = True) -> bool