2024-07-28 15:20:05 -07:00
import datetime
from typing import Any , Dict , List , Literal , Optional , Type , TypeVar , Union
from uuid import UUID
2023-07-07 18:03:18 -07:00
2024-07-28 15:20:05 -07:00
from pydantic import AnyUrl , Base64Bytes , BaseModel , ConfigDict , Field , RootModel
from pydantic_extra_types . phone_numbers import PhoneNumber
2023-11-29 10:32:31 -08:00
from typing_extensions import Annotated
2023-07-07 18:03:18 -07:00
2023-09-29 15:51:03 -07:00
from . . models . angle import Angle
2024-02-24 17:03:55 -08:00
from . . models . length_unit import LengthUnit
2023-07-07 18:03:18 -07:00
from . . models . point2d import Point2d
from . . models . point3d import Point3d
2024-07-28 15:20:05 -07:00
from . base64data import Base64Data
2023-07-07 18:03:18 -07:00
2023-11-27 16:01:20 -08:00
2023-11-28 23:50:50 -08:00
class line ( BaseModel ) :
2024-03-04 12:53:31 -08:00
""" 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-29 10:32:31 -08:00
type : Literal [ " line " ] = " line "
2023-07-07 18:03:18 -07:00
2024-01-06 18:32:21 -08:00
model_config = ConfigDict ( protected_namespaces = ( ) )
2023-07-07 18:03:18 -07:00
2023-11-28 23:50:50 -08:00
class arc ( BaseModel ) :
2024-05-02 14:03:09 -07:00
""" A circular arc segment. Arcs can be drawn clockwise when start > end. """
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-12-21 08:14:08 -08:00
end : Angle
2023-07-07 18:03:18 -07:00
2024-02-24 17:03:55 -08:00
radius : LengthUnit
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-12-21 08:14:08 -08:00
start : Angle
2023-09-29 16:05:40 -07:00
2023-11-29 10:32:31 -08:00
type : Literal [ " arc " ] = " arc "
2023-11-27 16:01:20 -08:00
2024-01-06 18:32:21 -08:00
model_config = ConfigDict ( protected_namespaces = ( ) )
2023-11-27 16:01:20 -08:00
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
2023-11-29 10:32:31 -08:00
type : Literal [ " bezier " ] = " bezier "
2023-11-27 16:01:20 -08:00
2024-01-06 18:32:21 -08:00
model_config = ConfigDict ( protected_namespaces = ( ) )
2023-11-27 16:01:20 -08:00
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
2024-02-24 17:03:55 -08:00
radius : LengthUnit
2023-11-27 16:01:20 -08:00
2023-11-29 10:32:31 -08:00
type : Literal [ " tangential_arc " ] = " tangential_arc "
2023-09-29 15:51:03 -07:00
2024-01-06 18:32:21 -08:00
model_config = ConfigDict ( protected_namespaces = ( ) )
2023-09-29 15:51:03 -07:00
2023-11-28 23:50:50 -08:00
class tangential_arc_to ( BaseModel ) :
2024-05-02 14:03:09 -07:00
""" Adds a tangent arc from current pen position to the new position. Arcs will choose a clockwise or counter-clockwise direction based on the arc end 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
2023-11-29 10:32:31 -08:00
type : Literal [ " tangential_arc_to " ] = " tangential_arc_to "
2023-11-27 16:01:20 -08:00
2024-01-06 18:32:21 -08:00
model_config = ConfigDict ( protected_namespaces = ( ) )
2023-09-29 15:51:03 -07:00
2023-11-29 00:39:14 -08:00
PathSegment = RootModel [
2023-11-29 10:32:31 -08:00
Annotated [
Union [
line ,
arc ,
bezier ,
tangential_arc ,
tangential_arc_to ,
] ,
Field ( discriminator = " type " ) ,
2023-11-28 14:29:16 -08:00
]
2023-11-29 00:39:14 -08:00
]