public override void ApplyLayout(LayoutGraph graph) { var affectedEdges = graph.GetDataProvider(BusRouter.DefaultAffectedEdgesDpKey); var selectedNodes = graph.GetDataProvider(SelectedNodesDpKey); var hider = new LayoutGraphHider(graph); var hiddenEdges = new HashSet <Edge>(); foreach (var edge in graph.Edges) { if (affectedEdges.GetBool(edge) && selectedNodes != null && !selectedNodes.GetBool(edge.Source) && !selectedNodes.GetBool(edge.Target)) { var path = graph.GetPath(edge).ToArray(); for (var i = 1; i < path.Length; i++) { var p1 = path[i - 1]; var p2 = path[i]; if (Math.Abs(p1.X - p2.X) >= 0.0001 && Math.Abs(p1.Y - p2.Y) >= 0.0001) { hiddenEdges.Add(edge); } } } } foreach (var edge in hiddenEdges) { hider.Hide(edge); } ApplyLayoutCore(graph); hider.UnhideEdges(); }
/// <inheritdoc/> public void ApplyLayout(LayoutGraph graph) { var affectedNodesDP = graph.GetDataProvider(AffectedNodesDpKey); for (IEdgeCursor ec = graph.GetEdgeCursor(); ec.Ok; ec.Next()) { Edge e = ec.Edge; YPointPath path = graph.GetPath(e); //adjust source point if (affectedNodesDP == null || affectedNodesDP.GetBool(e.Source)) { AdjustPortLocation(graph, e, path, true); } if (affectedNodesDP == null || affectedNodesDP.GetBool(e.Target)) { AdjustPortLocation(graph, e, path, false); } } }
public override void ApplyLayout(LayoutGraph graph) { ApplyLayoutCore(graph); foreach (Node n in graph.Nodes) { foreach (Edge e in n.OutEdges) { bool lastSegmentOverlap = false; IEdgeLayout er = graph.GetLayout(e); if (er.PointCount() > 0) { // last bend point YPoint bendPoint = er.GetPoint(er.PointCount() - 1); IEnumerator <Edge> ecc = n.OutEdges.GetEnumerator(); loop : while (ecc.MoveNext()) { Edge eccEdge = ecc.Current; if (eccEdge != e) { YPointPath path = graph.GetPath(eccEdge); for (ILineSegmentCursor lc = path.LineSegments(); lc.Ok; lc.Next()) { LineSegment seg = lc.LineSegment; if (seg.Contains(bendPoint)) { lastSegmentOverlap = true; goto loop; } } } } } YList points = graph.GetPointList(e); for (ListCell c = points.FirstCell; c != null; c = c.Succ()) { YPoint p = (YPoint)c.Info; if (c.Succ() == null && !lastSegmentOverlap) { break; } YPoint p0 = (YPoint)(c.Pred() == null ? graph.GetSourcePointAbs(e) : c.Pred().Info); YPoint p2; if (Math.Abs(p0.X - p.X) < 0.01) { p2 = new YPoint(p.X, p.Y - 0.001); } else { p2 = new YPoint(p.X - 0.001, p.Y); } points.InsertBefore(p2, c); } graph.SetPoints(e, points); } } }