diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-05 18:24:25 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-05 18:24:25 +0300 |
| commit | f6fe86625120c894db221bac54aeb7bb483da0ad (patch) | |
| tree | 72469727678d2fed165f2c0939adf29200d30aa5 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels | |
| parent | 142fe9ecfa594d93feb9ce5ea0df73f468cd2f79 (diff) | |
| parent | c246f372617b18255134b2d5495c6809d3e91904 (diff) | |
| download | Tango-f6fe86625120c894db221bac54aeb7bb483da0ad.tar.gz Tango-f6fe86625120c894db221bac54aeb7bb483da0ad.zip | |
MERGE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
2 files changed, 42 insertions, 20 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs index 452a4ae6f..4a6895df3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs @@ -250,15 +250,15 @@ namespace Tango.MachineStudio.RML.ViewModels Factor = GetLiquidFactor( ); }); + DataPoint targetPoint = GetTargetPoint(); Points.Clear(); TargetPoints.Clear(); To = 0; From = 0; - Measurements.ToList().ForEach(x =>{ - Points.Add(new DataPoint(x.Ink, x.L)); - TargetPoints.Add(new DataPoint(x.Ink,Factor)); }); + Measurements.ToList().ForEach(x =>{ Points.Add(new DataPoint(x.Ink, labType == "L" ? x.L : x.B)); + TargetPoints.Add(new DataPoint(x.Ink, targetPoint.Y)); }); _to = labType == "L"? 100 : 128; _from = labType == "L" ? 0 : -127; @@ -271,6 +271,34 @@ namespace Tango.MachineStudio.RML.ViewModels } + private DataPoint GetTargetPoint() + { + var listValues = Measurements.ToList(); + if (listValues.Count == 0 || Factor <=0) + return new DataPoint(0, 0); + + string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; + + var left = listValues.Where(y => y.Ink == listValues.Min(x => x.Ink)).ToList().First(); + var right = listValues.Where(y => y.Ink == listValues.Max(x => x.Ink)).ToList().First(); + // Normalize start/end to left right to make the offset calc simpler. + DataPoint leftPoint = new DataPoint(left.Ink, labType == "L" ? left.L : left.B); + DataPoint rightPoint = new DataPoint(right.Ink, labType == "L" ? right.L : right.B); + + double deltaX = rightPoint.X - leftPoint.X; + double deltaY = rightPoint.Y - leftPoint.Y; + + // prevents division by zero exceptions. + if (deltaX == 0 ) + return new DataPoint(0, 0); + + double slope = deltaY / deltaX; + double offset = leftPoint.Y - leftPoint.X * slope; + double calculatedY = Factor * slope + offset; + + return new DataPoint(Factor, calculatedY); ; + } + #endregion #region CreateLinearizationGraph @@ -346,7 +374,7 @@ namespace Tango.MachineStudio.RML.ViewModels if(!String.IsNullOrEmpty(result.ErrorMessage)) { - LogManager.Log($"Error occurred while trying to call GetLinearizationMeasurements.\n{result.ErrorMessage}"); + //LogManager.Log(result.ErrorMessage, "Error occurred while trying to call GetLinearizationMeasurements."); } return result.InkPercentage.ToList(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index c31c95800..229d62df7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -34,7 +34,6 @@ namespace Tango.MachineStudio.RML.ViewModels private IAuthenticationProvider _authentication; private IActionLogManager _actionLogManager; private RmlDTO _rmlBeforeSave; - private static object _syncLock = new object(); private ObservablesContext _rmls_context; private ObservablesContext _active_context; @@ -56,8 +55,6 @@ namespace Tango.MachineStudio.RML.ViewModels set { _rmlssCollectionView = value; - BindingOperations.EnableCollectionSynchronization(_rmlssCollectionView, _syncLock); - RaisePropertyChangedAuto(); } } @@ -311,6 +308,15 @@ namespace Tango.MachineStudio.RML.ViewModels } RmlsCollectionView = CollectionViewSource.GetDefaultView(Rmls); RmlsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Rml.LastUpdated), ListSortDirection.Descending)); + //RmlsCollectionView.Filter = new Predicate<object>(FilterCollection); + + RmlsCollectionView.Filter = (rml) => + { + Rml r = rml as Rml; + return String.IsNullOrWhiteSpace(RMLFilter) + || r.Name.ToLower().Contains(RMLFilter.ToLower()) //Rml name + || (r.MediaMaterial != null && r.MediaMaterial.Name.ToLower().Contains(RMLFilter.ToLower())); + }; } private async void LoadActiveRML(String guid) @@ -683,19 +689,7 @@ namespace Tango.MachineStudio.RML.ViewModels private void OnRMLFilterChanged() { - String filter = RMLFilter.ToLower(); - - RmlsCollectionView.Filter = (rml) => - { - Rml r = rml as Rml; - return String.IsNullOrWhiteSpace(filter) - || - r.Name.ToLower().Contains(filter) //Rml name - || - (r.MediaMaterial != null && r.MediaMaterial.Name.ToLower().Contains(filter)) // Material name - || - (r.Cct != null && r.Cct.FileName != null && r.Cct.FileName.ToString().Contains(filter)); //Cct.FileName - }; + RmlsCollectionView.Refresh(); } private void RemoveLiquidFactor(LiquidTypesRml liquidFactor) |
