wolfhece.assets.pie.controller

Module Contents

class wolfhece.assets.pie.controller.PieZonesController(values: Sequence[float], center: tuple[float, float], radius: float, *, id: str = 'pie_chart', labels: Sequence[str] | None = None, colors: Sequence[tuple[int, int, int] | tuple[int, int, int, int]] | None = None, start_angle_deg: float = 90.0, clockwise: bool = False, sectors_as_independent_zones: bool = False, legend_visible: bool = True, legend_show_percent: bool = True, legend_show_value: bool = False, legend_offset_factor: float = 0.65, legend_position_mode: str = 'auto', legend_positions: Sequence[tuple[float, float] | None] | None = None, legend_text_color: tuple[int, int, int] = (0, 0, 0), fill_clock_animation: bool = False, fill_anim_speed: float = 1.0, smoothing: bool = True, border_enabled: bool = True, border_width: float = 1.0, border_color: tuple[int, int, int] = (25, 25, 25), store_fraction_in_z: bool = True)[source]

Persistent controller for editable pie assets.

The controller stores editable parameters, keeps a pointer to the current Zones object in the mapviewer, and can rebuild geometry dynamically.

id = ''[source]
values[source]
colors = [][source]
center_x[source]
center_y[source]
radius[source]
start_angle_deg[source]
clockwise = False[source]
sectors_as_independent_zones = False[source]
legend_visible = True[source]
legend_show_percent = True[source]
legend_show_value = False[source]
legend_offset_factor[source]
legend_position_mode = 'auto'[source]
legend_positions[source]
legend_text_color[source]
fill_clock_animation = False[source]
fill_anim_speed[source]
smoothing = True[source]
border_enabled = True[source]
border_width[source]
border_color = (25, 25, 25)[source]
store_fraction_in_z = True[source]
mapviewer = None[source]
zones: wolfhece.PyVertexvectors.Zones | None = None[source]
editor: wolfhece.assets.pie.editor.PieZonesEditor | None = None[source]
_normalize_legend_positions(positions: Sequence[tuple[float, float] | None] | None) list[tuple[float, float] | None][source]
_ensure_legend_positions_length() None[source]
_get_mapviewer_objects() list[source]

Return all mapviewer objects, or an empty list if unavailable.

_get_vector_draw_type()[source]

Resolve the viewer enum value for vector objects lazily.

_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.

_build_asset() wolfhece.assets.pie.zones_asset.PieZonesAsset[source]
attach_to_mapviewer(mapviewer, id: str | None = None, ToCheck: bool = True) wolfhece.PyVertexvectors.Zones[source]
_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.

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_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_geometry(x: float | None = None, y: float | None = None, radius: float | None = None, start_angle_deg: float | None = None, clockwise: bool | None = None, rebuild: bool = True) None[source]
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.

Pie is circular: center follows bounds midpoint and radius is derived from the smallest side so the circle remains fully inside the box.

to_dict() dict[source]
classmethod from_dict(data: dict) PieZonesController[source]
save_json(filepath: str | pathlib.Path) pathlib.Path[source]
classmethod load_json(filepath: str | pathlib.Path) PieZonesController[source]
save_vec_or_vecz(filepath: str | pathlib.Path) pathlib.Path[source]
show_editor(parent=None)[source]
wolfhece.assets.pie.controller.build_pie_controller(values: Sequence[float], center: tuple[float, float], radius: float, **kwargs) PieZonesController[source]

Convenience function returning a persistent pie controller.