Esempio n. 1
0
        public void Test_CMVChangePalette_Creation()
        {
            var palette = new CMVChangePalette();

            palette.Should().NotBeNull();

            palette.PaletteTransitions.Should().NotBeNull();
            palette.PaletteTransitions.Length.Should().Be(8);
            palette.PaletteTransitions[0].Value.Should().Be(short.MinValue);
            palette.PaletteTransitions[0].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#D50000"));
            palette.PaletteTransitions[1].Value.Should().Be(-50);
            palette.PaletteTransitions[1].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#E57373"));
            palette.PaletteTransitions[2].Value.Should().Be(-20);
            palette.PaletteTransitions[2].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#FFCDD2"));
            palette.PaletteTransitions[3].Value.Should().Be(-10);
            palette.PaletteTransitions[3].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#8BC34A"));
            palette.PaletteTransitions[4].Value.Should().Be(0);
            palette.PaletteTransitions[4].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#B3E5FC"));
            palette.PaletteTransitions[5].Value.Should().Be(10);
            palette.PaletteTransitions[5].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#4FC3F7"));
            palette.PaletteTransitions[6].Value.Should().Be(20);
            palette.PaletteTransitions[6].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#039BE5"));
            palette.PaletteTransitions[7].Value.Should().Be(50);
            palette.PaletteTransitions[7].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#01579B"));
        }
Esempio n. 2
0
        public void Test_CMVChangePalette_ChooseColour()
        {
            var palette = new CMVChangePalette();

            palette.Should().NotBeNull();

            palette.ChooseColour(-60).Should().Be(palette.PaletteTransitions[0].Color);
            palette.ChooseColour(-50).Should().Be(palette.PaletteTransitions[1].Color);
            palette.ChooseColour(-15).Should().Be(palette.PaletteTransitions[2].Color);
            palette.ChooseColour(0).Should().Be(palette.PaletteTransitions[4].Color);
            palette.ChooseColour(35).Should().Be(palette.PaletteTransitions[6].Color);
            palette.ChooseColour(100).Should().Be(palette.PaletteTransitions[7].Color);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }