Skip to content

Commit f31a23e

Browse files
mlfarrellalteous
andauthored
new MBD API (#946)
* add mbd feature params to API * fmt * typo * Update shared.rs * ugh * Update shared.rs * good typo bot 🐶 * get rid of "label" for now * nevermind * attempting to fix mbd symbol enum * ... * ........ * rename things * fix lints... * fix cliippy * yet another round of changes needed for CI * :| * Tweak MbdSymbol enumeration names (#950) * unit length -> cxx * Update units.rs --------- Co-authored-by: alteous <[email protected]>
1 parent caecee0 commit f31a23e

File tree

4 files changed

+278
-0
lines changed

4 files changed

+278
-0
lines changed

modeling-cmds/src/shared.rs

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ pub struct AnnotationOptions {
101101
pub color: Option<Color>,
102102
/// Position to put the annotation
103103
pub position: Option<Point3d<f32>>,
104+
/// Set as an MBD measured basic dimension annotation
105+
pub dimension: Option<AnnotationBasicDimension>,
106+
/// Set as an MBD Feature control annotation
107+
pub feature_control: Option<AnnotationFeatureControl>,
108+
/// Set as a feature tag annotation
109+
pub feature_tag: Option<AnnotationFeatureTag>,
104110
}
105111

106112
/// Options for annotation text
@@ -131,6 +137,162 @@ pub struct AnnotationTextOptions {
131137
pub point_size: u32,
132138
}
133139

140+
/// Parameters for defining an MBD Geometric control frame
141+
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
142+
#[serde(rename_all = "snake_case")]
143+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
144+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
145+
pub struct AnnotationMbdControlFrame {
146+
///Geometric symbol, the type of geometric control specified
147+
pub symbol: MbdSymbol,
148+
/// Diameter symbol (if required) whether the geometric control requires a cylindrical or diameter tolerance
149+
pub diameter_symbol: Option<MbdSymbol>,
150+
/// Tolerance value - the total tolerance of the geometric control. The unit is based on the drawing standard.
151+
pub tolerance: f64,
152+
/// Feature of size or tolerance modifiers
153+
pub modifier: Option<MbdSymbol>,
154+
/// Primary datum
155+
pub primary_datum: Option<char>,
156+
/// Secondary datum
157+
pub secondary_datum: Option<char>,
158+
/// Tertiary datum
159+
pub tertiary_datum: Option<char>,
160+
}
161+
162+
/// Parameters for defining an MBD basic dimension
163+
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
164+
#[serde(rename_all = "snake_case")]
165+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
166+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
167+
pub struct AnnotationMbdBasicDimension {
168+
/// Type of symbol to use for this dimension (if required)
169+
pub symbol: Option<MbdSymbol>,
170+
/// The explicitly defined dimension. Only required if the measurement is not automatically calculated.
171+
pub dimension: Option<f64>,
172+
/// The tolerance of the dimension
173+
pub tolerance: f64,
174+
}
175+
176+
/// Parameters for defining an MBD Basic Dimension Annotation state which is measured between two positions in 3D
177+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
178+
#[serde(rename_all = "snake_case")]
179+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
180+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
181+
pub struct AnnotationBasicDimension {
182+
/// Entity to measure the dimension from
183+
pub from_entity_id: Uuid,
184+
185+
/// Normalized position within the entity to position the dimension from
186+
pub from_entity_pos: Point2d<f64>,
187+
188+
/// Entity to measure the dimension to
189+
pub to_entity_id: Uuid,
190+
191+
/// Normalized position within the entity to position the dimension to
192+
pub to_entity_pos: Point2d<f64>,
193+
194+
/// Basic dimension parameters (symbol and tolerance)
195+
pub dimension: AnnotationMbdBasicDimension,
196+
197+
/// Orientation plane. The annotation will lie in this plane which is positioned about the leader position as its origin.
198+
pub plane_id: Uuid,
199+
200+
/// 2D Position offset of the annotation within the plane.
201+
pub offset: Point2d<f64>,
202+
203+
/// Number of decimal places to use when displaying tolerance and dimension values
204+
pub precision: u32,
205+
206+
/// The scale of the font label in 3D space
207+
pub font_scale: f32,
208+
209+
/// The point size of the fonts used to generate the annotation label. Very large values can negatively affect performance.
210+
pub font_point_size: u32,
211+
}
212+
213+
/// Parameters for defining an MBD Feature Control Annotation state
214+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
215+
#[serde(rename_all = "snake_case")]
216+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
217+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
218+
pub struct AnnotationFeatureControl {
219+
/// Entity to place the annotation leader from
220+
pub entity_id: Uuid,
221+
222+
/// Normalized position within the entity to position the annotation leader from
223+
pub entity_pos: Point2d<f64>,
224+
225+
/// Type of leader to use
226+
pub leader_type: AnnotationLineEnd,
227+
228+
/// Basic dimensions
229+
pub dimension: Option<AnnotationMbdBasicDimension>,
230+
231+
/// MBD Control frame for geometric control
232+
pub control_frame: Option<AnnotationMbdControlFrame>,
233+
234+
/// Set if this annotation is defining a datum
235+
pub defined_datum: Option<char>,
236+
237+
/// Prefix text which will appear before the basic dimension
238+
pub prefix: Option<String>,
239+
240+
/// Suffix text which will appear after the basic dimension
241+
pub suffix: Option<String>,
242+
243+
/// Orientation plane. The annotation will lie in this plane which is positioned about the leader position as its origin.
244+
pub plane_id: Uuid,
245+
246+
/// 2D Position offset of the annotation within the plane.
247+
pub offset: Point2d<f64>,
248+
249+
/// Number of decimal places to use when displaying tolerance and dimension values
250+
pub precision: u32,
251+
252+
/// The scale of the font label in 3D space
253+
pub font_scale: f32,
254+
255+
/// The point size of the fonts used to generate the annotation label. Very large values can negatively affect performance.
256+
pub font_point_size: u32,
257+
}
258+
259+
/// Parameters for defining an MBD Feature Tag Annotation state
260+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
261+
#[serde(rename_all = "snake_case")]
262+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
263+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
264+
pub struct AnnotationFeatureTag {
265+
/// Entity to place the annotation leader from
266+
pub entity_id: Uuid,
267+
268+
/// Normalized position within the entity to position the annotation leader from
269+
pub entity_pos: Point2d<f64>,
270+
271+
/// Type of leader to use
272+
pub leader_type: AnnotationLineEnd,
273+
274+
/// Tag key
275+
pub key: String,
276+
277+
/// Tag value
278+
pub value: String,
279+
280+
/// Whether or not to display the key on the annotation label
281+
pub show_key: bool,
282+
283+
/// Orientation plane. The annotation will lie in this plane which is positioned about the leader position as its origin.
284+
pub plane_id: Uuid,
285+
286+
/// 2D Position offset of the annotation within the plane.
287+
pub offset: Point2d<f64>,
288+
289+
/// The scale of the font label in 3D space
290+
pub font_scale: f32,
291+
292+
/// The point size of the fonts used to generate the annotation label. Very large values can negatively affect performance.
293+
pub font_point_size: u32,
294+
}
295+
134296
/// The type of distance
135297
/// Distances can vary depending on
136298
/// the objects used as input.
@@ -220,6 +382,7 @@ pub enum AnnotationTextAlignmentY {
220382
pub enum AnnotationLineEnd {
221383
None,
222384
Arrow,
385+
Dot,
223386
}
224387

225388
/// The type of annotation
@@ -236,6 +399,108 @@ pub enum AnnotationType {
236399
T3D,
237400
}
238401

402+
/// MBD standard
403+
#[derive(
404+
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
405+
)]
406+
#[serde(rename_all = "lowercase")]
407+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
408+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
409+
pub enum MbdStandard {
410+
/// ASME Y14.5 GD&T
411+
AsmeY14_5,
412+
}
413+
414+
//SEE MIKE BEFORE MAKING ANY CHANGES TO THIS ENUM
415+
/// MBD symbol type
416+
#[allow(missing_docs)]
417+
#[derive(
418+
Default,
419+
Display,
420+
FromStr,
421+
Copy,
422+
Eq,
423+
PartialEq,
424+
Debug,
425+
JsonSchema,
426+
Deserialize,
427+
Serialize,
428+
Sequence,
429+
Clone,
430+
Ord,
431+
PartialOrd,
432+
)]
433+
#[serde(rename_all = "lowercase")]
434+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
435+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
436+
#[repr(u16)]
437+
pub enum MbdSymbol {
438+
#[default]
439+
None = 0,
440+
ArcLength = 174,
441+
Between = 175,
442+
Degrees = 176,
443+
PlusMinus = 177,
444+
Angularity = 178,
445+
Cylindricity = 179,
446+
Roundness = 180,
447+
Concentricity = 181,
448+
Straightness = 182,
449+
Parallelism = 183,
450+
Flatness = 184,
451+
ProfileOfLine = 185,
452+
SurfaceProfile = 186,
453+
Symmetry = 187,
454+
Perpendicularity = 188,
455+
Runout = 189,
456+
TotalRunout = 190,
457+
Position = 191,
458+
CenterLine = 192,
459+
PartingLine = 193,
460+
IsoEnvelope = 195,
461+
IsoEnvelopeNonY145M = 196,
462+
FreeState = 197,
463+
StatisticalTolerance = 198,
464+
ContinuousFeature = 199,
465+
Independency = 200,
466+
Depth = 201,
467+
Start = 202,
468+
LeastCondition = 203,
469+
MaxCondition = 204,
470+
ConicalTaper = 205,
471+
Projected = 206,
472+
Slope = 207,
473+
Micro = 208,
474+
TangentPlane = 210,
475+
Unilateral = 211,
476+
SquareFeature = 212,
477+
Countersink = 213,
478+
SpotFace = 214,
479+
Target = 215,
480+
Diameter = 216,
481+
Radius = 217,
482+
SphericalRadius = 218,
483+
SphericalDiameter = 219,
484+
ControlledRadius = 220,
485+
BoxStart = 123,
486+
BoxBar = 162,
487+
BoxBarBetween = 124,
488+
LetterBackwardUnderline = 95,
489+
PunctuationBackwardUnderline = 92,
490+
ModifierBackwardUnderline = 126,
491+
NumericBackwardUnderline = 96,
492+
BoxEnd = 125,
493+
DatumUp = 166,
494+
DatumLeft = 168,
495+
DatumRight = 167,
496+
DatumDown = 165,
497+
DatumTriangle = 295,
498+
HalfSpace = 236,
499+
QuarterSpace = 237,
500+
EighthSpace = 238,
501+
ModifierSpace = 239,
502+
}
503+
239504
/// The type of camera drag interaction.
240505
#[derive(
241506
Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd,
@@ -1050,6 +1315,8 @@ impl_extern_type! {
10501315
AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"
10511316
AnnotationTextAlignmentY = "Enums::_AnnotationTextAlignmentY"
10521317
AnnotationLineEnd = "Enums::_AnnotationLineEnd"
1318+
MbdStandard = "Enums::_MBDStandard"
1319+
MbdSymbol = "Enums::_MBDSymbol"
10531320

10541321
CurveType = "Enums::_CurveType"
10551322
PathCommand = "Enums::_PathCommand"

modeling-cmds/src/units.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use parse_display_derive::{Display, FromStr};
33
use schemars::JsonSchema;
44
use serde::{Deserialize, Serialize};
55

6+
#[cfg(feature = "cxx")]
7+
use crate::impl_extern_type;
8+
69
/// The valid types of length units.
710
#[derive(
811
Default,
@@ -68,6 +71,12 @@ impl UnitLength {
6871
}
6972
}
7073

74+
#[cfg(feature = "cxx")]
75+
impl_extern_type! {
76+
[Trivial]
77+
UnitLength = "Enums::_UnitLength"
78+
}
79+
7180
/// The valid types of angle formats.
7281
#[derive(
7382
Default,

modeling-cmds/src/websocket.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pub struct ModelingCmdReq {
6969
}
7070

7171
/// The websocket messages the server receives.
72+
#[allow(clippy::large_enum_variant)]
7273
#[derive(Serialize, Deserialize, Debug, Clone)]
7374
#[cfg_attr(feature = "derive-jsonschema-on-enums", derive(schemars::JsonSchema))]
7475
#[serde(tag = "type", rename_all = "snake_case")]

modeling-session/src/actor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::RunCommandError;
2020

2121
type Result<T> = std::result::Result<T, RunCommandError>;
2222

23+
#[allow(clippy::large_enum_variant)]
2324
pub enum Request {
2425
SendModelingCmd(ModelingCmdReq, oneshot::Sender<Result<()>>),
2526
GetResponse(ModelingCmdId, oneshot::Sender<Result<OkModelingCmdResponse>>),

0 commit comments

Comments
 (0)