Skip to content

Commit

Permalink
Merge branch 'master' into DynamoHomeAnalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang committed May 15, 2024
2 parents 61f5465 + 4fe92b9 commit 208007a
Show file tree
Hide file tree
Showing 24 changed files with 7,037 additions and 8,871 deletions.
16 changes: 15 additions & 1 deletion doc/distrib/NodeHelpFiles/CoreNodeModels.DefineData.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
## In Depth

Validates and returns data from a currently or previously connected input node.
The Define Data node validates the data type of incoming data. It can be used to ensure local data is of the desired type and is also designed to be used as an input or output node, declaring the type of data a graph expects or provides. The node supports a selection of commonly used Dynamo data types, for example 'String', 'Point', or 'Boolean'. The full list of supported data types is available in the drop-down menu of the node.

### Behavior
The node validates the data coming in from the input port based on the setting of the drop-down menu and the **List** toggle (see below for details). If the validation is successful, the output of the node is the same as the input. If the validation is not successful, the node will enter a warning state with a null output.

The node has four inputs:
- The "**>**" input - Connect to an upstream node to validate the type of its data.
- The **drop-down** menu - Shows the expected data type. When the form is unlocked, set a data type for validation. When the form is locked, the data type is chosen automatically based on incoming data. Data is valid if its type matches the shown type exactly or if its type is a child of the shown type (e.g. If the drop-down is set to "Curve", objects of type "Rectangle", "Line", etc. are valid).
- The **List** toggle - When on, the node expects incoming data to be a single flat list containing items of a valid data type (see above). When off, the node expects a single item of a valid data type.
- The **Lock** toggle - When off/unlocked, the drop-down menu and the **List** toggle controls accept user input to set the type of data expected. When on/locked, the node will validate* the incoming data, disable the controls, and set their value based on the data connected to the node's input port.

