DrawCurveThroughIntermediatePoints
(
IEdge oEdge,
GraphDrawingContext oGraphDrawingContext,
DrawingContext oDrawingContext,
VertexDrawingHistory oVertex1DrawingHistory,
VertexDrawingHistory oVertex2DrawingHistory,
Point oEdgeEndpoint1,
Point oEdgeEndpoint2,
Pen oPen
)
{
Debug.Assert(oEdge != null);
Debug.Assert(oGraphDrawingContext != null);
Debug.Assert(oDrawingContext != null);
Debug.Assert(oVertex1DrawingHistory != null);
Debug.Assert(oVertex2DrawingHistory != null);
Debug.Assert(oPen != null);
AssertValid();
// Note: Don't attempt to draw an arrow in this case.
// Create a list of intermediate points, excluding those that fall
// within the vertex bounds. An edge always terminates on the vertex
// bounds, so we don't want it venturing into the vertex itself.
List<Point> oCurvePoints = FilterIntermediatePoints(oEdge,
oVertex1DrawingHistory, oVertex2DrawingHistory);
Int32 iCurvePoints = oCurvePoints.Count;
if (iCurvePoints == 0)
{
// Just draw a straight line.
oDrawingContext.DrawLine(oPen, oEdgeEndpoint1, oEdgeEndpoint2);
return;
}
#if false
// Draw intermediate points for testing.
foreach (Point oPoint in oCurvePoints)
{
oDrawingContext.DrawEllipse(Brushes.Green, null, oPoint, 2, 2);
}
#endif
// The endpoints were originally calculated as if the edge was a
// straight line between the two vertices. Recalculate them so they
// connect more smoothly to the adjacent intermediate curve points.
oVertex1DrawingHistory.GetEdgeEndpoint(oCurvePoints[0],
out oEdgeEndpoint1);
oVertex2DrawingHistory.GetEdgeEndpoint(oCurvePoints[iCurvePoints - 1],
out oEdgeEndpoint2);
oCurvePoints.Insert(0, oEdgeEndpoint1);
oCurvePoints.Add(oEdgeEndpoint2);
PathGeometry oCurveThroughPoints =
WpfPathGeometryUtil.GetCurveThroughPoints(oCurvePoints, 0.5,
CurveThroughIntermediatePointsTolerance);
oDrawingContext.DrawGeometry(null, oPen, oCurveThroughPoints);
// Note: Don't attempt to draw a label in this case.
}