예제 #1
0
        public DownsamplerSeries(PlotDownsampler owner, XYAxisSeries series, IObservable <List <DataPoint> > pointsSouce)
        {
            Series      = series;
            PointsSouce = pointsSouce;
            Owner       = owner;

            RawPoints = new List <DataPoint>();
            pointsSouce.ObserveOnDispatcher().Subscribe(p => OnNewPoints(p));
        }
예제 #2
0
 public void RefreshPoints()
 {
     if (Owner.Downsample)
     {
         Series.ItemsSource = PlotDownsampler.LargestTriangleThreeBuckets(RawPoints, Owner.DownsampleLimit);
     }
     else
     {
         Series.ItemsSource = RawPoints;
     }
     Series.PlotModel.InvalidatePlot(true);
 }
예제 #3
0
        public FrameTimeViewModel(IEventAggregator events)
        {
            Events = events;

            DisplayName = "Frame Timeline";

            Model = new PlotModel();
            Model.LegendBackground = OxyColor.FromArgb(200, 255, 255, 255);
            Model.LegendBorder     = OxyColors.Black;
            Model.LegendPlacement  = LegendPlacement.Inside;
            Model.LegendPosition   = LegendPosition.RightTop;
            Model.Title            = "Frame Timeline";

            DownSampler = new PlotDownsampler();

            /*
             *    var timeLineAxis = new TimeSpanAxis() {
             *      MajorGridlineStyle = LineStyle.Solid,
             *      MinorGridlineStyle = LineStyle.Dot,
             *      IntervalLength = 30,
             *      MajorStep = 1,
             *      Position = AxisPosition.Bottom,
             *      AbsoluteMinimum = 0,
             *    };
             */
            BottomAxis = new LinearAxis()
            {
                AbsoluteMinimum = 0,
                Position        = AxisPosition.Bottom,
                MinorStep       = 1000,
                MajorStep       = 1000 * 60,
            };

            BottomAxis.AxisChanged   += TimeLineAxis_AxisChanged;
            BottomAxis.LabelFormatter = t => $"{t/60000}";

            Model.Axes.Add(BottomAxis);

            /*
             * var dateTimeAxis = new DateTimeAxis {
             * Position = AxisPosition.Bottom,
             * IntervalType = DateTimeIntervalType.Seconds,
             * MinorIntervalType = DateTimeIntervalType.Milliseconds,
             * //IntervalLength = 50
             * };
             *
             * plotModel.Axes.Add(dateTimeAxis);
             */

            LeftAxis = new LinearAxis()
            {
                AbsoluteMinimum = 0,
                Position        = AxisPosition.Left,
                MinorStep       = 1,
                MajorStep       = 10,
                Title           = "Time Ms",
            };
            Model.Axes.Add(LeftAxis);
            LeftAxis.Zoom(0, 40);

            FrameTimeSeries = new LineSeries {
                Title           = "Frame",
                StrokeThickness = 1,
                // DataFieldX = nameof(FrameEntry.Time),
                //DataFieldY = nameof(FrameEntry.TimeTaken),
            };

            Model.Series.Add(FrameTimeSeries);
            DownSampler.AddSeries(FrameTimeSeries, this.OnPropertyChanges(n => FrametimePoints));

            SelectedTimeSeries = new LineSeries {
                Title           = "Selected",
                StrokeThickness = 1,
                Color           = OxyColors.Red,
            };

            Model.Series.Add(SelectedTimeSeries);
            DownSampler.AddSeries(SelectedTimeSeries, this.OnPropertyChanges(n => SelectedNode).
                                  Where(n => n != null || PLog.NodeStats.Count == 0).
                                  Select(n => GetNodeDataPoints(n)));

            UpdateWorldJobTimeSeries = new LineSeries {
                Title           = "UpdateWorldJob",
                StrokeThickness = 1,
                Color           = OxyColors.Black,
            };

            Model.Series.Add(UpdateWorldJobTimeSeries);
            DownSampler.AddSeries(UpdateWorldJobTimeSeries, this.OnPropertyChanges(n => FrametimePoints).
                                  Where(n => this.PLog.GetNameId("UpdateWorldJob::Run") != -1).
                                  Select(n => GetNodeDataPoints(this.PLog.GetNodeStats("UpdateWorldJob::Run"), f => f.InclusiveTime)));

            Ranges = PlotRangeTracker.Install(Model);

            Ranges.RangeCreated += Ranges_RangeCreated;
            Ranges.RangeMoved   += Ranges_RangeCreated;
            Ranges.RangeRemoved += (r, min, max) => { NodeList = PLog.NodeStats; };

            PLog = new ProfileLog();
        }