### Use as an input node
When set as an input ("Is Input" in the node's context menu) the node can optionally use upstream nodes to set the default value for the input. A run of the graph will cache the Define Data node's value for use when running the graph externally, for example with the Engine Node.

---

## Example File
In the example below, the first group of "DefineData" nodes have an unlocked UI. The node correctly validates the Number input provided while rejecting the String input. The second group contains a node with locked UI. The node automatically adjusts the drop-down and the **List** toggle to match the input, in this case a list of integers.

![Define_Data](./CoreNodeModels.DefineData_img.jpg)

4 changes: 2 additions & 2 deletions src/DynamoCore/Engine/EngineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ internal bool GenerateGraphSyncDataForCustomNode(IEnumerable<NodeModel> nodes, C
/// </summary>
/// <param name="scheduler">The scheduler on which custom node compilation
/// task can be scheduled.</param>
///
internal void ProcessPendingCustomNodeSyncData(IScheduler scheduler)
{
while (pendingCustomNodeSyncData.Count > 0)
Expand Down Expand Up @@ -438,7 +437,8 @@ private bool VerifyGraphSyncData(IEnumerable<NodeModel> nodes)

foreach (var node in nodes)
{
if (!node.IsInputNode) continue;
//Ignore inputs, nodes with input ports, and nodes derived from custom nodes.
if (!node.IsInputNode || node.InPorts.Any() || node.IsCustomFunction) continue;

// Only one or the other of the two lists, Added or Modified, will match the node GUID if they do.
bool isAdded = false;
Expand Down
18 changes: 18 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3966,6 +3966,14 @@ To make this file into a new template, save it to a different folder, then move
<data name="DynamoXmlFileFormat" xml:space="preserve">
<value>Dynamo 1.x file format</value>
</data>
<data name="DataInputNodeModeLockTooltip" xml:space="preserve">
<value>When locked, this node only accepts the selected data type as input. When unlocked, the input can be any supported data type.</value>
<comment>Tool-tip for the padlock toggle button controlling auto/manual mode.</comment>
</data>
<data name="DataInputNodeInformationTooltip" xml:space="preserve">
<value>Toggle on if the input data contains a list.</value>
<comment>Tool-tip for info questionmark icon.</comment>
</data>
<data name="MessagePackageOlderDynamo" xml:space="preserve">
<value>This package or one of its dependencies were created for a previous version of Dynamo. It may not work in this version. Do you want to continue?</value>
</data>
Expand All @@ -3975,4 +3983,4 @@ To make this file into a new template, save it to a different folder, then move
<data name="MessagePackOlderDynamoLink" xml:space="preserve">
<value>#Learn more=https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/updating-your-packages-and-dynamo-libraries-for-dynamo-3x-net8</value>
</data>
</root>
</root>
10 changes: 9 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3953,6 +3953,14 @@ To make this file into a new template, save it to a different folder, then move
<data name="DynamoXmlFileFormat" xml:space="preserve">
<value>Dynamo 1.x file format</value>
</data>
<data name="DataInputNodeModeLockTooltip" xml:space="preserve">
<value>When locked, this node only accepts the selected data type as input. When unlocked, the input can be any supported data type.</value>
<comment>Tool-tip for the padlock button controlling auto/manual mode.</comment>
</data>
<data name="DataInputNodeInformationTooltip" xml:space="preserve">
<value>Toggle on if the input data contains a list.</value>
<comment>Tool-tip for info questionmark icon next to the List toggle control.</comment>
</data>
<data name="MessagePackageOlderDynamo" xml:space="preserve">
<value>This package or one of its dependencies were created for a previous version of Dynamo. It may not work in this version. Do you want to continue?</value>
</data>
Expand All @@ -3962,4 +3970,4 @@ To make this file into a new template, save it to a different folder, then move
<data name="MessagePackOlderDynamoLink" xml:space="preserve">
<value>#Learn more=https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/updating-your-packages-and-dynamo-libraries-for-dynamo-3x-net8</value>
</data>
</root>
</root>
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4458,6 +4458,8 @@ static Dynamo.Wpf.Properties.Resources.CustomNodePropertyWindowName.get -> strin
static Dynamo.Wpf.Properties.Resources.CustomNodePropertyWindowNameHint.get -> string
static Dynamo.Wpf.Properties.Resources.CustomNodePropertyWindowTitle.get -> string
static Dynamo.Wpf.Properties.Resources.CustomNodeTypeShortString.get -> string
static Dynamo.Wpf.Properties.Resources.DataInputNodeInformationTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.DataInputNodeModeLockTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.DefaultPythonEngineNone.get -> string
static Dynamo.Wpf.Properties.Resources.DeleteFailureMessageBoxTitle.get -> string
static Dynamo.Wpf.Properties.Resources.DeprecatingPackageMessageBoxTitle.get -> string
Expand Down
15 changes: 14 additions & 1 deletion src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ internal async void LoadingDone()
var recentFiles = startPage.RecentFiles;
if (recentFiles == null || !recentFiles.Any()) { return; }

// Subscribe to the DynamoViewModel refresh file changed event in order to refresh the Recent File metadata
// There is no way to track if the metadata has changed specifically, so we refresh in any change to the recent files
startPage.DynamoViewModel.RecentFiles.CollectionChanged += RecentFiles_CollectionChanged;

LoadGraphs(recentFiles);

var userLocale = CultureInfo.CurrentCulture.Name;
Expand All @@ -263,6 +267,11 @@ internal async void LoadingDone()
}
}

private void RecentFiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
LoadGraphs(startPage.RecentFiles);
}

#region FrontEnd Initialization Calls
/// <summary>
/// Sends graph data to react app
Expand Down Expand Up @@ -494,7 +503,11 @@ internal void ApplicationLoaded()
public void Dispose()
{
DataContextChanged -= OnDataContextChanged;
if(startPage != null) startPage.DynamoViewModel.PropertyChanged -= DynamoViewModel_PropertyChanged;
if (startPage != null)
{
startPage.DynamoViewModel.PropertyChanged -= DynamoViewModel_PropertyChanged;
startPage.DynamoViewModel.RecentFiles.CollectionChanged -= RecentFiles_CollectionChanged;
}

this.dynWebView.CoreWebView2.NewWindowRequested -= CoreWebView2_NewWindowRequested;

Expand Down
Loading

0 comments on commit 208007a

Please sign in to comment.