diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs | 171 |
1 files changed, 89 insertions, 82 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs index ffec3cfa1..430cb99cf 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs @@ -502,7 +502,7 @@ namespace Tango.PPC.Jobs.Models { get { - return ColorCatalogsItem == null? "" : ColorCatalogsItem.Guid; + return ColorCatalogsItem == null ? "" : ColorCatalogsItem.Guid; } } @@ -570,7 +570,7 @@ namespace Tango.PPC.Jobs.Models return System.Windows.Media.Colors.Transparent; } } - + [JsonIgnore] public SolidColorBrush ColorBrush { @@ -591,7 +591,7 @@ namespace Tango.PPC.Jobs.Models get { return _segmentmodel; } set { _segmentmodel = value; } } - + private bool _outOfGamutChecked; /// <summary> /// Gets or sets a value indicating whether out of gamut has been checked. @@ -660,34 +660,34 @@ namespace Tango.PPC.Jobs.Models { get { - if ( ColorSpace == ColorSpaces.Volume || ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume || ColorSpace == ColorSpaces.CMYK) { var minCyan = GetMinLimitLiquid(LiquidTypes.Cyan); - if(Cyan > 0 && Cyan < minCyan) - { + if (Cyan > 0 && Cyan < minCyan) + { LiquidVolumeBelowMinLimit = true; - LiquidVolumeBelowMinLimitmessage = String.Format($"{Cyan} Cyan should be > {minCyan}"); + LiquidVolumeBelowMinLimitmessage = $"{Cyan} Cyan should be > {minCyan.ToString("N3")}"; return LiquidVolumeBelowMinLimit; } var minMagenta = GetMinLimitLiquid(LiquidTypes.Magenta); if (Magenta > 0 && Magenta < minMagenta) { LiquidVolumeBelowMinLimit = true; - LiquidVolumeBelowMinLimitmessage = String.Format($"{Magenta} Magenta should be > {minMagenta}"); + LiquidVolumeBelowMinLimitmessage = $"{Magenta} Magenta should be > {minMagenta.ToString("N3")}"; return LiquidVolumeBelowMinLimit; } var minYellow = GetMinLimitLiquid(LiquidTypes.Yellow); if (Yellow > 0 && Yellow < minYellow) { LiquidVolumeBelowMinLimit = true; - LiquidVolumeBelowMinLimitmessage = String.Format($"{Yellow} Yellow should be > {minYellow}"); + LiquidVolumeBelowMinLimitmessage = $"{Yellow} Yellow should be > {minYellow.ToString("N3")}"; return LiquidVolumeBelowMinLimit; } var minBlack = GetMinLimitLiquid(LiquidTypes.Black); if (Black > 0 && Black < minBlack) { LiquidVolumeBelowMinLimit = true; - LiquidVolumeBelowMinLimitmessage = String.Format($"{Black} Black should be > {minBlack}"); + LiquidVolumeBelowMinLimitmessage = $"{Black} Black should be > {minBlack.ToString("N3")}"; return LiquidVolumeBelowMinLimit; } LiquidVolumeBelowMinLimit = false; @@ -702,7 +702,7 @@ namespace Tango.PPC.Jobs.Models [JsonIgnore] public string LiquidVolumeBelowMinLimitmessage { - get { return _liquidVolumeBelowMinLimitmessage;} + get { return _liquidVolumeBelowMinLimitmessage; } set { _liquidVolumeBelowMinLimitmessage = value; @@ -724,7 +724,7 @@ namespace Tango.PPC.Jobs.Models } } } - + [JsonIgnore] public ColorSpaces LastChangedColorSpace { get; set; } @@ -743,7 +743,7 @@ namespace Tango.PPC.Jobs.Models public Double YellowBeforeChange { get; set; } [JsonIgnore] public Double BlackBeforeChange { get; set; } - + public bool FineTuningChanged { get; set; } #endregion @@ -762,7 +762,7 @@ namespace Tango.PPC.Jobs.Models Color = Colors.White; var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); - ColorSpace = settings.DefaultTabColorSpace == null? ColorSpaces.Volume: (ColorSpaces)settings.DefaultTabColorSpace; + ColorSpace = settings.DefaultTabColorSpace == null ? ColorSpaces.Volume : (ColorSpaces)settings.DefaultTabColorSpace; if (ColorSpace == ColorSpaces.CMYK) ColorSpace = ColorSpaces.Volume; LastChangedColorSpace = ColorSpace; @@ -797,7 +797,7 @@ namespace Tango.PPC.Jobs.Models Yellow = brushStop.Yellow * 100; Black = brushStop.Black * 100; } - else + else { Cyan = brushStop.GetVolume(LiquidTypes.Cyan); Magenta = brushStop.GetVolume(LiquidTypes.Magenta); @@ -949,17 +949,17 @@ namespace Tango.PPC.Jobs.Models Configuration configuration = SegmentModel.Job.Machine.Configuration; Rml rml = SegmentModel.Job.Rml; s.SetLiquidVolumes(configuration, rml, rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); - - - s.ColorSpace.Space = BL.Enumerations.ColorSpaces.LAB; - s.L = this.L; - s.A = this.A; - s.B = this.B; - s.Cyan = cyan; - s.Yellow = yellow; - s.Magenta = magenta; - s.Black = black; - + + + s.ColorSpace.Space = BL.Enumerations.ColorSpaces.LAB; + s.L = this.L; + s.A = this.A; + s.B = this.B; + s.Cyan = cyan; + s.Yellow = yellow; + s.Magenta = magenta; + s.Black = black; + return s; } @@ -1043,7 +1043,7 @@ namespace Tango.PPC.Jobs.Models LiquidVolumesOutOfRange = false; } - + /// <summary> /// Creates the brush stop. /// </summary> @@ -1060,7 +1060,7 @@ namespace Tango.PPC.Jobs.Models Configuration configuration = SegmentModel.Job.Machine.Configuration; Rml rml = SegmentModel.Job.Rml; s.SetLiquidVolumes(configuration, rml, rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); - + s.OffsetPercent = OffsetPercent; s.StopIndex = StopIndex; s.IsOutOfGamut = IsOutOfGamut; @@ -1087,7 +1087,7 @@ namespace Tango.PPC.Jobs.Models //Fine Tuning public void UndoColorChanges() { - if(ColorSpace == ColorSpaces.LAB) + if (ColorSpace == ColorSpaces.LAB) { PreventPropertyUpdate = true; L = LBeforeChange; @@ -1095,7 +1095,7 @@ namespace Tango.PPC.Jobs.Models PreventPropertyUpdate = false; B = BBeforeChange; } - else if(ColorSpace == ColorSpaces.Volume) + else if (ColorSpace == ColorSpaces.Volume) { PreventPropertyUpdate = true; Cyan = CyanBeforeChange; @@ -1154,7 +1154,7 @@ namespace Tango.PPC.Jobs.Models { if (PreventPropertyUpdate) return; - // ColorSpace = ColorSpaces.HSB; + // ColorSpace = ColorSpaces.HSB; Rgb rgb = GetRGBColor(); _red = (int)rgb.R; _green = (int)rgb.G; @@ -1294,8 +1294,8 @@ namespace Tango.PPC.Jobs.Models { if (ColorSpace != ColorSpaces.RGB) { - - if ( LastChangedColorSpace != ColorSpaces.RGB) + + if (LastChangedColorSpace != ColorSpaces.RGB) { if (LastChangedColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) { @@ -1314,12 +1314,12 @@ namespace Tango.PPC.Jobs.Models _green = output.SingleCoordinates.Green; _blue = output.SingleCoordinates.Blue; IsOutOfGamut = false;//output.OutOfGamut; - if ( IsLiquidVolumesOutOfRange) - { - BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); - InitColor(); - } + if (IsLiquidVolumesOutOfRange) + { + BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + InitColor(); } + } catch (Exception ex) { LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); @@ -1353,19 +1353,19 @@ namespace Tango.PPC.Jobs.Models public void ConvertColorToLAB() { - if (ColorSpace != ColorSpaces.LAB ) + if (ColorSpace != ColorSpaces.LAB) { - if( LastChangedColorSpace != ColorSpaces.LAB) + if (LastChangedColorSpace != ColorSpaces.LAB) { Lab lab = null; if (LastChangedColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) { - _l = ColorCatalogsItem.L; - _a = ColorCatalogsItem.A; - _b = ColorCatalogsItem.B; - BestMatchL = _l; - BestMatchA = _a; - BestMatchB = _b; + _l = ColorCatalogsItem.L; + _a = ColorCatalogsItem.A; + _b = ColorCatalogsItem.B; + BestMatchL = _l; + BestMatchA = _a; + BestMatchB = _b; } else if (LastChangedColorSpace == ColorSpaces.Volume) { @@ -1381,7 +1381,7 @@ namespace Tango.PPC.Jobs.Models BestMatchA = _a; BestMatchB = _b; IsOutOfGamut = false;//output.OutOfGamut; - + if (IsLiquidVolumesOutOfRange) { _red = output.SingleCoordinates.Red; @@ -1438,7 +1438,7 @@ namespace Tango.PPC.Jobs.Models RequiredMaxLiquidTest = true; if (ColorSpace != ColorSpaces.Volume) { - if ( LastChangedColorSpace != ColorSpaces.Volume) + if (LastChangedColorSpace != ColorSpaces.Volume) { if (LastChangedColorSpace == ColorSpaces.Catalog) { @@ -1453,8 +1453,8 @@ namespace Tango.PPC.Jobs.Models RaisePropertyChanged(nameof(Magenta)); RaisePropertyChanged(nameof(Black)); IsOutOfGamut = false; - // RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); - // RaisePropertyChanged(nameof(IsLiquidVolumeBelowMinLimit)); + // RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); + // RaisePropertyChanged(nameof(IsLiquidVolumeBelowMinLimit)); } ColorSpace = ColorSpaces.Volume; RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); @@ -1467,9 +1467,9 @@ namespace Tango.PPC.Jobs.Models // colorSpace = ColorSpaces.RGB; //} //else - if (colorSpace == ColorSpaces.CMYK ) + if (colorSpace == ColorSpaces.CMYK) { - colorSpace = ColorSpaces. Volume; + colorSpace = ColorSpaces.Volume; } BrushStop stop = CreateBrushStop(colorSpace); @@ -1514,17 +1514,17 @@ namespace Tango.PPC.Jobs.Models RaisePropertyChanged(nameof(IsLiquidVolumeBelowMinLimit)); } } - + public void ConvertColorToCatalogs(List<ColorCatalog> catalogs) { if (ColorSpace != ColorSpaces.Catalog) { - if ( LastChangedColorSpace != ColorSpaces.Catalog) + if (LastChangedColorSpace != ColorSpaces.Catalog) { if (BestMatchColor == null) BestMatchColor = Color; var closestItem = catalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(BestMatchColor); - + _colorcatalogsitem = closestItem; if (ColorCatalogsItemChanged != null) { @@ -1540,10 +1540,10 @@ namespace Tango.PPC.Jobs.Models public void FineTuningConverter(double cyan, double yellow, double magenta, double black) { RequiredMaxLiquidTest = true; - - ColorSpaces colorSpace = ColorSpaces.LAB; + + ColorSpaces colorSpace = ColorSpaces.LAB; BrushStop stop = CreateBrushStopForFineTuning(colorSpace, cyan, yellow, magenta, black); - + try { IsBusy = true; @@ -1553,15 +1553,15 @@ namespace Tango.PPC.Jobs.Models _yellow = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume); _magenta = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume); _black = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Black).Volume); - if(_black > 0 && _black < 0.5)//bug 7959 0.001 < K% < 0.5 ==> reset the K to 0. + if (_black > 0 && _black < 0.5)//bug 7959 0.001 < K% < 0.5 ==> reset the K to 0. { _black = 0; } IsOutOfGamut = output.OutOfGamut; - if(IsOutOfGamut) + if (IsOutOfGamut) { BrushStop stopLAB = CreateBrushStop(ColorSpaces.Volume); - + IsBusy = true; var outputLAB = _converter.Convert(stopLAB, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); _l = output.SingleCoordinates.L; @@ -1609,7 +1609,7 @@ namespace Tango.PPC.Jobs.Models } InitColorsFromBestmatch(); } - + public void UpdateColorFromFineTuningDlg() { Rgb rgb = GetRGBColor(); @@ -1661,17 +1661,24 @@ namespace Tango.PPC.Jobs.Models } } - private double GetMinLimitLiquid( LiquidTypes type) + private double GetMinLimitLiquid(LiquidTypes type) { try { var tables = SegmentModel.Job.Rml.GetActiveProcessGroup().ProcessParametersTables.OrderBy(x => x.TableIndex).ToList(); LiquidTypesRml liquidType = SegmentModel.Job.Rml.LiquidTypesRmls.FirstOrDefault(x => x.LiquidType.Type == type); - + if (tables.Count > 0 && liquidType != null && liquidType.MaxNlPerCm != 0) { - return (0.5*tables[0].MinInkUptake)/ liquidType.MaxNlPerCm; + var vmax = Math.Max(SegmentModel.Job.Rml.VMax / 10d, 1); + + if (type == LiquidTypes.Black) + { + vmax = Math.Max(SegmentModel.Job.Rml.VMax, 1); + } + + return (vmax * tables[0].MinInkUptake) / liquidType.MaxNlPerCm; } else { @@ -1697,23 +1704,23 @@ namespace Tango.PPC.Jobs.Models } return 0.0; } - + public void OnBrushStopFieldValueChanged() { IsBusy = true; _volumeConversionTimer.ResetReplace(() => { - if (ColorSpace == BL.Enumerations.ColorSpaces.Volume) - { - //RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); - if (IsLiquidVolumesOutOfRange || IsLiquidVolumeBelowMinLimit) - { - IsBusy = false; - return; - } - } - ConvertColor(); + if (ColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + //RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); + if (IsLiquidVolumesOutOfRange || IsLiquidVolumeBelowMinLimit) + { + IsBusy = false; + return; + } + } + ConvertColor(); }); } @@ -1753,14 +1760,14 @@ namespace Tango.PPC.Jobs.Models else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) { IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); - if(IsOutOfGamut) + if (IsOutOfGamut) { BestMatchL = (double)output.SingleCoordinates.L; BestMatchA = (double)output.SingleCoordinates.A; BestMatchB = (double)output.SingleCoordinates.B; Lab lab = new Lab(output.SingleCoordinates.L, output.SingleCoordinates.A, output.SingleCoordinates.B); Rgb rgb = new Rgb(lab.ToRgb()); - BestMatchColor = Color.FromRgb((byte)(int)rgb.R, (byte)(int)rgb.G, (byte)(int)rgb.B); + BestMatchColor = Color.FromRgb((byte)(int)rgb.R, (byte)(int)rgb.G, (byte)(int)rgb.B); } else { @@ -1769,13 +1776,13 @@ namespace Tango.PPC.Jobs.Models BestMatchB = B; Lab lab1 = new Lab(L, A, B); Rgb rgb1 = new Rgb(lab1.ToRgb()); - BestMatchColor = Color.FromRgb((byte)(int)rgb1.R, (byte)(int)rgb1.G, (byte)(int)rgb1.B); + BestMatchColor = Color.FromRgb((byte)(int)rgb1.R, (byte)(int)rgb1.G, (byte)(int)rgb1.B); } } else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) { IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); - if(IsOutOfGamut) + if (IsOutOfGamut) { BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); } @@ -1783,9 +1790,9 @@ namespace Tango.PPC.Jobs.Models { BestMatchColor = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); } - if(IsOutOfGamut != output.OutOfGamut) + if (IsOutOfGamut != output.OutOfGamut) { - + } } //else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.HSB) |
