wolfhece.assets.bar.controller ============================== .. py:module:: wolfhece.assets.bar.controller .. autoapi-nested-parse:: 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 --------------- .. py:class:: 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) Persistent controller for editable bar assets. .. py:attribute:: values .. py:attribute:: position_x .. py:attribute:: position_y .. py:attribute:: width .. py:attribute:: height .. py:attribute:: orientation :value: '' .. py:attribute:: id :value: '' .. py:attribute:: labels .. py:attribute:: colors .. py:attribute:: legend_visible :value: True .. py:attribute:: legend_show_percent :value: True .. py:attribute:: legend_show_value :value: False .. py:attribute:: legend_offset_factor .. py:attribute:: legend_position_mode :value: 'auto' .. py:attribute:: legend_positions .. py:attribute:: legend_text_color .. py:attribute:: border_enabled :value: True .. py:attribute:: border_width .. py:attribute:: border_color :value: (25, 25, 25) .. py:attribute:: mapviewer :value: None .. py:attribute:: editor :value: None .. py:attribute:: zones :type: wolfhece.PyVertexvectors.Zones | None :value: None .. py:method:: _normalize_legend_positions(positions: Sequence[tuple[float, float] | None] | None) -> list[tuple[float, float] | None] .. py:method:: _ensure_legend_positions_length() -> None .. py:method:: _build_asset() -> wolfhece.assets.bar.zones_asset.BarZonesAsset Build BarZonesAsset from current controller state. .. py:method:: 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 Update segment data. .. py:method:: 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 Update bar geometry. .. py:method:: get_transform_bounds() -> tuple[float, float, float, float] Return editable asset bounds as ``(xmin, ymin, xmax, ymax)``. .. py:method:: apply_transform_bounds(bounds: tuple[float, float, float, float], *, rebuild: bool = True) -> None Apply rectangle bounds produced by map drag/resize handles. .. py:method:: 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 Update legend layout. .. py:method:: _sync_effective_legend_positions() -> None 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. .. py:method:: rebuild(ToCheck: bool = True) -> wolfhece.PyVertexvectors.Zones Rebuild geometry from current parameters and update mapviewer. .. py:method:: _get_mapviewer_objects() -> list Return all mapviewer objects, or an empty list if unavailable. .. py:method:: _get_vector_draw_type() Resolve the viewer enum value for vector objects lazily. .. py:method:: _get_vector_by_id(obj_id: str) Return a vector object by id without scanning unrelated draw types. .. py:method:: _find_bound_zones_in_mapviewer() -> wolfhece.PyVertexvectors.Zones | None Return the currently bound Zones object if it is still present in the viewer. .. py:method:: _resolve_unique_id(preferred: str, exclude_obj=None) -> str Return an id not used by other objects in the viewer. .. py:method:: attach_to_mapviewer(mapviewer, id: str | None = None, ToCheck: bool = True) -> wolfhece.PyVertexvectors.Zones Attach the controller to a mapviewer and rebuild geometry. .. py:method:: show_editor(parent=None) Open the editor UI window for this controller. .. py:method:: to_dict() -> dict Serialize controller state to dictionary. .. py:method:: from_dict(data: dict) -> BarZonesController :staticmethod: Deserialize controller state from dictionary. .. py:method:: save_json(path: str | pathlib.Path) -> None Save controller state to JSON file. .. py:method:: load_json(path: str | pathlib.Path) -> BarZonesController :staticmethod: Load controller state from JSON file.