Skip to content

Commit

Permalink
feat: add Context::operations() to get operations
Browse files Browse the repository at this point in the history
Get operations from the current context
  • Loading branch information
tirithen committed Oct 31, 2023
1 parent 6c4bfe2 commit 0d0d77c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ impl InnerContext {
bounds
}

/// Returns all operations for this context.
pub fn operations(&self) -> Vec<Operation> {
self.operations.clone()
}

/// Converts context to G-code instructions.
pub fn to_instructions(&self) -> Result<Vec<Instruction>> {
let mut instructions = vec![];
Expand Down Expand Up @@ -309,14 +314,22 @@ impl<'a> Context<'a> {
context.z_tool_change()
}

/// Returns the bounds for the context
/// Returns the bounds for this context.
pub fn bounds(&self) -> Bounds {
let program = self.program.lock().unwrap();
let mut binding = program.contexts.lock().unwrap();
let context = binding.get_mut(&self.tool).unwrap();
context.bounds()
}

/// Returns all operations for this context.
pub fn operations(&self) -> Vec<Operation> {
let program = self.program.lock().unwrap();
let mut binding = program.contexts.lock().unwrap();
let context = binding.get_mut(&self.tool).unwrap();
context.operations()
}

/// Converts context to G-code instructions.
pub fn to_instructions(&self) -> Result<Vec<Instruction>> {
let program = self.program.lock().unwrap();
Expand Down

0 comments on commit 0d0d77c

Please sign in to comment.