Esempio n. 1
0
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(ICollection <IGrouping <int, LapTelemetryDto> > lapsStintGrouping)
        {
            string            title       = BuildTitleForAllStints(lapsStintGrouping);
            AxisDefinition    xAxis       = new AxisDefinition(_y1AxisDataExtractor.XMajorTickSize, _y1AxisDataExtractor.XMajorTickSize / 4, _y1AxisDataExtractor.XUnit);
            AxisDefinition    y1Axis      = new AxisDefinition(_y1AxisDataExtractor.YMajorTickSize, _y1AxisDataExtractor.YMajorTickSize / 4, _y1AxisDataExtractor.YUnit);
            AxisDefinition    y2Axis      = new AxisDefinition(_y2AxisDataExtractor.YMajorTickSize, _y2AxisDataExtractor.YMajorTickSize / 4, _y2AxisDataExtractor.YUnit);
            ScatterPlot2YAxis scatterPlot = new ScatterPlot2YAxis(title, xAxis, y1Axis, y2Axis);

            IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider();

            foreach (IGrouping <int, LapTelemetryDto> lapsInStintGroup in lapsStintGrouping)
            {
                string series1Title = $"Laps: {string.Join(", ", lapsInStintGroup.Select(x => x.LapSummary.CustomDisplayName))} - Stint: {lapsInStintGroup.Key}";
                scatterPlot.AddScatterPlotSeries(_y1AxisDataExtractor.ExtractSeries(lapsInStintGroup, _filters, Y1Title + "-" + series1Title, colorPaletteProvider.GetNext().ToOxyColor()));
                scatterPlot.AddScatterPlotY2Series(_y2AxisDataExtractor.ExtractSeries(lapsInStintGroup, _filters, Y2Title + "-" + series1Title, colorPaletteProvider.GetNext().ToOxyColor()));
            }
            OnNewScatterPlot(scatterPlot);
            ScatterPlot2YAxisChartViewModel viewModel = new ScatterPlot2YAxisChartViewModel()
            {
                Title = ChartName
            };

            viewModel.FromModel(scatterPlot);
            return(new[] { viewModel });
        }
Esempio n. 2
0
        protected IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings)
        {
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();

            foreach (IGrouping <int, LapTelemetryDto> lapsInStintGroup in lapsStintGrouping)
            {
                string title = BuildSeriesTitle(lapsInStintGroup, aggregatedChartSettings);

                AxisDefinition    xAxis       = new AxisDefinition(_y1AxisDataExtractor.XMajorTickSize, _y1AxisDataExtractor.XMajorTickSize / 4, _y1AxisDataExtractor.XUnit);
                AxisDefinition    y1Axis      = new AxisDefinition(_y1AxisDataExtractor.YMajorTickSize, _y1AxisDataExtractor.YMajorTickSize / 4, _y1AxisDataExtractor.YUnit);
                AxisDefinition    y2Axis      = new AxisDefinition(_y2AxisDataExtractor.YMajorTickSize, _y2AxisDataExtractor.YMajorTickSize / 4, _y2AxisDataExtractor.YUnit);
                ScatterPlot2YAxis scatterPlot = new ScatterPlot2YAxis(title, xAxis, y1Axis, y2Axis);

                scatterPlot.AddScatterPlotSeries(_y1AxisDataExtractor.ExtractSeries(lapsInStintGroup, _filters, Y1Title + "-" + title, OxyColors.Green));
                scatterPlot.AddScatterPlotY2Series(_y2AxisDataExtractor.ExtractSeries(lapsInStintGroup, _filters, Y2Title + "-" + title, OxyColors.Red));
                OnNewScatterPlot(scatterPlot);
                ScatterPlot2YAxisChartViewModel viewModel = new ScatterPlot2YAxisChartViewModel()
                {
                    Title = ChartName
                };
                viewModel.FromModel(scatterPlot);
                charts.Add(viewModel);
            }

            return(charts);
        }
        protected IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings)
        {
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();

            foreach (IGrouping <int, LapTelemetryDto> lapsInStintGroup in lapsStintGrouping)
            {
                string title = BuildChartTitle(lapsInStintGroup, aggregatedChartSettings);

                AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit);
                AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit);
                ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis)
                {
                    IsLegendVisible = IsLegendVisible
                };

                scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeries(lapsInStintGroup, Enumerable.Empty <ITelemetryFilter>().ToList(), title, OxyColors.Green));

                ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
                {
                    Title = ChartName
                };
                viewModel.FromModel(scatterPlot);
                charts.Add(viewModel);
            }

            return(charts);
        }
