public void Test_SpeedSummaryPalette_ChooseColour() { var palette = new SpeedSummaryPalette(); palette.Should().NotBeNull(); var data = new MachineSpeedExtendedRecord(MEASURED_SPEED_MIN, MEASURED_SPEED_MAX); var colors = new[] { palette.LowerSpeedRangeColour, palette.WithinSpeedRangeColour, palette.WithinSpeedRangeColour, palette.WithinSpeedRangeColour, palette.WithinSpeedRangeColour, palette.OverSpeedRangeColour, palette.OverSpeedRangeColour, }; for (var i = 0; i < colors.Length; i++) { data.Min = (ushort)(MEASURED_SPEED_MIN + i * SPEED_INCREMENT); data.Max = (ushort)(MEASURED_SPEED_MAX + i * SPEED_INCREMENT); palette.ChooseColour(data).Should().Be(colors[i]); } }
public void Test_SpeedSummaryPalette_Creation() { var palette = new SpeedSummaryPalette(); palette.Should().NotBeNull(); palette.MachineSpeedTarget.Min.Should().Be(10); palette.MachineSpeedTarget.Max.Should().Be(30); palette.OverSpeedRangeColour.Should().Be(Color.Red); palette.WithinSpeedRangeColour.Should().Be(Color.Lime); palette.LowerSpeedRangeColour.Should().Be(Color.Blue); palette.PaletteTransitions.Should().BeNull(); }
public void Test_SpeedSummaryPalette_ChooseColour_NullTargetRange() { var palette = new SpeedSummaryPalette(); palette.Should().NotBeNull(); palette.MachineSpeedTarget = new MachineSpeedExtendedRecord(CellPassConsts.NullMachineSpeed, CellPassConsts.NullMachineSpeed); var data = new MachineSpeedExtendedRecord(MEASURED_SPEED_MIN, MEASURED_SPEED_MAX); var colors = new[] { Color.Empty, Color.Empty, Color.Empty, Color.Empty, Color.Empty, Color.Empty, Color.Empty }; for (var i = 0; i < colors.Length; i++) { data.Min = (ushort)(MEASURED_SPEED_MIN + i * SPEED_INCREMENT); data.Max = (ushort)(MEASURED_SPEED_MAX + i * SPEED_INCREMENT); palette.ChooseColour(data).Should().Be(colors[i]); } }
private PaletteBase ConvertColorPalettes(TRexTileRequest request, ISiteModel siteModel) { const double PERCENTAGE_RANGE_MIN = 0.0; const double PERCENTAGE_RANGE_MAX = 100.0; const ushort PASS_COUNT_TARGET_RANGE_MIN = 1; const ushort PASS_COUNT_TARGET_RANGE_MAX = ushort.MaxValue; const ushort TEMPERATURE_LEVELS_MIN = 0; const ushort TEMPERATURE_LEVELS_MAX = 100; var overrides = AutoMapperUtility.Automapper.Map <OverrideParameters>(request.Overrides); PaletteBase convertedPalette; var availableTransitions = request.Palettes != null?request.Palettes.Select(p => new Transition(p.Value, ColorUtility.UIntToColor(p.Color))).ToArray() : new Transition[0]; switch (request.Mode) { case DisplayMode.CCA: convertedPalette = new CCAPalette(); convertedPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.CCASummary: convertedPalette = new CCASummaryPalette(); var ccaSummaryPalette = ((CCASummaryPalette)convertedPalette); if (request.Palettes != null) { ccaSummaryPalette.UndercompactedColour = ColorUtility.UIntToColor(request.Palettes[0].Color); ccaSummaryPalette.CompactedColour = ColorUtility.UIntToColor(request.Palettes[1].Color); ccaSummaryPalette.OvercompactedColour = ColorUtility.UIntToColor(request.Palettes[2].Color); } break; case DisplayMode.CCV: convertedPalette = new CMVPalette(); var cmvPalette = ((CMVPalette)convertedPalette); cmvPalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN; cmvPalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX; cmvPalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true; cmvPalette.AbsoluteTargetCMV = overrides?.OverridingMachineCCV ?? 0; cmvPalette.TargetCCVColour = Color.Green; cmvPalette.DefaultDecoupledCMVColour = Color.Black; cmvPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.CCVPercent: case DisplayMode.CCVPercentSummary: case DisplayMode.CCVPercentChange: convertedPalette = new CCVPercentPalette(); var cmvPercentPalette = ((CCVPercentPalette)convertedPalette); cmvPercentPalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN; cmvPercentPalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX; cmvPercentPalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true; cmvPercentPalette.AbsoluteTargetCMV = overrides?.OverridingMachineCCV ?? 0; if (request.Palettes != null) { cmvPercentPalette.WithinCMVTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[0].Color); cmvPercentPalette.BelowCMVTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[2].Color); cmvPercentPalette.AboveCMVTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[3].Color); } break; case DisplayMode.CMVChange: convertedPalette = new CMVChangePalette(); var cmvPercentChangePalette = ((CMVChangePalette)convertedPalette); cmvPercentChangePalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN; cmvPercentChangePalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX; cmvPercentChangePalette.UseAbsoluteValues = false; cmvPercentChangePalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true; cmvPercentChangePalette.AbsoluteTargetCMV = overrides?.OverridingMachineCCV ?? 0; cmvPercentChangePalette.TargetCCVColour = Color.Green; cmvPercentChangePalette.DefaultDecoupledCMVColour = Color.Black; cmvPercentChangePalette.PaletteTransitions = availableTransitions; break; case DisplayMode.CutFill: convertedPalette = new CutFillPalette(); convertedPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.Height: convertedPalette = request.Palettes != null ? new HeightPalette(request.Palettes.First().Value, request.Palettes.Last().Value) : new HeightPalette(); ((HeightPalette)convertedPalette).ElevationPalette = request.Palettes?.Select(p => ColorUtility.UIntToColor(p.Color)).ToArray(); break; case DisplayMode.MDP: convertedPalette = new MDPPalette(); var mdpPalette = ((MDPPalette)convertedPalette); mdpPalette.MDPPercentageRange.Min = overrides?.MDPRange.Min ?? PERCENTAGE_RANGE_MIN; mdpPalette.MDPPercentageRange.Max = overrides?.MDPRange.Max ?? PERCENTAGE_RANGE_MAX; mdpPalette.UseMachineTargetMDP = !overrides?.OverrideMachineMDP ?? true; mdpPalette.AbsoluteTargetMDP = overrides?.OverridingMachineMDP ?? 0; mdpPalette.TargetMDPColour = Color.Green; mdpPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.MDPPercentSummary: convertedPalette = new MDPSummaryPalette(); var mdpSummaryPalette = ((MDPSummaryPalette)convertedPalette); mdpSummaryPalette.MDPPercentageRange.Min = overrides?.MDPRange.Min ?? PERCENTAGE_RANGE_MIN; mdpSummaryPalette.MDPPercentageRange.Max = overrides?.MDPRange.Max ?? PERCENTAGE_RANGE_MAX; mdpSummaryPalette.UseMachineTargetMDP = !overrides?.OverrideMachineMDP ?? true; mdpSummaryPalette.AbsoluteTargetMDP = overrides?.OverridingMachineMDP ?? 0; if (request.Palettes != null) { mdpSummaryPalette.WithinMDPTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[0].Color); mdpSummaryPalette.BelowMDPTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[2].Color); mdpSummaryPalette.AboveMDPTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[3].Color); } break; case DisplayMode.PassCount: convertedPalette = new PassCountPalette(); convertedPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.PassCountSummary: convertedPalette = new PassCountSummaryPalette(); var passCountPalette = ((PassCountSummaryPalette)convertedPalette); if (request.Palettes != null) { passCountPalette.AbovePassTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[2].Color); passCountPalette.WithinPassTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[1].Color); passCountPalette.BelowPassTargetRangeColour = ColorUtility.UIntToColor(request.Palettes[0].Color); } passCountPalette.UseMachineTargetPass = !overrides?.OverrideTargetPassCount ?? true; passCountPalette.TargetPassCountRange.Min = overrides?.OverridingTargetPassCountRange.Min ?? PASS_COUNT_TARGET_RANGE_MIN; passCountPalette.TargetPassCountRange.Max = overrides?.OverridingTargetPassCountRange.Max ?? PASS_COUNT_TARGET_RANGE_MAX; break; case DisplayMode.MachineSpeed: convertedPalette = new SpeedPalette(); convertedPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.TargetSpeedSummary: convertedPalette = new SpeedSummaryPalette(); var speedSummaryPalette = ((SpeedSummaryPalette)convertedPalette); if (request.Palettes != null) { speedSummaryPalette.LowerSpeedRangeColour = ColorUtility.UIntToColor(request.Palettes[0].Color); speedSummaryPalette.WithinSpeedRangeColour = ColorUtility.UIntToColor(request.Palettes[1].Color); speedSummaryPalette.OverSpeedRangeColour = ColorUtility.UIntToColor(request.Palettes[2].Color); } speedSummaryPalette.MachineSpeedTarget.Min = overrides?.TargetMachineSpeed.Min ?? CellPassConsts.NullMachineSpeed; speedSummaryPalette.MachineSpeedTarget.Max = overrides?.TargetMachineSpeed.Max ?? CellPassConsts.NullMachineSpeed; break; case DisplayMode.TemperatureDetail: convertedPalette = new TemperaturePalette(); convertedPalette.PaletteTransitions = availableTransitions; break; case DisplayMode.TemperatureSummary: convertedPalette = new TemperatureSummaryPalette(); var temperatureSummaryPalette = ((TemperatureSummaryPalette)convertedPalette); if (request.Palettes != null) { temperatureSummaryPalette.AboveMaxLevelColour = ColorUtility.UIntToColor(request.Palettes[2].Color); temperatureSummaryPalette.WithinLevelsColour = ColorUtility.UIntToColor(request.Palettes[1].Color); temperatureSummaryPalette.BelowMinLevelColour = ColorUtility.UIntToColor(request.Palettes[0].Color); } temperatureSummaryPalette.UseMachineTempWarningLevels = !overrides?.OverrideTemperatureWarningLevels ?? true; temperatureSummaryPalette.TemperatureLevels.Min = overrides?.OverridingTemperatureWarningLevels.Min ?? TEMPERATURE_LEVELS_MIN; temperatureSummaryPalette.TemperatureLevels.Max = overrides?.OverridingTemperatureWarningLevels.Max ?? TEMPERATURE_LEVELS_MAX; break; case DisplayMode.CompactionCoverage: convertedPalette = new CompactionCoveragePalette(); var compactionCoveragePalette = ((CompactionCoveragePalette)convertedPalette); compactionCoveragePalette.HasCMVData = availableTransitions[0].Color; compactionCoveragePalette.HasNoCMVData = availableTransitions[1].Color; break; default: // when adding modes, there are various other places in the code which will need work throw new TRexException($"No implemented colour palette for this mode ({request.Mode})"); } return(convertedPalette); }
private PaletteBase ConvertColorPalettes(DisplayMode mode, ISiteModel siteModel, OverrideParameters overrides) { const double PERCENTAGE_RANGE_MIN = 0.0; const double PERCENTAGE_RANGE_MAX = 100.0; const ushort PASS_COUNT_TARGET_RANGE_MIN = 1; const ushort PASS_COUNT_TARGET_RANGE_MAX = ushort.MaxValue; const ushort TEMPERATURE_LEVELS_MIN = 0; const ushort TEMPERATURE_LEVELS_MAX = 100; PaletteBase convertedPalette; switch (mode) { case DisplayMode.CCA: convertedPalette = new CCAPalette(); break; case DisplayMode.CCASummary: convertedPalette = new CCASummaryPalette(); break; case DisplayMode.CCV: convertedPalette = new CMVPalette(); var cmvPalette = ((CMVPalette)convertedPalette); cmvPalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN; cmvPalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX; cmvPalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true; cmvPalette.AbsoluteTargetCMV = overrides?.OverridingMachineCCV ?? 0; cmvPalette.TargetCCVColour = Color.Green; cmvPalette.DefaultDecoupledCMVColour = Color.Black; break; case DisplayMode.CCVPercent: case DisplayMode.CCVPercentSummary: case DisplayMode.CCVPercentChange: convertedPalette = new CCVPercentPalette(); var cmvSummaryPalette = ((CCVPercentPalette)convertedPalette); cmvSummaryPalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN; cmvSummaryPalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX; cmvSummaryPalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true; cmvSummaryPalette.AbsoluteTargetCMV = overrides?.OverridingMachineCCV ?? 0; break; case DisplayMode.CMVChange: convertedPalette = new CMVChangePalette(); var cmvPercentChangePalette = ((CMVChangePalette)convertedPalette); cmvPercentChangePalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN; cmvPercentChangePalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX; cmvPercentChangePalette.UseAbsoluteValues = false; cmvPercentChangePalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true; cmvPercentChangePalette.AbsoluteTargetCMV = overrides?.OverridingMachineCCV ?? 0; cmvPercentChangePalette.TargetCCVColour = Color.Green; cmvPercentChangePalette.DefaultDecoupledCMVColour = Color.Black; break; case DisplayMode.CutFill: convertedPalette = new CutFillPalette(); break; case DisplayMode.Height: var extent = siteModel.GetAdjustedDataModelSpatialExtents(new Guid[0]); convertedPalette = new HeightPalette(extent.MinZ, extent.MaxZ); break; case DisplayMode.MDP: convertedPalette = new MDPPalette(); var mdpPalette = ((MDPPalette)convertedPalette); mdpPalette.MDPPercentageRange.Min = overrides?.MDPRange.Min ?? PERCENTAGE_RANGE_MIN; mdpPalette.MDPPercentageRange.Max = overrides?.MDPRange.Max ?? PERCENTAGE_RANGE_MAX; mdpPalette.UseMachineTargetMDP = !overrides?.OverrideMachineMDP ?? true; mdpPalette.AbsoluteTargetMDP = overrides?.OverridingMachineMDP ?? 0; mdpPalette.TargetMDPColour = Color.Green; break; case DisplayMode.MDPPercentSummary: convertedPalette = new MDPSummaryPalette(); var mdpSummaryPalette = ((MDPSummaryPalette)convertedPalette); mdpSummaryPalette.MDPPercentageRange.Min = overrides?.MDPRange.Min ?? PERCENTAGE_RANGE_MIN; mdpSummaryPalette.MDPPercentageRange.Max = overrides?.MDPRange.Max ?? PERCENTAGE_RANGE_MAX; mdpSummaryPalette.UseMachineTargetMDP = !overrides?.OverrideMachineMDP ?? true; mdpSummaryPalette.AbsoluteTargetMDP = overrides?.OverridingMachineMDP ?? 0; break; case DisplayMode.PassCount: convertedPalette = new PassCountPalette(); break; case DisplayMode.PassCountSummary: convertedPalette = new PassCountSummaryPalette(); var passCountPalette = ((PassCountSummaryPalette)convertedPalette); passCountPalette.UseMachineTargetPass = !overrides?.OverrideTargetPassCount ?? true; passCountPalette.TargetPassCountRange.Min = overrides?.OverridingTargetPassCountRange.Min ?? PASS_COUNT_TARGET_RANGE_MIN; passCountPalette.TargetPassCountRange.Max = overrides?.OverridingTargetPassCountRange.Max ?? PASS_COUNT_TARGET_RANGE_MAX; break; case DisplayMode.MachineSpeed: convertedPalette = new SpeedPalette(); break; case DisplayMode.TargetSpeedSummary: convertedPalette = new SpeedSummaryPalette(); var speedSummaryPalette = ((SpeedSummaryPalette)convertedPalette); speedSummaryPalette.MachineSpeedTarget.Min = overrides?.TargetMachineSpeed.Min ?? CellPassConsts.NullMachineSpeed; speedSummaryPalette.MachineSpeedTarget.Max = overrides?.TargetMachineSpeed.Max ?? CellPassConsts.NullMachineSpeed; break; case DisplayMode.TemperatureDetail: convertedPalette = new TemperaturePalette(); break; case DisplayMode.TemperatureSummary: convertedPalette = new TemperatureSummaryPalette(); var temperatureSummaryPalette = ((TemperatureSummaryPalette)convertedPalette); temperatureSummaryPalette.UseMachineTempWarningLevels = !overrides?.OverrideTemperatureWarningLevels ?? true; temperatureSummaryPalette.TemperatureLevels.Min = overrides?.OverridingTemperatureWarningLevels.Min ?? TEMPERATURE_LEVELS_MIN; temperatureSummaryPalette.TemperatureLevels.Max = overrides?.OverridingTemperatureWarningLevels.Max ?? TEMPERATURE_LEVELS_MAX; break; default: throw new TRexException($"No implemented color palette for this mode ({mode})"); } return(convertedPalette); }