/// <summary> /// Transforms rectangle from data coordinates to viewport coordinates. /// </summary> /// <param name="dataRect">Rectangle in data coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Rectangle in viewport coordinates</returns> public static DataRect DataToViewport(this DataRect dataRect, DataTransform transform) { Point p1 = transform.DataToViewport(dataRect.XMinYMin); Point p2 = transform.DataToViewport(dataRect.XMaxYMax); return(new DataRect(p1, p2)); }
/// <summary> /// Transforms rectangle from viewport coordinates to data coordinates. /// </summary> /// <param name="viewportRect">Rectangle in viewport coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Rectangle in data coordinates</returns> public static DataRect ViewportToData(this DataRect viewportRect, DataTransform transform) { Point p1 = transform.ViewportToData(viewportRect.XMaxYMax); Point p2 = transform.ViewportToData(viewportRect.XMinYMin); return(new DataRect(p1, p2)); }
/// <summary> /// Creates a new instance of CoordinateTransform with the given data transform. /// </summary> /// <param name="dataTransform">The data transform.</param> /// <returns></returns> public CoordinateTransform WithDataTransform(DataTransform dataTransform) { if (dataTransform == null) { throw new ArgumentNullException("dataTransform"); } CoordinateTransform copy = new CoordinateTransform(visibleRect, screenRect); copy.dataTransform = dataTransform; return(copy); }
public static DataRect GetViewportBounds(IEnumerable <Point> dataPoints, DataTransform transform) { return(GetViewportBounds(dataPoints.DataToViewport(transform))); }
/// <summary> /// Transforms point in data coordinates to viewport coordinates. /// </summary> /// <param name="dataPoint">Point in data coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in viewport coordinates</returns> public static Point DataToViewport(this Point dataPoint, DataTransform transform) { return(transform.DataToViewport(dataPoint)); }
/// <summary> /// Transforms list of points from data coordinates to viewport coordinates. /// </summary> /// <param name="dataPoints">Points in data coordinates</param> /// <param name="transform">Data transform used to perform transformation</param> /// <returns>List of points in viewport coordinates</returns> public static IEnumerable <Point> DataToViewport(this IEnumerable <Point> dataPoints, DataTransform transform) { foreach (Point pt in dataPoints) { yield return(pt.DataToViewport(transform)); } }