Esempio n. 4
0
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping)
        {
            IColorPaletteProvider            colorPaletteProvider = new BasicColorPaletteProvider();
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();
            IEnumerable <IGrouping <int, LapTelemetryDto> > lapsInStints = lapsStintGrouping as IGrouping <int, LapTelemetryDto>[] ?? lapsStintGrouping.ToArray();

            string title = BuildTitleForAllStints(lapsInStints);
            double maxG  = 0;

            AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Lat Acc");
            AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Long Acc");
            ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis);

            foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsInStints)
            {
                string            seriesTitle = $"Laps: {string.Join(", ", lapsInStint.Select(x => x.LapSummary.CustomDisplayName))} - Stint: {lapsInStint.Key}";
                ScatterPlotSeries newSeries   = _dataExtractor.ExtractSeries(lapsInStint, Enumerable.Empty <ITelemetryFilter>().ToList(), seriesTitle, colorPaletteProvider.GetNext().ToOxyColor());
                scatterPlot.AddScatterPlotSeries(newSeries);
                maxG = Math.Max(maxG, newSeries.DataPoints.Max(x => Math.Abs(x.Y)));
            }

            SetAxisRanges(maxG, xAxis, yAxis);
            ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
            {
                Title = "Lateral / Longitudinal G"
            };

            viewModel.FromModel(scatterPlot);
            charts.Add(viewModel);
            return(charts);
        }
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping)
        {
            var    lapsInStints = lapsStintGrouping as IGrouping <int, LapTelemetryDto>[] ?? lapsStintGrouping.ToArray();
            string title        = BuildTitleForAllStints(lapsInStints);
            IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider();
            AxisDefinition        xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Rear Roll Angle");
            AxisDefinition        yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Front Roll Angle");
            ScatterPlot           scatterPlot = new ScatterPlot(title, xAxis, yAxis);

            _lateralAccFilter.MinimumG = 0;
            _lateralAccFilter.MaximumG = double.MaxValue;
            foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsInStints)
            {
                string            seriesTitle = BuildSeriesTitle(lapsInStint);
                ScatterPlotSeries newSeries   = _dataExtractor.ExtractSeries(lapsInStint, _filters, seriesTitle, colorPaletteProvider.GetNext().ToOxyColor());
                scatterPlot.AddScatterPlotSeries(newSeries);
            }

            scatterPlot.AddAnnotation(new LineAnnotation()
            {
                Slope = 1, Intercept = 0, Color = OxyColors.Red, StrokeThickness = 1, LineStyle = LineStyle.Solid
            });
            ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
            {
                Title = title
            };

            viewModel.FromModel(scatterPlot);
            return(new[] { viewModel });
        }
Esempio n. 6
0
    public static bool AddAxis( AxisDefinition axis )
    {
        if( AxisDefined( axis.name ) )
        {
            return false;
        }

        SerializedObject serializedObject = new SerializedObject( AssetDatabase.LoadAllAssetsAtPath( "ProjectSettings/InputManager.asset" )[0] );
        SerializedProperty axesProperty = serializedObject.FindProperty( "m_Axes" );

        axesProperty.arraySize++;
        serializedObject.ApplyModifiedProperties();

        SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex( axesProperty.arraySize - 1 );

        GetChildProperty( axisProperty, "m_Name" ).stringValue = axis.name;
        GetChildProperty( axisProperty, "descriptiveName" ).stringValue = axis.descriptiveName;
        GetChildProperty( axisProperty, "descriptiveNegativeName" ).stringValue = axis.descriptiveNegativeName;
        GetChildProperty( axisProperty, "negativeButton" ).stringValue = axis.negativeButton;
        GetChildProperty( axisProperty, "positiveButton" ).stringValue = axis.positiveButton;
        GetChildProperty( axisProperty, "altNegativeButton" ).stringValue = axis.altNegativeButton;
        GetChildProperty( axisProperty, "altPositiveButton" ).stringValue = axis.altPositiveButton;
        GetChildProperty( axisProperty, "gravity" ).floatValue = axis.gravity;
        GetChildProperty( axisProperty, "dead" ).floatValue = axis.dead;
        GetChildProperty( axisProperty, "sensitivity" ).floatValue = axis.sensitivity;
        GetChildProperty( axisProperty, "snap" ).boolValue = axis.snap;
        GetChildProperty( axisProperty, "invert" ).boolValue = axis.invert;
        GetChildProperty( axisProperty, "type" ).intValue = (int)axis.type;
        GetChildProperty( axisProperty, "axis" ).intValue = axis.axis - 1;
        GetChildProperty( axisProperty, "joyNum" ).intValue = axis.joyNum;

        serializedObject.ApplyModifiedProperties();
        return true;
    }
        public IAggregatedChartViewModel CreateAggregatedChartViewModel()
        {
            IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLapsCache.LoadedLaps;
            string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}";

            AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Lat Acc");
            AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Long Acc");
            ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis);

            for (int i = 0; i < 4; i++)
            {
                _throttlePositionFilter.Minimum = i * 0.25;;
                _throttlePositionFilter.Maximum = (i + 1) * 0.25;
                string seriesTitle = $"Throttle - {i * 25}% - {(i + 1) * 25:F2}%";
                scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeries(loadedLaps, _filters, seriesTitle, ColorMap[i]));
            }

            _throttlePositionFilter.Minimum = 1;
            _throttlePositionFilter.Maximum = double.MaxValue;
            scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeries(loadedLaps, _filters, "Throttle - 100%", ColorMap[4]));

            ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel()
            {
                Title = "Lateral / Longitudinal G"
            };

            viewModel.FromModel(scatterPlot);

            return(viewModel);
        }
