static Graph CreateGraphFromParsedStuff(Dictionary <string, Tuple <int, int, int, int> > labelsToGeom, List <Tuple <string, string> > edges)
        {
            var graph = new Graph();

            foreach (var label in labelsToGeom.Keys)
            {
                graph.AddNode(label);
            }
            foreach (var tuple in edges)
            {
                var e = graph.AddEdge(tuple.Item1, tuple.Item2);
                e.Attr.ArrowheadAtTarget = ArrowStyle.None;
            }

            graph.CreateGeometryGraph();
            foreach (var node in graph.Nodes)
            {
                var tuple   = labelsToGeom[node.Id];
                int centerX = tuple.Item1;
                int centerY = tuple.Item2;
                int w       = tuple.Item3;
                int h       = tuple.Item4;

                node.GeometryNode.BoundaryCurve = new RoundedRect(
                    new Rectangle(centerX - (double)w / 2, centerY - (double)h / 2, new Microsoft.Msagl.Core.Geometry.Point(tuple.Item3, tuple.Item4)), 3, 3);
            }

            var router = new SplineRouter(graph.GeometryGraph, 1, 1, Math.PI / 6, null);

            router.Run();
            graph.GeometryGraph.UpdateBoundingBox();
            //LayoutAlgorithmSettings.ShowGraph(graph.GeometryGraph);

            return(graph);
        }
예제 #2
0
        public static void DrawCrossEdges(DGraph graph, IEnumerable <DEdge> edges)
        {
            GeometryGraph ggAux = new GeometryGraph();
            Dictionary <DNode, GeometryNode> nodeMap = new Dictionary <DNode, GeometryNode>();

            foreach (DEdge edge in edges)
            {
                if (edge.Label != null)
                {
                    edge.Label.MeasureLabel();
                }
                nodeMap[edge.Source] = null;
                nodeMap[edge.Target] = null;
            }
            FillAuxGraph(ggAux, graph, new GeometryPoint(0.0, 0.0), nodeMap);
            Dictionary <DEdge, GeometryEdge> edgeMap = new Dictionary <DEdge, GeometryEdge>();

            foreach (DEdge edge in edges)
            {
                GeometryEdge gEdge = new GeometryEdge(nodeMap[edge.Source], nodeMap[edge.Target])
                {
                    GeometryParent = ggAux
                };
                gEdge.EdgeGeometry.SourceArrowhead = edge.GeometryEdge.EdgeGeometry.SourceArrowhead;
                gEdge.EdgeGeometry.TargetArrowhead = edge.GeometryEdge.EdgeGeometry.TargetArrowhead;
                gEdge.Label   = edge.GeometryEdge.Label;
                edgeMap[edge] = gEdge;
                ggAux.Edges.Add(gEdge);
            }
            var router = new SplineRouter(ggAux, 3.0, 2.0, Math.PI / 6.0)
            {
                ContinueOnOverlaps = true
            };

            router.Run();
            foreach (DEdge edge in edges)
            {
                edge.GeometryEdge = edgeMap[edge];
                if (edge.DrawingEdge.Label != null)
                {
                    if (edge.GeometryEdge.Label.Center == new GeometryPoint())
                    {
                        edge.GeometryEdge.Label.Center = edge.GeometryEdge.BoundingBox.Center;
                    }
                    edge.DrawingEdge.Label.GeometryLabel = edge.GeometryEdge.Label;
                }
            }
            foreach (DEdge edge in edges)
            {
                edge.MakeVisual();
                Canvas.SetZIndex(edge, 20000);
                graph.MainCanvas.Children.Add(edge);
                if (edge.Label != null)
                {
                    edge.Label.MakeVisual();
                    Canvas.SetZIndex(edge.Label, 20000);
                    graph.MainCanvas.Children.Add(edge.Label);
                }
            }
        }
        public void DoubleEdge()
        {
#if TEST_MSAGL
            GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions();
#endif
            var g = new GeometryGraph();
            var a = new Node {
                BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(
                    20,
                    20,
                    3,
                    3,
                    new Point(0, 0))
            };
            g.Nodes.Add(a);
            var b = new Node {
                BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(
                    20,
                    20,
                    3,
                    3,
                    new Point(0, 200))
            };
            g.Nodes.Add(b);
            var e = new Edge(a, b);
            g.Edges.Add(e);
            e = new Edge(a, b);
            g.Edges.Add(e);
            var sr = new SplineRouter(g, 2, 4, Math.PI / 6);
            sr.Run();
#if TEST_MSAGL
//            GraphViewerGdi.DisplayGeometryGraph.ShowGraph(g);
            GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions();
#endif
        }
