using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Collections; namespace Microsoft.Research.DynamicDataDisplay.Charts.Isolines { /// /// LevelLine contains all data for one isoline line - its start point, other points and value in field. /// public sealed class LevelLine { /// /// Gets or sets the value of line in limits of [0..1]. /// /// The value01. public double Value01 { get; set; } /// /// Gets or sets the real value of line - without scaling to [0..1] segment. /// /// The real value. public double RealValue { get; set; } /// /// Gets or sets the start point of line. /// /// The start point. public Point StartPoint { get; set; } private readonly List otherPoints = new List(); /// /// Gets other points of line, except first point. /// /// The other points. public List OtherPoints { get { return otherPoints; } } /// /// Gets all points of line, including start point. /// /// All points. public IEnumerable AllPoints { get { yield return StartPoint; for (int i = 0; i < otherPoints.Count; i++) { yield return otherPoints[i]; } } } /// /// Gets all the segments of lines. /// /// public IEnumerable> GetSegments() { if (otherPoints.Count < 1) yield break; yield return new Range(StartPoint, otherPoints[0]); for (int i = 1; i < otherPoints.Count; i++) { yield return new Range(otherPoints[i - 1], otherPoints[i]); } } } /// /// IsolineTextLabel contains information about one label in isoline - its text, position and rotation. /// public sealed class IsolineTextLabel { /// /// Gets or sets the rotation of isoline text label. /// /// The rotation. public double Rotation { get; internal set; } /// /// Gets or sets the text of isoline label. /// /// The text. public double Value { get; internal set; } /// /// Gets or sets the position of isoline text label. /// /// The position. public Point Position { get; internal set; } } /// /// Collection which contains all data generated by . /// public sealed class IsolineCollection : IEnumerable { private double min; public double Min { get { return min; } set { min = value; } } private double max; public double Max { get { return max; } set { max = value; } } private readonly List lines = new List(); /// /// Gets the list of isoline lines. /// /// The lines. public List Lines { get { return lines; } } internal void StartLine(Point p, double value01, double realValue) { LevelLine segment = new LevelLine { StartPoint = p, Value01 = value01, RealValue = realValue }; if (lines.Count == 0 || lines[lines.Count - 1].OtherPoints.Count > 0) lines.Add(segment); else lines[lines.Count - 1] = segment; } internal void AddPoint(Point p) { lines[lines.Count - 1].OtherPoints.Add(p); } #region IEnumerable Members public IEnumerator GetEnumerator() { return lines.GetEnumerator(); } #endregion #region IEnumerable Members IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } #endregion } }