【问题标题】:Routing only edges with MSAGL使用 MSAGL 仅路由边
【发布时间】:2015-10-30 09:23:06
【问题描述】:

有没有办法使用 MSAGL 仅在现有布局中路由边缘?

我有一个 GeometryGraph 对象,其布局使用 LayeredLayout 生成,我想删除/添加边而不再次运行布局算法(此操作对节点位置进行了剧烈更改,最终用户会感到困惑)。

我可以以某种方式简单地在所有节点位置固定的情况下再次运行布局吗?

【问题讨论】:

    标签: c# .net microsoft-glee msagl


    【解决方案1】:

    您需要使InteractiveEdgeRouter 与您的图表保持同步:

    edgeRouter_ = new InteractiveEdgeRouter(Graph.Nodes.Select(n => n.BoundaryCurve), 3, 0.65 * 3, 0);
    

    图形布局的每次重新计算还应调用edgeRouter_.Run() 以使其与障碍物变化保持同步(您还应添加新节点)。

    添加新边缘后,无需再次计算布局,而是使用路由器手动设置边缘曲线:

     private void RouteMissingEdges()
     {
         foreach (var edge in Graph.Edges)
         {
             if (edge.Curve == null)
             {
                 SmoothedPolyline ignore;
    
                 edge.Curve = edgeRouter_.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(
                     new FloatingPort(edge.Source.BoundaryCurve, edge.Source.Center),
                     new FloatingPort(edge.Target.BoundaryCurve, edge.Target.Center),
                     true, out ignore);
    
                 Arrowheads.TrimSplineAndCalculateArrowheads(edge.EdgeGeometry,
                                                 edge.Source.BoundaryCurve,
                                                 edge.Target.BoundaryCurve,
                                                 edge.Curve, true,
                                                 false);
    
             }
         }
    }
    

    【讨论】:

      【解决方案2】:

      使用可以使用LayoutHelpers.RouteAndLabelEdges:

      LayoutAlgorithmSettings settings = new MdsLayoutSettings();
      RouteAndLabelEdges(geometryGraph, settings, geometryGraph.Edges);
      

      它比ghord的解决方案更短,但需要更多的计算。

      【讨论】:

        猜你喜欢
        • 2016-10-25
        • 1970-01-01
        • 2019-06-14
        • 1970-01-01
        • 2019-03-10
        • 2012-01-09
        • 2018-04-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多