예제 #4
0
        void CreatClusteredLayout()
        {
            FastIncrementalLayoutSettings settings;
            Graph drawingGraph  = CtreateDrawingGraph(out settings);
            var   geometryGraph = drawingGraph.GeometryGraph;

            FillClustersAndSettings(settings, geometryGraph);
            (new InitialLayout(geometryGraph, settings)).Run();
            geometryGraph.UpdateBoundingBox();



#if DEBUG
            DisplayGeometryGraph.BindGeomGraphToDrawingGraph(drawingGraph, geometryGraph);
            drawingGraph.DebugCurves = GetClusterBounds(geometryGraph.RootCluster.Clusters).ToArray();
#endif

            //LayoutAlgorithmSettings.Show(geometryGraph.Nodes.Select(node => node.BoundaryCurve).ToArray());

            var splineRouter = new SplineRouter(geometryGraph, settings.NodeSeparation / 6, settings.NodeSeparation / 6, Math.PI / 6);
            splineRouter.Run();

            gViewer.NeedToCalculateLayout = false;
            gViewer.Graph = drawingGraph;
            gViewer.ZoomF = 1;
        }
예제 #5
0
        public void TenEdges()
        {
            //GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions();

            GeometryGraph graph = new GeometryGraph();
            var           a     = new Node {
                BoundaryCurve = CurveFactory.CreateCircle(15, new Point(65, 25)), UserData = "a",
            };

            graph.Nodes.Add(a);
            var b = new Node {
                UserData      = "b",
                BoundaryCurve = CurveFactory.CreateCircle(15, new Point(25, 25))
            };

            graph.Nodes.Add(b);
            graph.Edges.Add(new Edge(b, a));
            graph.Edges.Add(new Edge(b, a));
            for (int i = 0; i < 8; i++)
            {
                graph.Edges.Add(new Edge(a, b));
            }

            var sr = new SplineRouter(graph, 2, 1.5, Math.PI / 6, new BundlingSettings()
            {
                EdgeSeparation = 1
            });

            sr.Run();
            //GraphViewerGdi.DisplayGeometryGraph.ShowGraph(graph);
        }
        public void Clusterabc()
        {
#if TEST_MSAGL
            DisplayGeometryGraph.SetShowFunctions();
#endif
            var geometryGraph = new GeometryGraph();
            geometryGraph.RootCluster = new Cluster();
            var a = new Node();
            a.BoundaryCurve = CurveFactory.CreateCircle(20, new Point());
            var b = new Node();
            b.BoundaryCurve = CurveFactory.CreateCircle(20, new Point());
            var c = new Node();
            c.BoundaryCurve = CurveFactory.CreateCircle(20, new Point());


            geometryGraph.RootCluster.AddNode(a);
            geometryGraph.RootCluster.AddNode(b);
            geometryGraph.RootCluster.AddNode(c);
            b.AddInEdge(new Edge(a, b));
            c.AddInEdge(new Edge(a, c));
            var mdsLayoutSettings = new MdsLayoutSettings {
                RemoveOverlaps = true, NodeSeparation = 10
            };
            var mdsLayout = new MdsGraphLayout(mdsLayoutSettings, geometryGraph);
            mdsLayout.Run();
            var splineRouter = new SplineRouter(geometryGraph, geometryGraph.Edges, 2,
                                                3,
                                                Math.PI / 6, null);
            splineRouter.Run();

#if TEST_MSAGL
            DisplayGeometryGraph.ShowGraph(geometryGraph);
#endif
        }
예제 #7
0
        public static void Layout(GeometryGraph graph)
        {
            foreach (Node n in graph.Nodes)
            {
                n.BoundaryCurve = CurveFactory.CreateEllipse(20.0, 10.0, new Point());
            }
            foreach (Cluster c in graph.RootCluster.AllClustersDepthFirst())
            {
                c.BoundaryCurve = c.BoundingBox.Perimeter();
            }

            var settings = new FastIncrementalLayoutSettings();

            settings.AvoidOverlaps  = true;
            settings.NodeSeparation = 30;
            settings.RouteEdges     = true;

            LayoutHelpers.CalculateLayout(graph, settings, new CancelToken());
            foreach (Cluster c in graph.RootCluster.AllClustersDepthFirst())
            {
                c.BoundaryCurve = c.BoundingBox.Perimeter();
            }

            var bundlingsettings = new BundlingSettings()
            {
                EdgeSeparation = 5, CreateUnderlyingPolyline = true
            };
            var router = new SplineRouter(graph, 10.0, 1.25, Math.PI / 6.0, bundlingsettings);

            router.Run();

            graph.UpdateBoundingBox();
        }
