diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-09-10 13:32:00 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-09-10 13:32:00 +0300 |
| commit | eee2ca563c712da4d8ef976238642b5247330740 (patch) | |
| tree | c8a8a8a06cbcb118b3e71e43338cee67d7d9316e /Software/Visual_Studio/MachineStudio/Modules | |
| parent | c794c0c66533fc6d02563444d329b8af3d0fe482 (diff) | |
| parent | 6e127075e212e66a890fe130c9b9b90953c70bbd (diff) | |
| download | Tango-eee2ca563c712da4d8ef976238642b5247330740.tar.gz Tango-eee2ca563c712da4d8ef976238642b5247330740.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
8 files changed, 268 insertions, 79 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 1bbcfb8fe..78a7551c0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -125,7 +125,7 @@ <Grid Margin="0 20 0 0"> <commonControls:LoadingPanel IsLoading="{Binding CanWork,Converter={StaticResource BooleanInverseConverter}}"> - <controls:MultiSelectDataGrid MouseDoubleClick="MultiSelectDataGrid_MouseDoubleClick" AutomationProperties.AutomationId="{x:Static automation:Developer.JobsDataGrid}" Style="{StaticResource {x:Type DataGrid}}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="True" CanUserSortColumns="True" AutoGenerateColumns="False" Background="Transparent" ItemsSource="{Binding JobsCollectionView}" SelectedItem="{Binding SelectedMachineJob}" SelectedItemsList="{Binding SelectedJobs,Mode=TwoWay}"> + <controls:MultiSelectDataGrid DoubleClickCommand="{Binding LoadJobCommand}" AutomationProperties.AutomationId="{x:Static automation:Developer.JobsDataGrid}" Style="{StaticResource {x:Type DataGrid}}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="True" CanUserSortColumns="True" AutoGenerateColumns="False" Background="Transparent" ItemsSource="{Binding JobsCollectionView}" SelectedItem="{Binding SelectedMachineJob}" SelectedItemsList="{Binding SelectedJobs,Mode=TwoWay}"> <DataGrid.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> <Setter Property="BorderThickness" Value="0"/> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs index 87eba8ba2..6345d5f59 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs @@ -79,5 +79,12 @@ namespace Tango.MachineStudio.RML.Models { } + public CalibrationMeasurementModel(Tango.MachineStudio.RML.Models.ColorLinearizationModel.LinearizationDataItem model) + { + L = model.L; + A = model.A; + B = model.B; + Ink = model.InkPercentage; + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs index 53e15f976..23179b3f2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/ColorLinearizationModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,11 +23,21 @@ namespace Tango.MachineStudio.RML.Models } - public void GetDataFromFile(string fileName, out List<LinearizationDataItem> items) + public void GetDataFromFile(string fileName, out List<LinearizationDataItem> items, ref string errors) { - ExcelReader reader = new ExcelReader(fileName); - items = reader.GetDataByIndex<LinearizationDataItem>("Sheet1", 2); - reader.Dispose(); + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex<LinearizationDataItem>("Sheet1", 2); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs index b34ef83bc..fd69fef35 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Calibration; +using Tango.BL.Entities; using Tango.Core.Commands; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; @@ -106,5 +107,14 @@ namespace Tango.MachineStudio.RML.ViewModels _notification.ShowError("An error occurred while trying to export the calibration data."); } } + + public void ApplyCalibrationData(LiquidType liquidType, List<CalibrationDataPointVM> newpoints) + { + CalibrationDataVM vm = LiquidsCalibrationData.FirstOrDefault(x => x.LiquidType == liquidType); + if(vm != null) + { + newpoints.ForEach(x => vm.CalibrationPoints.Add(x)); + } + } } } 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 4a6895df3..f04eccd90 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 @@ -41,7 +41,7 @@ namespace Tango.MachineStudio.RML.ViewModels public BL.Entities.LiquidType LiquidType { get { return _liquidType; } - set { _liquidType = value; RaisePropertyChangedAuto(); } + set { _liquidType = value; RaisePropertyChangedAuto(); RaisePropertyChanged("LiquidTypeName"); } } private List<BL.Entities.LiquidType> _liquidTypes; @@ -89,15 +89,17 @@ namespace Tango.MachineStudio.RML.ViewModels get { return _hasError; } set { _hasError = value; RaisePropertyChangedAuto(); } } - + + public RelayCommand ImportDataCommand { get; set; } public RelayCommand CreateGraphCommand { get; set; } public RelayCommand CreateLinearizationGraphCommand { get; set; } public RelayCommand ExportGraphCommand { get; set; } + public RelayCommand ApplyCalibrationDataCommand { get; set; } public string LiquidTypeName { - get { return LiquidType == null ?"" : LiquidType.Name; } + get { return LiquidType == null ?"" : LiquidType.Name; } } public Plot PlotControl { get; set; } @@ -160,7 +162,23 @@ namespace Tango.MachineStudio.RML.ViewModels } } - + private double _LabMinVal; + + public double LabMinVal + { + get { return _LabMinVal; } + set { _LabMinVal = value; RaisePropertyChangedAuto(); } + } + + private double _LabMaxVal; + + public double LabMaxVal + { + get { return _LabMaxVal; } + set { _LabMaxVal = value; RaisePropertyChangedAuto(); } + } + + public Plot LABLinearizationPlotControl { get; set; } public Plot LinearizationPlotControl { get; set; } private IList<DataPoint> _linearizationPoints; /// <summary> @@ -176,6 +194,31 @@ namespace Tango.MachineStudio.RML.ViewModels } } + private IList<DataPoint> _LPoints; + + public IList<DataPoint> LPoints + { + get { return _LPoints; } + set { _LPoints = value; } + } + + private IList<DataPoint> _APoints; + + public IList<DataPoint> APoints + { + get { return _APoints; } + set { _APoints = value; } + } + + private IList<DataPoint> _BPoints; + + public IList<DataPoint> BPoints + { + get { return _BPoints; } + set { _BPoints = value; } + } + + #endregion public ColorCalibrationViewVM(INotificationProvider notification) @@ -189,12 +232,17 @@ namespace Tango.MachineStudio.RML.ViewModels }; Factor = 0; HasError = false; + ImportDataCommand = new RelayCommand(ImportDataForCalcFactorExcel); CreateGraphCommand = new RelayCommand(CreateGraph); CreateLinearizationGraphCommand = new RelayCommand(CreateLinearizationGraph); ExportGraphCommand = new RelayCommand(ExportGraph); + ApplyCalibrationDataCommand = new RelayCommand(ApplyCalibrationData); this.Points = new List<DataPoint>(); TargetPoints = new List<DataPoint>(); LinearizationPoints = new List<DataPoint>(); + LPoints = new List<DataPoint>(); + APoints = new List<DataPoint>(); + BPoints = new List<DataPoint>(); } public void Loading() @@ -205,6 +253,15 @@ namespace Tango.MachineStudio.RML.ViewModels } + public void ClearResults() + { + Points.Clear(); + TargetPoints.Clear(); + ErrorMessage = ""; + HasError = false; + Factor = 0.0; + } + private double GetLiquidFactor() { try @@ -236,14 +293,46 @@ namespace Tango.MachineStudio.RML.ViewModels } return 0.0; } + + private void ImportDataForCalcFactorExcel() + { + OpenFileDialog dlg = new OpenFileDialog(); + + try + { + dlg.Title = $"Import excel file for calculate Factor"; + dlg.Filter = "Excel Files|*.xlsx"; + if (dlg.ShowDialog().Value) + { + ClearResults(); + List<ColorLinearizationModel.LinearizationDataItem> items;//List<LinearizationDataItem> items + ColorLinearizationModel model = new ColorLinearizationModel(); + string error = ""; + model.GetDataFromFile(dlg.FileName, out items, ref error); + if (false == String.IsNullOrEmpty(error) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); + return; + } + Measurements.Clear(); + items.ForEach(x => Measurements.Add(new CalibrationMeasurementModel(x))); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing excel file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to import the selected excel file. Please check the file format if valid and is available to read."); + } + } #region CreateGraph private async void CreateGraph(object obj) { if (_liquidType == null) return; - + ClearResults(); + PlotControl.InvalidatePlot(true); string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; await Task.Factory.StartNew(() => { @@ -251,8 +340,6 @@ namespace Tango.MachineStudio.RML.ViewModels }); DataPoint targetPoint = GetTargetPoint(); - Points.Clear(); - TargetPoints.Clear(); To = 0; From = 0; @@ -314,18 +401,39 @@ namespace Tango.MachineStudio.RML.ViewModels if (fileName == null) return; + LinearizationPoints.Clear(); + LinearizationPlotControl.InvalidatePlot(true); + LPoints.Clear(); + APoints.Clear(); + BPoints.Clear(); + LabMinVal = LabMaxVal = 0; + LABLinearizationPlotControl.InvalidatePlot(true); + List<ColorLinearizationModel.LinearizationDataItem> items; - model.GetDataFromFile(fileName, out items); - if (items.Count == 0) + string errors = ""; + model.GetDataFromFile(fileName, out items, ref errors); + if(false == String.IsNullOrEmpty(errors) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); return; + } - List<double> outputPoints = new List<double>(); + List<double> outputPoints = new List<double>(); + await Task.Factory.StartNew(() => { outputPoints = GetLinearizationMeasurements(items); }); - LinearizationPoints.Clear(); + LabMinVal = items.Min(x => Math.Min(x.L, Math.Min(x.A, x.B))); + LabMaxVal = items.Max(x => Math.Max(x.L, Math.Max(x.A, x.B))); + foreach (var labItem in items) + { + LPoints.Add(new DataPoint(labItem.InkPercentage, labItem.L)); + APoints.Add(new DataPoint(labItem.InkPercentage, labItem.A)); + BPoints.Add(new DataPoint(labItem.InkPercentage, labItem.B)); + } + LABLinearizationPlotControl.InvalidatePlot(true); if (outputPoints == null || outputPoints.Count != items.Count) return; @@ -363,6 +471,17 @@ namespace Tango.MachineStudio.RML.ViewModels items.ForEach(x => linearizationInput.Measurements.Add(new LinearizationMeasurement { L = x.L, A = x.A, B = x.B, InkPercentage = x.InkPercentage })); linearizationInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; + LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); + + if(!String.IsNullOrEmpty(result.ErrorMessage)) + { + LogManager.Log(result.ErrorMessage, "GetLinearizationMeasurements returns error." + result.ErrorMessage); + InvokeUI(() => + { + _notification.ShowError("Linearization failed. " + result.ErrorMessage); + }); + } + LAB lab; if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) { @@ -370,12 +489,6 @@ namespace Tango.MachineStudio.RML.ViewModels linearizationInput.TargetA = lab.A; linearizationInput.TargetB = lab.B; } - LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); - - if(!String.IsNullOrEmpty(result.ErrorMessage)) - { - //LogManager.Log(result.ErrorMessage, "Error occurred while trying to call GetLinearizationMeasurements."); - } return result.InkPercentage.ToList(); } catch (Exception ex) @@ -420,6 +533,19 @@ namespace Tango.MachineStudio.RML.ViewModels Y = point.Y, }; } + + /// <summary> + /// Applies the calibration data. + /// </summary> + protected void ApplyCalibrationData() + { + if (LinearizationPoints.Count == 0) + return; + + List<CalibrationDataPointVM> points = new List<CalibrationDataPointVM>(); + LinearizationPoints.ToList().ForEach(x => points.Add(new CalibrationDataPointVM(x.X, x.Y))); + ViewModelLocator.MainViewVM.CalibrationDataViewVM.ApplyCalibrationData(LiquidType, points); + } #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 548ea7d8c..cadd1fb95 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 @@ -883,6 +883,12 @@ namespace Tango.MachineStudio.RML.ViewModels String file = GetCCTFileOpen(); if (file != null) { + if (CCTS.ToList().Exists(x => x.FileName == Path.GetFileName(file))) + { + _notification.ShowError("The selected CCT file already exists on the database. Please select the CCT file from the dropdown box."); + return; + } + CctModel cctModel = new CctModel(); cctModel.Guid = Guid.NewGuid().ToString(); cctModel.IsNew = true; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml index b9077d365..116500f80 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml @@ -11,7 +11,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="450" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <UserControl.Resources> <converters:EmptyStringToNullConverter x:Key="EmptyStringToNullConverter" /> @@ -29,8 +29,8 @@ </StackPanel> <Grid> <Grid.ColumnDefinitions> - <ColumnDefinition Width="2*"/> - <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1.1*"/> + <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <DockPanel Grid.Column="0"> <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> @@ -52,62 +52,68 @@ <RowDefinition Height="Auto"/> </Grid.RowDefinitions> - <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="20 0 20 0"> - <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="False" ItemsSource="{Binding Measurements}" Margin="0 30 0 50"> - <DataGrid.CellStyle> - <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> - <Setter Property="BorderThickness" Value="0"/> - <Setter Property="FocusVisualStyle" Value="{x:Null}"/> - <Setter Property="VerticalContentAlignment" Value="Center"></Setter> - </Style> - </DataGrid.CellStyle> - <DataGrid.Resources> - <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> - <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> - <Setter Property="HorizontalContentAlignment" Value="Left"/> - <Setter Property="Background" Value="Transparent"/> - <Setter Property="BorderThickness" Value="0"/> - <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> - <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> - <Setter Property="Focusable" Value="false"/> - <Setter Property="IsHitTestVisible" Value="false"/> - <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> - <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> - <Setter Property="VerticalContentAlignment" Value="Center"/> - <Setter Property="FrameworkElement.MinHeight" Value="0"/> - <Setter Property="HideUpDownButtons" Value="true"/> - </Style> - <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> - <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> - <Setter Property="HorizontalContentAlignment" Value="Left"/> - <Setter Property="BorderThickness" Value="0"/> - <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> - <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> - <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> - <Setter Property="VerticalContentAlignment" Value="Center"/> - <Setter Property="FrameworkElement.MinHeight" Value="0"/> - </Style> - </DataGrid.Resources> - <DataGrid.Columns> - <mahapps:DataGridNumericUpDownColumn Header="Ink nl/cm" Minimum="0" Maximum="100000" Binding="{Binding Ink}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> - <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> - <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> - <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> - </DataGrid.Columns> - </DataGrid> + <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="20 0 10 0"> + <StackPanel Orientation="Vertical"> + <Button HorizontalAlignment="Left" Padding="6" Width="120" Background="{StaticResource TransparentBackgroundBrush200}" Command="{Binding ImportDataCommand}" ToolTip="Import data to calculate Liquid factor." Margin="0 0 10 4" BorderBrush="{StaticResource TransparentBackgroundBrush200}"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="280" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="False" ItemsSource="{Binding Measurements}" Margin="0 0 0 50"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Resources> + <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + </Style> + <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + </Style> + </DataGrid.Resources> + <DataGrid.Columns> + <mahapps:DataGridNumericUpDownColumn Header="Ink nl/cm" Minimum="0" Maximum="100000" Binding="{Binding Ink}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + + </StackPanel> </Grid> - <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="20 0 0 0"> - <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0 20 0 0" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> - <oxy:Plot Title="{Binding LiquidTypeName}" x:Name="CalibrationPlot" Margin="0 0 10 0" Background="Transparent"> + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="10 0 0 0"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot Title="{Binding LiquidTypeName}" TitleFontSize="14" x:Name="CalibrationPlot" Margin="0 0 10 0" Background="Transparent" > <oxy:Plot.Series > <oxy:LineSeries ItemsSource="{Binding Points}" Color="#73B6EC" MarkerFill="SteelBlue" MarkerType="Circle" /> <oxy:LineSeries ItemsSource="{Binding TargetPoints}" Color="#E14141" /> </oxy:Plot.Series> <oxy:Plot.Axes> - <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True"/> - <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding From}" Maximum="{Binding To}"/> + <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" /> + <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding From}" Maximum="{Binding To}" /> </oxy:Plot.Axes> </oxy:Plot> </Border> @@ -155,21 +161,43 @@ <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Margin="0 0 0 0"> - <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> - <oxy:Plot Title="{Binding LiquidTypeName}" x:Name="LinearizationPlot" Margin="0 0 0 0" Background="Transparent"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"></ColumnDefinition> + <ColumnDefinition Width="1*"></ColumnDefinition> + </Grid.ColumnDefinitions> + + <Border Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot Title="{Binding LiquidTypeName}" TitleFontSize="14" x:Name="LABLinearizationPlot" Margin="0 0 10 0" Background="Transparent" LegendPlacement="Inside" LegendPosition="TopRight" LegendOrientation="Vertical" LegendFontSize="9" LegendItemAlignment="Left" LegendLineSpacing="3" Foreground="{StaticResource Dialog.Foreground}"> + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding LPoints}" Color="LawnGreen" Title="L" StrokeThickness="1.5"/> + <oxy:LineSeries ItemsSource="{Binding APoints}" Color="#E14141" Title="A" StrokeThickness="1.5"/> + <oxy:LineSeries ItemsSource="{Binding BPoints}" Color="#73B6EC" Title="B" StrokeThickness="1.5"/> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "Ink%" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" AxisTitleDistance ="12" Minimum="0" Maximum="100" /> + <oxy:LinearAxis Position="Left" Title = "LAB" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding LabMinVal}" Maximum="{Binding LabMaxVal}" MinorStep="10" /> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + + <Border Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5" > + <oxy:Plot Title="{Binding LiquidTypeName}" TitleFontSize="14" x:Name="LinearizationPlot" Margin="0 0 0 0" Background="Transparent" LegendPlacement="Inside" LegendPosition="RightTop" LegendOrientation="Vertical" > <oxy:Plot.Series > <oxy:LineSeries ItemsSource="{Binding LinearizationPoints}" Color="#73B6EC" MarkerFill="SteelBlue" MarkerType="Circle"/> </oxy:Plot.Series> <oxy:Plot.Axes> - <oxy:LinearAxis Position="Bottom" Title = "In Ink" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="0"/> - <oxy:LinearAxis Position="Left" Title = "Out Ink" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="0" /> + <oxy:LinearAxis Position="Bottom" Title = "In Ink" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="0" Maximum="100"/> + <oxy:LinearAxis Position="Left" Title = "Out Ink" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="0" Maximum="100"/> </oxy:Plot.Axes> </oxy:Plot> </Border> </Grid> <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="0 20 10 0" HorizontalAlignment="Right"> - <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" Background="{StaticResource TransparentBackgroundBrush200}" MinWidth="100" BorderBrush="{StaticResource TransparentBackgroundBrush200}" Command="{Binding ExportGraphCommand}" > - <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">Export</TextBlock> + <Button Background="{StaticResource TransparentBackgroundBrush200}" BorderBrush="{StaticResource TransparentBackgroundBrush200}" Padding="6" MinWidth="130" Command="{Binding ApplyCalibrationDataCommand}" ToolTip="Apply the calibration data to the current RML calibration tables."> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">APPLY TO RML</TextBlock> + </Button> + <Button Margin="20 0 0 0" Background="{StaticResource TransparentBackgroundBrush200}" BorderBrush="{StaticResource TransparentBackgroundBrush200}" Padding="6" ToolTip="Export to excel" MinWidth="130" Command="{Binding ExportGraphCommand}"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">EXPORT TO FILE</TextBlock> </Button> <Button Margin="20 0 0 0" VerticalAlignment="Bottom" HorizontalAlignment="Right" Background="{StaticResource TransparentBackgroundBrush200}" MinWidth="180" BorderBrush="{StaticResource TransparentBackgroundBrush200}" Command="{Binding CreateLinearizationGraphCommand}" > <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">CREATE LINEARIZATION GRAPH</TextBlock> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs index d56b3c6c9..c29bb68fb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs @@ -34,6 +34,7 @@ namespace Tango.MachineStudio.RML.Views ColorCalibrationViewVM vm = (ColorCalibrationViewVM)DataContext; vm.PlotControl = CalibrationPlot; vm.LinearizationPlotControl = LinearizationPlot; + vm.LABLinearizationPlotControl = LABLinearizationPlot; vm.Loading(); } } |
