void DragObjectsForRectilinearCase(Point delta)
        {
            foreach (GeomNode node in objectsToDrag.Where(n => n is GeomNode))
            {
                node.Center += delta;
            }

            RectilinearInteractiveEditor.CreatePortsAndRouteEdges(LayoutSettings.NodeSeparation / 3, 1, graph.Nodes,
                                                                  graph.Edges,
                                                                  LayoutSettings.EdgeRoutingSettings.EdgeRoutingMode,
                                                                  true,
                                                                  LayoutSettings.EdgeRoutingSettings
                                                                  .UseObstacleRectangles,
                                                                  LayoutSettings.EdgeRoutingSettings.BendPenalty);
            var labelPlacer = new EdgeLabelPlacement(graph);

            labelPlacer.Run();

            foreach (GeomEdge e in Graph.Edges)
            {
                UpdateGraphBoundingBoxWithCheck(e);
            }
            foreach (GeomNode n in Graph.Nodes)
            {
                UpdateGraphBoundingBoxWithCheck(n);
            }
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        void DragObjectsForRectilinearCase(Point delta)
        {
            foreach (GeomNode node in objectsToDrag.Where(n => n is GeomNode))
            {
                node.Center += delta;
            }

            RectilinearInteractiveEditor.CreatePortsAndRouteEdges(
                LayoutSettings.NodeSeparation / 3,
                1,
                graph.Nodes,
                graph.Edges,
                LayoutSettings.EdgeRoutingSettings.EdgeRoutingMode,
                true,
                LayoutSettings.EdgeRoutingSettings.UseObstacleRectangles,
                LayoutSettings.EdgeRoutingSettings.BendPenalty);

            new EdgeLabelPlacement(graph).Run();

            foreach (GeomEdge e in Graph.Edges)
            {
                UpdateGraphBoundingBoxWithCheck(e);
            }
            foreach (GeomNode n in Graph.Nodes)
            {
                UpdateGraphBoundingBoxWithCheck(n);
            }

            foreach (var node in objectsToDrag.OfType <Cluster>())
            {
                node.DeepContentsTranslation(delta, false);
                node.RectangularBoundary.TranslateRectangle(delta);
            }

            PropagateChangesToClusterParents();
        }