Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR - Jira Issues: [DYN-4095] Cleanup layout rearranges pin and node #12039

Merged
merged 3 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/DynamoCore/Graph/Workspaces/LayoutExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,15 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
// Treat a group as a node, but do not process edges within a group
if (startGroup == null || endGroup == null || startGroup != endGroup)
{
AddConnectorPinEdges(combinedGraph, edge);
var startGuid = startGroup == null ? edge.Start.Owner.GUID : startGroup.GUID;
var endGuid = endGroup == null ? edge.End.Owner.GUID : endGroup.GUID;

combinedGraph.AddEdge(
startGroup == null ? edge.Start.Owner.GUID : startGroup.GUID,
endGroup == null ? edge.End.Owner.GUID : endGroup.GUID,
edge.Start.Center.X, edge.Start.Center.Y, edge.End.Center.X, edge.End.Center.Y);
AddConnectorEdgesIncludingPinEdges(combinedGraph, edge, startGuid, endGuid);
}
}
else
{
AddConnectorPinEdges(combinedGraph, edge);

// Edges within a group are also processed
combinedGraph.AddEdge(edge.Start.Owner.GUID, edge.End.Owner.GUID,
edge.Start.Center.X, edge.Start.Center.Y, edge.End.Center.X, edge.End.Center.Y);
AddConnectorEdgesIncludingPinEdges(combinedGraph, edge);
}
}

Expand Down Expand Up @@ -222,10 +216,18 @@ private static void GenerateCombinedGraph(this WorkspaceModel workspace, bool is
/// </summary>
/// <param name="combinedGraph"></param>
/// <param name="connector"></param>
private static void AddConnectorPinEdges(GraphLayout.Graph combinedGraph, ConnectorModel connector)
private static void AddConnectorEdgesIncludingPinEdges(GraphLayout.Graph combinedGraph, ConnectorModel connector, Guid? start = null, Guid? end = null)
{
///Bail if there are no connectorPins
if (connector.ConnectorPinModels.Count < 1) return;
if (connector.ConnectorPinModels.Count < 1)
{
Guid startGuid = start == null ? connector.Start.Owner.GUID : (Guid)start;
Guid endGuid = end == null ? connector.End.Owner.GUID : (Guid)end;

combinedGraph.AddEdge(startGuid, endGuid,
connector.Start.Center.X, connector.Start.Center.Y, connector.End.Center.X, connector.End.Center.Y);
return;
}

///Add an edge between the left-most (start) node
///(its corresponding port) to which this connector connects, and the first connectorPin.
Expand Down Expand Up @@ -519,10 +521,9 @@ private static void SaveLayoutGraph(this WorkspaceModel workspace, List<GraphLay
if (graph != null)
{
GraphLayout.Node n = graph.FindNode(pin.GUID);
double offsetY = graph.OffsetY;

pin.CenterX = n.X;
pin.CenterY = n.Y + offsetY - (pin.Width * 0.3);
pin.CenterY = n.Y;
pin.ReportPosition();
workspace.HasUnsavedChanges = true;
}
Expand All @@ -546,11 +547,10 @@ private static void SaveLayoutGraphForNodeAutoComplete(this WorkspaceModel works
GraphLayout.Node n = graph.FindNode(node.GUID);
double offsetY = graph.OffsetY;
//skipping the original node to avoid jumping of node
if (node.GUID != originalNodeGUID )
if (node.GUID != originalNodeGUID)
{
node.X = n.X;
node.Y = n.Y + n.NotesHeight + offsetY;

node.X = n.X;
node.Y = n.Y + n.NotesHeight + offsetY;
}
node.ReportPosition();
workspace.HasUnsavedChanges = true;
Expand Down
6 changes: 4 additions & 2 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorPinViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ public double Left
/// </summary>
public double Top
{
get { return model.Y; }
get { return model.Y- OneThirdWidth; }
M-JULIANI marked this conversation as resolved.
Show resolved Hide resolved
set
{
model.Y = value;
//Through trial and error using the OneThirdWidth value to offset the pin location works
//better than using OneHalf.
model.Y = value + OneThirdWidth;
RaisePropertyChanged(nameof(Top));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ private void BreakConnectionCommandExecute(object parameter)
{
// The deletion (and accompanying undo/redo actions) get relayed to the WorkspaceModel.
workspaceViewModel.Model.ClearConnector(ConnectorModel);
workspaceViewModel.Model.HasUnsavedChanges = true;
}
/// <summary>
/// Toggles wire viz on/off. This can be overwritten when a node is selected in hidden mode.
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/GraphLayout/GraphLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public void OrderNodes()
}
else if (n.LeftEdges.Count > 0 && AnchorRightEdges.Count == 0)
{
n.Y = prevY + 10;
n.Y = prevY;
prevY = n.Y;
layerUpdated = true;
}
Expand Down