static void DrawEdgeWithPort(Edge edge, InteractiveEdgeRouter portRouter, double par0, double par1) { var port0 = new CurvePort(edge.Source.BoundaryCurve, par0); var port1 = new CurvePort(edge.Target.BoundaryCurve,par1); SmoothedPolyline sp; var spline = portRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(port0, port1, true, out sp); Arrowheads.TrimSplineAndCalculateArrowheads(edge.EdgeGeometry, edge.Source.BoundaryCurve, edge.Target.BoundaryCurve, spline, true, false); }
private void Route() { //foreach (var edge in graph.Edges) { // edge.EdgeGeometry.Curve = new LineSegment(edge.Source.Center, edge.Target.Center); //} //return; var edgeRouter = new InteractiveEdgeRouter(from v in AllLabels() select v.BoundaryCurve, this.locationRadius / 3, this.locationRadius/9, Math.PI/6); edgeRouter.Run();//it will calculate the visibility graph edgeRouter.GetVisibilityGraph(); foreach (var edge in Edges()) { SmoothedPolyline sp; edge.EdgeGeometry.Curve = edgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(new FloatingPort(edge.Source.BoundaryCurve, edge.Source.Center), new FloatingPort(null, edge.Target.Center), true, out sp); TrimAtSource(edge); } }
void RouteEdgeGeometry(Edge edge, InteractiveEdgeRouter iRouter) { var edgeGeometry = edge.EdgeGeometry; var addedEdges = new List<VisibilityEdge>(); if (!(edgeGeometry.SourcePort is HookUpAnywhereFromInsidePort)) addedEdges.AddRange(AddVisibilityEdgesFromPort(edgeGeometry.SourcePort)); if (!(edgeGeometry.TargetPort is HookUpAnywhereFromInsidePort)) addedEdges.AddRange(AddVisibilityEdgesFromPort(edgeGeometry.TargetPort)); SmoothedPolyline smoothedPolyline; if (!ApproximateComparer.Close(edgeGeometry.SourcePort.Location, edgeGeometry.TargetPort.Location)) edgeGeometry.Curve = iRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady( edgeGeometry.SourcePort, edgeGeometry.TargetPort, true, out smoothedPolyline); else { edgeGeometry.Curve = Edge.RouteSelfEdge(edgeGeometry.SourcePort.Curve, Math.Max(LoosePadding * 2, edgeGeometry.GetMaxArrowheadLength()), out smoothedPolyline); } edgeGeometry.SmoothedPolyline = smoothedPolyline; if (edgeGeometry.Curve == null) throw new NotImplementedException(); foreach (var visibilityEdge in addedEdges) VisibilityGraph.RemoveEdge(visibilityEdge); Arrowheads.TrimSplineAndCalculateArrowheads(edgeGeometry, edgeGeometry.SourcePort.Curve, edgeGeometry.TargetPort.Curve, edgeGeometry.Curve, false, KeepOriginalSpline); if (ReplaceEdgeByRails != null) ReplaceEdgeByRails(edge); // SetTransparency(transparentShapes, false); }