internal CoordinateTransform WithScreenOffset(double x, double y) { Rect screenCopy = screenRect; screenCopy.Offset(x, y); CoordinateTransform copy = new CoordinateTransform(visibleRect, screenCopy); return copy; }
/// <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 PhysicalRectAnimation(Viewport2D viewport, Point initialMousePos) { this.from = viewport.Visible; this.viewport = viewport; this.initialMousePos = initialMousePos; initialTransform = viewport.Transform; position = from.Location.ToVector(); }
/// <summary> /// Transforms list of points from data coordinates to screen coordinates. /// </summary> /// <param name="dataPoints">Points in data coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Points in screen coordinates</returns> public static List <Point> DataToScreen(this IEnumerable <Point> dataPoints, CoordinateTransform transform) { ICollection <Point> iCollection = dataPoints as ICollection <Point>; List <Point> res; if (iCollection != null) { res = new List <Point>(iCollection.Count); } else { res = new List <Point>(); } foreach (var point in dataPoints) { res.Add(transform.DataToScreen(point)); } return(res); }
/// <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 Rect ViewportToData(this Rect viewportRect, CoordinateTransform transform) { Point p1 = viewportRect.BottomLeft.ViewportToData(transform); Point p2 = viewportRect.TopRight.ViewportToData(transform); return new Rect(p1, p2); }
/// <summary> /// Transforms point in data coordinates to screen coordinates. /// </summary> /// <param name="dataPoint">Point in data coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in screen coordinates</returns> public static Point DataToScreen(this Point dataPoint, CoordinateTransform transform) { return transform.DataToScreen(dataPoint); }
/// <summary> /// Transforms point in screen coordinates to viewport coordinates. /// </summary> /// <param name="screenPoint">Point in screen coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in viewport coordinates</returns> public static Point ScreenToViewport(this Point screenPoint, CoordinateTransform transform) { return(transform.ScreenToViewport(screenPoint)); }
/// <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, CoordinateTransform transform) { return(transform.DataTransform.DataToViewport(dataPoint)); }
public static List <Point> DataToScreenAsList(this CoordinateTransform transform, IEnumerable <Point> dataPoints) { return(dataPoints.DataToScreenAsList(transform)); }
public static IEnumerable <Point> ScreenToData(this IEnumerable <Point> screenPoints, CoordinateTransform transform) { foreach (Point pt in screenPoints) { yield return(pt.ScreenToData(transform)); } }
public static IEnumerable<Point> DataToViewport(this IEnumerable<Point> dataPoints, CoordinateTransform transform) { return dataPoints.DataToViewport(transform.DataTransform); }
public static IEnumerable<IndexWrapper<Point>> ScreenToData(this IEnumerable<IndexWrapper<Point>> viewportPoints, CoordinateTransform transform) { foreach (var index in viewportPoints) { Point pt = index.Data.ScreenToData(transform); var copy = index; copy.Data = pt; yield return copy; } }
public static IEnumerable<Point> ViewportToScreen(this IEnumerable<Point> viewportPoints, CoordinateTransform transform) { foreach (var point in viewportPoints) { yield return point.ViewportToScreen(transform); } }
public static IEnumerable<Point> DataToScreen(this IEnumerable<Point> dataPoints, CoordinateTransform transform) { foreach (var point in dataPoints) { yield return point.DataToScreen(transform); } }
/// <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, CoordinateTransform transform) { Point p1 = dataRect.XMaxYMax.DataToViewport(transform); Point p2 = dataRect.XMinYMin.DataToViewport(transform); 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, CoordinateTransform transform) { Point p1 = viewportRect.XMaxYMax.ViewportToData(transform); Point p2 = viewportRect.XMinYMin.ViewportToData(transform); return new DataRect(p1, p2); }
private void UpdateTransform() { transform = transform.WithRects(Visible, Output); }
/// <summary> /// Transforms point in screen coordinates to viewport coordinates. /// </summary> /// <param name="screenPoint">Point in screen coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in viewport coordinates</returns> public static Point ScreenToViewport(this Point screenPoint, CoordinateTransform transform) { return transform.ScreenToViewport(screenPoint); }
public static IEnumerable<Point> ScreenToData(this IEnumerable<Point> screenPoints, CoordinateTransform transform) { foreach (Point pt in screenPoints) { yield return pt.ScreenToData(transform); } }
/// <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 Rect ViewportToData(this Rect viewportRect, CoordinateTransform transform) { Point p1 = new Point(viewportRect.Left, viewportRect.Bottom).ViewportToData(transform); Point p2 = new Point(viewportRect.Right,viewportRect.Top).ViewportToData(transform); return new Rect(p1, p2); }
/// <summary> /// Creates CoordinateTransform fro specified rectangles and with Identity transform. /// </summary> /// <param name="visibleRect">The visible rect.</param> /// <param name="screenRect">The screen rect.</param> /// <returns></returns> public static CoordinateTransform FromRects(DataRect visibleRect, Rect screenRect) { CoordinateTransform result = new CoordinateTransform(visibleRect, screenRect); return result; }
public static IEnumerable <Point> DataToScreen(this IEnumerable <Point> dataPoints, CoordinateTransform transform) { foreach (var point in dataPoints) { yield return(point.DataToScreen(transform)); } }
/// <summary> /// Closnes transform with current dataTransform and specified rectangles. /// </summary> /// <param name="visibleRect">The visible rect.</param> /// <param name="screenRect">The screen rect.</param> /// <returns></returns> public CoordinateTransform WithRects(DataRect visibleRect, Rect screenRect) { CoordinateTransform copy = new CoordinateTransform(visibleRect, screenRect); copy.dataTransform = dataTransform; return copy; }
public static IEnumerable <Point> DataToViewport(this IEnumerable <Point> dataPoints, CoordinateTransform transform) { return(dataPoints.DataToViewport(transform.DataTransform)); }
/// <summary> /// Transforms rectangle from screen coordinates to viewport coordinates. /// </summary> /// <param name="screenRect">Rectangle in screen coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Rectangle in viewport coordinates</returns> public static Rect ScreenToViewport(this Rect screenRect, CoordinateTransform transform) { Point p1 = new Point(screenRect.Left,screenRect.Bottom).ScreenToViewport(transform); Point p2 = new Point(screenRect.Right,screenRect.Top).ScreenToViewport(transform); return new Rect(p1, p2); }
public static IEnumerable <IndexWrapper <Point> > ScreenToData(this IEnumerable <IndexWrapper <Point> > viewportPoints, CoordinateTransform transform) { foreach (var index in viewportPoints) { Point pt = index.Data.ScreenToData(transform); var copy = index; copy.Data = pt; yield return(copy); } }
internal static CoordinateTransform CreateDefault() { CoordinateTransform transform = new CoordinateTransform(new Rect(0, 0, 1, 1), new Rect(0, 0, 1, 1)); return transform; }
/// <summary> /// Transforms point in viewport coordinates to data coordinates. /// </summary> /// <param name="viewportPoint">Point in viewport coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in data coordinates</returns> public static Point ViewportToData(this Point viewportPoint, CoordinateTransform transform) { return(transform.DataTransform.ViewportToData(viewportPoint)); }
private void FillVertexBuffer() { if (DxHost == null) return; if (DataSource == null) return; if (Palette == null) return; if (Device == null) return; var dataSource = DataSource; var palette = Palette; var minMax = dataSource.GetMinMax(); transform = Plotter.Transform; vertexCount = DataSource.Width * DataSource.Height; verticesArray = new VertexPosition4Color[vertexCount]; for (int i = 0; i < verticesArray.Length; i++) { int ix = i % DataSource.Width; int iy = i / DataSource.Width; Point point = dataSource.Grid[ix, iy]; double data = dataSource.Data[ix, iy]; double interpolatedData = (data - minMax.Min) / minMax.GetLength(); var color = palette.GetColor(interpolatedData); var pointInScreen = point;//.DataToScreen(transform); var position = new Vector4((float)pointInScreen.X, (float)pointInScreen.Y, 0.5f, 1); verticesArray[i] = new VertexPosition4Color { Position = position, Color = //System.Windows.Media.Colors.Blue.ToArgb() color.ToArgb() }; } vertexBuffer = new VertexBuffer(Device, vertexCount * VertexPosition4Color.SizeInBytes, Usage.WriteOnly, VertexFormat.Position | VertexFormat.Diffuse, Pool.Default); using (var stream = vertexBuffer.Lock(0, vertexCount * VertexPosition4Color.SizeInBytes, LockFlags.None)) { stream.WriteRange<VertexPosition4Color>(verticesArray); } vertexBuffer.Unlock(); indicesCount = (dataSource.Width - 1) * (dataSource.Height - 1) * 2 * 3; indicesArray = new int[indicesCount]; int index = 0; int width = dataSource.Width; for (int iy = 0; iy < dataSource.Height - 1; iy++) { for (int ix = 0; ix < dataSource.Width - 1; ix++) { indicesArray[index + 0] = ix + 0 + iy * width; indicesArray[index + 1] = ix + 1 + iy * width; indicesArray[index + 2] = ix + (iy + 1) * width; indicesArray[index + 3] = ix + 1 + iy * width; indicesArray[index + 4] = ix + (iy + 1) * width; indicesArray[index + 5] = ix + 1 + (iy + 1) * width; index += 6; } } indexBuffer = new IndexBuffer(Device, indicesCount * sizeof(int), Usage.WriteOnly, Pool.Default, false); using (var stream = indexBuffer.Lock(0, indicesCount * sizeof(int), LockFlags.None)) { stream.WriteRange<int>(indicesArray); } indexBuffer.Unlock(); }
/// <summary> /// Transforms rectangle from screen coordinates to viewport coordinates. /// </summary> /// <param name="screenRect">Rectangle in screen coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Rectangle in viewport coordinates</returns> public static Rect ScreenToViewport(this Rect screenRect, CoordinateTransform transform) { Point p1 = screenRect.BottomLeft.ScreenToViewport(transform); Point p2 = screenRect.TopRight.ScreenToViewport(transform); return new Rect(p1, p2); }
/// <summary> /// Transforms point in viewport coordinates to data coordinates. /// </summary> /// <param name="viewportPoint">Point in viewport coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in data coordinates</returns> public static Point ViewportToData(this Point viewportPoint, CoordinateTransform transform) { return transform.DataTransform.ViewportToData(viewportPoint); }
/// <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 Rect DataToViewport(this Rect dataRect, CoordinateTransform transform) { Point p1 = dataRect.BottomLeft.DataToViewport(transform); Point p2 = dataRect.TopRight.DataToViewport(transform); return new Rect(p1, p2); }
protected virtual void UpdateLevel(CoordinateTransform transform) { bool ok = false; do { double width = tileProvider.GetTileWidth(tileProvider.Level); double height = tileProvider.GetTileHeight(tileProvider.Level); DataRect size = new DataRect(new Size(width, height)); Rect onScreen = size.ViewportToScreen(transform); // todo написать нормально if (onScreen.Width > tileWidth * 1.45) { if (tileProvider.IncreaseLevel()) { continue; } } else if (onScreen.Width < tileWidth / 1.45) { if (tileProvider.DecreaseLevel()) { continue; } } ok = true; } while (!ok); }
/// <summary> /// Transforms list of points from data coordinates to screen coordinates. /// </summary> /// <param name="dataPoints">Points in data coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Points in screen coordinates</returns> public static List<Point> DataToScreen(this IEnumerable<Point> dataPoints, CoordinateTransform transform) { ICollection<Point> iCollection = dataPoints as ICollection<Point>; List<Point> res; if (iCollection != null) { res = new List<Point>(iCollection.Count); } else { res = new List<Point>(); } foreach (var point in dataPoints) { res.Add(transform.DataToScreen(point)); } return res; }
internal static CoordinateTransform FromRects(DataRect visibleRect, Rect screenRect) { CoordinateTransform result = new CoordinateTransform(visibleRect, screenRect); return(result); }
/// <summary> /// Transforms point in viewport coordinates to screen coordinates. /// </summary> /// <param name="viewportPoint">Point in viewport coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in screen coordinates</returns> public static Point ViewportToScreen(this Point viewportPoint, CoordinateTransform transform) { return transform.ViewportToScreen(viewportPoint); }
/// <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 Rect DataToViewport(this Rect dataRect, CoordinateTransform transform) { Point p1 = new Point(dataRect.Left,dataRect.Bottom).DataToViewport(transform); Point p2 = new Point(dataRect.Right,dataRect.Top).DataToViewport(transform); return new Rect(p1, p2); }
/// <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, CoordinateTransform transform) { return transform.DataTransform.DataToViewport(dataPoint); }
public static IEnumerable <Point> ViewportToScreen(this IEnumerable <Point> viewportPoints, CoordinateTransform transform) { foreach (var point in viewportPoints) { yield return(point.ViewportToScreen(transform)); } }
private void UniteWithBounds(CoordinateTransform transform, Rect bounds) { var childViewportBounds = bounds.ScreenToViewport(transform); if (boundsUnionMode == BoundsUnionMode.Bounds) overallViewportBounds.Union(childViewportBounds); else { overallViewportBounds.Union(childViewportBounds.GetCenter()); } }
/// <summary> /// Transforms point in data coordinates to screen coordinates. /// </summary> /// <param name="dataPoint">Point in data coordinates</param> /// <param name="transform">CoordinateTransform used to perform transformation</param> /// <returns>Point in screen coordinates</returns> public static Point DataToScreen(this Point dataPoint, CoordinateTransform transform) { return(transform.DataToScreen(dataPoint)); }
internal static CoordinateTransform CreateDefault() { CoordinateTransform transform = new CoordinateTransform(new Rect(0, 0, 1, 1), new Rect(0, 0, 1, 1)); return(transform); }
private void Update() { if (Plotter == null) return; if (DataSource == null) return; layoutTransform.X = 0; layoutTransform.Y = 0; var dataSource = DataSource; var dataPoints = dataSource.GetPoints(); transformWhenCreated = plotter.Transform; var contentBounds = dataPoints.GetBounds(); Viewport2D.SetContentBounds(this, contentBounds); foreach (Polyline polyline in Children) { polylinePool.Put(polyline); } Children.Clear(); PointCollection pointCollection = new PointCollection(); foreach (var screenPoint in dataPoints.DataToScreen(plotter.Transform)) { if (pointCollection.Count < pointCount) { pointCollection.Add(screenPoint); } else { var polyline = polylinePool.GetOrCreate(); polyline.Points = pointCollection; SetPolylineBindings(polyline); Children.Add(polyline); Dispatcher.Invoke(() => { }, DispatcherPriority.ApplicationIdle); pointCollection = new PointCollection(); } } }