microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.35k stars 302 forks source link

WPF Subgraph Label #313

Closed Brains closed 2 years ago

Brains commented 2 years ago

Implementation for #128, #276

Just enabled TextBlock creation for Subgraph. Only at Top position for now (better than nothing). Then fixed some overlapping issues

ghost commented 2 years ago

CLA assistant check
All CLA requirements met.

Brains commented 2 years ago

Currently, WpfApplicationSample looks so right after the launch image

No margins around subgraph labels, but dragging elements or collapse/expand fixes that instantly image

Brains commented 2 years ago

The last commit fixes no margins issues

The only problem is the edge from 58 to Inner subgraph. But noticed it is buggy in other cases as well, like dragging Inner subgraph. Anyway, dragging 58 node corrects this.

image

Brains commented 2 years ago

Collapsed Outer Subgraph image

But when collapsing Inner it crashes. However, same crash happens on master, guess not related to this PR. image

AutomaticGraphLayout.dll!Microsoft.Msagl.Routing.ShapeCreator.GetShapesOnDict(System.Collections.Generic.Dictionary<Microsoft.Msagl.Core.Layout.Node, Microsoft.Msagl.Routing.Shape> nodesToShapes, Microsoft.Msagl.Core.Layout.Cluster c) Line 51  C#
AutomaticGraphLayout.dll!Microsoft.Msagl.Routing.ShapeCreator.GetShapes(Microsoft.Msagl.Core.Layout.GeometryGraph graph) Line 31    C#
AutomaticGraphLayout.dll!Microsoft.Msagl.Routing.SplineRouter.SplineRouter(Microsoft.Msagl.Core.Layout.GeometryGraph graph, System.Collections.Generic.IEnumerable<Microsoft.Msagl.Core.Layout.Edge> edges, double tightPadding, double loosePadding, double coneAngle, Microsoft.Msagl.Core.Routing.BundlingSettings bundlingSettings) Line 128    C#
AutomaticGraphLayout.dll!Microsoft.Msagl.Miscellaneous.LayoutHelpers.RouteAndLabelEdges(Microsoft.Msagl.Core.Layout.GeometryGraph geometryGraph, Microsoft.Msagl.Core.Layout.LayoutAlgorithmSettings layoutSettings, System.Collections.Generic.IEnumerable<Microsoft.Msagl.Core.Layout.Edge> edgesToRoute, int straighLineRoutingThreshold, Microsoft.Msagl.Core.CancelToken cancelToken) Line 205 C#
AutomaticGraphLayout.dll!Microsoft.Msagl.Layout.Initial.Relayout.RunInternal() Line 89  C#
AutomaticGraphLayout.dll!Microsoft.Msagl.Core.AlgorithmBase.Run() Line 17   C#
AutomaticGraphLayout.Drawing.dll!Microsoft.Msagl.Drawing.LayoutEditor.CollapseCluster(Microsoft.Msagl.Core.Layout.Cluster cluster) Line 372 C#
AutomaticGraphLayout.Drawing.dll!Microsoft.Msagl.Drawing.LayoutEditor.RelayoutOnIsCollapsedChanged(Microsoft.Msagl.Drawing.IViewerNode iCluster) Line 306   C#
Microsoft.Msagl.WpfGraphControl.dll!Microsoft.Msagl.WpfGraphControl.VNode.InvokeIsCollapsedChanged() Line 172   C#
Microsoft.Msagl.WpfGraphControl.dll!Microsoft.Msagl.WpfGraphControl.VNode.TopMarginRectMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) Line 184 C#
Brains commented 2 years ago

Now label position depends on LgNodeInfo.LabelPlacement.

image

levnach commented 2 years ago

@Brains, thank to working on it. The crash in GetShapesOnDict can be fixed as follows: foreach (var cc in c.Clusters) { if (cc.IsCollapsed) continue; GetShapesOnDict(nodesToShapes, cc); cShape.AddChild(nodesToShapes[cc]); } But then the problems, further crashes, persist in master. I will try to work on it later. I think the pull request needs to be merged after the crashes are fixed and the edge routing works correctly.

Brains commented 2 years ago

the edge routing works correctly.

image

Fixed image

Brains commented 2 years ago

I think the pull request needs to be merged after the crashes are fixed and the edge routing works correctly.

Fixed edge routing Fixed overlap of CollapseButton in collapsed state and few minor things Seems like all issues related to this PR were resolved

But the crash really has no connection to my PR, it was there before on master. I tried to figure out why it happened but stuck completely, too complex, really no idea. Consider the PR and the crash separately please, they are not related to each other.

levnach commented 2 years ago

Thanks for the change! I will try to fix the routing bugs.

Brains commented 2 years ago

Thank you for doing this cool project