Skip to content

Commit b2b08c5

Browse files
jesusalvinoQilongTang
authored andcommitted
Fixing Ghost warning (#13820)
* Fixing Ghost warning * Keeping the Warning Color for the new state * Adding the Unit test * Revert "Keeping the Warning Color for the new state" This reverts commit 40e9643. * Revert "Fixing Ghost warning" This reverts commit 04c14c1. * Updates, Implementation and Test
1 parent 517bd45 commit b2b08c5

File tree

3 files changed

+281
-3
lines changed

3 files changed

+281
-3
lines changed

src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,14 @@ private void Logic_NodeMessagesClearing(NodeModel obj)
893893
// 1. Compile-time warnings in CBNs
894894
// 2. Obsolete nodes with warnings
895895
// 3. Dummy or unresolved nodes
896-
if (nodeLogic.State == ElementState.Error || nodeLogic.State == ElementState.PersistentWarning || ErrorBubble == null) return;
896+
if (nodeLogic.State == ElementState.Error || nodeLogic.State == ElementState.PersistentWarning) return;
897+
898+
// For certain nodes without ErrorBubble in place, handle color overlay specifically
899+
if (ErrorBubble == null)
900+
{
901+
HandleColorOverlayChange();
902+
return;
903+
}
897904

898905
if (DynamoViewModel.UIDispatcher != null)
899906
{

test/DynamoCoreWpfTests/NodeViewTests.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
44
using System.IO;
@@ -405,6 +405,38 @@ public void ZoomChangeVisibilityTest()
405405
Assert.AreEqual(nodeViewWarningWarningFrozenHidden.nodeColorOverlayZoomOut.Visibility, System.Windows.Visibility.Collapsed);
406406
}
407407

408+
[Test]
409+
public void ZoomWarningFileFromPathTest()
410+
{
411+
// Arrange
412+
Open(@"UI\DisplayImage.dyn");
413+
414+
NodeView filePathNode = NodeViewWithGuid(Guid.Parse("5a424eaa78c84cffaef5469c034de703").ToString());
415+
NodeView fileFromPathNode = NodeViewWithGuid(Guid.Parse("eeeadd2b09294b5fbe3ea2668b99777a").ToString());
416+
NodeView imageReadFromFileNode = NodeViewWithGuid(Guid.Parse("8d82e3934d0e464cb810ddc7389ab0ae").ToString());
417+
418+
// Get a reference to the NodeViewModels and the current workspace
419+
NodeViewModel filePathNodeViewModel = filePathNode.DataContext as NodeViewModel;
420+
NodeViewModel fileFromPathNodeViewModel = (fileFromPathNode.DataContext as NodeViewModel);
421+
NodeViewModel imageReadFromFileNodeViewModel = imageReadFromFileNode.DataContext as NodeViewModel;
422+
423+
WorkspaceViewModel wvm = filePathNodeViewModel.WorkspaceViewModel as WorkspaceViewModel;
424+
425+
// Zoom out, less than 0.4
426+
wvm.Zoom = 0.3;
427+
428+
Assert.AreEqual(fileFromPathNode.nodeColorOverlayZoomOut.Visibility, System.Windows.Visibility.Visible);
429+
Assert.AreEqual(fileFromPathNode.zoomGlyphsGrid.Visibility, System.Windows.Visibility.Visible);
430+
431+
// Fix the image path and re run the engine
432+
filePathNodeViewModel.NodeModel.UpdateValue(new Dynamo.Graph.UpdateValueParams("Value", ".\\Bricks.PNG"));
433+
434+
wvm.Zoom = 0.6;
435+
436+
Assert.AreEqual(fileFromPathNode.nodeColorOverlayZoomOut.Visibility, System.Windows.Visibility.Collapsed);
437+
Assert.AreEqual(fileFromPathNode.zoomGlyphsGrid.Visibility, System.Windows.Visibility.Collapsed);
438+
}
439+
408440
/// <summary>
409441
/// Tests the GetWarningColor method to ensure that the node's WarningBar displays
410442
/// the proper colors when a node is displaying Info/Warning/Error messages.
@@ -607,4 +639,4 @@ public void TestPortDefaultValueMarket_Visibility()
607639
Assert.AreEqual(outPort_Without_Function.ValueMarkerWidth, outPort_Without_Function.ValueMarkerWidthWithoutFunction);
608640
}
609641
}
610-
}
642+
}