예제 #8
0
        static void EdgeSeparationTrackBarValueChanged(object sender, EventArgs e)
        {
            var     edgeSeparationTruckBar = (TrackBar)sender;
            GViewer gviewer = GetGviewer(edgeSeparationTruckBar);

            Graph drawingGraph = gviewer.Graph;

            if (drawingGraph == null)
            {
                return;
            }


            EdgeRoutingSettings edgeRoutingSettings = drawingGraph.LayoutAlgorithmSettings.EdgeRoutingSettings;

            edgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling;
            if (edgeRoutingSettings.BundlingSettings == null)
            {
                edgeRoutingSettings.BundlingSettings = new BundlingSettings();
            }
            edgeRoutingSettings.BundlingSettings.EdgeSeparation = GetEdgeSeparation(edgeSeparationTruckBar);
            var br = new SplineRouter(drawingGraph.GeometryGraph, 1, 1, Math.PI / 6, edgeRoutingSettings.BundlingSettings);

            br.Run();

            IViewer iv = gviewer;

            foreach (IViewerObject edge in iv.Entities)
            {
                if (edge is IViewerEdge)
                {
                    iv.Invalidate(edge);
                }
            }
        }
        public void ComplexGeomGraph()
        {
            var graph    = GeometryGraphReader.CreateFromFile(GetGeomGraphFileName("complex.msagl.geom"));
            var settings = new BundlingSettings();
            var br       = new SplineRouter(graph, 1, 1.5, Math.PI / 6, settings);

            br.Run();
        }
        public void BundlingWithGroups()
        {
            var graph    = GeometryGraphReader.CreateFromFile(GetGeomGraphFileName("graphWithGroups.msagl.geom"));
            var settings = new BundlingSettings();
            var router   = new SplineRouter(graph, 3, 1, Math.PI / 6, settings);

            router.Run();
        }
예제 #11
0
        /// <summary>
        /// </summary>
        /// <param name="geometryGraph"></param>
        /// <param name="layoutSettings"></param>
        /// <param name="edgesToRoute"></param>
        public static void RouteAndLabelEdges(GeometryGraph geometryGraph, LayoutAlgorithmSettings layoutSettings, IEnumerable <Edge> edgesToRoute, int straighLineRoutingThreshold, CancelToken cancelToken)
        {
            //todo: what about parent edges!!!!
            var filteredEdgesToRoute =
                edgesToRoute.Where(e => !e.UnderCollapsedCluster()).ToArray();

            var ers  = layoutSettings.EdgeRoutingSettings;
            var mode = (straighLineRoutingThreshold == 0 || geometryGraph.Nodes.Count < straighLineRoutingThreshold) ? ers.EdgeRoutingMode : EdgeRoutingMode.StraightLine;

            if (mode == EdgeRoutingMode.Rectilinear ||
                mode == EdgeRoutingMode.RectilinearToCenter)
            {
                RectilinearInteractiveEditor.CreatePortsAndRouteEdges(
                    layoutSettings.NodeSeparation / 3,
                    layoutSettings.NodeSeparation / 3,
                    geometryGraph.Nodes,
                    edgesToRoute,
                    mode,
                    true,
                    ers.UseObstacleRectangles,
                    ers.BendPenalty, cancelToken);
            }
            else if (mode == EdgeRoutingMode.Spline || mode == EdgeRoutingMode.SugiyamaSplines)
            {
                new SplineRouter(geometryGraph, filteredEdgesToRoute, ers.Padding, ers.PolylinePadding, ers.ConeAngle, null)
                {
                    ContinueOnOverlaps = true,
                    KeepOriginalSpline = ers.KeepOriginalSpline
                }.Run(cancelToken);
            }
            else if (mode == EdgeRoutingMode.SplineBundling)
            {
                var edgeBundlingSettings = ers.BundlingSettings ?? new BundlingSettings();
                var bundleRouter         = new SplineRouter(geometryGraph, filteredEdgesToRoute, ers.Padding, ers.PolylinePadding, ers.ConeAngle,
                                                            edgeBundlingSettings)
                {
                    KeepOriginalSpline = ers.KeepOriginalSpline
                };
                bundleRouter.Run(cancelToken);
                if (bundleRouter.OverlapsDetected)
                {
                    new SplineRouter(geometryGraph, filteredEdgesToRoute, ers.Padding, ers.PolylinePadding, ers.ConeAngle, null)
                    {
                        ContinueOnOverlaps = true,
                        KeepOriginalSpline = ers.KeepOriginalSpline
                    }.Run(cancelToken);
                }
            }
            else if (mode == EdgeRoutingMode.StraightLine)
            {
                var router = new StraightLineEdges(filteredEdgesToRoute, ers.Padding);
                router.Run();
            }
            var elb = new EdgeLabelPlacement(geometryGraph.Nodes, filteredEdgesToRoute);

            elb.Run();
            geometryGraph.UpdateBoundingBox();
        }
