Skip to content

Commit a292c5a

Browse files
committed
Commented out render output click targets/footprints
1 parent 8c08ce5 commit a292c5a

File tree

9 files changed

+208
-85
lines changed

9 files changed

+208
-85
lines changed

editor/src/messages/portfolio/document/document_message.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ pub enum DocumentMessage {
159159
UpdateUpstreamTransforms {
160160
upstream_transforms: HashMap<NodeId, (Footprint, DAffine2)>,
161161
},
162+
// UpdateClickTargets {
163+
// click_targets: HashMap<NodeId, Vec<ClickTarget>>,
164+
// },
165+
// UpdateVectorModify {
166+
// vector_modify: HashMap<NodeId, VectorData>,
167+
// },
162168
Undo,
163169
UngroupSelectedLayers,
164170
UngroupLayer {

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,26 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
10411041
responses.add(PortfolioMessage::UpdateDocumentWidgets);
10421042
}
10431043
DocumentMessage::UpdateUpstreamTransforms { upstream_transforms } => {
1044-
self.network_interface.document_metadata_mut().update_transforms(upstream_transforms);
1045-
}
1044+
self.network_interface.update_transforms(upstream_transforms);
1045+
}
1046+
// DocumentMessage::UpdateClickTargets { click_targets } => {
1047+
// // TODO: Allow non layer nodes to have click targets
1048+
// let layer_click_targets = click_targets
1049+
// .into_iter()
1050+
// .filter_map(|(node_id, click_targets)| {
1051+
// if self.network_interface.is_layer(&node_id, &[]) {
1052+
// let layer = LayerNodeIdentifier::new(node_id, &self.network_interface, &[]);
1053+
// Some((layer, click_targets))
1054+
// } else {
1055+
// None
1056+
// }
1057+
// })
1058+
// .collect();
1059+
// self.network_interface.document_metadata_mut().update_click_targets(layer_click_targets);
1060+
// }
1061+
// DocumentMessage::UpdateVectorModify { vector_modify } => {
1062+
// self.network_interface.document_metadata_mut().update_vector_modify(vector_modify);
1063+
// }
10461064
DocumentMessage::Undo => {
10471065
if self.network_interface.transaction_status() != TransactionStatus::Finished {
10481066
return;

editor/src/messages/portfolio/document/utility_types/document_metadata.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ impl DocumentMetadata {
9292
// ============================
9393

9494
impl DocumentMetadata {
95-
/// Update the cached transforms of the layers
96-
pub fn update_transforms(&mut self, new_upstream_transforms: HashMap<NodeId, (Footprint, DAffine2)>) {
97-
self.upstream_transforms = new_upstream_transforms;
98-
}
99-
10095
/// Access the cached transformation to document space from layer space
10196
pub fn transform_to_document(&self, layer: LayerNodeIdentifier) -> DAffine2 {
10297
self.document_to_viewport.inverse() * self.transform_to_viewport(layer)
@@ -140,12 +135,6 @@ impl DocumentMetadata {
140135
// ===============================
141136

142137
impl DocumentMetadata {
143-
/// Update the cached click targets and vector modify values of the layers
144-
pub fn update_from_monitor(&mut self, new_click_targets: HashMap<LayerNodeIdentifier, Vec<ClickTarget>>, new_vector_modify: HashMap<NodeId, VectorData>) {
145-
self.click_targets = new_click_targets;
146-
self.vector_modify = new_vector_modify;
147-
}
148-
149138
/// Get the bounding box of the click target of the specified layer in the specified transform space
150139
pub fn bounding_box_with_transform(&self, layer: LayerNodeIdentifier, transform: DAffine2) -> Option<[DVec2; 2]> {
151140
self.click_targets

editor/src/messages/portfolio/document/utility_types/network_interface.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use bezier_rs::Subpath;
99
use graph_craft::document::{value::TaggedValue, DocumentNode, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, OldDocumentNodeImplementation, OldNodeNetwork};
1010
use graph_craft::{concrete, Type};
1111
use graphene_std::renderer::{ClickTarget, Quad};
12-
use graphene_std::vector::{PointId, VectorModificationType};
12+
use graphene_std::transform::Footprint;
13+
use graphene_std::vector::{PointId, VectorData, VectorModificationType};
1314
use interpreted_executor::{dynamic_executor::ResolvedDocumentNodeTypes, node_registry::NODE_REGISTRY};
1415

1516
use glam::{DAffine2, DVec2, IVec2};
@@ -2447,8 +2448,7 @@ impl NodeNetworkInterface {
24472448
}
24482449

24492450
pub fn set_document_to_viewport_transform(&mut self, transform: DAffine2) {
2450-
let document_metadata = self.document_metadata_mut();
2451-
document_metadata.document_to_viewport = transform;
2451+
self.document_metadata.document_to_viewport = transform;
24522452
}
24532453

24542454
pub fn is_eligible_to_be_layer(&mut self, node_id: &NodeId, network_path: &[NodeId]) -> bool {
@@ -2787,7 +2787,7 @@ impl NodeNetworkInterface {
27872787
}
27882788

27892789
for (parent, child) in children {
2790-
parent.push_child(self.document_metadata_mut(), child);
2790+
parent.push_child(&mut self.document_metadata, child);
27912791
}
27922792

27932793
while let Some((primary_root_node_id, parent_layer_node)) = awaiting_primary_flow.pop() {
@@ -2807,7 +2807,7 @@ impl NodeNetworkInterface {
28072807
}
28082808
}
28092809
for child in children {
2810-
parent_layer_node.push_child(self.document_metadata_mut(), child);
2810+
parent_layer_node.push_child(&mut self.document_metadata, child);
28112811
}
28122812
}
28132813
}
@@ -2819,8 +2819,19 @@ impl NodeNetworkInterface {
28192819
self.document_metadata.click_targets.retain(|layer, _| self.document_metadata.structure.contains_key(layer));
28202820
}
28212821

2822-
pub fn document_metadata_mut(&mut self) -> &mut DocumentMetadata {
2823-
&mut self.document_metadata
2822+
/// Update the cached transforms of the layers
2823+
pub fn update_transforms(&mut self, new_upstream_transforms: HashMap<NodeId, (Footprint, DAffine2)>) {
2824+
self.document_metadata.upstream_transforms = new_upstream_transforms;
2825+
}
2826+
2827+
/// Update the cached click targets of the layers
2828+
pub fn update_click_targets(&mut self, new_click_targets: HashMap<LayerNodeIdentifier, Vec<ClickTarget>>) {
2829+
self.document_metadata.click_targets = new_click_targets;
2830+
}
2831+
2832+
/// Update the vector modify of the layers
2833+
pub fn update_vector_modify(&mut self, new_vector_modify: HashMap<NodeId, VectorData>) {
2834+
self.document_metadata.vector_modify = new_vector_modify;
28242835
}
28252836
}
28262837

editor/src/node_graph_executor.rs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ use graphene_std::renderer::format_transform_matrix;
2424
use graphene_std::wasm_application_io::{WasmApplicationIo, WasmEditorApi};
2525
use interpreted_executor::dynamic_executor::{DynamicExecutor, IntrospectError, ResolvedDocumentNodeTypesDelta};
2626

27+
use core::hash;
2728
use glam::{DAffine2, DVec2, UVec2};
2829
use once_cell::sync::Lazy;
2930
use spin::Mutex;
31+
use std::hash::Hash;
3032
use std::sync::mpsc::{Receiver, Sender};
3133
use std::sync::Arc;
3234

@@ -52,8 +54,6 @@ pub struct NodeRuntime {
5254
click_targets: HashMap<NodeId, Vec<ClickTarget>>,
5355
/// Vector data in Path nodes.
5456
vector_modify: HashMap<NodeId, VectorData>,
55-
/// The current upstream transforms for nodes.
56-
upstream_transforms: HashMap<NodeId, (Footprint, DAffine2)>,
5757
}
5858

5959
/// Messages passed from the editor thread to the node runtime thread.
@@ -85,7 +85,6 @@ pub struct ExecutionResponse {
8585
responses: VecDeque<FrontendMessage>,
8686
new_click_targets: HashMap<LayerNodeIdentifier, Vec<ClickTarget>>,
8787
new_vector_modify: HashMap<NodeId, VectorData>,
88-
new_upstream_transforms: HashMap<NodeId, (Footprint, DAffine2)>,
8988
transform: DAffine2,
9089
}
9190

@@ -146,7 +145,6 @@ impl NodeRuntime {
146145
thumbnail_renders: Default::default(),
147146
click_targets: HashMap::new(),
148147
vector_modify: HashMap::new(),
149-
upstream_transforms: HashMap::new(),
150148
}
151149
}
152150

@@ -228,7 +226,6 @@ impl NodeRuntime {
228226
responses,
229227
new_click_targets: self.click_targets.clone().into_iter().map(|(id, targets)| (LayerNodeIdentifier::new_unchecked(id), targets)).collect(),
230228
new_vector_modify: self.vector_modify.clone(),
231-
new_upstream_transforms: self.upstream_transforms.clone(),
232229
transform,
233230
});
234231
}
@@ -310,19 +307,19 @@ impl NodeRuntime {
310307

311308
// If this is `VectorData`, `ImageFrame`, or `GraphicElement` data:
312309
// Update the stored upstream transforms for this layer/node.
313-
if let Some(transform) = {
314-
fn try_downcast<T: Transform + 'static>(value: &dyn std::any::Any) -> Option<(Footprint, DAffine2)> {
315-
let io_data = value.downcast_ref::<IORecord<Footprint, T>>()?;
316-
let transform = io_data.output.transform();
317-
Some((io_data.input, transform))
318-
}
319-
None.or_else(|| try_downcast::<VectorData>(introspected_data.as_ref()))
320-
.or_else(|| try_downcast::<ImageFrame<Color>>(introspected_data.as_ref()))
321-
.or_else(|| try_downcast::<GraphicElement>(introspected_data.as_ref()))
322-
.or_else(|| try_downcast::<graphene_core::Artboard>(introspected_data.as_ref()))
323-
} {
324-
self.upstream_transforms.insert(parent_network_node_id, transform);
325-
}
310+
// if let Some(transform) = {
311+
// fn try_downcast<T: Transform + 'static>(value: &dyn std::any::Any) -> Option<(Footprint, DAffine2)> {
312+
// let io_data = value.downcast_ref::<IORecord<Footprint, T>>()?;
313+
// let transform = io_data.output.transform();
314+
// Some((io_data.input, transform))
315+
// }
316+
// None.or_else(|| try_downcast::<VectorData>(introspected_data.as_ref()))
317+
// .or_else(|| try_downcast::<ImageFrame<Color>>(introspected_data.as_ref()))
318+
// .or_else(|| try_downcast::<GraphicElement>(introspected_data.as_ref()))
319+
// .or_else(|| try_downcast::<graphene_core::Artboard>(introspected_data.as_ref()))
320+
// } {
321+
// self.upstream_transforms.insert(parent_network_node_id, transform);
322+
// }
326323
}
327324
}
328325

@@ -537,7 +534,7 @@ impl NodeGraphExecutor {
537534

538535
fn export(&self, node_graph_output: TaggedValue, export_config: ExportConfig, responses: &mut VecDeque<Message>) -> Result<(), String> {
539536
let TaggedValue::RenderOutput(graphene_std::wasm_application_io::RenderOutput::Svg((svg, _))) = node_graph_output else {
540-
return Err("Incorrect render type for exportign (expected RenderOutput::Svg)".to_string());
537+
return Err("Incorrect render type for exporting (expected RenderOutput::Svg)".to_string());
541538
};
542539

543540
let ExportConfig {
@@ -575,7 +572,6 @@ impl NodeGraphExecutor {
575572
new_click_targets,
576573
responses: existing_responses,
577574
new_vector_modify,
578-
new_upstream_transforms,
579575
transform,
580576
} = execution_response;
581577

@@ -585,15 +581,17 @@ impl NodeGraphExecutor {
585581
Ok(output) => output,
586582
Err(e) => {
587583
// Clear the click targets while the graph is in an un-renderable state
588-
document.network_interface.document_metadata_mut().update_from_monitor(HashMap::new(), HashMap::new());
589-
584+
// responses.add(DocumentMessage::UpdateUpstreamTransforms { upstream_transforms: HashMap::new() });
585+
// responses.add(DocumentMessage::UpdateClickTargets { click_targets: HashMap::new() });
586+
document.network_interface.update_click_targets(HashMap::new());
587+
document.network_interface.update_vector_modify(HashMap::new());
590588
return Err(format!("Node graph evaluation failed:\n{e}"));
591589
}
592590
};
593591

594592
responses.extend(existing_responses.into_iter().map(Into::into));
595-
//document.network_interface.document_metadata_mut().update_transforms(new_upstream_transforms);
596-
document.network_interface.document_metadata_mut().update_from_monitor(new_click_targets, new_vector_modify);
593+
document.network_interface.update_click_targets(new_click_targets);
594+
document.network_interface.update_vector_modify(new_vector_modify);
597595

598596
let execution_context = self.futures.remove(&execution_id).ok_or_else(|| "Invalid generation ID".to_string())?;
599597
if let Some(export_config) = execution_context.export_config {
@@ -608,7 +606,13 @@ impl NodeGraphExecutor {
608606
let type_delta = match result {
609607
Err(e) => {
610608
// Clear the click targets while the graph is in an un-renderable state
611-
document.network_interface.document_metadata_mut().update_from_monitor(HashMap::new(), HashMap::new());
609+
610+
document.network_interface.update_click_targets(HashMap::new());
611+
document.network_interface.update_vector_modify(HashMap::new());
612+
613+
// responses.add(DocumentMessage::UpdateUpstreamTransforms { upstream_transforms: HashMap::new() });
614+
// .add(DocumentMessage::UpdateClickTargets { click_targets: HashMap::new() });
615+
612616
log::trace!("{e}");
613617

614618
responses.add(NodeGraphMessage::UpdateTypes {
@@ -664,6 +668,8 @@ impl NodeGraphExecutor {
664668
responses.add(DocumentMessage::RenderScrollbars);
665669
responses.add(DocumentMessage::RenderRulers);
666670
responses.add(DocumentMessage::UpdateUpstreamTransforms { upstream_transforms: footprints });
671+
// responses.add(DocumentMessage::UpdateClickTargets { click_targets });
672+
// responses.add(DocumentMessage::UpdateVectorModify { vector_modify });
667673
responses.add(OverlaysMessage::Draw);
668674
}
669675

node-graph/gcore/src/graphic_element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl AlphaBlending {
4343
#[derive(Clone, Debug, PartialEq, DynAny, Default)]
4444
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4545
pub struct GraphicGroup {
46-
// TODO: Separate into multiple Vecs in a spread sheet format.
46+
// TODO: Convert to spread sheet format
4747
elements: Vec<(GraphicElement, Option<NodeId>)>,
4848
// TODO: Convert to Vec<DAffine2>
4949
pub transform: DAffine2,

0 commit comments

Comments
 (0)