Skip to content

Commit

Permalink
[DYN-2654] groups of nodes in graph should be displayed as group in t…
Browse files Browse the repository at this point in the history
…uneup list view (#51)

* temp

* temp

* temp

* mostly works

Group colors do not update
Not teste with nested groups

* works

* final

* clean

* display groups in tuneUp

* RunAll button fix
  • Loading branch information
ivaylo-matov authored Jul 26, 2024
1 parent 0d8e8d8 commit f578164
Show file tree
Hide file tree
Showing 4 changed files with 504 additions and 138 deletions.
135 changes: 114 additions & 21 deletions TuneUp/ProfiledNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Windows.Media;
using Dynamo.Core;
using Dynamo.Graph.Annotations;
using Dynamo.Graph.Nodes;

namespace TuneUp
Expand All @@ -16,6 +18,8 @@ public class ProfiledNodeViewModel : NotificationObject
/// </summary>
public static readonly string ExecutionTimelString = "Execution Time";

public static readonly string GroupNodePrefix = "Group: ";

private string name = String.Empty;
/// <summary>
/// The name of this profiled node. This value can be either an actual
Expand All @@ -27,7 +31,7 @@ public string Name
get
{
// For virtual row, do not attempt to grab node name
if (!name.Contains(ExecutionTimelString))
if (!name.Contains(ExecutionTimelString) && !name.StartsWith(GroupNodePrefix))
name = NodeModel?.Name;
return name;
}
Expand All @@ -40,10 +44,7 @@ public string Name
/// </summary>
public int? ExecutionOrderNumber
{
get
{
return executionOrderNumber;
}
get => executionOrderNumber;
set
{
executionOrderNumber = value;
Expand All @@ -52,16 +53,27 @@ public int? ExecutionOrderNumber
}
private int? executionOrderNumber;

/// <summary>
/// The order number of this group in the most recent graph run.
/// This number is assigned to each node within the group.
/// </summary>
public int? GroupExecutionOrderNumber
{
get => groupExecutionOrderNumber;
set
{
groupExecutionOrderNumber = value;
RaisePropertyChanged(nameof(GroupExecutionOrderNumber));
}
}
private int? groupExecutionOrderNumber;

/// <summary>
/// The most recent execution time of this node
/// </summary>
public TimeSpan ExecutionTime
{
get
{
return executionTime;
}
get => executionTime;
set
{
executionTime = value;
Expand All @@ -72,25 +84,33 @@ public TimeSpan ExecutionTime
private TimeSpan executionTime;

/// <summary>
/// The most recent execution time of this node in milliseconds
/// The total execution time of all node in the group.
/// </summary>
public int ExecutionMilliseconds
public TimeSpan GroupExecutionTime
{
get
get => groupExecutionTime;
set
{
return (int)Math.Round(ExecutionTime.TotalMilliseconds);
groupExecutionTime = value;
RaisePropertyChanged(nameof(GroupExecutionTime));
}
}
private TimeSpan groupExecutionTime;

/// <summary>
/// The most recent execution time of this node in milliseconds
/// </summary>
public int ExecutionMilliseconds
{
get => (int)Math.Round(ExecutionTime.TotalMilliseconds);
}

/// <summary>
/// Indicates whether this node was executed on the most recent graph run
/// </summary>
public bool WasExecutedOnLastRun
{
get
{
return wasExecutedOnLastRun;
}
get => wasExecutedOnLastRun;
set
{
wasExecutedOnLastRun = value;
Expand All @@ -104,10 +124,7 @@ public bool WasExecutedOnLastRun
/// </summary>
public ProfiledNodeState State
{
get
{
return state;
}
get => state;
set
{
state = value;
Expand All @@ -116,6 +133,67 @@ public ProfiledNodeState State
}
private ProfiledNodeState state;

/// <summary>
/// The GUID of the group to which this node belongs
/// </summary>
public Guid GroupGUID
{
get => groupGIUD;
set
{
groupGIUD = value;
RaisePropertyChanged(nameof(GroupGUID));
}
}
private Guid groupGIUD;

/// <summary>
/// The name of the group to which this node belongs
/// This property is also applied to individual nodes and is used when sorting by name
/// </summary>
public string GroupName
{
get => groupName;
set
{
groupName = value;
RaisePropertyChanged(nameof(GroupName));
}
}
private string groupName;

/// <summary>
/// Indicates if this node is a group
/// </summary>
public bool IsGroup
{
get => isGroup;
set
{
isGroup = value;
RaisePropertyChanged(nameof(IsGroup));
}
}
private bool isGroup;

/// <summary>
/// The background brush for this node
/// If this node represents a group, it inherits the background color from the associated AnnotationModel
/// </summary>
public SolidColorBrush BackgroundBrush
{
get => backgroundBrush;
set
{
if (value != null)
{
backgroundBrush = value;
RaisePropertyChanged(nameof(BackgroundBrush));
}
}
}
private SolidColorBrush backgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#333333"));

/// <summary>
/// Return the display name of state enum.
/// Making this identical property because of datagrid binding
Expand Down Expand Up @@ -165,5 +243,20 @@ public ProfiledNodeViewModel(string name, TimeSpan exTimeSum, ProfiledNodeState
this.ExecutionTime = exTimeSum;
State = state;
}

/// <summary>
/// An alternative constructor to represent an annotation model as a group node.
/// </summary>
/// <param name="group">the annotation model</param>
public ProfiledNodeViewModel(AnnotationModel group)
{
NodeModel = null;
Name = $"{GroupNodePrefix}{group.AnnotationText}";
GroupName = group.AnnotationText;
GroupGUID = group.GUID;
BackgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(group.Background));
IsGroup = true;
State = ProfiledNodeState.NotExecuted;
}
}
}
Loading

0 comments on commit f578164

Please sign in to comment.