예제 #12
0
        static void RouteEdges(GeometryGraph graph, double edgeSeparation)
        {
            var bs = new BundlingSettings();

            bs.EdgeSeparation = edgeSeparation;
            var br = new SplineRouter(graph, 0.25, 10, Math.PI / 6, bs);

            br.Run();
        }
예제 #13
0
        static void RouteBundledEdges(GeometryGraph geometryGraph, ArgsParser.ArgsParser argsParser)
        {
            double loosePadding;
            double tightPadding = GetPaddings(argsParser, out loosePadding);

            var br = new SplineRouter(geometryGraph, tightPadding, loosePadding, Math.PI / 6, new BundlingSettings());

            br.Run();
        }
        public void BundlingBug1GeomGraph()
        {
#if TEST_MSAGL && TEST_MSAGL
            DisplayGeometryGraph.SetShowFunctions();
#endif
            var graph    = GeometryGraphReader.CreateFromFile(GetGeomGraphFileName("bug1.msagl.geom"));
            var settings = new BundlingSettings();
            var router   = new SplineRouter(graph, 0.1, 0.75, Math.PI / 6, settings);
            router.Run();
        }
        public void RouteEdges_SplineRoutingRegressionBug20110127()
        {
            double        tightPadding = 1;
            double        loosePadding = 20;
            double        coneAngle    = Math.PI / 6;
            GeometryGraph graph        = LoadGraph("RoutingRegressionBug20110127.msagl.geom");
            SplineRouter  splineRouter = new SplineRouter(graph, tightPadding, loosePadding, coneAngle, null);

            splineRouter.Run();
            //DisplayGeometryGraph.ShowGraph(graph);
            CheckEdgesForOverlapWithNodes(tightPadding, graph);
        }
        void RunSplineRouterAndPutLabels()
        {
            var router = new SplineRouter(graph, LayoutSettings.EdgeRoutingSettings.Padding,
                                          LayoutSettings.EdgeRoutingSettings.PolylinePadding,
                                          LayoutSettings.EdgeRoutingSettings.ConeAngle,
                                          LayoutSettings.EdgeRoutingSettings.BundlingSettings);

            router.Run();
            var elp = new EdgeLabelPlacement(graph);

            elp.Run();
            UpdateGraphBoundingBoxWithCheck();
        }
        public void RouteEdges_SplineRouting1138Bus()
        {
            var g  = LoadGraph("GeometryGraph_1138bus.msagl.geom");
            var sw = new Stopwatch();

            sw.Start();
            var          loosePadding = SplineRouter.ComputeLooseSplinePadding(10, 2);
            SplineRouter splineRouter = new SplineRouter(g, 2, loosePadding, Math.PI / 6, null);

            splineRouter.Run();

            sw.Stop();
            System.Diagnostics.Debug.WriteLine("Edge routing took: {0} seconds.", sw.ElapsedMilliseconds / 1000.0);
        }
        public void OneEdgeWithTwoObstacles()
        {
#if TEST_MSAGL
            GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions();
#endif
            var g = new GeometryGraph();
            var a = new Node {
                BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(
                    20,
                    20,
                    3,
                    3,
                    new Point(0, 0))
            };
            g.Nodes.Add(a);
            var b = new Node {
                BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(
                    40,
                    20,
                    3,
                    3,
                    new Point(-10, 200))
            };
            g.Nodes.Add(b);
            var c = new Node {
                BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(
                    60,
                    20,
                    3,
                    3,
                    new Point(35, 170))
            };
            g.Nodes.Add(c);
            var d = new Node {
                BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(
                    20,
                    20,
                    3,
                    3,
                    new Point(0, 270))
            };
            g.Nodes.Add(d);
            var e = new Edge(a, d);
            g.Edges.Add(e);
            var sr = new SplineRouter(g, 2, 4, Math.PI / 6);
            sr.Run();
#if TEST_MSAGL
            GraphViewerGdi.DisplayGeometryGraph.ShowGraph(g);
#endif
        }
        public void SplineRoutingSmallCompleteGraph()
        {
            //DisplayGeometryGraph.SetShowFunctions();
            var g  = LoadGraph("K20.msagl.geom");
            var sw = new Stopwatch();

            sw.Start();
            var          loosePadding = SplineRouter.ComputeLooseSplinePadding(10, 2);
            SplineRouter splineRouter = new SplineRouter(g, 2, loosePadding, Math.PI / 6, null);

            splineRouter.Run();
            sw.Stop();
            TestContext.WriteLine("Edge routing took: {0} seconds.", sw.ElapsedMilliseconds / 1000.0);
        }
        public void SelfEdge()
        {
            var g = new GeometryGraph();
            var n = SetNode(g, "a", 10, 10);
            var e = new Edge(n, n);

            g.Edges.Add(e);
            var l = new LayeredLayout(g, new SugiyamaLayoutSettings());

            l.Run();
            g.Translate(-n.Center);
            var sr = new SplineRouter(g, 2, 4, Math.PI / 6);

            sr.Run();
        }
        public void RouteEdges_Nodes50()
        {
            var g  = LoadGraph("nodes50.msagl.geom");
            var sw = new Stopwatch();

            sw.Start();
            const double TightPadding = 2.0;
            var          loosePadding = SplineRouter.ComputeLooseSplinePadding(10, TightPadding);
            SplineRouter splineRouter = new SplineRouter(g, TightPadding, loosePadding, Math.PI / 6, null);

            splineRouter.Run();
            sw.Stop();
            System.Diagnostics.Debug.WriteLine("Edge routing took: {0} seconds.", sw.ElapsedMilliseconds / 1000.0);
            CheckEdgesForOverlapWithNodes(TightPadding, g);
        }
        static void LabelParentEdgesAndMaybeRerouteThemNicely(GeometryGraph graph, List<Edge> inParentEdges,
            List<Edge> outParentEdges, EdgeRoutingSettings edgeRoutingSettings) {
            if (AllowedToRoute(inParentEdges, outParentEdges, edgeRoutingSettings)) {
                var shapeGroupRouter = new SplineRouter(graph, edgeRoutingSettings.Padding,
                    edgeRoutingSettings.PolylinePadding,
                    edgeRoutingSettings.RoutingToParentConeAngle, inParentEdges, outParentEdges);
                shapeGroupRouter.Run();
            }

            var labeledEdges = outParentEdges.Concat(inParentEdges).Where(e => e.Labels.Any());
            if (labeledEdges.Any()) {
                var elb = new EdgeLabelPlacement(graph.Nodes, labeledEdges);
                //consider adding more nodes here: some sibling clusters maybe
                elb.Run();
            }
        }
