Skip to content

Commit

Permalink
RC2.13.1 initial cherrypicks (#12559)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
6 people authored Jan 20, 2022
1 parent f09fdd8 commit 6213399
Show file tree
Hide file tree
Showing 19 changed files with 218 additions and 52 deletions.
Binary file removed doc/distrib/Samples/Data/DynamoSample_2020.rvt
Binary file not shown.
Binary file added doc/distrib/Samples/Data/DynamoSample_2023.rvt
Binary file not shown.
1 change: 1 addition & 0 deletions src/DynamoCore/Graph/Annotations/AnnotationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ protected override void DeserializeCore(XmlElement element, SaveContext context)
RaisePropertyChanged("FontSize");
RaisePropertyChanged("AnnotationText");
RaisePropertyChanged("Nodes");
this.ReportPosition();
}

/// <summary>
Expand Down
59 changes: 45 additions & 14 deletions src/DynamoCore/Graph/Workspaces/LayoutExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
{
foreach (AnnotationModel group in workspace.Annotations)
{
// We dont care about nested groups here,
// as the parent group is treated as one big
// node.
if (workspace.Annotations.ContainsModel(group))
{
continue;
}

// Treat a group as a graph layout node/vertex
combinedGraph.AddNode(group.GUID, group.Width, group.Height, group.X, group.Y,
group.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
Expand All @@ -96,15 +104,15 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
{
if (!isGroupLayout)
{
AnnotationModel group = workspace.Annotations.Where(
g => g.Nodes.Contains(node)).ToList().FirstOrDefault();
AnnotationModel group = workspace.Annotations
.Where(g => g.ContainsModel(node))
.FirstOrDefault();

// Do not process nodes within groups
if (group == null)
{
combinedGraph.AddNode(node.GUID, node.Width, node.Height, node.X, node.Y,
if (group != null) continue;

combinedGraph.AddNode(node.GUID, node.Width, node.Height, node.X, node.Y,
node.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
}
}
else
{
Expand All @@ -114,7 +122,7 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
}
}

///Adding all connectorPins (belonging to all connectors) as graph.nodes to the combined graph.
// Adding all connectorPins (belonging to all connectors) as graph.nodes to the combined graph.
foreach (ConnectorModel edge in workspace.Connectors)
{
foreach (var pin in edge.ConnectorPinModels)
Expand All @@ -133,10 +141,22 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
if (!isGroupLayout)
{
AnnotationModel startGroup = null, endGroup = null;
startGroup = workspace.Annotations.Where(
g => g.Nodes.Contains(edge.Start.Owner)).ToList().FirstOrDefault();
endGroup = workspace.Annotations.Where(
g => g.Nodes.Contains(edge.End.Owner)).ToList().FirstOrDefault();

// To get the start/end group we first make sure
// that all nested groups are filterd out as we dont
// care about them. We then check if the edge
// start/end owner is in either the parent or child group
var groupsFiltered = workspace.Annotations.Where(g => !workspace.Annotations.ContainsModel(g));

startGroup = groupsFiltered
.Where(g => g.ContainsModel(edge.Start.Owner) ||
g.Nodes.OfType<AnnotationModel>().SelectMany(x => x.Nodes).Contains(edge.Start.Owner))
.FirstOrDefault();

endGroup = groupsFiltered
.Where(g => g.ContainsModel(edge.End.Owner) ||
g.Nodes.OfType<AnnotationModel>().SelectMany(x => x.Nodes).Contains(edge.End.Owner))
.FirstOrDefault();

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

AnnotationModel group = workspace.Annotations.Where(
g => g.Nodes.Contains(note)).ToList().FirstOrDefault();
AnnotationModel group = workspace.Annotations
.Where(g => g.Nodes.Contains(note))
.FirstOrDefault();

GraphLayout.Node nd = null;

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

double deltaX = n.X - group.X;
double deltaY = n.Y - group.Y + graph.OffsetY;
foreach (var node in group.Nodes.OfType<NodeModel>())

// We update the posistion of all nodes in the
// parent group + all nodes in any potential
// nested groups.
foreach (var node in group.Nodes
.OfType<NodeModel>()
.Union(group.Nodes.OfType<AnnotationModel>().SelectMany(x => x.Nodes.OfType<NodeModel>())))
{
node.X += deltaX;
node.Y += deltaY;
Expand All @@ -492,6 +521,8 @@ private static void SaveLayoutGraph(this WorkspaceModel workspace, List<GraphLay
note.ReportPosition();
}
}

group.ReportPosition();
}
}

Expand Down
44 changes: 44 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3294,4 +3294,48 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
throw new NotImplementedException();
}
}

/// <summary>
/// Converts a PointColletion to a Geometry so the points can be drawn using a Path
/// </summary>
[ValueConversion(typeof(PointCollection), typeof(Geometry))]
public class PointsToPathConverter : IValueConverter
{
#region IValueConverter Members

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return null;

if (value.GetType() != typeof(PointCollection))
return null;

PointCollection points = (value as PointCollection);
if (points.Count > 0)
{
Point start = points[0];
List<LineSegment> segments = new List<LineSegment>();
for (int i = 1; i < points.Count; i++)
{
segments.Add(new LineSegment(points[i], true));
}
PathFigure figure = new PathFigure(start, segments, false);
PathGeometry geometry = new PathGeometry();
geometry.Figures.Add(figure);
return geometry;
}
else
{
return null;
}
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}

#endregion
}
}
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ internal static void CollapseExpandPackage(Step stepInfo)
{
CurrentExecutingStep = stepInfo;
var firstUIAutomation = stepInfo.UIAutomation.FirstOrDefault();
if (firstUIAutomation == null) return;
if (firstUIAutomation == null || firstUIAutomation.JSParameters.Count == 0) return;
object[] parametersInvokeScript = new object[] { firstUIAutomation.JSFunctionName, new object[] { firstUIAutomation.JSParameters.FirstOrDefault() } };
ResourceUtilities.ExecuteJSFunction(stepInfo.MainWindow, stepInfo.HostPopupInfo, parametersInvokeScript);
}
Expand Down
5 changes: 5 additions & 0 deletions src/DynamoCoreWpf/UI/GuidedTour/Step.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public enum PointerDirection { TOP_RIGHT, TOP_LEFT, BOTTOM_RIGHT, BOTTOM_LEFT, B
/// </summary>
public PointCollection TooltipPointerPoints { get; set; }

/// <summary>
/// This will contains the shadow direction in degrees that will be shown in the pointer
/// </summary>
public double ShadowTooltipDirection { get; set; }

/// <summary>
/// This property holds the DynamoViewModel that will be used when executing PreValidation functions
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Tooltip : Step
double PointerTooltipOverlap = 5;
double PointerVerticalOffset;
double PointerHorizontalOffset;
enum SHADOW_DIRECTION { LEFT = 180, RIGHT = 0, BOTTOM = 270, TOP = 90};

/// <summary>
/// The Tooltip constructor
Expand Down Expand Up @@ -71,6 +72,8 @@ private void DrawPointerDirection(PointerDirection direction)

pointX3 = 0;
pointY3 = PointerHeight / 2 + PointerVerticalOffset;
//Left Shadow
ShadowTooltipDirection = (double)SHADOW_DIRECTION.LEFT;

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

pointX3 = 0;
pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset;
//Left Shadow
ShadowTooltipDirection = (double)SHADOW_DIRECTION.LEFT;
}
else if (direction == PointerDirection.TOP_RIGHT)
{
Expand All @@ -94,6 +99,8 @@ private void DrawPointerDirection(PointerDirection direction)

pointX3 = realWidth;
pointY3 = PointerHeight / 2 + PointerVerticalOffset;
//Right Shadow
ShadowTooltipDirection = (double)SHADOW_DIRECTION.RIGHT;

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

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

pointX3 = PointerDownWidth / 2 + PointerHorizontalOffset;
pointY3 = realHeight - PointerHeight;
//Bottom Shadow
ShadowTooltipDirection = (double)SHADOW_DIRECTION.BOTTOM;
}

TooltipPointerPoints = new PointCollection(new[] { new Point(pointX1, pointY1),
Expand Down
28 changes: 22 additions & 6 deletions src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@
"Name": "SubscribeNextButtonClickEvent",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSParameters": [ "SampleLibraryUI" ],
"JSParameters": [ "SampleLibraryUI", "LibraryItemText" ],
"AutomaticHandlers": [
{
"HandlerElement": "NextButton",
Expand Down Expand Up @@ -795,7 +795,7 @@
"Type": "tooltip",
"TooltipPointerDirection": "top_left",
"Width": 480,
"Height": 490,
"Height": 400,
"ShowLibrary": true,
"StepContent": {
"Title": "PackagesGuidePackagesNodeTitle",
Expand All @@ -806,8 +806,8 @@
"DynamicHostWindow": true,
"HostUIElementString": "sidebarGrid",
"WindowName": "LibraryView",
"VerticalPopupOffset": 300,
"HorizontalPopupOffset": 300,
"VerticalPopupOffset": 450,
"HorizontalPopupOffset": 320,
"HtmlPage": {
"FileName": "nodePackage.html",
"Resources": {
Expand All @@ -830,7 +830,23 @@
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSParameters": [ "Revit" ]
"JSParameters": [ "SampleLibraryUI", "LibraryItemText" ]
},
{
"Sequence": 2,
"ControlType": "JSFunction",
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSParameters": [ "Examples", "LibraryItemGroupText" ]
},
{
"Sequence": 3,
"ControlType": "function",
"Name": "LibraryScrollToBottom",
"JSFunctionName": "scrollToBottom",
"JSParameters": [],
"Action": "execute"
}
]
},
Expand All @@ -853,7 +869,7 @@
"HostPopupInfo": {
"PopupPlacement": "center",
"HostUIElementString": "WorkspaceTabs",
"VerticalPopupOffset": 0
"VerticalPopupOffset": 0
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4075,7 +4075,7 @@
<Setter Property="Fill" Value="{StaticResource PopupWhiteColor}" />
</Style>

<Style x:Key="PoupPolygonPointerStyle" TargetType="{x:Type Polygon}">
<Style x:Key="PoupPathPointerStyle" TargetType="{x:Type Path}">
<Setter Property="Fill" Value="{StaticResource PopupWhiteColor}" />
</Style>

Expand Down
26 changes: 21 additions & 5 deletions src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,16 +625,24 @@ internal IEnumerable<PortModel> GetGroupInPorts(IEnumerable<NodeModel> ownerNode
if (ownerNodes != null)
{
return ownerNodes.SelectMany(x => x.InPorts
.Where(p => !p.IsConnected || !p.Connectors.Any(c => ownerNodes.Contains(c.Start.Owner)))
) ;
.Where(p => !p.IsConnected ||
!p.Connectors.Any(c => ownerNodes.Contains(c.Start.Owner)) ||
// If the port is connected to any of the groups outports
// we need to return it as well
p.Connectors.Any(c => outPorts.Select(m => m.PortModel).Contains(c.Start)))
);
}

// If this group does contain any AnnotationModels
// we only want to get the ports where the owner does
// not belong to a group.
return Nodes.OfType<NodeModel>()
.SelectMany(x => x.InPorts
.Where(p => !p.IsConnected || !p.Connectors.Any(c => Nodes.Contains(c.Start.Owner)))
.Where(p => !p.IsConnected ||
!p.Connectors.Any(c => Nodes.Contains(c.Start.Owner)) ||
// If the port is connected to any of the groups outports
// we need to return it as well
p.Connectors.Any(c => outPorts.Select(m => m.PortModel).Contains(c.Start)))
);
}

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

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

Expand Down
Loading

0 comments on commit 6213399

Please sign in to comment.