diff options
| author | Roy <Roy.mail.net@gmail.com> | 2022-08-03 18:11:59 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2022-08-03 18:11:59 +0300 |
| commit | 4bd401b6165128a151bcb5c97c0c6ae9ea7f69ee (patch) | |
| tree | 42c263220ef2e52336dad6f89359c75e964da612 /Software/Visual_Studio | |
| parent | d8df045b1a0819773f854bfca490076377329098 (diff) | |
| parent | 1f73bbbaf6a90a503f4b6c76ae4921a574300bb5 (diff) | |
| download | Tango-4bd401b6165128a151bcb5c97c0c6ae9ea7f69ee.tar.gz Tango-4bd401b6165128a151bcb5c97c0c6ae9ea7f69ee.zip | |
Merge branch 'software' of https://twinetfs.visualstudio.com/Tango/_git/Tango into software
Diffstat (limited to 'Software/Visual_Studio')
4 files changed, 162 insertions, 16 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs index b8e23c710..9a3230ea8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs @@ -236,7 +236,7 @@ namespace Tango.PPC.Jobs.Dialogs } } } - + protected Double _cyan; /// <summary> @@ -473,6 +473,7 @@ namespace Tango.PPC.Jobs.Dialogs TargetL = l; TargetB = b; TargetA = a; + TargetColor = targetColor; BrushStopModel.ConvertColorToVolume(); @@ -490,6 +491,10 @@ namespace Tango.PPC.Jobs.Dialogs if (TestColor == null) { ActiveLogModel = new TrialsLogModel(0, Cyan, Magenta, Yellow, Black); + ActiveLogModel.SuggestionL = TargetL; + ActiveLogModel.SuggestionA = TargetA; + ActiveLogModel.SuggestionB = TargetB; + ActiveLogModel.HasSuggestionsLAB = true; TrialsLogitems = new SynchronizedObservableCollection<TrialsLogModel>(); TrialsLogitems.Add(ActiveLogModel); //TEST @@ -503,7 +508,19 @@ namespace Tango.PPC.Jobs.Dialogs else { TrialsLogitems = new SynchronizedObservableCollection<TrialsLogModel>(TestColor.TrialslogList.OrderByDescending(x=>x.TrialNumber)); - TrialsLogitems.ToList().ForEach(x => x.IsTested = true); + double lastSuggestionL = TargetL; + double lastSuggestionA = TargetA; + double lastSuggestionB = TargetB; + + foreach ( var trial in TrialsLogitems.OrderBy(x=>x.TrialNumber)) + { + trial.IsTested = true; + CalculateSuggestionLAB(lastSuggestionL, lastSuggestionA, lastSuggestionB, trial); + lastSuggestionL = trial.SuggestionL; + lastSuggestionA = trial.SuggestionA; + lastSuggestionB = trial.SuggestionB; + } + //TrialsLogitems.ToList().ForEach(x => x.IsTested = true); int maxTrialsNumber = TrialsLogitems.Max( x=>x.TrialNumber); ActiveLogModel = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == maxTrialsNumber); if (ActiveLogModel == null) @@ -514,6 +531,11 @@ namespace Tango.PPC.Jobs.Dialogs ActiveLogModel.IsActiveTrial = true; ActiveLogModel.IsTested = false; ActiveLogModel.IsSelectionEnable = true; + + ActiveLogModel.SuggestionL = lastSuggestionL; + ActiveLogModel.SuggestionA = lastSuggestionA; + ActiveLogModel.SuggestionB = lastSuggestionB; + var minValue = TrialsLogitems.Min(x => x.DeltaE); if(minValue != null && minValue < 2) { @@ -608,6 +630,10 @@ namespace Tango.PPC.Jobs.Dialogs ActiveLogModel.L = ActiveLogModel.A = ActiveLogModel.B = null; ActiveLogModel.DeltaE = null; TrialsLogitems.Clear(); + if (TestColor != null) + { + TrialsLogEngine.Default.Delete(TestColor); + } TrialsLogitems.Add(ActiveLogModel); RaisePropertyChanged(nameof(TrialsLogitems)); RaisePropertyChanged(nameof(IsDisableInputLAB)); @@ -650,19 +676,37 @@ namespace Tango.PPC.Jobs.Dialogs } if(SelectedLog.L != null && SelectedLog.A != null && SelectedLog.B != null) { - BrushStopModel.L = (double)SelectedLog.L; - BrushStopModel.A = (double)SelectedLog.A; + + if (SelectedLog.IsTested) + { + BrushStopModel.PreventPropertyUpdate = true; + BrushStopModel.Cyan = SelectedLog.TestC; + BrushStopModel.Magenta = SelectedLog.TestM; + BrushStopModel.Yellow = SelectedLog.TestY; + BrushStopModel.PreventPropertyUpdate = false; + BrushStopModel.Black = SelectedLog.TestK; + + } + if(false == SelectedLog.HasSuggestionsLAB) + { + double lastSuggestionL = TargetL; + double lastSuggestionA = TargetA; + double lastSuggestionB = TargetB; + TrialsLogModel lastTested = TrialsLogitems.OrderBy(x => x.TrialNumber).LastOrDefault(y => y.IsTested); + if (lastTested != null) + { + lastSuggestionL = lastTested.SuggestionL; + lastSuggestionA = lastTested.SuggestionA; + lastSuggestionB = lastTested.SuggestionB; + } + CalculateSuggestionLAB(lastSuggestionL, lastSuggestionA, lastSuggestionB, SelectedLog); + } + BrushStopModel.PreventPropertyUpdate = true; + BrushStopModel.L = SelectedLog.SuggestionL; + BrushStopModel.A = SelectedLog.SuggestionA; + BrushStopModel.B = SelectedLog.SuggestionB; BrushStopModel.PreventPropertyUpdate = false; - BrushStopModel.B = (double)SelectedLog.B; } - if(SelectedLog.IsTested) - { - BrushStopModel.Cyan = SelectedLog.TestC; - BrushStopModel.Magenta = SelectedLog.TestM; - BrushStopModel.Yellow = SelectedLog.TestY; - BrushStopModel.Black = SelectedLog.TestK; - } - if (TestColor != null) { TrialsLogEngine.Default.Delete(TestColor); @@ -755,8 +799,26 @@ namespace Tango.PPC.Jobs.Dialogs if(true == await NotificationProvider.ShowQuestion("Previous trial seems to be very close; no more trials are recommended")) return; } - - + BrushStopModel.PreventPropertyUpdate = true; + double lastSuggestionL = TargetL; + double lastSuggestionA = TargetA; + double lastSuggestionB = TargetB; + if (!ActiveLogModel.HasSuggestionsLAB) + { + TrialsLogModel lastTested = TrialsLogitems.OrderBy(x => x.TrialNumber).LastOrDefault(y=>y.IsTested); + if(lastTested != null) + { + lastSuggestionL = lastTested.SuggestionL; + lastSuggestionA = lastTested.SuggestionA; + lastSuggestionB = lastTested.SuggestionB; + } + CalculateSuggestionLAB(lastSuggestionL, lastSuggestionA, lastSuggestionB, ActiveLogModel); + } + BrushStopModel.PreventPropertyUpdate = true; + BrushStopModel.L = ActiveLogModel.SuggestionL; + BrushStopModel.A = ActiveLogModel.SuggestionA; + BrushStopModel.B = ActiveLogModel.SuggestionB; + BrushStopModel.PreventPropertyUpdate = false; //calculate CMYK BrushStopModel.ConvertColorToVolume(); @@ -766,6 +828,7 @@ namespace Tango.PPC.Jobs.Dialogs using (ObservablesContext db = ObservablesContext.CreateDefault()) { Job job = new Job(); + job.EnableLubrication = true; job.Designation = JobDesignations.FineTuning; job.Machine = await new MachineBuilder(db).Set(MachineProvider.Machine.Guid).WithConfiguration().WithSpools().WithCats().WithVersion().BuildAsync(); job.Name = $"Manual color test #{ActiveLogModel.TrialNumber}"; @@ -773,6 +836,9 @@ namespace Tango.PPC.Jobs.Dialogs job.SpoolType = db.SpoolTypes.FirstOrDefault(x => x.Guid == settings.SpoolTypeGuid); job.WindingMethod = db.WindingMethods.FirstOrDefault(); + + + Segment segment = new Segment(); segment.Name = "Standard Segment"; segment.Length = settings.FineTuningTrialLengthMeters; @@ -1087,6 +1153,36 @@ namespace Tango.PPC.Jobs.Dialogs return; } + private bool CalculateSuggestionLAB(double lastSuggestionL, double lastSuggestionA, double lastSuggestionB, TrialsLogModel trial) + { + if(MeasuredL != null && MeasuredA != null && MeasuredB != null) + { + trial.SuggestionL = LimitToRange((lastSuggestionL + (TargetL - (double)MeasuredL)),0, 100) ; + trial.SuggestionA = LimitToRange((lastSuggestionA + (TargetA - (double)MeasuredA)), -128, 127); + trial.SuggestionB = LimitToRange((lastSuggestionB + (TargetB - (double)MeasuredB )), -128, 127); + trial.HasSuggestionsLAB = true; + return true; + + } + trial.SuggestionL = lastSuggestionL; + trial.SuggestionA = lastSuggestionA; + trial.SuggestionB = lastSuggestionB; + return false; + } + + public double LimitToRange(double value, double inclusiveMinimum, double inlusiveMaximum) + { + if (value >= inclusiveMinimum) + { + if (value <= inlusiveMaximum) + { + return value; + } + return inlusiveMaximum; + } + return inclusiveMinimum; + } + #endregion } 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 c655f5a21..07bf2fa5c 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 @@ -681,6 +681,8 @@ namespace Tango.PPC.Jobs.Models Color = Colors.White; var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); ColorSpace = settings.DefaultTabColorSpace == null? ColorSpaces.Volume: (ColorSpaces)settings.DefaultTabColorSpace; + if (ColorSpace == ColorSpaces.CMYK) + ColorSpace = ColorSpaces.Volume; LastChangedColorSpace = ColorSpace; ColorCatalogsItem = null; PreventPropertyUpdate = false; @@ -944,6 +946,8 @@ namespace Tango.PPC.Jobs.Models BrushStop s = new BrushStop(); + if (ColorSpace == ColorSpaces.CMYK) + ColorSpace = ColorSpaces.Volume; s.ColorSpace = list.FirstOrDefault(x => x.Space == ColorSpace); Configuration configuration = SegmentModel.Job.Machine.Configuration; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs index dd055f52f..3b16a65a2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs @@ -57,7 +57,16 @@ namespace Tango.PPC.Jobs.Models get { return _b; } set { _b = value; RaisePropertyChanged(nameof(LAB)); OnLABChanged(); } } - + + [BsonIgnore] + public double SuggestionL { get; set; } + [BsonIgnore] + public double SuggestionA { get; set; } + [BsonIgnore] + public double SuggestionB { get; set; } + [BsonIgnore] + public bool HasSuggestionsLAB { get; set; } + public double C { get; set; } public double M { get; set; } public double Y { get; set; } @@ -186,6 +195,7 @@ namespace Tango.PPC.Jobs.Models IsTested = false; IsSelectionEnable = true; IsBest = false; + HasSuggestionsLAB = false; } #region Methods diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index 66e1aff2e..dac84bc7b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -44,6 +44,7 @@ using Tango.Core; using Tango.PPC.Jobs.UndoRedoCommands; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Tango.PPC.Jobs.ColorCorrectionTool; namespace Tango.PPC.Jobs.ViewModels { @@ -704,6 +705,41 @@ namespace Tango.PPC.Jobs.ViewModels if(vm.SelectedRML.Guid != SelectedRML.Guid) { SelectedRML = _rmls.FirstOrDefault(x=>x.Guid == vm.SelectedRML.Guid); + // for LAB color remove all available tests + foreach (var segment in JobModel.OrderedSegmentsWithGroups) + { + if (segment is SegmentModel innerSegment) + { + foreach (var stop in innerSegment.BrushStops.OrderBy(x => x.StopIndex).ToList()) + { + if (stop.ColorSpace == Tango.BL.Enumerations.ColorSpaces.LAB) + { + var testColor = TrialsLogEngine.Default.GetByBrushStopGuid(stop.Guid); + if (testColor != null && testColor.TrialslogList.Count > 0) + { + TrialsLogEngine.Default.Delete(testColor); + } + } + } + } + else if (segment is SegmentsGroupModel group) + { + foreach (var segm_group in group.Segments.OrderBy(x => x.SegmentIndex)) + { + foreach (var stop in segm_group.BrushStops.OrderBy(x => x.StopIndex).ToList()) + { + if (stop.ColorSpace == Tango.BL.Enumerations.ColorSpaces.LAB) + { + var testColor = TrialsLogEngine.Default.GetByBrushStopGuid(stop.Guid); + if (testColor != null && testColor.TrialslogList.Count > 0) + { + TrialsLogEngine.Default.Delete(testColor); + } + } + } + } + } + } } if (vm.IsDuplicate) |
