From 86d945642f9600cf6154004a37a6d566cc238e8d Mon Sep 17 00:00:00 2001 From: gserena01 Date: Mon, 11 Dec 2023 16:08:38 -0500 Subject: [PATCH 1/6] types for linear patterns --- modeling-cmds/src/each_cmd.rs | 13 +++++++++++++ modeling-cmds/src/ok_response.rs | 2 ++ modeling-cmds/src/output.rs | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/modeling-cmds/src/each_cmd.rs b/modeling-cmds/src/each_cmd.rs index 63b3a08f..0365ecd1 100644 --- a/modeling-cmds/src/each_cmd.rs +++ b/modeling-cmds/src/each_cmd.rs @@ -184,6 +184,19 @@ pub struct EntityGetDistance { pub distance_type: DistanceType, } +/// Create a linear patter using this entity +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +pub struct EntityLinearPattern { + /// ID of the entity being copied. + pub entity_id: Uuid, + /// Axis along which to make the copites + pub axis: Point3d, + /// Number of repetitions to make. + pub num_repetitions: u32, + /// Spacing between repetitions. + pub spacing: f64, +} + /// Enter edit mode #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] pub struct EditModeEnter { diff --git a/modeling-cmds/src/ok_response.rs b/modeling-cmds/src/ok_response.rs index a86a3470..e5eb336e 100644 --- a/modeling-cmds/src/ok_response.rs +++ b/modeling-cmds/src/ok_response.rs @@ -33,6 +33,8 @@ pub enum OkModelingCmdResponse { GetEntityType(output::GetEntityType), /// The response from the `EntityGetDistance` command. EntityGetDistance(output::EntityGetDistance), + /// The response from the `EntityLinearPatter` command. + EntityLinearPattern(output::EntityLinearPattern), /// The response from the `Solid3dGetAllEdgeFaces` command. Solid3dGetAllEdgeFaces(output::Solid3dGetAllEdgeFaces), /// The response from the `Solid3dGetAllOppositeEdges` command. diff --git a/modeling-cmds/src/output.rs b/modeling-cmds/src/output.rs index 185b9562..07dc04b9 100644 --- a/modeling-cmds/src/output.rs +++ b/modeling-cmds/src/output.rs @@ -256,6 +256,13 @@ pub struct EntityGetDistance { pub max_distance: f64, } +/// The response from the `EntityLinearPattern` command. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct EntityLinearPattern { + /// The UUIDs of the entities that were created. + pub entity_ids: Vec, +} + impl<'de> ModelingCmdOutput<'de> for Export {} impl<'de> ModelingCmdOutput<'de> for SelectWithPoint {} impl<'de> ModelingCmdOutput<'de> for HighlightSetEntity {} @@ -264,6 +271,7 @@ impl<'de> ModelingCmdOutput<'de> for EntityGetNumChildren {} impl<'de> ModelingCmdOutput<'de> for EntityGetParentId {} impl<'de> ModelingCmdOutput<'de> for EntityGetAllChildUuids {} impl<'de> ModelingCmdOutput<'de> for EntityGetDistance {} +impl<'de> ModelingCmdOutput<'de> for EntityLinearPattern {} impl<'de> ModelingCmdOutput<'de> for SelectGet {} impl<'de> ModelingCmdOutput<'de> for GetEntityType {} impl<'de> ModelingCmdOutput<'de> for Solid3dGetAllEdgeFaces {} From e65319a854871d31ef5d1cf658a22fafde6bdd14 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Wed, 13 Dec 2023 11:03:13 -0600 Subject: [PATCH 2/6] Impl more traits --- modeling-cmds/src/def_enum.rs | 2 ++ modeling-cmds/src/impl_traits.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index b920066d..538aa9cc 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -163,6 +163,8 @@ pub enum ModelingCmd { ObjectSetMaterialParamsPbr(ObjectSetMaterialParamsPbr), /// What is the distance between these two entities? EntityGetDistance(EntityGetDistance), + /// Duplicate the given entity, evenly spaced along the chosen axis. + EntityLinearPattern(EntityLinearPattern), } impl ModelingCmd { diff --git a/modeling-cmds/src/impl_traits.rs b/modeling-cmds/src/impl_traits.rs index 3723b73c..e47488e4 100644 --- a/modeling-cmds/src/impl_traits.rs +++ b/modeling-cmds/src/impl_traits.rs @@ -420,3 +420,9 @@ impl<'de> ModelingCmdVariant<'de> for GetSketchModePlane { ModelingCmd::GetSketchModePlane(self) } } +impl<'de> ModelingCmdVariant<'de> for EntityLinearPattern { + type Output = out::GetSketchModePlane; + fn into_enum(self) -> ModelingCmd { + ModelingCmd::EntityLinearPattern(self) + } +} From 4a4c23fe820967e7de6af92e2428c348a84cc9b0 Mon Sep 17 00:00:00 2001 From: gserena01 Date: Wed, 13 Dec 2023 12:47:42 -0500 Subject: [PATCH 3/6] change output to correct type --- modeling-cmds/src/impl_traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modeling-cmds/src/impl_traits.rs b/modeling-cmds/src/impl_traits.rs index e47488e4..d207fba4 100644 --- a/modeling-cmds/src/impl_traits.rs +++ b/modeling-cmds/src/impl_traits.rs @@ -421,7 +421,7 @@ impl<'de> ModelingCmdVariant<'de> for GetSketchModePlane { } } impl<'de> ModelingCmdVariant<'de> for EntityLinearPattern { - type Output = out::GetSketchModePlane; + type Output = out::EntityLinearPattern; fn into_enum(self) -> ModelingCmd { ModelingCmd::EntityLinearPattern(self) } From 6df4ac1376ae347d2428a1148aef6112ee1632ee Mon Sep 17 00:00:00 2001 From: gserena01 Date: Mon, 18 Dec 2023 11:37:01 -0500 Subject: [PATCH 4/6] fix typo in CONTRIBUTING, add output struct back in --- CONTRIBUTING.md | 2 +- modeling-cmds/src/output.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1a0fd34..4381d56a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Adding a new modeling command - - In `each_command.rs` add your new `struct MyNewCommand` with one field for each parameter the command has. + - In `each_cmd.rs` add your new `struct MyNewCommand` with one field for each parameter the command has. - In `def_enum.rs` add a new variant of `ModelingCmd` with your type, e.g. `MyNewCommand(MyNewCommand)`. - If your command responds with data: - In `output.rs`, add a `struct MyNewCommand` following the existing examples. diff --git a/modeling-cmds/src/output.rs b/modeling-cmds/src/output.rs index c74e5061..b23e1382 100644 --- a/modeling-cmds/src/output.rs +++ b/modeling-cmds/src/output.rs @@ -8,7 +8,7 @@ use crate::{ id::ModelingCmdId, shared::{CurveType, EntityType, ExportFile, PathCommand, Point2d, Point3d}, traits::ModelingCmdOutput, - units, EntityLinearPattern, + units, }; /// The response from the `Export` endpoint. @@ -256,6 +256,13 @@ pub struct EntityGetDistance { pub max_distance: f64, } +/// The response from the `EntityLinearPattern` command. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct EntityLinearPattern { + /// The UUIDs of the entities that were created. + pub entity_ids: Vec, +} + impl ModelingCmdOutput for Export {} impl ModelingCmdOutput for SelectWithPoint {} impl ModelingCmdOutput for HighlightSetEntity {} From b0dc640afbc1e8c9da3087b9a687aa45207ed79e Mon Sep 17 00:00:00 2001 From: gserena01 Date: Mon, 18 Dec 2023 16:27:14 -0500 Subject: [PATCH 5/6] fix typo --- modeling-cmds/src/each_cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modeling-cmds/src/each_cmd.rs b/modeling-cmds/src/each_cmd.rs index 03582208..e3673a6e 100644 --- a/modeling-cmds/src/each_cmd.rs +++ b/modeling-cmds/src/each_cmd.rs @@ -189,7 +189,7 @@ pub struct EntityGetDistance { pub distance_type: DistanceType, } -/// Create a linear patter using this entity +/// Create a linear pattern using this entity #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] pub struct EntityLinearPattern { /// ID of the entity being copied. From 315c6d819b70e71c74d285045691364e59285c0d Mon Sep 17 00:00:00 2001 From: gserena01 Date: Tue, 19 Dec 2023 11:38:25 -0500 Subject: [PATCH 6/6] clarify use cases --- modeling-cmds/src/each_cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modeling-cmds/src/each_cmd.rs b/modeling-cmds/src/each_cmd.rs index e3673a6e..b907ced9 100644 --- a/modeling-cmds/src/each_cmd.rs +++ b/modeling-cmds/src/each_cmd.rs @@ -189,7 +189,7 @@ pub struct EntityGetDistance { pub distance_type: DistanceType, } -/// Create a linear pattern using this entity +/// Create a linear pattern using this entity (currently only valid for 3D solids). #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] pub struct EntityLinearPattern { /// ID of the entity being copied.