Esempio n. 8
0
		public static void SaveAxis (AxisDefinition axis, int index)
		{
			SerializedObject inputManager = GetInputManager ();
			SerializedProperty axes = inputManager.FindProperty ("m_Axes");
			AxisDefinition.Save (axis, axes.GetArrayElementAtIndex (index));

			inputManager.ApplyModifiedProperties ();
		}
        protected ScatterPlot CreateScatterPlot(IReadOnlyCollection <LapTelemetryDto> loadedLaps, int gear)
        {
            AxisDefinition xAxis       = new AxisDefinition(_rpmToHorizontalGExtractor.XMajorTickSize, _rpmToHorizontalGExtractor.XMajorTickSize / 4, _rpmToHorizontalGExtractor.XUnit);
            AxisDefinition yAxis       = new AxisDefinition(_rpmToHorizontalGExtractor.YMajorTickSize, _rpmToHorizontalGExtractor.YMajorTickSize / 4, _rpmToHorizontalGExtractor.YUnit);
            ScatterPlot    scatterPlot = new ScatterPlot($"Gear: {gear}", xAxis, yAxis);

            scatterPlot.AddScatterPlotSeries(_rpmToHorizontalGExtractor.ExtractSeriesForGear(loadedLaps, gear.ToString()));
            return(scatterPlot);
        }
        protected ScatterPlot CreateScatterPlot(IEnumerable <LapTelemetryDto> loadedLaps, int gear)
        {
            AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 5, _dataExtractor.XUnit);
            AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit);
            ScatterPlot    scatterPlot = new ScatterPlot($"Gear: {gear}", xAxis, yAxis);

            scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeriesForGear(loadedLaps, gear.ToString()));
            return(scatterPlot);
        }
Esempio n. 11
0
        private void SetAxisRanges(double maximumG, AxisDefinition xAxis, AxisDefinition yAxis)
        {
            double maximum = Math.Ceiling(maximumG);

            xAxis.UseCustomRange = true;
            yAxis.UseCustomRange = true;
            xAxis.Minimum        = -maximum;
            xAxis.Maximum        = maximum;
            yAxis.Minimum        = -maximum;
            yAxis.Maximum        = maximum;
        }
