Skip to content

Commit

Permalink
Types for linear patterns
Browse files Browse the repository at this point in the history
Co-authored-by: gserena01 <[email protected]>
Co-authored-by: Adam Chalmers <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2023
1 parent 0c10405 commit d15c461
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions modeling-cmds/src/def_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions modeling-cmds/src/each_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ pub struct EntityGetDistance {
pub distance_type: DistanceType,
}

/// 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.
pub entity_id: Uuid,
/// Axis along which to make the copites
pub axis: Point3d<f64>,
/// 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 {
Expand Down
1 change: 1 addition & 0 deletions modeling-cmds/src/impl_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl_variant_output!(EntityGetNumChildren);
impl_variant_output!(EntityGetChildUuid);
impl_variant_output!(EntityGetAllChildUuids);
impl_variant_output!(EntityGetDistance);
impl_variant_output!(EntityLinearPattern);
impl_variant_empty!(EditModeEnter);
impl_variant_output!(SelectWithPoint);
impl_variant_empty!(SelectAdd);
Expand Down
1 change: 1 addition & 0 deletions modeling-cmds/src/ok_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ build_enum! {
SelectGet,
GetEntityType,
EntityGetDistance,
EntityLinearPattern,
Solid3dGetAllEdgeFaces,
Solid3dGetAllOppositeEdges,
Solid3dGetOppositeEdge,
Expand Down
8 changes: 8 additions & 0 deletions modeling-cmds/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uuid>,
}

impl ModelingCmdOutput for Export {}
impl ModelingCmdOutput for SelectWithPoint {}
impl ModelingCmdOutput for HighlightSetEntity {}
Expand All @@ -264,6 +271,7 @@ impl ModelingCmdOutput for EntityGetNumChildren {}
impl ModelingCmdOutput for EntityGetParentId {}
impl ModelingCmdOutput for EntityGetAllChildUuids {}
impl ModelingCmdOutput for EntityGetDistance {}
impl ModelingCmdOutput for EntityLinearPattern {}
impl ModelingCmdOutput for SelectGet {}
impl ModelingCmdOutput for GetEntityType {}
impl ModelingCmdOutput for Solid3dGetAllEdgeFaces {}
Expand Down

0 comments on commit d15c461

Please sign in to comment.