diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-06-21 15:19:41 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-06-21 15:19:41 +0300 |
| commit | bdce9ac6cda523781bae61e08587df974974ea98 (patch) | |
| tree | f351912a9d926ae6e0d0dffc1149f9b620eaf98f /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels | |
| parent | 06b6fa90661475665cf9c02df9fea8c6a0f6a60d (diff) | |
| download | Tango-bdce9ac6cda523781bae61e08587df974974ea98.tar.gz Tango-bdce9ac6cda523781bae61e08587df974974ea98.zip | |
Color Calibrator . Added C++ functions. MaximalDispensingRate.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
2 files changed, 98 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 24867122e..dd0c66c58 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 @@ -14,12 +14,16 @@ using OxyPlot.Wpf; using OxyPlot.Annotations; using Tango.ColorCalibration; using Tango.PMR.ColorLab; +using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; namespace Tango.MachineStudio.RML.ViewModels { public class ColorCalibrationViewVM : ExtendedObject { private IColorCalibrator _calibrator; + private INotificationProvider _notification; + #region Properties private Rml _rml; @@ -138,8 +142,9 @@ namespace Tango.MachineStudio.RML.ViewModels #endregion - public ColorCalibrationViewVM() + public ColorCalibrationViewVM(INotificationProvider notification) { + _notification = notification; Measurements = new ObservableCollection<CalibrationMeasurementModel>() { new CalibrationMeasurementModel(), @@ -165,7 +170,8 @@ namespace Tango.MachineStudio.RML.ViewModels CalibrationInput conversionInput = new CalibrationInput(); Measurements.ToList().ForEach(x => conversionInput.Measurements.Add(new CalibrationMeasurement{ L = x.L, A = x.A, B = x.B, NanoliterPerCentimeter = x.Ink })); conversionInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; - + + LAB lab; if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) { @@ -183,6 +189,8 @@ namespace Tango.MachineStudio.RML.ViewModels return 0.0; } + #region CreateGraph + private async void CreateGraph(object obj) { if (_liquidType == null) @@ -213,6 +221,93 @@ namespace Tango.MachineStudio.RML.ViewModels XStep = (int)(Points.Count / 6); RaisePropertyChanged("CalibrationType"); PlotControl.InvalidatePlot(true); + + //await Task.Factory.StartNew(() => + //{ + // DataPoint ? intersectionpoints = FindIntersection(Points.ToArray(), TargetPoints.ToArray()); + // if(intersectionpoints == null) + // { + // InvokeUI(() => + // { + // _notification.ShowWarning(LogManager.Log($"No intersect target value with input values", LogCategory.Warning)); + // }); + // } + //}); + + } + + #endregion + + #region Intersect + + public DataPoint? FindIntersection(DataPoint[] line1, DataPoint[] line2) + { + for (int i = 0; i < line1.Length; i++) + { + int nextI = i; + nextI++; + if (nextI == line1.Length) break; + + for (int j = 0; j < line2.Length; j++) + { + int nextJ = j; + nextJ++; + if (nextJ == line2.Length) break; + DataPoint? d = CheckIntersecting(line1[i], line1[nextI], line2[j], line2[nextJ]); + return d; + + } + } + return null; } + + public DataPoint? CheckIntersecting(DataPoint A, DataPoint B, DataPoint C, DataPoint D) + { + // Line AB represented as a1x + b1y = c1 + double a1 = B.Y - A.Y; + double b1 = A.X - B.X; + double c1 = a1 * (A.X) + b1 * (A.Y); + + // Line CD represented as a2x + b2y = c2 + double a2 = D.Y - C.Y; + double b2 = C.X - D.X; + double c2 = a2 * (C.X) + b2 * (C.Y); + + double determinant = a1 * b2 - a2 * b1; + + if (determinant == 0) + { + // The lines are parallel. This is simplified + } + else + { + double x = (b2 * c1 - b1 * c2) / determinant; + double y = (a1 * c2 - a2 * c1) / determinant; + + // check if the point lies on given line segment + /* To check if "x" is between "a" and "b"; + int m = (a+b)/2; + if(Math.abs(x-m) <= (Math.abs(a-m))) + { + } + */ + double mx1 = (A.X + B.X) / 2; + double mx2 = (C.X + D.X) / 2; + double my1 = (A.Y + B.Y) / 2; + double my2 = (C.Y + D.Y) / 2; + if (Math.Abs(x - mx1) <= Math.Abs(A.X - mx1) + && Math.Abs(x - mx2) <= Math.Abs(C.X - mx2) + && Math.Abs(y - my1) <= Math.Abs(A.Y - my1) + && Math.Abs(y - my2) <= Math.Abs(C.Y - my2)) + { + return new DataPoint(x, y); + } + + } + return null; + } + + #endregion + } } 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 4939cbb48..36398a593 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 @@ -380,7 +380,7 @@ namespace Tango.MachineStudio.RML.ViewModels LiquidTypesRmls = LiquidTypesRmls, }; - ColorCalibrationVM = new ColorCalibrationViewVM() + ColorCalibrationVM = new ColorCalibrationViewVM(_notification) { RML = ActiveRML, LiquidTypes = LiquidTypesRmls.Where(x => x.LiquidType.HasPigment).ToList().Select(y => y.LiquidType).ToList(), |
