use enum_iterator::Sequence;
use parse_display_derive::{Display, FromStr};
use schemars::{schema::SchemaObject, JsonSchema};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[cfg(feature = "cxx")]
use crate::impl_extern_type;
use crate::{length_unit::LengthUnit, output::ExtrusionFaceInfo, units::UnitAngle};
pub use point::{Point2d, Point3d, Point4d, Quaternion};
mod point;
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum CutType {
#[default]
Fillet,
Chamfer,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct Rotation {
pub axis: Point3d<f64>,
pub angle: Angle,
pub origin: OriginType,
}
impl Default for Rotation {
fn default() -> Self {
Self {
axis: z_axis(),
angle: Angle::default(),
origin: OriginType::Local,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct Transform {
#[serde(default)]
pub translate: Point3d<LengthUnit>,
#[serde(default = "same_scale")]
pub scale: Point3d<f64>,
#[serde(default)]
pub rotation: Rotation,
#[serde(default = "bool_true")]
pub replicate: bool,
}
impl Default for Transform {
fn default() -> Self {
Self {
scale: same_scale(),
replicate: true,
translate: Default::default(),
rotation: Rotation::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct AnnotationOptions {
pub text: Option<AnnotationTextOptions>,
pub line_ends: Option<AnnotationLineEndOptions>,
pub line_width: Option<f32>,
pub color: Option<Color>,
pub position: Option<Point3d<f32>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct AnnotationLineEndOptions {
pub start: AnnotationLineEnd,
pub end: AnnotationLineEnd,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct AnnotationTextOptions {
pub x: AnnotationTextAlignmentX,
pub y: AnnotationTextAlignmentY,
pub text: String,
pub point_size: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum DistanceType {
Euclidean {},
OnAxis {
axis: GlobalAxis,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum OriginType {
#[default]
Local,
Global,
Custom {
origin: Point3d<f64>,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum AnnotationTextAlignmentX {
Left,
Center,
Right,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum AnnotationTextAlignmentY {
Bottom,
Center,
Top,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum AnnotationLineEnd {
None,
Arrow,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum AnnotationType {
T2D,
T3D,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum CameraDragInteractionType {
Pan,
Rotate,
RotateTrackball,
Zoom,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case", tag = "type")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum PathSegment {
Line {
end: Point3d<LengthUnit>,
relative: bool,
},
Arc {
center: Point2d<LengthUnit>,
radius: LengthUnit,
start: Angle,
end: Angle,
relative: bool,
},
Bezier {
control1: Point3d<LengthUnit>,
control2: Point3d<LengthUnit>,
end: Point3d<LengthUnit>,
relative: bool,
},
TangentialArc {
radius: LengthUnit,
offset: Angle,
},
TangentialArcTo {
to: Point3d<LengthUnit>,
angle_snap_increment: Option<Angle>,
},
ArcTo {
interior: Point3d<LengthUnit>,
end: Point3d<LengthUnit>,
relative: bool,
},
}
#[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct Angle {
pub unit: UnitAngle,
pub value: f64,
}
impl Angle {
pub fn to_degrees(self) -> f64 {
match self.unit {
UnitAngle::Degrees => self.value,
UnitAngle::Radians => self.value.to_degrees(),
}
}
pub fn to_radians(self) -> f64 {
match self.unit {
UnitAngle::Degrees => self.value.to_radians(),
UnitAngle::Radians => self.value,
}
}
pub const fn from_degrees(value: f64) -> Self {
Self {
unit: UnitAngle::Degrees,
value,
}
}
pub const fn from_radians(value: f64) -> Self {
Self {
unit: UnitAngle::Radians,
value,
}
}
pub const fn turn() -> Self {
Self::from_degrees(360.0)
}
pub const fn half_circle() -> Self {
Self::from_degrees(180.0)
}
pub const fn quarter_circle() -> Self {
Self::from_degrees(90.0)
}
pub const fn zero() -> Self {
Self::from_degrees(0.0)
}
}
impl Default for Angle {
fn default() -> Self {
Self::zero()
}
}
impl PartialOrd for Angle {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match (self.unit, other.unit) {
(UnitAngle::Degrees, UnitAngle::Degrees) => self.value.partial_cmp(&other.value),
(UnitAngle::Radians, UnitAngle::Radians) => self.value.partial_cmp(&other.value),
_ => self.to_degrees().partial_cmp(&other.to_degrees()),
}
}
}
impl std::ops::Add for Angle {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self {
unit: UnitAngle::Degrees,
value: self.to_degrees() + rhs.to_degrees(),
}
}
}
impl std::ops::AddAssign for Angle {
fn add_assign(&mut self, rhs: Self) {
match self.unit {
UnitAngle::Degrees => {
self.value += rhs.to_degrees();
}
UnitAngle::Radians => {
self.value += rhs.to_radians();
}
}
}
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum SceneSelectionType {
Replace,
Add,
Remove,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum SceneToolType {
CameraRevolve,
Select,
Move,
SketchLine,
SketchTangentialArc,
SketchCurve,
SketchCurveMod,
}
#[allow(missing_docs)]
#[derive(
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
Default,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum PathComponentConstraintBound {
#[default]
Unconstrained,
PartiallyConstrained,
FullyConstrained,
}
#[allow(missing_docs)]
#[derive(
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
Default,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum PathComponentConstraintType {
#[default]
Unconstrained,
Vertical,
Horizontal,
EqualLength,
Parallel,
AngleBetween,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum PathCommand {
MoveTo,
LineTo,
BezCurveTo,
NurbsCurveTo,
AddArc,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[repr(u8)]
pub enum EntityType {
Entity,
Object,
Path,
Curve,
Solid2D,
Solid3D,
Edge,
Face,
Plane,
Vertex,
}
#[allow(missing_docs)]
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum CurveType {
Line,
Arc,
Nurbs,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
pub struct ExportFile {
pub name: String,
pub contents: crate::base64::Base64Data,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
)]
#[serde(rename_all = "lowercase")]
#[display(style = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum FileExportFormat {
Fbx,
Glb,
Gltf,
Obj,
Ply,
Step,
Stl,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd, Sequence,
)]
#[serde(rename_all = "lowercase")]
#[display(style = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum FileImportFormat {
Fbx,
Gltf,
Obj,
Ply,
Sldprt,
Step,
Stl,
}
#[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum EngineErrorCode {
BadRequest = 1,
InternalEngine,
}
impl From<EngineErrorCode> for http::StatusCode {
fn from(e: EngineErrorCode) -> Self {
match e {
EngineErrorCode::BadRequest => Self::BAD_REQUEST,
EngineErrorCode::InternalEngine => Self::INTERNAL_SERVER_ERROR,
}
}
}
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct ExtrudedFaceInfo {
pub bottom: Option<Uuid>,
pub top: Uuid,
pub sides: Vec<SideFace>,
}
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct SideFace {
pub path_id: Uuid,
pub face_id: Uuid,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct CameraSettings {
pub pos: Point3d,
pub center: Point3d,
pub up: Point3d,
pub orientation: Quaternion,
pub fov_y: Option<f32>,
pub ortho_scale: Option<f32>,
pub ortho: bool,
}
impl From<CameraSettings> for crate::output::DefaultCameraZoom {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::CameraDragMove {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::CameraDragEnd {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::DefaultCameraGetSettings {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::ZoomToFit {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
impl From<CameraSettings> for crate::output::ViewIsometric {
fn from(settings: CameraSettings) -> Self {
Self { settings }
}
}
#[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct PerspectiveCameraParameters {
pub fov_y: Option<f32>,
pub z_near: Option<f32>,
pub z_far: Option<f32>,
}
#[derive(
Default,
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum CameraMovement {
#[default]
Vantage,
None,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum GlobalAxis {
X,
Y,
Z,
}
#[derive(
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[repr(u8)]
pub enum ExtrusionFaceCapType {
None,
Top,
Bottom,
Both,
}
#[allow(missing_docs)]
#[derive(
Display,
FromStr,
Copy,
Eq,
PartialEq,
Debug,
JsonSchema,
Deserialize,
Serialize,
Sequence,
Clone,
Ord,
PartialOrd,
Default,
)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub enum PostEffectType {
Phosphor,
Ssao,
#[default]
NoEffect,
}
#[cfg(feature = "cxx")]
impl_extern_type! {
[Trivial]
FileImportFormat = "Enums::_FileImportFormat"
FileExportFormat = "Enums::_FileExportFormat"
CameraDragInteractionType = "Enums::_CameraDragInteractionType"
SceneSelectionType = "Enums::_SceneSelectionType"
SceneToolType = "Enums::_SceneToolType"
EntityType = "Enums::_EntityType"
AnnotationType = "Enums::_AnnotationType"
AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
AnnotationLineEnd = "Enums::_AnnotationLineEnd"
CurveType = "Enums::_CurveType"
PathCommand = "Enums::_PathCommand"
PathComponentConstraintBound = "Enums::_PathComponentConstraintBound"
PathComponentConstraintType = "Enums::_PathComponentConstraintType"
ExtrusionFaceCapType = "Enums::_ExtrusionFaceCapType"
EngineErrorCode = "Enums::_ErrorCode"
GlobalAxis = "Enums::_GlobalAxis"
OriginType = "Enums::_OriginType"
PostEffectType = "Enums::_PostEffectType"
}
fn bool_true() -> bool {
true
}
fn same_scale() -> Point3d<f64> {
Point3d::uniform(1.0)
}
fn z_axis() -> Point3d<f64> {
Point3d { x: 0.0, y: 0.0, z: 1.0 }
}
impl ExtrudedFaceInfo {
pub fn list_faces(self) -> Vec<ExtrusionFaceInfo> {
let mut face_infos: Vec<_> = self
.sides
.into_iter()
.map(|side| ExtrusionFaceInfo {
curve_id: Some(side.path_id),
face_id: Some(side.face_id),
cap: ExtrusionFaceCapType::None,
})
.collect();
face_infos.push(ExtrusionFaceInfo {
curve_id: None,
face_id: Some(self.top),
cap: ExtrusionFaceCapType::Top,
});
if let Some(bottom) = self.bottom {
face_infos.push(ExtrusionFaceInfo {
curve_id: None,
face_id: Some(bottom),
cap: ExtrusionFaceCapType::Bottom,
});
}
face_infos
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_angle_comparison() {
let a = Angle::from_degrees(90.0);
assert!(a < Angle::from_degrees(91.0));
assert!(a > Angle::from_degrees(89.0));
assert!(a <= Angle::from_degrees(90.0));
assert!(a >= Angle::from_degrees(90.0));
let b = Angle::from_radians(std::f64::consts::FRAC_PI_4);
assert!(b < Angle::from_radians(std::f64::consts::FRAC_PI_2));
assert!(b > Angle::from_radians(std::f64::consts::FRAC_PI_8));
assert!(b <= Angle::from_radians(std::f64::consts::FRAC_PI_4));
assert!(b >= Angle::from_radians(std::f64::consts::FRAC_PI_4));
assert!(a > b);
assert!(a >= b);
assert!(b < a);
assert!(b <= a);
let c = Angle::from_radians(std::f64::consts::FRAC_PI_2 * 3.0);
assert!(a < c);
assert!(a <= c);
assert!(c > a);
assert!(c >= a);
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct TransformBy<T> {
pub property: T,
pub set: bool,
pub is_local: bool,
}
impl<T: JsonSchema> JsonSchema for TransformBy<T> {
fn schema_name() -> String {
format!("TransformByFor{}", T::schema_name())
}
fn schema_id() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Owned(format!("{}::TransformBy<{}>", module_path!(), T::schema_id()))
}
fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
SchemaObject {
instance_type: Some(schemars::schema::InstanceType::String.into()),
..Default::default()
}
.into()
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct ComponentTransform {
pub translate: Option<TransformBy<Point3d<LengthUnit>>>,
pub rotate_rpy: Option<TransformBy<Point3d<f64>>>,
pub rotate_angle_axis: Option<TransformBy<Point4d<f64>>>,
pub scale: Option<TransformBy<Point3d<f64>>>,
}