Esempio n. 12
0
        public void TestAxis()
        {
            var axis = new AxisDefinition();

            axis.ShowLines.Should().BeTrue();
            axis.ShowTicks.Should().BeTrue();
            axis.Spacing.Should().Be(100);
            axis.Caption.Should().BeNull();
            axis.LinePen.Should().NotBeNull();
            axis.LinePen.Thickness.Should().Be(1);
            axis.LinePen.Brush.Should().NotBeNull();
        }
        protected ScatterPlot CreateScatterPlotAllGear(IReadOnlyCollection <LapTelemetryDto> loadedLaps, int maxGear)
        {
            AxisDefinition xAxis       = new AxisDefinition(_rpmToHorizontalGExtractor.XMajorTickSize, _rpmToHorizontalGExtractor.XMajorTickSize / 4, _rpmToHorizontalGExtractor.XUnit);
            AxisDefinition yAxis       = new AxisDefinition(_rpmToHorizontalGExtractor.YMajorTickSize, _rpmToHorizontalGExtractor.YMajorTickSize / 4, _rpmToHorizontalGExtractor.YUnit);
            ScatterPlot    scatterPlot = new ScatterPlot("All Gears", xAxis, yAxis);

            for (int i = 1; i <= maxGear; i++)
            {
                scatterPlot.AddScatterPlotSeries(_rpmToHorizontalGExtractor.ExtractSeriesForGear(loadedLaps, i.ToString()));
            }

            return(scatterPlot);
        }
Esempio n. 14
0
            static Vector3 Convert(AxisDefinition axisDef)
            {
                if (axisDef.axis == Axis.X)
                {
                    return(Vector3.right * (axisDef.negative ? -1f : 1f));
                }

                if (axisDef.axis == Axis.Y)
                {
                    return(Vector3.up * (axisDef.negative ? -1f : 1f));
                }

                return(Vector3.forward * (axisDef.negative ? -1f : 1f));
            }
        private ScatterPlot CreateScatterPlotAllGear(IGrouping <int, LapTelemetryDto>[] lapsInStints, int maxGear)
        {
            IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider();
            AxisDefinition        xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 5, _dataExtractor.XUnit);
            AxisDefinition        yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit);
            ScatterPlot           scatterPlot = new ScatterPlot("All Gears", xAxis, yAxis);

            foreach (IGrouping <int, LapTelemetryDto> stint in lapsInStints)
            {
                string seriesTitle = $"Laps: {string.Join(", ", stint.Select(x => x.LapSummary.CustomDisplayName))} - Stint: {stint.Key}";
                scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeriesForAllGears(stint, seriesTitle, colorPaletteProvider.GetNext().ToOxyColor()));
            }

            return(scatterPlot);
        }
Esempio n. 16
0
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings)
        {
            IColorPaletteProvider            colorPaletteProvider = new RedGreenGradientPalette();
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();

            foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsStintGrouping)
            {
                string            title       = BuildChartTitle(lapsInStint, aggregatedChartSettings);
                double            maxG        = 0;
                AxisDefinition    xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Lat Acc");
                AxisDefinition    yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Long Acc");
                ScatterPlot       scatterPlot = new ScatterPlot(title, xAxis, yAxis);
                ScatterPlotSeries newSeries;
                double            throttlePortion = 1.0 / colorPaletteProvider.PaletteSize;

                for (int i = 0; i < colorPaletteProvider.PaletteSize - 1; i++)
                {
                    _throttlePositionFilter.Minimum = i * throttlePortion;
                    _throttlePositionFilter.Maximum = (i + 1) * throttlePortion;
                    string seriesTitle = $"Throttle - {i * throttlePortion * 100:F2}% - {(i + 1) * throttlePortion * 100:F2}%";
                    newSeries = _dataExtractor.ExtractSeries(lapsInStint, _filters, seriesTitle, colorPaletteProvider.GetNext().ToOxyColor());
                    if (newSeries == null)
                    {
                        continue;
                    }
                    scatterPlot.AddScatterPlotSeries(newSeries);
                    maxG = Math.Max(maxG, newSeries.DataPoints.Max(x => Math.Abs(x.Y)));
                }


                _throttlePositionFilter.Minimum = 1;
                _throttlePositionFilter.Maximum = double.MaxValue;
                newSeries = _dataExtractor.ExtractSeries(lapsInStint, _filters, "Throttle - 100%", colorPaletteProvider.GetNext().ToOxyColor());
                maxG      = Math.Max(maxG, newSeries.DataPoints.Max(x => Math.Abs(x.Y)));
                scatterPlot.AddScatterPlotSeries(newSeries);

                SetAxisRanges(maxG, xAxis, yAxis);
                ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
                {
                    Title = "Lateral / Longitudinal G"
                };
                viewModel.FromModel(scatterPlot);
                charts.Add(viewModel);
            }

            return(charts);
        }
