wolfhece.assets.bar.controller
Persistent controller for editable bar chart assets.
The controller stores editable parameters, keeps a pointer to the current Zones object in the mapviewer, and can rebuild geometry dynamically.
Module Contents
- class wolfhece.assets.bar.controller.BarZonesController(values: Sequence[float], position: tuple[float, float] = (0.0, 0.0), width: float = 10.0, height: float = 2.0, *, id: str = 'bar_chart', orientation: str = 'horizontal', labels: Sequence[str] | None = None, colors: Sequence[tuple[int, int, int] | tuple[int, int, int, int]] | None = None, legend_visible: bool = True, legend_show_percent: bool = True, legend_show_value: bool = False, legend_offset_factor: float = 0.3, legend_position_mode: str = 'auto', legend_positions: Sequence[tuple[float, float] | None] | None = None, legend_text_color: tuple[int, int, int] = (0, 0, 0), border_enabled: bool = True, border_width: float = 1.0, border_color: tuple[int, int, int] = (25, 25, 25), mapviewer=None, editor: wolfhece.assets.bar.editor.BarZonesEditor | None = None)[source]
Persistent controller for editable bar assets.
- _normalize_legend_positions(positions: Sequence[tuple[float, float] | None] | None) list[tuple[float, float] | None][source]
- _build_asset() wolfhece.assets.bar.zones_asset.BarZonesAsset[source]
Build BarZonesAsset from current controller state.
- update_data(values: Sequence[float] | None = None, labels: Sequence[str] | None = None, colors: Sequence[tuple[int, int, int] | tuple[int, int, int, int]] | None = None, rebuild: bool = True) None[source]
Update segment data.
- update_geometry(x: float | None = None, y: float | None = None, width: float | None = None, height: float | None = None, orientation: str | None = None, rebuild: bool = True) None[source]
Update bar geometry.
- get_transform_bounds() tuple[float, float, float, float][source]
Return editable asset bounds as
(xmin, ymin, xmax, ymax).
- apply_transform_bounds(bounds: tuple[float, float, float, float], *, rebuild: bool = True) None[source]
Apply rectangle bounds produced by map drag/resize handles.
- update_legend_layout(*, position_mode: str | None = None, positions: Sequence[tuple[float, float] | None] | None = None, offset_factor: float | None = None, legend_text_color: tuple[int, int, int] | None = None, rebuild: bool = True) None[source]
Update legend layout.
- _sync_effective_legend_positions() None[source]
Read back legend positions from the built Zones vectors.
In ‘auto’ mode the positions are computed inside
to_zones()but never stored in the controller. This helper copies them back so that the editor grid can display them.
- rebuild(ToCheck: bool = True) wolfhece.PyVertexvectors.Zones[source]
Rebuild geometry from current parameters and update mapviewer.
- _get_mapviewer_objects() list[source]
Return all mapviewer objects, or an empty list if unavailable.
- _get_vector_by_id(obj_id: str)[source]
Return a vector object by id without scanning unrelated draw types.
- _find_bound_zones_in_mapviewer() wolfhece.PyVertexvectors.Zones | None[source]
Return the currently bound Zones object if it is still present in the viewer.
- _resolve_unique_id(preferred: str, exclude_obj=None) str[source]
Return an id not used by other objects in the viewer.
- attach_to_mapviewer(mapviewer, id: str | None = None, ToCheck: bool = True) wolfhece.PyVertexvectors.Zones[source]
Attach the controller to a mapviewer and rebuild geometry.
- static from_dict(data: dict) BarZonesController[source]
Deserialize controller state from dictionary.
- static load_json(path: str | pathlib.Path) BarZonesController[source]
Load controller state from JSON file.