mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-13 14:28:27 +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)]
|
#[derive(Clone)]
|
||||||
pub struct OperationView {
|
pub struct OperationView {
|
||||||
operation: HandleAny,
|
operation: HandleAny,
|
||||||
|
children: Vec<Self>,
|
||||||
selected: Option<usize>,
|
selected: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OperationView {
|
impl OperationView {
|
||||||
pub fn new(operation: HandleAny) -> Self {
|
pub fn new(operation: HandleAny) -> Self {
|
||||||
|
let children = operation
|
||||||
|
.children()
|
||||||
|
.into_iter()
|
||||||
|
.map(|op| Self::new(HandleAny::new(op)))
|
||||||
|
.collect();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
operation,
|
operation,
|
||||||
|
children,
|
||||||
selected: None,
|
selected: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn operations(&self) -> Vec<(Self, bool, usize)> {
|
pub fn operations(&self) -> Vec<(Self, bool, usize)> {
|
||||||
iter::once((self.clone(), true, 0))
|
iter::once((self.clone(), true, 0))
|
||||||
.chain(self.operation.children().into_iter().enumerate().map(
|
.chain(
|
||||||
|(i, op)| {
|
self.children
|
||||||
(
|
.iter()
|
||||||
OperationView {
|
.enumerate()
|
||||||
operation: op,
|
.map(|(i, op)| (op.clone(), Some(i) == self.selected, 1)),
|
||||||
selected: None,
|
|
||||||
},
|
|
||||||
Some(i) == self.selected,
|
|
||||||
1,
|
|
||||||
)
|
)
|
||||||
},
|
|
||||||
))
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user