Browse Source

Added internal names to nodes

CPKreuz 1 year ago
parent
commit
4d914edcc4

+ 8 - 3
src/PixiEditor.AvaloniaUI/Models/DocumentModels/DocumentUpdater.cs

@@ -486,9 +486,14 @@ internal class DocumentUpdater
     
     
     private void ProcessCreateNode<T>(CreateNode_ChangeInfo info) where T : NodeViewModel, new()
     private void ProcessCreateNode<T>(CreateNode_ChangeInfo info) where T : NodeViewModel, new()
     {
     {
-        T node = new T() { 
-            NodeName = info.NodeName, Id = info.Id, 
-            Document = (DocumentViewModel)doc, Internals = helper };
+        T node = new T()
+        {
+            NodeName = info.NodeName,
+            InternalName = info.InternalName,
+            Id = info.Id,
+            Document = (DocumentViewModel)doc,
+            Internals = helper
+        };
 
 
         node.SetPosition(info.Position);
         node.SetPosition(info.Position);
         
         

+ 1 - 0
src/PixiEditor.AvaloniaUI/Models/Handlers/INodeHandler.cs

@@ -11,6 +11,7 @@ public interface INodeHandler : INotifyPropertyChanged
 {
 {
     public Guid Id { get; }
     public Guid Id { get; }
     public string NodeName { get; set; }
     public string NodeName { get; set; }
+    public string InternalName { get; }
     public ObservableRangeCollection<INodePropertyHandler> Inputs { get; }
     public ObservableRangeCollection<INodePropertyHandler> Inputs { get; }
     public ObservableRangeCollection<INodePropertyHandler> Outputs { get; }
     public ObservableRangeCollection<INodePropertyHandler> Outputs { get; }
     public Surface ResultPreview { get; set; }
     public Surface ResultPreview { get; set; }

+ 2 - 0
src/PixiEditor.AvaloniaUI/ViewModels/Nodes/NodeViewModel.cs

@@ -35,6 +35,8 @@ internal class NodeViewModel : ObservableObject, INodeHandler
         set => SetProperty(ref nodeName, value);
         set => SetProperty(ref nodeName, value);
     }
     }
 
 
+    public string InternalName { get; init; }
+
     public VecD PositionBindable
     public VecD PositionBindable
     {
     {
         get => position;
         get => position;

+ 4 - 3
src/PixiEditor.ChangeableDocument/ChangeInfos/NodeGraph/CreateNode_ChangeInfo.cs

@@ -6,6 +6,7 @@ using PixiEditor.Numerics;
 namespace PixiEditor.ChangeableDocument.ChangeInfos.NodeGraph;
 namespace PixiEditor.ChangeableDocument.ChangeInfos.NodeGraph;
 
 
 public record CreateNode_ChangeInfo(
 public record CreateNode_ChangeInfo(
+    string InternalName,
     string NodeName,
     string NodeName,
     VecD Position,
     VecD Position,
     Guid Id,
     Guid Id,
@@ -24,8 +25,8 @@ public record CreateNode_ChangeInfo(
     
     
     public static CreateNode_ChangeInfo CreateFromNode(IReadOnlyNode node, string name)
     public static CreateNode_ChangeInfo CreateFromNode(IReadOnlyNode node, string name)
     {
     {
-        return new CreateNode_ChangeInfo(name, node.Position, node.Id,
-            CreatePropertyInfos(node.InputProperties, true, node.Id),
-            CreatePropertyInfos(node.OutputProperties, false, node.Id));
+        return new CreateNode_ChangeInfo(node.InternalName, name, node.Position,
+            node.Id,
+            CreatePropertyInfos(node.InputProperties, true, node.Id), CreatePropertyInfos(node.OutputProperties, false, node.Id));
     }
     }
 }
 }

+ 3 - 1
src/PixiEditor.ChangeableDocument/ChangeInfos/Structure/CreateFolder_ChangeInfo.cs

@@ -8,6 +8,7 @@ namespace PixiEditor.ChangeableDocument.ChangeInfos.Structure;
 public record class CreateFolder_ChangeInfo : CreateStructureMember_ChangeInfo
 public record class CreateFolder_ChangeInfo : CreateStructureMember_ChangeInfo
 {
 {
     public CreateFolder_ChangeInfo(
     public CreateFolder_ChangeInfo(
+        string internalName,
         Guid parentGuid,
         Guid parentGuid,
         float opacity,
         float opacity,
         bool isVisible,
         bool isVisible,
@@ -19,7 +20,7 @@ public record class CreateFolder_ChangeInfo : CreateStructureMember_ChangeInfo
         bool maskIsVisible,
         bool maskIsVisible,
         ImmutableArray<NodePropertyInfo> Inputs,
         ImmutableArray<NodePropertyInfo> Inputs,
         ImmutableArray<NodePropertyInfo> Outputs
         ImmutableArray<NodePropertyInfo> Outputs
-    ) : base(parentGuid, opacity, isVisible, clipToMemberBelow, name, blendMode, guidValue, hasMask,
+    ) : base(internalName, parentGuid, opacity, isVisible, clipToMemberBelow, name, blendMode, guidValue, hasMask,
         maskIsVisible, Inputs, Outputs)
         maskIsVisible, Inputs, Outputs)
     {
     {
     }
     }
@@ -27,6 +28,7 @@ public record class CreateFolder_ChangeInfo : CreateStructureMember_ChangeInfo
     internal static CreateFolder_ChangeInfo FromFolder(Guid parentGuid, FolderNode folder)
     internal static CreateFolder_ChangeInfo FromFolder(Guid parentGuid, FolderNode folder)
     {
     {
         return new CreateFolder_ChangeInfo(
         return new CreateFolder_ChangeInfo(
+            folder.InternalName,
             parentGuid,
             parentGuid,
             folder.Opacity.Value,
             folder.Opacity.Value,
             folder.IsVisible.Value,
             folder.IsVisible.Value,

+ 3 - 1
src/PixiEditor.ChangeableDocument/ChangeInfos/Structure/CreateLayer_ChangeInfo.cs

@@ -10,6 +10,7 @@ namespace PixiEditor.ChangeableDocument.ChangeInfos.Structure;
 public record class CreateLayer_ChangeInfo : CreateStructureMember_ChangeInfo
 public record class CreateLayer_ChangeInfo : CreateStructureMember_ChangeInfo
 {
 {
     public CreateLayer_ChangeInfo(
     public CreateLayer_ChangeInfo(
+        string internalName,
         Guid parentGuid,
         Guid parentGuid,
         float opacity,
         float opacity,
         bool isVisible,
         bool isVisible,
@@ -22,7 +23,7 @@ public record class CreateLayer_ChangeInfo : CreateStructureMember_ChangeInfo
         bool lockTransparency,
         bool lockTransparency,
         ImmutableArray<NodePropertyInfo> inputs,
         ImmutableArray<NodePropertyInfo> inputs,
         ImmutableArray<NodePropertyInfo> outputs) :
         ImmutableArray<NodePropertyInfo> outputs) :
-        base(parentGuid, opacity, isVisible, clipToMemberBelow, name, blendMode, guidValue, hasMask,
+        base(internalName, parentGuid, opacity, isVisible, clipToMemberBelow, name, blendMode, guidValue, hasMask,
             maskIsVisible, inputs, outputs)
             maskIsVisible, inputs, outputs)
     {
     {
         LockTransparency = lockTransparency;
         LockTransparency = lockTransparency;
@@ -33,6 +34,7 @@ public record class CreateLayer_ChangeInfo : CreateStructureMember_ChangeInfo
     internal static CreateLayer_ChangeInfo FromLayer(Guid parentGuid, LayerNode layer)
     internal static CreateLayer_ChangeInfo FromLayer(Guid parentGuid, LayerNode layer)
     {
     {
         return new CreateLayer_ChangeInfo(
         return new CreateLayer_ChangeInfo(
+            layer.InternalName,
             parentGuid,
             parentGuid,
             layer.Opacity.Value,
             layer.Opacity.Value,
             layer.IsVisible.Value,
             layer.IsVisible.Value,

+ 2 - 1
src/PixiEditor.ChangeableDocument/ChangeInfos/Structure/CreateStructureMember_ChangeInfo.cs

@@ -7,6 +7,7 @@ using PixiEditor.Numerics;
 namespace PixiEditor.ChangeableDocument.ChangeInfos.Structure;
 namespace PixiEditor.ChangeableDocument.ChangeInfos.Structure;
 
 
 public abstract record class CreateStructureMember_ChangeInfo(
 public abstract record class CreateStructureMember_ChangeInfo(
+    string InternalName,
     Guid ParentGuid,
     Guid ParentGuid,
     float Opacity,
     float Opacity,
     bool IsVisible,
     bool IsVisible,
@@ -18,7 +19,7 @@ public abstract record class CreateStructureMember_ChangeInfo(
     bool MaskIsVisible,
     bool MaskIsVisible,
     ImmutableArray<NodePropertyInfo> InputProperties,
     ImmutableArray<NodePropertyInfo> InputProperties,
     ImmutableArray<NodePropertyInfo> OutputProperties
     ImmutableArray<NodePropertyInfo> OutputProperties
-) : CreateNode_ChangeInfo(Name, new VecD(0, 0), Id, InputProperties, OutputProperties)
+) : CreateNode_ChangeInfo(InternalName, Name, new VecD(0, 0), Id, InputProperties, OutputProperties)
 {
 {
     public ImmutableArray<NodePropertyInfo> InputProperties { get; init; } = InputProperties;
     public ImmutableArray<NodePropertyInfo> InputProperties { get; init; } = InputProperties;
     public ImmutableArray<NodePropertyInfo> OutputProperties { get; init; } = OutputProperties;
     public ImmutableArray<NodePropertyInfo> OutputProperties { get; init; } = OutputProperties;

+ 2 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Interfaces/IReadOnlyNode.cs

@@ -11,6 +11,8 @@ public interface IReadOnlyNode
     public IReadOnlyCollection<IReadOnlyNode> ConnectedOutputNodes { get; }
     public IReadOnlyCollection<IReadOnlyNode> ConnectedOutputNodes { get; }
     public VecD Position { get; }
     public VecD Position { get; }
     public IReadOnlyChunkyImage? CachedResult { get; }
     public IReadOnlyChunkyImage? CachedResult { get; }
+    
+    public string InternalName { get; }
 
 
     public IReadOnlyChunkyImage? Execute(KeyFrameTime frame);
     public IReadOnlyChunkyImage? Execute(KeyFrameTime frame);
     public bool Validate();
     public bool Validate();

+ 7 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Node.cs

@@ -20,6 +20,13 @@ public abstract class Node : IReadOnlyNode, IDisposable
     public IReadOnlyCollection<IReadOnlyNode> ConnectedOutputNodes => _connectedNodes;
     public IReadOnlyCollection<IReadOnlyNode> ConnectedOutputNodes => _connectedNodes;
     public IReadOnlyChunkyImage CachedResult { get; private set; }
     public IReadOnlyChunkyImage CachedResult { get; private set; }
 
 
+    public virtual string InternalName { get; }
+
+    protected Node()
+    {
+        InternalName = $"PixiEditor.{GetType().Name}";
+    }
+    
     IReadOnlyCollection<IInputProperty> IReadOnlyNode.InputProperties => inputs;
     IReadOnlyCollection<IInputProperty> IReadOnlyNode.InputProperties => inputs;
     IReadOnlyCollection<IOutputProperty> IReadOnlyNode.OutputProperties => outputs;
     IReadOnlyCollection<IOutputProperty> IReadOnlyNode.OutputProperties => outputs;
     public VecD Position { get; set; }
     public VecD Position { get; set; }