aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-08-06 12:19:12 +0300
committerAvi Levkovich <avi@twine-s.com>2020-08-06 12:19:12 +0300
commit704d1cd963b0b4bbabbbc34fd5e1786a7e8d3c32 (patch)
tree685a734ec70e4d57e1763d4a48fb5181543c3a91 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
parent5b715b86dfef2e7211d5e6a359d34a7bdc64e68a (diff)
parent9142ea8c08d9f71a7538c2c8b29c012d99c88b32 (diff)
downloadTango-704d1cd963b0b4bbabbbc34fd5e1786a7e8d3c32.tar.gz
Tango-704d1cd963b0b4bbabbbc34fd5e1786a7e8d3c32.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs34
1 files changed, 31 insertions, 3 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 7d913299e..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