test/UI/DisplayImage.dyn

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
{
2+
"Uuid": "1f5822e6-f571-49f3-b3d0-1563463dd413",
3+
"IsCustomNode": false,
4+
"Description": "",
5+
"Name": "DisplayImage",
6+
"ElementResolver": {
7+
"ResolutionMap": {}
8+
},
9+
"Inputs": [],
10+
"Outputs": [],
11+
"Nodes": [
12+
{
13+
"ConcreteType": "CoreNodeModels.Input.Filename, CoreNodeModels",
14+
"Id": "5a424eaa78c84cffaef5469c034de703",
15+
"NodeType": "ExtensionNode",
16+
"Inputs": [],
17+
"Outputs": [
18+
{
19+
"Id": "9df84a67c8d847cd9c818d6f0091d009",
20+
"Name": "",
21+
"Description": "File Path",
22+
"UsingDefaultValue": false,
23+
"Level": 2,
24+
"UseLevels": false,
25+
"KeepListStructure": false
26+
}
27+
],
28+
"Replication": "Disabled",
29+
"Description": "Allows you to select a file on the system and returns its file path",
30+
"HintPath": "itdoesnotexist.PNG",
31+
"InputValue": ".\\itdoesnotexist.PNG"
32+
},
33+
{
34+
"ConcreteType": "CoreNodeModels.Input.FileObject, CoreNodeModels",
35+
"Id": "eeeadd2b09294b5fbe3ea2668b99777a",
36+
"NodeType": "ExtensionNode",
37+
"Inputs": [
38+
{
39+
"Id": "60510ef2339b432ba5b22000927716d7",
40+
"Name": "path",
41+
"Description": "Path to the file.",
42+
"UsingDefaultValue": false,
43+
"Level": 2,
44+
"UseLevels": false,
45+
"KeepListStructure": false
46+
}
47+
],
48+
"Outputs": [
49+
{
50+
"Id": "a3b7e85ec31a411abe7d95bdac28aebc",
51+
"Name": "file",
52+
"Description": "File object",
53+
"UsingDefaultValue": false,
54+
"Level": 2,
55+
"UseLevels": false,
56+
"KeepListStructure": false
57+
}
58+
],
59+
"Replication": "Disabled",
60+
"Description": "Creates a file object from the given path"
61+
},
62+
{
63+
"ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore",
64+
"Id": "8d82e3934d0e464cb810ddc7389ab0ae",
65+
"NodeType": "FunctionNode",
66+
"Inputs": [
67+
{
68+
"Id": "811aee997ed343aa858171a49bc73e3d",
69+
"Name": "file",
70+
"Description": "File object to load image from\n\nvar",
71+
"UsingDefaultValue": false,
72+
"Level": 2,
73+
"UseLevels": false,
74+
"KeepListStructure": false
75+
}
76+
],
77+
"Outputs": [
78+
{
79+
"Id": "7023d4943db8442ab181d252c7b05831",
80+
"Name": "image",
81+
"Description": "Image object from file",
82+
"UsingDefaultValue": false,
83+
"Level": 2,
84+
"UseLevels": false,
85+
"KeepListStructure": false
86+
}
87+
],
88+
"FunctionSignature": "DSCore.IO.Image.ReadFromFile@var",
89+
"Replication": "Auto",
90+
"Description": "Loads the file as a bitmap.\n\nImage.ReadFromFile (file: var): var"
91+
},
92+
{
93+
"ConcreteType": "CoreNodeModels.WatchImageCore, CoreNodeModels",
94+
"Id": "2aaf0ef3f7e04f0fb9b8b01ae48b60d6",
95+
"NodeType": "ExtensionNode",
96+
"Inputs": [
97+
{
98+
"Id": "d72318275ee84c649cc8eb450501ac5e",
99+
"Name": "image",
100+
"Description": "Image for visualization",
101+
"UsingDefaultValue": false,
102+
"Level": 2,
103+
"UseLevels": false,
104+
"KeepListStructure": false
105+
}
106+
],
107+
"Outputs": [
108+
{
109+
"Id": "238c79fd3de247ca8218a53cb2ab1cc0",
110+
"Name": "image",
111+
"Description": "Image for visualization",
112+
"UsingDefaultValue": false,
113+
"Level": 2,
114+
"UseLevels": false,
115+
"KeepListStructure": false
116+
}
117+
],
118+
"Replication": "Disabled",
119+
"Description": "Previews an image"
120+
}
121+
],
122+
"Connectors": [
123+
{
124+
"Start": "9df84a67c8d847cd9c818d6f0091d009",
125+
"End": "60510ef2339b432ba5b22000927716d7",
126+
"Id": "9fbbd1b6a983440ebbafb4bbc8a1fda3",
127+
"IsHidden": "False"
128+
},
129+
{
130+
"Start": "a3b7e85ec31a411abe7d95bdac28aebc",
131+
"End": "811aee997ed343aa858171a49bc73e3d",
132+
"Id": "038a6fed7465486a8c9b253cdb9e8b1b",
133+
"IsHidden": "False"
134+
},
135+
{
136+
"Start": "7023d4943db8442ab181d252c7b05831",
137+
"End": "d72318275ee84c649cc8eb450501ac5e",
138+
"Id": "67f785414dc74426bb8901bce334112c",
139+
"IsHidden": "False"
140+
}
141+
],
142+
"Dependencies": [],
143+
"NodeLibraryDependencies": [
144+
{
145+
"Name": "Bricks.PNG",
146+
"ReferenceType": "External",
147+
"Nodes": [
148+
"5a424eaa78c84cffaef5469c034de703"
149+
]
150+
}
151+
],
152+
"Thumbnail": "",
153+
"GraphDocumentationURL": null,
154+
"ExtensionWorkspaceData": [
155+
{
156+
"ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670",
157+
"Name": "Properties",
158+
"Version": "2.18",
159+
"Data": {}
160+
}
161+
],
162+
"Author": "",
163+
"Linting": {
164+
"activeLinter": "None",
165+
"activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a",
166+
"warningCount": 0,
167+
"errorCount": 0
168+
},
169+
"Bindings": [],
170+
"View": {
171+
"Dynamo": {
172+
"ScaleFactor": 1.0,
173+
"HasRunWithoutCrash": true,
174+
"IsVisibleInDynamoLibrary": true,
175+
"Version": "2.18.0.4326",
176+
"RunType": "Automatic",
177+
"RunPeriod": "1000"
178+
},
179+
"Camera": {
180+
"Name": "_Background Preview",
181+
"EyeX": -17.0,
182+
"EyeY": 24.0,
183+
"EyeZ": 50.0,
184+
"LookX": 12.0,
185+
"LookY": -13.0,
186+
"LookZ": -58.0,
187+
"UpX": 0.0,
188+
"UpY": 1.0,
189+
"UpZ": 0.0
190+
},
191+
"ConnectorPins": [],
192+
"NodeViews": [
193+
{
194+
"Id": "5a424eaa78c84cffaef5469c034de703",
195+
"Name": "File Path",
196+
"IsSetAsInput": false,
197+
"IsSetAsOutput": false,
198+
"Excluded": false,
199+
"ShowGeometry": true,
200+
"X": 148.5,
201+
"Y": 396.0
202+
},
203+
{
204+
"Id": "eeeadd2b09294b5fbe3ea2668b99777a",
205+
"Name": "File From Path",
206+
"IsSetAsInput": false,
207+
"IsSetAsOutput": false,
208+
"Excluded": false,
209+
"ShowGeometry": true,
210+
"X": 452.5,
211+
"Y": 394.0
212+
},
213+
{
214+
"Id": "8d82e3934d0e464cb810ddc7389ab0ae",
215+
"Name": "Image.ReadFromFile",
216+
"IsSetAsInput": false,
217+
"IsSetAsOutput": false,
218+
"Excluded": false,
219+
"ShowGeometry": true,
220+
"X": 749.5,
221+
"Y": 390.0
222+
},
223+
{
224+
"Id": "2aaf0ef3f7e04f0fb9b8b01ae48b60d6",
225+
"Name": "Watch Image",
226+
"IsSetAsInput": false,
227+
"IsSetAsOutput": false,
228+
"Excluded": false,
229+
"ShowGeometry": true,
230+
"X": 1087.5,
231+
"Y": 391.0
232+
}
233+
],
234+
"Annotations": [],
235+
"X": 677.747002299156,
236+
"Y": 207.86594408547023,
237+
"Zoom": 0.43202951305004778
238+
}
239+
}

0 commit comments

Comments
 (0)