예제 #23
0
        static void RouteEdges(GeometryGraph graph, FastIncrementalLayoutSettings settings)
        {
            if (graph.Edges.Count < 1000)
            {
                var router = new SplineRouter(graph, settings.EdgeRoutingSettings.Padding,
                                              settings.EdgeRoutingSettings.PolylinePadding,
                                              settings.EdgeRoutingSettings.ConeAngle,
                                              settings.EdgeRoutingSettings.BundlingSettings);

                router.Run();
            }
            else
            {
                var sr = new StraightLineEdges(graph.Edges, 1);
                sr.Run();
            }
        }
예제 #24
0
        static void DemoEdgeRouterHelper(GeometryGraph graph)
        {
            DemoRoutingFromPortToPort(graph);

            var router = new SplineRouter(graph, 3, 3, Math.PI / 6, null);


            router.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif

            var rectRouter = new RectilinearEdgeRouter(graph, 3, 3, true);
            rectRouter.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif
        }
        internal static void RouteEdges(GeometryGraph component, LayoutAlgorithmSettings settings, CancelToken cancelToken)
        {
            EdgeRoutingMode mode = settings.EdgeRoutingSettings.EdgeRoutingMode;

            // Use straight line routing on very large graphs otherwise it is too slow
            if (component.Nodes.Count >= 2000)
            {
                mode = EdgeRoutingMode.StraightLine;
            }

            switch (mode)
            {
            case EdgeRoutingMode.Spline:
                var splineRouter = new SplineRouter(
                    component,
                    settings.EdgeRoutingSettings.Padding,
                    settings.NodeSeparation, settings.EdgeRoutingSettings.ConeAngle, null);
                splineRouter.Run(cancelToken);
                break;

            case EdgeRoutingMode.SplineBundling:
                splineRouter = new SplineRouter(
                    component,
                    settings.EdgeRoutingSettings.Padding,
                    settings.NodeSeparation / 20, settings.EdgeRoutingSettings.ConeAngle,
                    new BundlingSettings());
                splineRouter.Run(cancelToken);
                break;

            case EdgeRoutingMode.Rectilinear:
                double edgePadding           = settings.EdgeRoutingSettings.Padding;
                double cornerRadius          = settings.EdgeRoutingSettings.CornerRadius;
                var    rectilinearEdgeRouter = new RectilinearEdgeRouter(component, edgePadding, cornerRadius,
                                                                         true);
                rectilinearEdgeRouter.Run(cancelToken);
                break;

            case EdgeRoutingMode.StraightLine:
                var router = new StraightLineEdges(component.Edges,
                                                   settings.EdgeRoutingSettings.Padding);
                router.Run(cancelToken);
                break;
            }
        }
