Example #1
0
 private void UpdateBounds(IPointDataSource dataSource)
 {
     if (Plotter2D != null)
     {
         var      transform = GetTransform();
         DataRect bounds    = BoundsHelper.GetViewportBounds(dataSource.GetPoints(), transform.DataTransform);
         Viewport2D.SetContentBounds(this, bounds);
     }
 }
Example #2
0
        protected override void UpdateCore()
        {
            if (DataSource == null)
            {
                return;
            }
            if (Plotter == null)
            {
                return;
            }
            if (!IsEnabled)
            {
                return;
            }

            Rect output    = Viewport.Output;
            var  transform = GetTransform();

            if (filteredPoints == null || !(transform.DataTransform is IdentityTransform))
            {
                IEnumerable <Point> points = GetPoints();

                var bounds = BoundsHelper.GetViewportBounds(points, transform.DataTransform);
                Viewport2D.SetContentBounds(this, bounds);

                // getting new value of transform as it could change after calculating and setting content bounds.
                transform = GetTransform();
                List <Point> transformedPoints = transform.DataToScreenAsList(points);

                // Analysis and filtering of unnecessary points
                filteredPoints = new FakePointList(FilterPoints(transformedPoints),
                                                   output.Left, output.Right);

                if (ProvideVisiblePoints)
                {
                    List <Point> viewportPointsList = null;
                    viewportPointsList = new List <Point>(transformedPoints.Count);
                    if (transform.DataTransform is IdentityTransform)
                    {
                        viewportPointsList.AddRange(points);
                    }
                    else
                    {
                        var viewportPoints = points.DataToViewport(transform.DataTransform);
                        viewportPointsList.AddRange(viewportPoints);
                    }
                    SetVisiblePoints(this, new ReadOnlyCollection <Point>(viewportPointsList));
                }
                Offset = new Vector();
            }
            else
            {
                double left  = output.Left;
                double right = output.Right;
                double shift = Offset.X;
                left  -= shift;
                right -= shift;

                filteredPoints.SetXBorders(left, right);
            }
        }
 public static DataRect GetBounds(this IEnumerable <Point> points)
 {
     return(BoundsHelper.GetViewportBounds(points));
 }