public static void Main(string[] args) { var ds = new BenchmarkDataSource(200, 200); var builder = new IsolineBuilder(ds); Console.WriteLine("Data field size is {0}x{1}", ds.Width, ds.Height); DateTime start = DateTime.Now; int pointCount = 0; for (double level = -2.0; level <= 2.0; level += 0.01) { Console.WriteLine("Building coutour line at {0}", level); foreach (LevelLine line in builder.BuildIsoline(level).Lines) { pointCount += 1 + line.OtherPoints.Count; } } TimeSpan elapsed = DateTime.Now - start; Console.WriteLine("Points generated: {0}", pointCount); Console.WriteLine("Elapsed time: {0} ms", elapsed.TotalMilliseconds); }
private void UpdateUIRepresentation() { foreach (var path in addedPaths) { content.Children.Remove(path); } addedPaths.Clear(); if (DataSource == null) { labelGrid.Visibility = Visibility.Hidden; return; } Rect output = Plotter2D.Viewport.Output; Point mousePos = Mouse.GetPosition(this); if (!output.Contains(mousePos)) { return; } var transform = Plotter2D.Viewport.Transform; Point visiblePoint = mousePos.ScreenToData(transform); Rect visible = Plotter2D.Viewport.Visible; double isolineLevel; if (Search(visiblePoint, out isolineLevel)) { var collection = IsolineBuilder.Build(isolineLevel); string format = "G3"; if (Math.Abs(isolineLevel) < 1000) { format = "F"; } textBlock.Text = isolineLevel.ToString(format); double x = mousePos.X + labelShift.X; if (x + labelGrid.ActualWidth > output.Right) { x = mousePos.X - labelShift.X - labelGrid.ActualWidth; } double y = mousePos.Y - labelShift.Y - labelGrid.ActualHeight; if (y < output.Top) { y = mousePos.Y + labelShift.Y; } Canvas.SetLeft(labelGrid, x); Canvas.SetTop(labelGrid, y); foreach (LevelLine segment in collection.Lines) { StreamGeometry streamGeom = new StreamGeometry(); using (StreamGeometryContext context = streamGeom.Open()) { Point startPoint = segment.StartPoint.DataToScreen(transform); var otherPoints = segment.OtherPoints.DataToScreen(transform); context.BeginFigure(startPoint, false, false); context.PolyLineTo(otherPoints, true, true); } Path path = new Path { Stroke = new SolidColorBrush(Palette.GetColor(segment.Value01)), Data = streamGeom, Style = pathStyle }; content.Children.Add(path); addedPaths.Add(path); labelGrid.Visibility = Visibility.Visible; Binding pathBinding = new Binding { Path = new PropertyPath("StrokeThickness"), Source = this }; path.SetBinding(Path.StrokeThicknessProperty, pathBinding); } } else { labelGrid.Visibility = Visibility.Hidden; } }