Esempio n. 17
0
        public void TestShowLines()
        {
            var axis    = new AxisDefinition();
            var changes = new List <string>();

            axis.PropertyChanged += (sender, args) => changes.Add(args.PropertyName);

            axis.ShowLines = false;
            axis.ShowLines.Should().BeFalse();
            changes.Should().Equal(new object[] { "ShowLines" });

            axis.ShowLines = false;
            changes.Should().Equal(new object[] { "ShowLines" });

            axis.ShowLines = true;
            axis.ShowLines.Should().BeTrue();
            changes.Should().Equal(new object[] { "ShowLines", "ShowLines" });
        }
Esempio n. 18
0
        public void TestSpacing()
        {
            var axis    = new AxisDefinition();
            var changes = new List <string>();

            axis.PropertyChanged += (sender, args) => changes.Add(args.PropertyName);

            axis.Spacing = 50;
            axis.Spacing.Should().Be(50);
            changes.Should().Equal(new object[] { "Spacing" });

            axis.Spacing = 50;
            changes.Should().Equal(new object[] { "Spacing" });

            axis.Spacing = 50.00001;
            axis.Spacing.Should().Be(50.00001);
            changes.Should().Equal(new object[] { "Spacing", "Spacing" });
        }
Esempio n. 19
0
        public void TestCaption()
        {
            var axis    = new AxisDefinition();
            var changes = new List <string>();

            axis.PropertyChanged += (sender, args) => changes.Add(args.PropertyName);

            axis.Caption = "foo";
            axis.Caption.Should().Be("foo");
            changes.Should().Equal(new object[] { "Caption" });

            axis.Caption = "foo";
            changes.Should().Equal(new object[] { "Caption" });

            axis.Caption = "bar";
            axis.Caption.Should().Be("bar");
            changes.Should().Equal(new object[] { "Caption", "Caption" });
        }
Esempio n. 20
0
        public IAggregatedChartViewModel CreateAggregatedChartViewModel()
        {
            IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLapsCache.LoadedLaps;
            string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}";

            AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit);
            AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit);
            ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis);

            scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeries(loadedLaps, Enumerable.Empty <ITelemetryFilter>().ToList(), title, OxyColors.Green));

            ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel()
            {
                Title = "Downforce"
            };

            viewModel.FromModel(scatterPlot);

            return(viewModel);
        }
Esempio n. 21
0
        public void TestLinePen()
        {
            var axis    = new AxisDefinition();
            var changes = new List <string>();

            axis.PropertyChanged += (sender, args) => changes.Add(args.PropertyName);

            var pen = new Pen(Brushes.Blue, 2);

            axis.LinePen = pen;
            axis.LinePen.Should().Be(pen);
            changes.Should().Equal(new object[] { "LinePen" });

            axis.LinePen = pen;
            changes.Should().Equal(new object[] { "LinePen" });

            var pen2 = new Pen(Brushes.Black, 2);

            axis.LinePen = pen2;
            axis.LinePen.Should().Be(pen2);
            changes.Should().Equal(new object[] { "LinePen", "LinePen" });
        }
        public IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings)
        {
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();

            foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsStintGrouping)
            {
                string         title       = BuildChartTitle(lapsInStint, aggregatedChartSettings);
                AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Rear Roll Angle");
                AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Front Roll Angle");
                ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis);

                for (int i = 0; i < ColorMap.Count; i++)
                {
                    double minG = i * 0.25;
                    double maxG = i + 1 == ColorMap.Count ? double.MaxValue : (i + 1) * 0.25;
                    _lateralAccFilter.MinimumG = minG;
                    _lateralAccFilter.MaximumG = maxG;
                    string            seriesTitle = maxG < double.MaxValue ? $"{minG:F2}G - {maxG:F2}G" : $"{minG:F2}G+";
                    ScatterPlotSeries newSeries   = _dataExtractor.ExtractSeries(lapsInStint, _filters, seriesTitle, ColorMap[i]);
                    if (newSeries == null)
                    {
                        continue;
                    }
                }

                scatterPlot.AddAnnotation(new LineAnnotation()
                {
                    Slope = 1, Intercept = 0, Color = OxyColors.Red, StrokeThickness = 1, LineStyle = LineStyle.Solid
                });
                ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
                {
                    Title = title
                };
                viewModel.FromModel(scatterPlot);
                charts.Add(viewModel);
            }

            return(charts);
        }
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(ICollection <IGrouping <int, LapTelemetryDto> > lapsStintGrouping)
        {
            string         title       = BuildTitleForAllStints(lapsStintGrouping);
            AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit);
            AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit);
            ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis);

            IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider();

            foreach (IGrouping <int, LapTelemetryDto> lapsInStintGroup in lapsStintGrouping)
            {
                string seriesTitle = $"Laps: {string.Join(", ", lapsInStintGroup.Select(x => x.LapSummary.CustomDisplayName))} - Stint: {lapsInStintGroup.Key}";
                scatterPlot.AddScatterPlotSeries(_dataExtractor.ExtractSeries(lapsInStintGroup, Enumerable.Empty <ITelemetryFilter>().ToList(), seriesTitle, colorPaletteProvider.GetNext().ToOxyColor()));
            }

            ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
            {
                Title = ChartName
            };

            viewModel.FromModel(scatterPlot);
            return(new[] { viewModel });
        }
