mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 18:38:28 +00:00
Prepare to support nested operations
This commit is contained in:
parent
7257090783
commit
9a2c311d18
@ -5,31 +5,33 @@ use crate::geometry::{HandleAny, Operation, Triangle, Vertex};
|
||||
#[derive(Clone)]
|
||||
pub struct OperationView {
|
||||
operation: HandleAny,
|
||||
children: Vec<Self>,
|
||||
selected: Option<usize>,
|
||||
}
|
||||
|
||||
impl OperationView {
|
||||
pub fn new(operation: HandleAny) -> Self {
|
||||
let children = operation
|
||||
.children()
|
||||
.into_iter()
|
||||
.map(|op| Self::new(HandleAny::new(op)))
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
operation,
|
||||
children,
|
||||
selected: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn operations(&self) -> Vec<(Self, bool, usize)> {
|
||||
iter::once((self.clone(), true, 0))
|
||||
.chain(self.operation.children().into_iter().enumerate().map(
|
||||
|(i, op)| {
|
||||
(
|
||||
OperationView {
|
||||
operation: op,
|
||||
selected: None,
|
||||
},
|
||||
Some(i) == self.selected,
|
||||
1,
|
||||
.chain(
|
||||
self.children
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, op)| (op.clone(), Some(i) == self.selected, 1)),
|
||||
)
|
||||
},
|
||||
))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user