2023-11-29 00:39:14 -08:00
|
|
|
from typing import Optional, Union
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-29 00:39:14 -08:00
|
|
|
from pydantic import BaseModel, RootModel
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-09-29 15:51:03 -07:00
|
|
|
from ..models.angle import Angle
|
2023-07-07 18:03:18 -07:00
|
|
|
from ..models.point2d import Point2d
|
|
|
|
from ..models.point3d import Point3d
|
|
|
|
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
class line(BaseModel):
|
|
|
|
"""A straight line segment. Goes from the current path "pen" to the given endpoint."""
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
end: Point3d
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
relative: bool
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
type: str = "line"
|
2023-07-07 18:03:18 -07:00
|
|
|
|
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
class arc(BaseModel):
|
|
|
|
"""A circular arc segment."""
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
angle_end: float
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
angle_start: float
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
center: Point2d
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
end: Optional[Angle] = None
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
radius: float
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
relative: bool
|
2023-07-07 18:03:18 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
start: Optional[Angle] = None
|
2023-09-29 16:05:40 -07:00
|
|
|
|
2023-11-27 16:01:20 -08:00
|
|
|
type: str = "arc"
|
|
|
|
|
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
class bezier(BaseModel):
|
|
|
|
"""A cubic bezier curve segment. Start at the end of the current line, go through control point 1 and 2, then end at a given point."""
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
control1: Point3d
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
control2: Point3d
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
end: Point3d
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
relative: bool
|
2023-11-27 16:01:20 -08:00
|
|
|
|
|
|
|
type: str = "bezier"
|
|
|
|
|
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
class tangential_arc(BaseModel):
|
|
|
|
"""Adds a tangent arc from current pen position with the given radius and angle."""
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
offset: Angle
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
radius: float
|
2023-11-27 16:01:20 -08:00
|
|
|
|
|
|
|
type: str = "tangential_arc"
|
2023-09-29 15:51:03 -07:00
|
|
|
|
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
class tangential_arc_to(BaseModel):
|
|
|
|
"""Adds a tangent arc from current pen position to the new position."""
|
2023-09-29 15:51:03 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
angle_snap_increment: Optional[Angle] = None
|
2023-09-29 15:51:03 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
to: Point3d
|
2023-11-27 16:01:20 -08:00
|
|
|
|
|
|
|
type: str = "tangential_arc_to"
|
|
|
|
|
2023-09-29 15:51:03 -07:00
|
|
|
|
2023-11-29 00:39:14 -08:00
|
|
|
PathSegment = RootModel[
|
|
|
|
Union[
|
2023-11-28 14:16:05 -08:00
|
|
|
line,
|
|
|
|
arc,
|
|
|
|
bezier,
|
|
|
|
tangential_arc,
|
|
|
|
tangential_arc_to,
|
2023-11-28 14:29:16 -08:00
|
|
|
]
|
2023-11-29 00:39:14 -08:00
|
|
|
]
|