Skip to main content

Module operation

Module operation 

Source
Expand description

What an operation is.

An operation is a unit struct implementing Operation, with an Args struct holding everything a step of it needs and a Session holding the temporary state of editing one, if it needs any. Built, a step maps

(part, args) -> part                                            apply

and edited, it shows a Form — fields, each with what setting it does, and visuals — whose fields the editor sets:

(part, args, selection)                -> form                  form
(part, args, selection, field, value)  -> args, selection       set

set is the form’s: each field is described once, with its setter.

Picking entities for a field, dragging handles, selecting visuals and dragging them are the editor’s (see crate::ui::StepEditor), the same for every operation; an operation that draws in a canvas of its own — a sketch — also takes what the pointer and the keys do beyond that (Operation::event), with a Session for what it keeps between events.

Arguments are plain design data — f64 lengths, sketches — and refer to existing entities of the part only by name, never by an internal id: an id only means something inside the one build that produced it, a name means the same thing in every build of the same program (see the crate docs). Entities a step builds on directly — a sketch’s plane, what a datum is built from — are EntityRefs.

A set of operations is an enum with one variant Name(NameArgs) per operation, implementing Operations through #[derive(Operations)]: what a program step holds, and what serializes as {"operation": "extrude", "args": {...}}.

Structs§

Aspects
Everything an entity can be used as. An entity is usually several at once: a straight edge is a line and a curve, a circular edge an arc, a curve and something round, a datum point a point and a frame, a datum frame the same.
OperationInfo
An operation of a set: how a step spells it, its short name and what it does — what an editor offers it by.

Enums§

EntityRef
Something picked in the viewport, to build on or to use.
Role
What a step needs an entity it builds on to be: what a pick looks for, and what a datum construction needs as an input.

Traits§

Operation
One kind of operation on a Part.
Operations
A set of operations, each together with its arguments: the enum a crate::Program’s steps hold.

Functions§

describe_roles
roles in words, as a requirement reads: a point or a plane.
frame_along
A right-handed orthonormal frame at origin with w along normal, and u the world axis most parallel to the plane normal to it, projected into that plane — so frames with parallel normals line up.

Derive Macros§

Operations
impl Operations and the conversions for the enum of a set of operations.