1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows;
|
---|
6 | using System.Collections;
|
---|
7 |
|
---|
8 | namespace Microsoft.Research.DynamicDataDisplay.Charts.Isolines
|
---|
9 | {
|
---|
10 | /// <summary>
|
---|
11 | /// LevelLine contains all data for one isoline line - its start point, other points and value in field.
|
---|
12 | /// </summary>
|
---|
13 | public sealed class LevelLine
|
---|
14 | {
|
---|
15 | /// <summary>
|
---|
16 | /// Gets or sets the value of line in limits of [0..1].
|
---|
17 | /// </summary>
|
---|
18 | /// <value>The value01.</value>
|
---|
19 | public double Value01 { get; set; }
|
---|
20 | /// <summary>
|
---|
21 | /// Gets or sets the real value of line - without scaling to [0..1] segment.
|
---|
22 | /// </summary>
|
---|
23 | /// <value>The real value.</value>
|
---|
24 | public double RealValue { get; set; }
|
---|
25 |
|
---|
26 | /// <summary>
|
---|
27 | /// Gets or sets the start point of line.
|
---|
28 | /// </summary>
|
---|
29 | /// <value>The start point.</value>
|
---|
30 | public Point StartPoint { get; set; }
|
---|
31 |
|
---|
32 | private readonly List<Point> otherPoints = new List<Point>();
|
---|
33 | /// <summary>
|
---|
34 | /// Gets other points of line, except first point.
|
---|
35 | /// </summary>
|
---|
36 | /// <value>The other points.</value>
|
---|
37 | public List<Point> OtherPoints
|
---|
38 | {
|
---|
39 | get { return otherPoints; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | /// <summary>
|
---|
43 | /// Gets all points of line, including start point.
|
---|
44 | /// </summary>
|
---|
45 | /// <value>All points.</value>
|
---|
46 | public IEnumerable<Point> AllPoints
|
---|
47 | {
|
---|
48 | get
|
---|
49 | {
|
---|
50 | yield return StartPoint;
|
---|
51 | for (int i = 0; i < otherPoints.Count; i++)
|
---|
52 | {
|
---|
53 | yield return otherPoints[i];
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|
57 |
|
---|
58 | /// <summary>
|
---|
59 | /// Gets all the segments of lines.
|
---|
60 | /// </summary>
|
---|
61 | /// <returns></returns>
|
---|
62 | public IEnumerable<Range<Point>> GetSegments()
|
---|
63 | {
|
---|
64 | if (otherPoints.Count < 1)
|
---|
65 | yield break;
|
---|
66 |
|
---|
67 | yield return new Range<Point>(StartPoint, otherPoints[0]);
|
---|
68 | for (int i = 1; i < otherPoints.Count; i++)
|
---|
69 | {
|
---|
70 | yield return new Range<Point>(otherPoints[i - 1], otherPoints[i]);
|
---|
71 | }
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | /// <summary>
|
---|
76 | /// IsolineTextLabel contains information about one label in isoline - its text, position and rotation.
|
---|
77 | /// </summary>
|
---|
78 | public sealed class IsolineTextLabel
|
---|
79 | {
|
---|
80 | /// <summary>
|
---|
81 | /// Gets or sets the rotation of isoline text label.
|
---|
82 | /// </summary>
|
---|
83 | /// <value>The rotation.</value>
|
---|
84 | public double Rotation { get; internal set; }
|
---|
85 | /// <summary>
|
---|
86 | /// Gets or sets the text of isoline label.
|
---|
87 | /// </summary>
|
---|
88 | /// <value>The text.</value>
|
---|
89 | public double Value { get; internal set; }
|
---|
90 | /// <summary>
|
---|
91 | /// Gets or sets the position of isoline text label.
|
---|
92 | /// </summary>
|
---|
93 | /// <value>The position.</value>
|
---|
94 | public Point Position { get; internal set; }
|
---|
95 | }
|
---|
96 |
|
---|
97 | /// <summary>
|
---|
98 | /// Collection which contains all data generated by <seealso cref="IsolineBuilder"/>.
|
---|
99 | /// </summary>
|
---|
100 | public sealed class IsolineCollection : IEnumerable<LevelLine>
|
---|
101 | {
|
---|
102 | private double min;
|
---|
103 | public double Min
|
---|
104 | {
|
---|
105 | get { return min; }
|
---|
106 | set { min = value; }
|
---|
107 | }
|
---|
108 |
|
---|
109 | private double max;
|
---|
110 | public double Max
|
---|
111 | {
|
---|
112 | get { return max; }
|
---|
113 | set { max = value; }
|
---|
114 | }
|
---|
115 |
|
---|
116 | private readonly List<LevelLine> lines = new List<LevelLine>();
|
---|
117 | /// <summary>
|
---|
118 | /// Gets the list of isoline lines.
|
---|
119 | /// </summary>
|
---|
120 | /// <value>The lines.</value>
|
---|
121 | public List<LevelLine> Lines
|
---|
122 | {
|
---|
123 | get { return lines; }
|
---|
124 | }
|
---|
125 |
|
---|
126 | internal void StartLine(Point p, double value01, double realValue)
|
---|
127 | {
|
---|
128 | LevelLine segment = new LevelLine { StartPoint = p, Value01 = value01, RealValue = realValue };
|
---|
129 | if (lines.Count == 0 || lines[lines.Count - 1].OtherPoints.Count > 0)
|
---|
130 | lines.Add(segment);
|
---|
131 | else
|
---|
132 | lines[lines.Count - 1] = segment;
|
---|
133 |
|
---|
134 | }
|
---|
135 |
|
---|
136 | internal void AddPoint(Point p)
|
---|
137 | {
|
---|
138 | lines[lines.Count - 1].OtherPoints.Add(p);
|
---|
139 | }
|
---|
140 |
|
---|
141 | #region IEnumerable<LevelLine> Members
|
---|
142 |
|
---|
143 | public IEnumerator<LevelLine> GetEnumerator()
|
---|
144 | {
|
---|
145 | return lines.GetEnumerator();
|
---|
146 | }
|
---|
147 |
|
---|
148 | #endregion
|
---|
149 |
|
---|
150 | #region IEnumerable Members
|
---|
151 |
|
---|
152 | IEnumerator IEnumerable.GetEnumerator()
|
---|
153 | {
|
---|
154 | return GetEnumerator();
|
---|
155 | }
|
---|
156 |
|
---|
157 | #endregion
|
---|
158 | }
|
---|
159 | }
|
---|