Source code for ephemeris_tools.rendering.escher.state

"""Escher and view state classes (FORTRAN common block equivalents)."""

from __future__ import annotations

from typing import TextIO

from ephemeris_tools.rendering.escher.constants import MINWIDTH


[docs] class EscherState: """Mutable state for Escher PostScript output (replaces FORTRAN ESCOMM common block). Holds output file path, stream, last-drawn point (xsave, ysave), and current line width/color for grouping strokes. """ def __init__(self) -> None: """Initialize Escher output state (stream, position, line width/color).""" self.outfil = ' ' self.creator = ' ' self.fonts = ' ' self.outuni: TextIO | None = None self.xsave = 0 self.ysave = 0 self.drawn = False self.open = False self.oldcol = -9999 self.oldwidth = MINWIDTH self.external_stream = False # If True, ESCL07 full-page does not close outuni.
[docs] class EscherViewState: """Viewport, FOV, and segment buffer for Escher (ESVIEW/ESMAP1 state). Holds device, view (0-1), FOV rectangle, mapping parameters (_ux, _uy, _xcen, _ycen, _pcen, _lcen), and the segment buffer for esdraw/esdump. """ def __init__(self) -> None: """Initialize Escher view state (viewport, FOV, segment buffer).""" self.device = 0 self.view = (0.0, 0.0, 0.0, 0.0) # Hmin, Hmax, Vmin, Vmax (0-1) self.fov = (0.0, 0.0, 0.0, 0.0) # Xmin, Xmax, Ymin, Ymax self._xmin = 0.0 self._xmax = 0.0 self._ymin = 0.0 self._ymax = 0.0 self._ux = 0.0 self._uy = 0.0 self._xcen = 0.0 self._ycen = 0.0 self._pcen = 0.0 self._lcen = 0.0 self.segbuf: list[int] = [] self._initialized = False