Skip to content

Commit 6213399

Browse files
QilongTangfilipeoteroZiyunShangZiyun Shang Application AdminRobertGlobant20
authored
RC2.13.1 initial cherrypicks (#12559)
* Popup aligment (#12491) * Upgrade DynamoSample rvt to 2023 after Revit DDFreeze. (#12507) Co-authored-by: Ziyun Shang Application Admin <[email protected]> * Fix collapase menu and popup position (#12501) * DYN-4252-Shadow-Under-Pointer (#12503) * DYN-4252-Shadow-Under-Pointer I had to replace the Polygon (tree points connected by 3 lines) by a Path (tree points connected by 2 lines) due that the shadow was being applied to all sides of the Polygon(triangle), then now due that is a Path with 2 lines the shadow will be applied just in two lines. I had to add a Converter so a PointCollection can be converted to a Path.Data. * DYN-4252-Shadow-Under-Pointer Code Review Fixed one comment * Update AnnotationViewModel.cs (#12537) * Update librarie.min.js (#12554) * Update AnnotationView.xaml (#12555) * [DYN-4493] fix behavior with cleanup node layout feature and groups (#12535) * Fix nested groups auto layout bug * fix collapsed groups auto layout issue * fix clean up node layout issue with collapsed groups * Update AnnotationViewModel.cs Co-authored-by: filipeotero <[email protected]> Co-authored-by: ZiyunShang <[email protected]> Co-authored-by: Ziyun Shang Application Admin <[email protected]> Co-authored-by: Roberto T <[email protected]> Co-authored-by: Sylvester Knudsen <[email protected]>
1 parent f09fdd8 commit 6213399

File tree

19 files changed

+218
-52
lines changed

19 files changed

+218
-52
lines changed
-5.76 MB
Binary file not shown.
6.18 MB
Binary file not shown.

src/DynamoCore/Graph/Annotations/AnnotationModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ protected override void DeserializeCore(XmlElement element, SaveContext context)
657657
RaisePropertyChanged("FontSize");
658658
RaisePropertyChanged("AnnotationText");
659659
RaisePropertyChanged("Nodes");
660+
this.ReportPosition();
660661
}
661662

662663
/// <summary>

src/DynamoCore/Graph/Workspaces/LayoutExtensions.cs

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
8686
{
8787
foreach (AnnotationModel group in workspace.Annotations)
8888
{
89+
// We dont care about nested groups here,
90+
// as the parent group is treated as one big
91+
// node.
92+
if (workspace.Annotations.ContainsModel(group))
93+
{
94+
continue;
95+
}
96+
8997
// Treat a group as a graph layout node/vertex
9098
combinedGraph.AddNode(group.GUID, group.Width, group.Height, group.X, group.Y,
9199
group.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
@@ -96,15 +104,15 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
96104
{
97105
if (!isGroupLayout)
98106
{
99-
AnnotationModel group = workspace.Annotations.Where(
100-
g => g.Nodes.Contains(node)).ToList().FirstOrDefault();
107+
AnnotationModel group = workspace.Annotations
108+
.Where(g => g.ContainsModel(node))
109+
.FirstOrDefault();
101110

102111
// Do not process nodes within groups
103-
if (group == null)
104-
{
105-
combinedGraph.AddNode(node.GUID, node.Width, node.Height, node.X, node.Y,
112+
if (group != null) continue;
113+
114+
combinedGraph.AddNode(node.GUID, node.Width, node.Height, node.X, node.Y,
106115
node.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
107-
}
108116
}
109117
else
110118
{
@@ -114,7 +122,7 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
114122
}
115123
}
116124

117-
///Adding all connectorPins (belonging to all connectors) as graph.nodes to the combined graph.
125+
// Adding all connectorPins (belonging to all connectors) as graph.nodes to the combined graph.
118126
foreach (ConnectorModel edge in workspace.Connectors)
119127
{
120128
foreach (var pin in edge.ConnectorPinModels)
@@ -133,10 +141,22 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
133141
if (!isGroupLayout)
134142
{
135143
AnnotationModel startGroup = null, endGroup = null;
136-
startGroup = workspace.Annotations.Where(
137-
g => g.Nodes.Contains(edge.Start.Owner)).ToList().FirstOrDefault();
138-
endGroup = workspace.Annotations.Where(
139-
g => g.Nodes.Contains(edge.End.Owner)).ToList().FirstOrDefault();
144+
145+
// To get the start/end group we first make sure
146+
// that all nested groups are filterd out as we dont
147+
// care about them. We then check if the edge
148+
// start/end owner is in either the parent or child group
149+
var groupsFiltered = workspace.Annotations.Where(g => !workspace.Annotations.ContainsModel(g));
150+
151+
startGroup = groupsFiltered
152+
.Where(g => g.ContainsModel(edge.Start.Owner) ||
153+
g.Nodes.OfType<AnnotationModel>().SelectMany(x => x.Nodes).Contains(edge.Start.Owner))
154+
.FirstOrDefault();
155+
156+
endGroup = groupsFiltered
157+
.Where(g => g.ContainsModel(edge.End.Owner) ||
158+
g.Nodes.OfType<AnnotationModel>().SelectMany(x => x.Nodes).Contains(edge.End.Owner))
159+
.FirstOrDefault();
140160

141161
// Treat a group as a node, but do not process edges within a group
142162
if (startGroup == null || endGroup == null || startGroup != endGroup)
@@ -163,13 +183,15 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
163183
// We add this note to the LinkedNotes on the
164184
// pinned node.
165185
var graphNode = combinedGraph.FindNode(note.PinnedNode.GUID);
186+
if (graphNode is null) continue;
166187
var height = note.PinnedNode.Rect.Top - note.Rect.Top;
167188
graphNode.LinkNote(note, note.Width, height);
168189
continue;
169190
}
170191

171-
AnnotationModel group = workspace.Annotations.Where(
172-
g => g.Nodes.Contains(note)).ToList().FirstOrDefault();
192+
AnnotationModel group = workspace.Annotations
193+
.Where(g => g.Nodes.Contains(note))
194+
.FirstOrDefault();
173195

174196
GraphLayout.Node nd = null;
175197

@@ -289,6 +311,7 @@ private static void RecordUndoGraphLayout(this WorkspaceModel workspace, bool is
289311
if (!isGroupLayout)
290312
{
291313
// Add all selected items to the undo recorder
314+
undoItems.AddRange(workspace.Annotations);
292315
undoItems.AddRange(workspace.Connectors.SelectMany(conn => conn.ConnectorPinModels));
293316
undoItems.AddRange(workspace.Nodes);
294317
undoItems.AddRange(workspace.Notes);
@@ -475,7 +498,13 @@ private static void SaveLayoutGraph(this WorkspaceModel workspace, List<GraphLay
475498

476499
double deltaX = n.X - group.X;
477500
double deltaY = n.Y - group.Y + graph.OffsetY;
478-
foreach (var node in group.Nodes.OfType<NodeModel>())
501+
502+
// We update the posistion of all nodes in the
503+
// parent group + all nodes in any potential
504+
// nested groups.
505+
foreach (var node in group.Nodes
506+
.OfType<NodeModel>()
507+
.Union(group.Nodes.OfType<AnnotationModel>().SelectMany(x => x.Nodes.OfType<NodeModel>())))
479508
{
480509
node.X += deltaX;
481510
node.Y += deltaY;
@@ -492,6 +521,8 @@ private static void SaveLayoutGraph(this WorkspaceModel workspace, List<GraphLay
492521
note.ReportPosition();
493522
}
494523
}
524+
525+
group.ReportPosition();
495526
}
496527
}
497528

src/DynamoCoreWpf/UI/Converters.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,4 +3294,48 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
32943294
throw new NotImplementedException();
32953295
}
32963296
}
3297+
3298+
/// <summary>
3299+
/// Converts a PointColletion to a Geometry so the points can be drawn using a Path
3300+
/// </summary>
3301+
[ValueConversion(typeof(PointCollection), typeof(Geometry))]
3302+
public class PointsToPathConverter : IValueConverter
3303+
{
3304+
#region IValueConverter Members
3305+
3306+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
3307+
{
3308+
if (value == null)
3309+
return null;
3310+
3311+
if (value.GetType() != typeof(PointCollection))
3312+
return null;
3313+
3314+
PointCollection points = (value as PointCollection);
3315+
if (points.Count > 0)
3316+
{
3317+
Point start = points[0];
3318+
List<LineSegment> segments = new List<LineSegment>();
3319+
for (int i = 1; i < points.Count; i++)
3320+
{
3321+
segments.Add(new LineSegment(points[i], true));
3322+
}
3323+
PathFigure figure = new PathFigure(start, segments, false);
3324+
PathGeometry geometry = new PathGeometry();
3325+
geometry.Figures.Add(figure);
3326+
return geometry;
3327+
}
3328+
else
3329+
{
3330+
return null;
3331+
}
3332+
}
3333+
3334+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
3335+
{
3336+
throw new NotSupportedException();
3337+
}
3338+
3339+
#endregion
3340+
}
32973341
}

src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ internal static void CollapseExpandPackage(Step stepInfo)
438438
{
439439
CurrentExecutingStep = stepInfo;
440440
var firstUIAutomation = stepInfo.UIAutomation.FirstOrDefault();
441-
if (firstUIAutomation == null) return;
441+
if (firstUIAutomation == null || firstUIAutomation.JSParameters.Count == 0) return;
442442
object[] parametersInvokeScript = new object[] { firstUIAutomation.JSFunctionName, new object[] { firstUIAutomation.JSParameters.FirstOrDefault() } };
443443
ResourceUtilities.ExecuteJSFunction(stepInfo.MainWindow, stepInfo.HostPopupInfo, parametersInvokeScript);
444444
}

src/DynamoCoreWpf/UI/GuidedTour/Step.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public enum PointerDirection { TOP_RIGHT, TOP_LEFT, BOTTOM_RIGHT, BOTTOM_LEFT, B
132132
/// </summary>
133133
public PointCollection TooltipPointerPoints { get; set; }
134134

135+
/// <summary>
136+
/// This will contains the shadow direction in degrees that will be shown in the pointer
137+
/// </summary>
138+
public double ShadowTooltipDirection { get; set; }
139+
135140
/// <summary>
136141
/// This property holds the DynamoViewModel that will be used when executing PreValidation functions
137142
/// </summary>

src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Tooltip : Step
1717
double PointerTooltipOverlap = 5;
1818
double PointerVerticalOffset;
1919
double PointerHorizontalOffset;
20+
enum SHADOW_DIRECTION { LEFT = 180, RIGHT = 0, BOTTOM = 270, TOP = 90};
2021

2122
/// <summary>
2223
/// The Tooltip constructor
@@ -71,6 +72,8 @@ private void DrawPointerDirection(PointerDirection direction)
7172

7273
pointX3 = 0;
7374
pointY3 = PointerHeight / 2 + PointerVerticalOffset;
75+
//Left Shadow
76+
ShadowTooltipDirection = (double)SHADOW_DIRECTION.LEFT;
7477

7578
}
7679
else if (direction == PointerDirection.BOTTOM_LEFT)
@@ -83,6 +86,8 @@ private void DrawPointerDirection(PointerDirection direction)
8386

8487
pointX3 = 0;
8588
pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset;
89+
//Left Shadow
90+
ShadowTooltipDirection = (double)SHADOW_DIRECTION.LEFT;
8691
}
8792
else if (direction == PointerDirection.TOP_RIGHT)
8893
{
@@ -94,6 +99,8 @@ private void DrawPointerDirection(PointerDirection direction)
9499

95100
pointX3 = realWidth;
96101
pointY3 = PointerHeight / 2 + PointerVerticalOffset;
102+
//Right Shadow
103+
ShadowTooltipDirection = (double)SHADOW_DIRECTION.RIGHT;
97104

98105
}
99106
else if (direction == PointerDirection.BOTTOM_RIGHT)
@@ -106,6 +113,8 @@ private void DrawPointerDirection(PointerDirection direction)
106113

107114
pointX3 = realWidth;
108115
pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset;
116+
//Right Shadow
117+
ShadowTooltipDirection = (double)SHADOW_DIRECTION.RIGHT;
109118
}
110119
else if (direction == PointerDirection.BOTTOM_DOWN)
111120
{
@@ -117,6 +126,8 @@ private void DrawPointerDirection(PointerDirection direction)
117126

118127
pointX3 = PointerDownWidth / 2 + PointerHorizontalOffset;
119128
pointY3 = realHeight - PointerHeight;
129+
//Bottom Shadow
130+
ShadowTooltipDirection = (double)SHADOW_DIRECTION.BOTTOM;
120131
}
121132

122133
TooltipPointerPoints = new PointCollection(new[] { new Point(pointX1, pointY1),

src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@
738738
"Name": "SubscribeNextButtonClickEvent",
739739
"Action": "execute",
740740
"JSFunctionName": "collapseExpandPackage",
741-
"JSParameters": [ "SampleLibraryUI" ],
741+
"JSParameters": [ "SampleLibraryUI", "LibraryItemText" ],
742742
"AutomaticHandlers": [
743743
{
744744
"HandlerElement": "NextButton",
@@ -795,7 +795,7 @@
795795
"Type": "tooltip",
796796
"TooltipPointerDirection": "top_left",
797797
"Width": 480,
798-
"Height": 490,
798+
"Height": 400,
799799
"ShowLibrary": true,
800800
"StepContent": {
801801
"Title": "PackagesGuidePackagesNodeTitle",
@@ -806,8 +806,8 @@
806806
"DynamicHostWindow": true,
807807
"HostUIElementString": "sidebarGrid",
808808
"WindowName": "LibraryView",
809-
"VerticalPopupOffset": 300,
810-
"HorizontalPopupOffset": 300,
809+
"VerticalPopupOffset": 450,
810+
"HorizontalPopupOffset": 320,
811811
"HtmlPage": {
812812
"FileName": "nodePackage.html",
813813
"Resources": {
@@ -830,7 +830,23 @@
830830
"Name": "InvokeJSFunction",
831831
"Action": "execute",
832832
"JSFunctionName": "collapseExpandPackage",
833-
"JSParameters": [ "Revit" ]
833+
"JSParameters": [ "SampleLibraryUI", "LibraryItemText" ]
834+
},
835+
{
836+
"Sequence": 2,
837+
"ControlType": "JSFunction",
838+
"Name": "InvokeJSFunction",
839+
"Action": "execute",
840+
"JSFunctionName": "collapseExpandPackage",
841+
"JSParameters": [ "Examples", "LibraryItemGroupText" ]
842+
},
843+
{
844+
"Sequence": 3,
845+
"ControlType": "function",
846+
"Name": "LibraryScrollToBottom",
847+
"JSFunctionName": "scrollToBottom",
848+
"JSParameters": [],
849+
"Action": "execute"
834850
}
835851
]
836852
},
@@ -853,7 +869,7 @@
853869
"HostPopupInfo": {
854870
"PopupPlacement": "center",
855871
"HostUIElementString": "WorkspaceTabs",
856-
"VerticalPopupOffset": 0
872+
"VerticalPopupOffset": 0
857873
}
858874
}
859875
]

src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4075,7 +4075,7 @@
40754075
<Setter Property="Fill" Value="{StaticResource PopupWhiteColor}" />
40764076
</Style>
40774077

4078-
<Style x:Key="PoupPolygonPointerStyle" TargetType="{x:Type Polygon}">
4078+
<Style x:Key="PoupPathPointerStyle" TargetType="{x:Type Path}">
40794079
<Setter Property="Fill" Value="{StaticResource PopupWhiteColor}" />
40804080
</Style>
40814081

src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,16 +625,24 @@ internal IEnumerable<PortModel> GetGroupInPorts(IEnumerable<NodeModel> ownerNode
625625
if (ownerNodes != null)
626626
{
627627
return ownerNodes.SelectMany(x => x.InPorts
628-
.Where(p => !p.IsConnected || !p.Connectors.Any(c => ownerNodes.Contains(c.Start.Owner)))
629-
) ;
628+
.Where(p => !p.IsConnected ||
629+
!p.Connectors.Any(c => ownerNodes.Contains(c.Start.Owner)) ||
630+
// If the port is connected to any of the groups outports
631+
// we need to return it as well
632+
p.Connectors.Any(c => outPorts.Select(m => m.PortModel).Contains(c.Start)))
633+
);
630634
}
631635

632636
// If this group does contain any AnnotationModels
633637
// we only want to get the ports where the owner does
634638
// not belong to a group.
635639
return Nodes.OfType<NodeModel>()
636640
.SelectMany(x => x.InPorts
637-
.Where(p => !p.IsConnected || !p.Connectors.Any(c => Nodes.Contains(c.Start.Owner)))
641+
.Where(p => !p.IsConnected ||
642+
!p.Connectors.Any(c => Nodes.Contains(c.Start.Owner)) ||
643+
// If the port is connected to any of the groups outports
644+
// we need to return it as well
645+
p.Connectors.Any(c => outPorts.Select(m => m.PortModel).Contains(c.Start)))
638646
);
639647
}
640648

@@ -647,7 +655,11 @@ internal IEnumerable<PortModel> GetGroupOutPorts(IEnumerable<NodeModel> ownerNod
647655
{
648656
return ownerNodes
649657
.SelectMany(x => x.OutPorts
650-
.Where(p => !p.IsConnected || !p.Connectors.Any(c => ownerNodes.Contains(c.End.Owner)))
658+
.Where(p => !p.IsConnected ||
659+
!p.Connectors.Any(c => ownerNodes.Contains(c.End.Owner)) ||
660+
// If the port is connected to any of the groups inports
661+
// we need to return it as well
662+
p.Connectors.Any(c => inPorts.Select(m => m.PortModel).Contains(c.End)))
651663
);
652664
}
653665

@@ -656,7 +668,11 @@ internal IEnumerable<PortModel> GetGroupOutPorts(IEnumerable<NodeModel> ownerNod
656668
// not belong to a group.
657669
return Nodes.OfType<NodeModel>()
658670
.SelectMany(x => x.OutPorts
659-
.Where(p => !p.IsConnected || !p.Connectors.Any(c => Nodes.Contains(c.End.Owner)))
671+
.Where(p => !p.IsConnected ||
672+
!p.Connectors.Any(c => Nodes.Contains(c.End.Owner)) ||
673+
// If the port is connected to any of the groups inports
674+
// we need to return it as well
675+
p.Connectors.Any(c => inPorts.Select(m => m.PortModel).Contains(c.End)))
660676
);
661677
}
662678

0 commit comments

Comments
 (0)