# -*- coding: utf-8 -*-
from __future__ import annotations
from typing import TYPE_CHECKING
from pygerber.constants import Interpolation, Mirroring, Polarity, Unit
from .coparser import CoParser
if TYPE_CHECKING:
from pygerber.tokens.fs import FormatSpecifierToken
[docs]class DrawingState:
mirroring: str
rotation: float
scale: float
unit: Unit
polarity: str
interpolation: Interpolation
is_regionmode: bool
coparser: CoParser
def __init__(self) -> None:
self.set_defaults()
[docs] def set_defaults(self):
self.coparser = CoParser()
self.mirroring = Mirroring.No
self.rotation = 0.0
self.scale = 1.0
self.is_regionmode = False
self.unit = Unit.MILLIMETERS
self.polarity = Polarity.DARK
self.interpolation = Interpolation.Linear
[docs] def parse_co(self, float_string: str):
return self.coparser.parse(float_string)
[docs] def set_rotation(self, angle: float):
self.rotation = angle
[docs] def set_scaling(self, scale: float):
self.scale = scale
[docs] def set_mirroring(self, mode):
self.mirroring = mode
[docs] def set_unit(self, unit):
self.unit = unit
[docs] def set_polarity(self, polarity):
self.polarity = polarity
[docs] def set_interpolation(self, interpolation):
self.interpolation = interpolation
[docs] def begin_region(self):
self.is_regionmode = True
[docs] def end_region(self):
self.is_regionmode = False