aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-06-17 14:43:46 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-06-17 14:43:46 +0300
commit487fc03281c2dfde034e73ad99bd74ec4f63f69a (patch)
tree9a397d30e17294ba7dc2d809771647f0d158efc1 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parentfeda803e41536dca61353263647589a3cff72e56 (diff)
downloadTango-487fc03281c2dfde034e73ad99bd74ec4f63f69a.tar.gz
Tango-487fc03281c2dfde034e73ad99bd74ec4f63f69a.zip
RML color calibration.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs199
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs12
2 files changed, 211 insertions, 0 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
new file mode 100644
index 000000000..a6a2b3f7b
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs
@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.Core;
+using Tango.Core.Commands;
+using Tango.MachineStudio.RML.Models;
+using Tango.SharedUI;
+using OxyPlot;
+using OxyPlot.Wpf;
+using OxyPlot.Annotations;
+
+
+namespace Tango.MachineStudio.RML.ViewModels
+{
+ public class ColorCalibrationViewVM : ExtendedObject
+ {
+
+ #region Properties
+
+ private Rml _rml;
+ public Rml RML
+ {
+ get { return _rml; }
+ set { _rml = value; RaisePropertyChangedAuto(); }
+ }
+
+ private LiquidType _liquidType;
+
+ public LiquidType LiquidType
+ {
+ get { return _liquidType; }
+ set { _liquidType = value; RaisePropertyChangedAuto(); }
+ }
+
+ private List<LiquidType> _liquidTypes;
+
+ public List<LiquidType> LiquidTypes
+ {
+ get { return _liquidTypes; }
+ set { _liquidTypes = value; }
+ }
+
+
+ private ObservableCollection<CalibrationMeasurementModel> _measurements;
+ public ObservableCollection<CalibrationMeasurementModel> Measurements
+ {
+ get
+ {
+ return _measurements;
+ }
+ set
+ {
+ _measurements = value; RaisePropertyChangedAuto();
+ }
+ }
+
+
+ private double _factor;
+
+ public double Factor
+ {
+ get { return _factor; }
+ set { _factor = value; }
+ }
+
+ public RelayCommand CreateGraphCommand { get; set; }
+
+
+ public string CalibrationType
+ {
+ get { return LiquidType == null ?"" : LiquidType.Name; }
+ }
+
+ public Plot PlotControl { get; set; }
+ private IList<DataPoint> _points;
+ /// <summary>
+ /// Binding to ItemsSource of line chart.
+ /// </summary>
+ public IList<DataPoint> Points
+ {
+ get { return _points; }
+ set
+ {
+ _points = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+ private IList<DataPoint> _targetPoints;
+ /// <summary>
+ /// Binding to ItemsSource of line chart.
+ /// </summary>
+ public IList<DataPoint> TargetPoints
+ {
+ get { return _targetPoints; }
+ set
+ {
+ _targetPoints = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+ private int _step;
+ public int XStep
+ {
+ get { return _step; }
+ set { _step = value; RaisePropertyChangedAuto(); }
+ }
+
+ private double _from;
+ /// <summary>
+ /// From use to binding to bottom axis min value
+ /// </summary>
+ public double From
+ {
+ get { return _from; }
+ set
+ {
+ _from = value; RaisePropertyChangedAuto();
+ }
+ }
+
+ private double _to;
+ /// <summary>
+ /// To use to binding to bottom axis max value
+ /// </summary>
+ public double To
+ {
+ get { return _to; }
+ set
+ {
+ _to = value; RaisePropertyChangedAuto();
+ }
+ }
+
+ #endregion
+
+ public ColorCalibrationViewVM()
+ {
+ Measurements = new ObservableCollection<CalibrationMeasurementModel>()
+ {
+ new CalibrationMeasurementModel(),
+ new CalibrationMeasurementModel(),
+ new CalibrationMeasurementModel(),
+ };
+ Factor = 0;
+ CreateGraphCommand = new RelayCommand(CreateGraph);
+ this.Points = new List<DataPoint>();
+ TargetPoints = new List<DataPoint>();
+ }
+
+ public void Loading()
+ {
+ LiquidType = LiquidTypes.Count > 0 ? LiquidTypes[0] : null;
+ }
+
+ private void CreateGraph(object obj)
+ {
+ if (_liquidType == null)
+ return;
+
+ LAB lab;
+ string color = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type];
+ if( ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab))
+ {
+ var value = lab.GetType().GetProperty(color)?.GetValue(lab, null);
+ Factor = (double)value;
+ }
+
+
+
+ //call color calibration function
+ ////////////////////////
+ ///
+
+
+ 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)); });
+
+ _to = color == "L"? 100 : 128;
+ _from = color == "L" ? 0 : -127;
+
+ RaisePropertyChanged("To");
+ RaisePropertyChanged("From");
+ XStep = (int)(Points.Count / 6);
+ RaisePropertyChanged("CalibrationType");
+ PlotControl.InvalidatePlot(true);
+ }
+ }
+}
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 1ceaf07df..4939cbb48 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
@@ -164,6 +164,12 @@ namespace Tango.MachineStudio.RML.ViewModels
set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
+ private ColorCalibrationViewVM _colorCalibrationVM;
+ public ColorCalibrationViewVM ColorCalibrationVM
+ {
+ get { return _colorCalibrationVM; }
+ set { _colorCalibrationVM = value; RaisePropertyChangedAuto(); }
+ }
/// <summary>
/// Gets or sets the manage RML command.
@@ -374,6 +380,12 @@ namespace Tango.MachineStudio.RML.ViewModels
LiquidTypesRmls = LiquidTypesRmls,
};
+ ColorCalibrationVM = new ColorCalibrationViewVM()
+ {
+ RML = ActiveRML,
+ LiquidTypes = LiquidTypesRmls.Where(x => x.LiquidType.HasPigment).ToList().Select(y => y.LiquidType).ToList(),
+ };
+
_rmlBeforeSave = RmlDTO.FromObservable(ActiveRML);
View.NavigateTo(RmlNavigationView.RmlView);