Initial Commit
This commit is contained in:
51
DataSources/MultiDimensional/DataSource2DHelper.cs
Normal file
51
DataSources/MultiDimensional/DataSource2DHelper.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
|
||||
{
|
||||
public static class DataSource2DHelper
|
||||
{
|
||||
public static Point[,] CreateUniformGrid(int width, int height, double gridWidth, double gridHeight)
|
||||
{
|
||||
return CreateUniformGrid(width, height, 0, 0, gridWidth / width, gridHeight / height);
|
||||
}
|
||||
|
||||
public static Point[,] CreateUniformGrid(int width, int height, double xStart, double yStart, double xStep, double yStep)
|
||||
{
|
||||
Point[,] result = new Point[width, height];
|
||||
|
||||
double x = xStart;
|
||||
for (int ix = 0; ix < width; ix++)
|
||||
{
|
||||
double y = yStart;
|
||||
for (int iy = 0; iy < height; iy++)
|
||||
{
|
||||
result[ix, iy] = new Point(x, y);
|
||||
|
||||
y += yStep;
|
||||
}
|
||||
x += xStep;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Vector[,] CreateVectorData(int width, int height, Func<int, int, Vector> generator)
|
||||
{
|
||||
Vector[,] result = new Vector[width, height];
|
||||
|
||||
for (int ix = 0; ix < width; ix++)
|
||||
{
|
||||
for (int iy = 0; iy < height; iy++)
|
||||
{
|
||||
result[ix, iy] = generator(ix, iy);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
DataSources/MultiDimensional/EmptyDataSource2D.cs
Normal file
75
DataSources/MultiDimensional/EmptyDataSource2D.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines empty two-dimensional data source.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public sealed class EmptyDataSource2D<T> : IDataSource2D<T> where T : struct
|
||||
{
|
||||
#region IDataSource2D<T> Members
|
||||
|
||||
private T[,] data = new T[0, 0];
|
||||
public T[,] Data
|
||||
{
|
||||
get { return data; }
|
||||
}
|
||||
|
||||
private Point[,] grid = new Point[0, 0];
|
||||
public Point[,] Grid
|
||||
{
|
||||
get { return grid; }
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
private void RaiseChanged()
|
||||
{
|
||||
if (Changed != null)
|
||||
{
|
||||
Changed(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
public event EventHandler Changed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDataSource2D<T> Members
|
||||
|
||||
|
||||
public Microsoft.Research.DynamicDataDisplay.Charts.Range<T>? Range
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public T? MissingValue
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDataSource2D<T> Members
|
||||
|
||||
|
||||
public IDataSource2D<T> GetSubset(int x0, int y0, int countX, int countY, int stepX, int stepY)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
55
DataSources/MultiDimensional/IDataSource2D.cs
Normal file
55
DataSources/MultiDimensional/IDataSource2D.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using Microsoft.Research.DynamicDataDisplay.Charts;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.DataSources
|
||||
{
|
||||
/// <summary>
|
||||
/// General interface for two-dimensional data source. Contains two-dimensional array of data items.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Data type - type of each data piece.</typeparam>
|
||||
public interface IDataSource2D<T> : IGridSource2D where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets two-dimensional data array.
|
||||
/// </summary>
|
||||
/// <value>The data.</value>
|
||||
T[,] Data { get; }
|
||||
|
||||
IDataSource2D<T> GetSubset(int x0, int y0, int countX, int countY, int stepX, int stepY);
|
||||
|
||||
Range<T>? Range { get; }
|
||||
|
||||
T? MissingValue { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// General interface for two-dimensional data grids. Contains two-dimensional array of data points.
|
||||
/// </summary>
|
||||
public interface IGridSource2D
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the grid of data source.
|
||||
/// </summary>
|
||||
/// <value>The grid.</value>
|
||||
Point[,] Grid { get; }
|
||||
/// <summary>
|
||||
/// Gets data grid width.
|
||||
/// </summary>
|
||||
/// <value>The width.</value>
|
||||
int Width { get; }
|
||||
/// <summary>
|
||||
/// Gets data grid height.
|
||||
/// </summary>
|
||||
/// <value>The height.</value>
|
||||
int Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when data source changes.
|
||||
/// </summary>
|
||||
event EventHandler Changed;
|
||||
}
|
||||
}
|
||||
13
DataSources/MultiDimensional/INonUniformDataSource2D.cs
Normal file
13
DataSources/MultiDimensional/INonUniformDataSource2D.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.DataSources
|
||||
{
|
||||
public interface INonUniformDataSource2D<T> : IDataSource2D<T> where T : struct
|
||||
{
|
||||
double[] XCoordinates { get; }
|
||||
double[] YCoordinates { get; }
|
||||
}
|
||||
}
|
||||
113
DataSources/MultiDimensional/NonUniformDataSource2D.cs
Normal file
113
DataSources/MultiDimensional/NonUniformDataSource2D.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
|
||||
{
|
||||
public class NonUniformDataSource2D<T> : INonUniformDataSource2D<T> where T : struct
|
||||
{
|
||||
public NonUniformDataSource2D(double[] xcoordinates, double[] ycoordinates, T[,] data)
|
||||
{
|
||||
if (xcoordinates == null)
|
||||
throw new ArgumentNullException("xcoordinates");
|
||||
if (ycoordinates == null)
|
||||
throw new ArgumentNullException("ycoordinates");
|
||||
if (data == null)
|
||||
throw new ArgumentNullException("data");
|
||||
|
||||
this.xCoordinates = xcoordinates;
|
||||
this.yCoordinates = ycoordinates;
|
||||
|
||||
BuildGrid();
|
||||
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private void BuildGrid()
|
||||
{
|
||||
grid = new Point[Width, Height];
|
||||
for (int iy = 0; iy < Height; iy++)
|
||||
{
|
||||
for (int ix = 0; ix < Width; ix++)
|
||||
{
|
||||
grid[ix, iy] = new Point(xCoordinates[ix], yCoordinates[iy]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region INonUniformDataSource2D<T> Members
|
||||
|
||||
private double[] xCoordinates;
|
||||
public double[] XCoordinates
|
||||
{
|
||||
get { return xCoordinates; }
|
||||
}
|
||||
|
||||
private double[] yCoordinates;
|
||||
public double[] YCoordinates
|
||||
{
|
||||
get { return yCoordinates; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDataSource2D<T> Members
|
||||
|
||||
private T[,] data;
|
||||
public T[,] Data
|
||||
{
|
||||
get { return data; }
|
||||
}
|
||||
|
||||
public IDataSource2D<T> GetSubset(int x0, int y0, int countX, int countY, int stepX, int stepY)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ApplyMappings(DependencyObject marker, int x, int y)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IGridSource2D Members
|
||||
|
||||
private Point[,] grid;
|
||||
public Point[,] Grid
|
||||
{
|
||||
get { return grid; }
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get { return xCoordinates.Length; }
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get { return yCoordinates.Length; }
|
||||
}
|
||||
#pragma warning disable 0067
|
||||
public event EventHandler Changed;
|
||||
#pragma warning restore 0067
|
||||
#endregion
|
||||
|
||||
#region IDataSource2D<T> Members
|
||||
|
||||
|
||||
public Microsoft.Research.DynamicDataDisplay.Charts.Range<T>? Range
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public T? MissingValue
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
113
DataSources/MultiDimensional/WarpedDataSource2D.cs
Normal file
113
DataSources/MultiDimensional/WarpedDataSource2D.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using Microsoft.Research.DynamicDataDisplay.Common.Auxiliary;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines warped two-dimensional data source.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Data piece type</typeparam>
|
||||
public sealed class WarpedDataSource2D<T> : IDataSource2D<T> where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WarpedDataSource2D<T>"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">Data.</param>
|
||||
/// <param name="grid">Grid.</param>
|
||||
public WarpedDataSource2D(T[,] data, Point[,] grid)
|
||||
{
|
||||
if (data == null)
|
||||
throw new ArgumentNullException("data");
|
||||
if (grid == null)
|
||||
throw new ArgumentNullException("grid");
|
||||
|
||||
Verify.IsTrue(data.GetLength(0) == grid.GetLength(0));
|
||||
Verify.IsTrue(data.GetLength(1) == grid.GetLength(1));
|
||||
|
||||
this.data = data;
|
||||
this.grid = grid;
|
||||
width = data.GetLength(0);
|
||||
height = data.GetLength(1);
|
||||
}
|
||||
|
||||
#region DataSource<T> Members
|
||||
|
||||
private readonly T[,] data;
|
||||
/// <summary>
|
||||
/// Gets two-dimensional data array.
|
||||
/// </summary>
|
||||
/// <value>The data.</value>
|
||||
public T[,] Data
|
||||
{
|
||||
get { return data; }
|
||||
}
|
||||
|
||||
private readonly Point[,] grid;
|
||||
/// <summary>
|
||||
/// Gets the grid of data source.
|
||||
/// </summary>
|
||||
/// <value>The grid.</value>
|
||||
public Point[,] Grid
|
||||
{
|
||||
get { return grid; }
|
||||
}
|
||||
|
||||
private readonly int width;
|
||||
/// <summary>
|
||||
/// Gets data grid width.
|
||||
/// </summary>
|
||||
/// <value>The width.</value>
|
||||
public int Width
|
||||
{
|
||||
get { return width; }
|
||||
}
|
||||
|
||||
private readonly int height;
|
||||
/// <summary>
|
||||
/// Gets data grid height.
|
||||
/// </summary>
|
||||
/// <value>The height.</value>
|
||||
public int Height
|
||||
{
|
||||
get { return height; }
|
||||
}
|
||||
|
||||
public IDataSource2D<T> GetSubset(int x0, int y0, int countX, int countY, int stepX, int stepY)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void RaiseChanged()
|
||||
{
|
||||
if (Changed != null)
|
||||
{
|
||||
Changed(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when data source changes.
|
||||
/// </summary>
|
||||
public event EventHandler Changed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDataSource2D<T> Members
|
||||
|
||||
|
||||
public Microsoft.Research.DynamicDataDisplay.Charts.Range<T>? Range
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public T? MissingValue
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user