Esempio n. 24
0
        public IAggregatedChartViewModel CreateAggregatedChartViewModel()
        {
            IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLapsCache.LoadedLaps;
            string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}";

            AxisDefinition xAxis       = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Rear Roll Angle");
            AxisDefinition yAxis       = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Front Roll Angle");
            ScatterPlot    scatterPlot = new ScatterPlot(title, xAxis, yAxis);

            for (int i = 0; i < ColorMap.Count; i++)
            {
                double minG = i * 0.25;
                double maxG = i + 1 == ColorMap.Count ? double.MaxValue : (i + 1) * 0.25;
                _lateralAccFilter.MinimumG = minG;
                _lateralAccFilter.MaximumG = maxG;
                string            seriesTitle = maxG < double.MaxValue ? $"{minG:F2}G - {maxG:F2}G" : $"{minG:F2}G+";
                ScatterPlotSeries newSeries   = _dataExtractor.ExtractSeries(loadedLaps, _filters, seriesTitle, ColorMap[i]);
                if (newSeries == null)
                {
                    continue;
                }

                scatterPlot.AddScatterPlotSeries(newSeries);
            }
            scatterPlot.AddAnnotation(new LineAnnotation()
            {
                Slope = 1, Intercept = 0, Color = OxyColors.Red, StrokeThickness = 1, LineStyle = LineStyle.Solid
            });
            ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel()
            {
                Title = title
            };

            viewModel.FromModel(scatterPlot);

            return(viewModel);
        }
Esempio n. 25
0
    public static void Import(bool manual = false)
    {
        Object[] assets = Resources.FindObjectsOfTypeAll(typeof(SettingsImport));

        if (assets.Length < 1)
        {
            if (manual)
            {
                Debug.LogError("Did not find a settings export asset for importing");
            }
            return;
        }

        SettingsImport   asset      = (SettingsImport)assets[0];
        SerializedObject tagManager = GetTagManager();

        Debug.Log("Importing settings...", asset);

        SerializedProperty tags = tagManager.FindProperty("tags");

        for (int i = 0; i < asset.tags.Length; ++i)
        {
            if (i > tags.arraySize - 1)
            {
                tags.InsertArrayElementAtIndex(i);
                SerializedProperty userTag = tags.GetArrayElementAtIndex(i);
                userTag.stringValue = asset.tags[i];
            }
            else
            {
                SerializedProperty userTag = tags.GetArrayElementAtIndex(i);

                if (asset.Collision(userTag.stringValue, asset.tags[i], "Tag", manual))
                {
                    tagManager.ApplyModifiedProperties();
                    return;
                }

                userTag.stringValue = asset.tags[i];
            }
        }

        for (int i = 0; i < asset.layers.Length; ++i)
        {
            SerializedProperty userLayer = tagManager.FindProperty(kUserLayerPrefix + (i + 8));

            if (asset.Collision(userLayer.stringValue, asset.layers[i], "Layer", manual))
            {
                tagManager.ApplyModifiedProperties();
                return;
            }

            userLayer.stringValue = asset.layers[i];
        }

        List <AxisDefinition> axes = InputInterface.GetAxes();

        foreach (AxisDefinition axis in asset.axes)
        {
            if (axes.Contains(axis))
            {
                continue;
            }

            AxisDefinition collision = axes.Where(other => axis.InterfaceEquals(other)).FirstOrDefault();

            if (collision != null)
            {
                InputInterface.SaveAxis(axis, axes.IndexOf(collision));
                axes = InputInterface.GetAxes();
                continue;
            }

            InputInterface.AddAxis(axis);
            axes = InputInterface.GetAxes();
        }


        tagManager.ApplyModifiedProperties();
    }