/// <summary> /// Creates the environment. /// </summary> /// <param name="viewport">The viewport.</param> /// <returns></returns> public override DataSourceEnvironment CreateEnvironment(Viewport2D viewport) { DataSourceEnvironment result = new DataSourceEnvironment { Output = viewport.Output, Visible = viewport.Visible, RealVisible = viewport.Visible, Transform = viewport.Transform }; return(result); }
/// <summary> /// Creates the environment. /// </summary> /// <returns></returns> protected DataSourceEnvironment CreateEnvironment() { if (plotter == null) { throw new InvalidOperationException(); } Viewport2D viewport = plotter.Viewport; DataSourceEnvironment result = environmentPlugin.CreateEnvironment(viewport); visibleWhileCreation = result.Visible; outputWhileCreation = result.Output; return(result); }
private void UpdateUIRepresentation() { Viewport2D viewport = Plotter.Viewport; DataSourceEnvironment environment = EnvironmentPlugin.CreateEnvironment(viewport); bool visibleChangedSignificantly = !DataRect.EqualsEpsSizes( environment.Visible, VisibleWhileCreation, rectanglesEps); bool outputChangedSignificantly = !DataRect.EqualsEpsSizes( new DataRect(environment.Output), new DataRect(OutputWhileCreation), rectanglesEps); bool visibleIsOutOfVisibleWhileCreation = !VisibleWhileCreation.Contains(viewport.Visible); if (visibleChangedSignificantly || outputChangedSignificantly || visibleIsOutOfVisibleWhileCreation) { DestroyUIRepresentation(); CreateUIRepresentation(); return; } }
protected override IEnumerable GetDataCore(DataSourceEnvironment environment) { if (XSequence == null || YSequence == null) { throw new InvalidOperationException(xAndYShouldNotBeNull); } IEnumerator <double> xEnumerator = XSequence.GetEnumerator(); IEnumerator <double> yEnumerator = YSequence.GetEnumerator(); double xMin = Double.MaxValue; double xMax = Double.MinValue; double yMin = Double.MaxValue; double yMax = Double.MinValue; while (xEnumerator.MoveNext() && yEnumerator.MoveNext()) { double x = xEnumerator.Current; double y = yEnumerator.Current; if (x < xMin) { xMin = x; } if (x > xMax) { xMax = x; } if (y < yMin) { yMin = y; } if (y > yMax) { yMax = y; } yield return(new Point(x, y)); } environment.ContentBounds = new DataRect(new Point(xMin, yMin), new Point(xMax, yMax)); }
protected override IEnumerable GetDataCore(DataSourceEnvironment environment) { double time = watch.Elapsed.TotalSeconds; DataRect visible = environment.Visible; DataRect realVisible = environment.RealVisible; Rect output = environment.Output; CoordinateTransform transform = environment.Transform; double yMin = Double.PositiveInfinity; double yMax = Double.NegativeInfinity; double step = visible.Width / output.Width; for (double x = visible.XMin; x <= visible.XMax; x += step) { double dataX = x; double viewportY = func(dataX, time); if (realVisible.HorizontalRange.Contains(x)) { if (viewportY < yMin) { yMin = viewportY; } if (viewportY > yMax) { yMax = viewportY; } } yield return(new Point(dataX, viewportY)); } DataRect bounds = DataRect.Empty; bounds.UnionY(yMin); bounds.UnionY(yMax); environment.ContentBounds = bounds; }
protected override System.Collections.IEnumerable GetDataCore(DataSourceEnvironment environment) { yield return(new Point()); yield return(new Point()); }
internal IEnumerable <IndexWrapper <Point> > Filter(IEnumerable <IndexWrapper <Point> > points, DataSourceEnvironment environment) { foreach (var filter in Items) { filter.Environment = environment; points = filter.Filter(points); } return(points); }
public static IEnumerable <Point> GetPoints(this PointDataSourceBase dataSource, DataSourceEnvironment environment) { return(dataSource.GetData(environment).Cast <object>().Select(o => dataSource.DataToPoint(o))); }
private void CreateUIRepresentation() { if (Plotter == null) { return; } if (DataSource == null) { return; } drawnPaths.Clear(); DataSourceEnvironment environment = CreateEnvironment(); var points = DataSource.GetPoints(environment); var indexedPoints = IndexWrapper.Generate(points); // do nothing if there is nothing to draw if (!points.Any()) { return; } transformWhileCreateUI = Plotter.Viewport.Transform; int globalMinIndex; int globalMaxIndex; CreateAndAddPath(indexedPoints, out globalMinIndex, out globalMaxIndex, transformWhileCreateUI); indexRange = new Range <int>(globalMinIndex, globalMaxIndex); ViewportPanel.SetViewportBounds(canvas, Plotter.Viewport.Visible); // switching off content bounds calculation for children of ViewportHostPanel. panel.BeginBatchAdd(); if (canvas.Parent == null) { panel.Children.Add(canvas); } if (panel.Plotter == null) { Plotter.Dispatcher.BeginInvoke(() => { if (panel.Plotter == null && Plotter != null) { Plotter.Children.Add(panel); } }); } DataRect bounds = DataRect.Empty; if (environment.ContentBounds != null) { bounds = environment.ContentBounds.Value; } else { // todo is this necessary? bounds = points.GetBounds(); } Viewport2D.SetContentBounds(this, bounds); }
protected override IEnumerable GetDataCore(DataSourceEnvironment environment) { return(Enumerable.Empty <Point>()); }