step 2: add thread safe state commands and cache model
This commit is contained in:
@@ -1 +1,72 @@
|
||||
"""Logical overlay models."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from .types import Color, LatLon, Tag
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Overlay:
|
||||
"""Base logical overlay state."""
|
||||
|
||||
tag: Tag
|
||||
map_tag: Tag
|
||||
layer: str
|
||||
show: bool = True
|
||||
user_data: Any = None
|
||||
revision: int = 0
|
||||
|
||||
def touch(self) -> None:
|
||||
"""Mark this overlay as changed."""
|
||||
|
||||
self.revision += 1
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class MarkerOverlay(Overlay):
|
||||
"""Logical marker overlay."""
|
||||
|
||||
lat: float = 0.0
|
||||
lon: float = 0.0
|
||||
label: str | None = None
|
||||
color: Color = (255, 80, 80, 255)
|
||||
radius: float = 5.0
|
||||
show_label: bool = False
|
||||
callback: Callable[..., Any] | None = None
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class PolylineOverlay(Overlay):
|
||||
"""Logical polyline overlay."""
|
||||
|
||||
points: tuple[LatLon, ...] = ()
|
||||
color: Color = (80, 180, 255, 255)
|
||||
thickness: float = 2.0
|
||||
closed: bool = False
|
||||
simplify: bool = True
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class TrajectoryOverlay(Overlay):
|
||||
"""Logical trajectory overlay."""
|
||||
|
||||
points: tuple[LatLon, ...] = ()
|
||||
timestamps: tuple[float, ...] | None = None
|
||||
color: Color = (255, 180, 60, 255)
|
||||
thickness: float = 2.0
|
||||
show_points: bool = False
|
||||
point_stride: int = 1
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class LayerState:
|
||||
"""Logical layer visibility and ordering state."""
|
||||
|
||||
name: str
|
||||
z_index: int = 0
|
||||
show: bool = True
|
||||
overlay_tags: set[Tag] = field(default_factory=set)
|
||||
|
||||
Reference in New Issue
Block a user