Example #1
0
        public void Test_CCAPalette_ChooseColour()
        {
            var palette = new CCAPalette();

            palette.Should().NotBeNull();

            for (var i = 0; i < palette.PaletteTransitions.Length; i++)
            {
                palette.ChooseColour(i).Should().Be(palette.PaletteTransitions[i].Color);
            }
        }
Example #2
0
        public void Test_CCAPalette_Creation()
        {
            var palette = new CCAPalette();

            palette.Should().NotBeNull();

            palette.PaletteTransitions.Should().NotBeNull();
            palette.PaletteTransitions.Length.Should().Be(50);
            palette.PaletteTransitions[0].Value.Should().Be(0);
            palette.PaletteTransitions[0].Color.Should().Be(Color.Yellow);
            palette.PaletteTransitions[1].Value.Should().Be(1);
            palette.PaletteTransitions[1].Color.Should().Be(Color.Red);
            palette.PaletteTransitions[2].Value.Should().Be(2);
            palette.PaletteTransitions[2].Color.Should().Be(Color.Aqua);
            palette.PaletteTransitions[3].Value.Should().Be(3);
            palette.PaletteTransitions[3].Color.Should().Be(Color.Lime);
            palette.PaletteTransitions[4].Value.Should().Be(4);
            palette.PaletteTransitions[4].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#FF8080"));
            palette.PaletteTransitions[5].Value.Should().Be(5);
            palette.PaletteTransitions[5].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#91C8FF"));
            palette.PaletteTransitions[6].Value.Should().Be(6);
            palette.PaletteTransitions[6].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#ACFDEB"));
            palette.PaletteTransitions[7].Value.Should().Be(7);
            palette.PaletteTransitions[7].Color.Should().Be(Color.Green);
            palette.PaletteTransitions[8].Value.Should().Be(8);
            palette.PaletteTransitions[8].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#FFC0FF"));
            palette.PaletteTransitions[9].Value.Should().Be(9);
            palette.PaletteTransitions[9].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#FFCB96"));
            palette.PaletteTransitions[10].Value.Should().Be(10);
            palette.PaletteTransitions[10].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#6C8EB5"));
            palette.PaletteTransitions[11].Value.Should().Be(11);
            palette.PaletteTransitions[11].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#80FFFF"));
            palette.PaletteTransitions[12].Value.Should().Be(12);
            palette.PaletteTransitions[12].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#8080FF"));
            palette.PaletteTransitions[13].Value.Should().Be(13);
            palette.PaletteTransitions[13].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#00FF80"));
            palette.PaletteTransitions[14].Value.Should().Be(14);
            palette.PaletteTransitions[14].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#FF8000"));
            palette.PaletteTransitions[15].Value.Should().Be(15);
            palette.PaletteTransitions[15].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#8000FF"));
            palette.PaletteTransitions[16].Value.Should().Be(16);
            palette.PaletteTransitions[16].Color.Should().Be(Color.Teal);
            palette.PaletteTransitions[17].Value.Should().Be(17);
            palette.PaletteTransitions[17].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#C0C0FF"));
            palette.PaletteTransitions[18].Value.Should().Be(18);
            palette.PaletteTransitions[18].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#FF80FF"));

            for (var i = 19; i <= 49; i++)
            {
                palette.PaletteTransitions[i].Value.Should().Be(i);
                palette.PaletteTransitions[i].Color.Should().Be(System.Drawing.ColorTranslator.FromHtml("#80FF00"));
            }
        }
Example #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);
        }
Example #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);
        }