예제 #26
0
        void RouteChangedEdges()
        {
            ChangedGraph = GetChangedFlatGraph();
            var changedClusteredGraph = LgInteractor.CreateClusteredSubgraphFromFlatGraph(ChangedGraph, graph);


            InitLabelFixtures(changedClusteredGraph);
            var router = new SplineRouter(changedClusteredGraph, layoutSettings.EdgeRoutingSettings.Padding,
                                          layoutSettings.EdgeRoutingSettings.PolylinePadding,
                                          layoutSettings.EdgeRoutingSettings.ConeAngle,
                                          layoutSettings.EdgeRoutingSettings.BundlingSettings)
            {
                ContinueOnOverlaps
                    = true
            };

            router.Run();
            PositionLabels(changedClusteredGraph);
        }
예제 #27
0
        void RouteGraphEdgesAsSplines()
        {
            var geomGraph      = gViewer.Graph.GeometryGraph;
            var layoutSettings = gViewer.Graph.LayoutAlgorithmSettings;
            EdgeRoutingSettings routingSettings = layoutSettings.EdgeRoutingSettings;

            if (routingSettings.EdgeRoutingMode == EdgeRoutingMode.StraightLine)
            {
                RouteStraightLines();
            }
            else
            if (routingSettings.EdgeRoutingMode == EdgeRoutingMode.Spline)
            {
                var coneAngle = routingSettings.ConeAngle;
                var padding   = layoutSettings.NodeSeparation * gViewer.TightOffsetForRouting * 2;
                this.currentCancelToken = new CancelToken();
                var router = new SplineRouter(geomGraph, padding, 0.65 * padding, coneAngle, null);
                router.Run(this.currentCancelToken);
            }
            else if (routingSettings.EdgeRoutingMode == EdgeRoutingMode.SplineBundling)
            {
                var coneAngle    = routingSettings.ConeAngle;
                var padding      = layoutSettings.NodeSeparation / 3;
                var loosePadding = SplineRouter.ComputeLooseSplinePadding(layoutSettings.NodeSeparation, padding);
                if (layoutSettings.EdgeRoutingSettings.BundlingSettings == null)
                {
                    layoutSettings.EdgeRoutingSettings.BundlingSettings = new BundlingSettings();
                }
                var br = new SplineRouter(geomGraph, padding, loosePadding, coneAngle, layoutSettings.EdgeRoutingSettings.BundlingSettings);
                br.Run();
            }
            else
            {
                MessageBox.Show(String.Format("Mode {0} is not supported with this settings",
                                              routingSettings.EdgeRoutingMode));
                return;
            }

            new EdgeLabelPlacement(geomGraph).Run();

            InvalidateEdges();
        }
