to single products

This commit is contained in:
elvis
2025-12-17 18:03:35 +01:00
parent a2ca25ccd1
commit 5a2577b2bc
2 changed files with 37 additions and 6 deletions

View File

@ -308,6 +308,7 @@ pub enum NodeInstruction {
FastFrequency, FastFrequency,
OverwriteContextEntities, OverwriteContextEntities,
OverwriteReactionEntities, OverwriteReactionEntities,
ToSingleProducts,
// positive system instructions // positive system instructions
PositiveSystem, PositiveSystem,
@ -500,6 +501,7 @@ impl NodeInstruction {
| Self::SaveSvg => vec![("path", Path), ("value", Svg)], | Self::SaveSvg => vec![("path", Path), ("value", Svg)],
| Self::SaveRasterization => vec![("path", Path), ("value", Svg)], | Self::SaveRasterization => vec![("path", Path), ("value", Svg)],
| Self::ExecuteCommand => vec![("command", String), ("value", String)], | Self::ExecuteCommand => vec![("command", String), ("value", String)],
| Self::ToSingleProducts => vec![("sys", System)],
} }
.into_iter() .into_iter()
.map(|e| (e.0.to_string(), e.1)) .map(|e| (e.0.to_string(), e.1))
@ -599,6 +601,7 @@ impl NodeInstruction {
| Self::SaveSvg => vec![], | Self::SaveSvg => vec![],
| Self::SaveRasterization => vec![], | Self::SaveRasterization => vec![],
| Self::ExecuteCommand => vec![("out", String)], | Self::ExecuteCommand => vec![("out", String)],
| Self::ToSingleProducts => vec![("out", System)],
}; };
res.into_iter() res.into_iter()
.map(|res| (res.0.to_string(), res.1)) .map(|res| (res.0.to_string(), res.1))
@ -1109,6 +1112,8 @@ impl NodeTemplateTrait for NodeInstruction {
| Self::PositiveGroupFunction => "Create Grouping Function for Positive System", | Self::PositiveGroupFunction => "Create Grouping Function for Positive System",
| Self::PositiveGroupNodes => "Group Nodes of Positive System", | Self::PositiveGroupNodes => "Group Nodes of Positive System",
| Self::ExecuteCommand => "Execute Command", | Self::ExecuteCommand => "Execute Command",
| Self::ToSingleProducts => "Convert to Single Products",
}) })
} }
@ -1136,7 +1141,8 @@ impl NodeTemplateTrait for NodeInstruction {
| Self::Reactions | Self::Reactions
| Self::DecomposeSystem | Self::DecomposeSystem
| Self::OverwriteContextEntities | Self::OverwriteContextEntities
| Self::OverwriteReactionEntities => vec!["System"], | Self::OverwriteReactionEntities
| Self::ToSingleProducts => vec!["System"],
| Self::Frequency | Self::LimitFrequency | Self::FastFrequency => | Self::Frequency | Self::LimitFrequency | Self::FastFrequency =>
vec!["System", "Frequency"], vec!["System", "Frequency"],
| Self::Experiment => vec!["Frequency", "Positive Frequency"], | Self::Experiment => vec!["Frequency", "Positive Frequency"],
@ -1302,6 +1308,7 @@ impl NodeTemplateIter for AllInstructions {
NodeInstruction::SaveSvg, NodeInstruction::SaveSvg,
NodeInstruction::SaveRasterization, NodeInstruction::SaveRasterization,
NodeInstruction::ExecuteCommand, NodeInstruction::ExecuteCommand,
NodeInstruction::ToSingleProducts,
] ]
} }
} }
@ -1989,10 +1996,12 @@ impl eframe::App for AppHandle {
self.cached_last_value = None; self.cached_last_value = None;
}, },
| NodeResponse::DisconnectEvent { output: _, input } => { | NodeResponse::DisconnectEvent { output: _, input } => {
if let Some(i) = self.state.graph.try_get_input(*input) {
self.cache.invalidate_outputs( self.cache.invalidate_outputs(
&self.state.graph, &self.state.graph,
self.state.graph.get_input(*input).node i.node
); );
}
self.cache.invalidate_last_state(); self.cache.invalidate_last_state();
self.cached_last_value = None; self.cached_last_value = None;
}, },
@ -2008,6 +2017,11 @@ impl eframe::App for AppHandle {
self.cache.invalidate_last_state(); self.cache.invalidate_last_state();
self.cached_last_value = None; self.cached_last_value = None;
}, },
| NodeResponse::DeleteNodeFull { node_id: _, node } => {
for (_, output_id) in node.outputs.iter() {
self.cache.invalidate_cache(output_id);
}
},
| _ => {}, | _ => {},
} }
} }

View File

@ -2709,7 +2709,24 @@ fn process_template(
anyhow::bail!("Values of wrong type"); anyhow::bail!("Values of wrong type");
}, },
} }
},
| NodeInstruction::ToSingleProducts => {
let s = retrieve_from_cache![1];
let hash_inputs = hash_inputs!(s);
if let BasicValue::System { value } = s {
let res = BasicValue::System {
value: value.to_single_products(),
};
set_cache_output!((
output_names.first().unwrap(),
res,
hash_inputs
));
} else {
anyhow::bail!("Not a system");
} }
},
} }
Ok(None) Ok(None)
} }