예제 #28
0
        static void LabelParentEdgesAndMaybeRerouteThemNicely(GeometryGraph graph, List <Edge> inParentEdges,
                                                              List <Edge> outParentEdges, EdgeRoutingSettings edgeRoutingSettings)
        {
            if (AllowedToRoute(inParentEdges, outParentEdges, edgeRoutingSettings))
            {
                var shapeGroupRouter = new SplineRouter(graph, edgeRoutingSettings.Padding,
                                                        edgeRoutingSettings.PolylinePadding,
                                                        edgeRoutingSettings.RoutingToParentConeAngle, inParentEdges, outParentEdges);
                shapeGroupRouter.Run();
            }

            var labeledEdges = outParentEdges.Concat(inParentEdges).Where(e => e.Labels.Any());

            if (labeledEdges.Any())
            {
                var elb = new EdgeLabelPlacement(graph.Nodes, labeledEdges);
                //consider adding more nodes here: some sibling clusters maybe
                elb.Run();
            }

            /*//*************debug code start
             * var parentEdges = inParentEdges.Concat(outParentEdges);
             * var ll = new List<DebugCurve>();
             * var marked = new Microsoft.Msagl.Core.DataStructures.Set<Node>();
             * foreach (var e in parentEdges) {
             *  marked.Insert(e.Source);
             *  marked.Insert(e.Target);
             *  ll.Add(new DebugCurve(100, 1, "blue", e.Curve));
             * }
             * foreach (var c in graph.RootCluster.AllClustersDepthFirst()) {
             *  var color = marked.Contains(c) ? "red" : "green";
             *  ll.Add(new DebugCurve(100, 1, color, c.BoundaryCurve));
             * }
             * foreach (var c in graph.Nodes) {
             *  var color = marked.Contains(c) ? "red" : "green";
             *  ll.Add(new DebugCurve(100, 1, color, c.BoundaryCurve));
             * }
             *
             * LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(ll);
             */
            //*************debug code end
        }
예제 #29
0
        static void RouteEdges(LgLayoutSettings lgLayoutSettings,
                               GeometryGraph tmpGraphForRouting,
                               LgData lgData,
                               LgLevel level)
        {
            int routedEdges = 0;

            Console.WriteLine("\nrouting for level {0}", level.ZoomLevel);
            var router = new SplineRouter(tmpGraphForRouting, lgLayoutSettings.EdgeRoutingSettings.Padding,
                                          lgLayoutSettings.EdgeRoutingSettings.PolylinePadding, Math.PI / 6,
                                          null)
            {
                RouteMultiEdgesAsBundles     = false,
                UseEdgeLengthMultiplier      = true,
                UsePolylineEndShortcutting   = false,
                UseInnerPolylingShortcutting = false,
                // LineSweeperPorts = GetLineSweeperPorts(tmpGraphForRouting, tileSize),
                AllowedShootingStraightLines = false,
                ContinueOnOverlaps           = true,
                CacheCornersForSmoothing     = true,
                ReplaceEdgeByRails           =
                    e => {
                    routedEdges++;
                    if (routedEdges % 1000 == 0)
                    {
                        Console.Write(".");
                    }
                    level.RegisterRailsOfEdge(lgData.GeometryEdgesToLgEdgeInfos[e]);
                },
                Bidirectional = true
            };    //new BundlingSettings {KeepOverlaps = true, EdgeSeparation = 0, StopAfterShortestPaths = true});

            router.Run();
            level.CreateRailTree();
            foreach (var edge in tmpGraphForRouting.Edges)
            {
                level.FillRailDictionaryForEdge(edge);
                edge.Curve = null;
            }
            // level.RunLevelStatistics(lgData.GeometryNodesToLgNodeInfos.Where(e=>e.Value.ZoomLevel<=level.ZoomLevel).Select(p=>p.Key));
        }
예제 #30
0
        static void DemoEdgeRouterHelper(GeometryGraph graph)
        {
            DemoRoutingFromPortToPort(graph);

            var bundlingSettings = new BundlingSettings();
            // set bundling settings to null to disable the bundling of the edges

            var router = new SplineRouter(graph, 3, 3, Math.PI / 6, bundlingSettings);


            router.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif

            var rectRouter = new RectilinearEdgeRouter(graph, 3, 3, true);
            rectRouter.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif
        }