diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-07-11 14:01:43 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-07-11 14:01:43 +0300 |
| commit | b2e41ba5213c6a7f08cf8bcb2e4e2654aa6a6224 (patch) | |
| tree | 1b574ea3bf255621bfdd2fde03a93d988ff5a9de /Software/Visual_Studio/MachineStudio/Modules | |
| parent | c839fa3d339f90f15e0548fc056828c533123bfc (diff) | |
| download | Tango-b2e41ba5213c6a7f08cf8bcb2e4e2654aa6a6224.tar.gz Tango-b2e41ba5213c6a7f08cf8bcb2e4e2654aa6a6224.zip | |
Refactored CCT to single CCT per RML.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
6 files changed, 87 insertions, 44 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index a106ea184..94fa36e57 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -248,12 +248,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels public RelayCommand ImportForwardDataCommand { get; set; } - public RelayCommand ImportInverseDataCommand { get; set; } - public RelayCommand ExportForwardDataCommand { get; set; } - public RelayCommand ExportInverseDataCommand { get; set; } - public RelayCommand SaveCommand { get; set; } #endregion @@ -274,10 +270,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels SourceColor.ColorChanged += SourceColor_ColorChanged; ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => SelectedRML != null && IsFree); - ImportInverseDataCommand = new RelayCommand(ImportInverseData, () => SelectedRML != null && IsFree); - ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => SelectedRML != null && CCT != null && CCT.ForwardFileName != null && IsFree); - ExportInverseDataCommand = new RelayCommand(ExportInverseData, () => SelectedRML != null && CCT != null && CCT.InverseFileName != null && IsFree); + ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => SelectedRML != null && CCT != null && CCT.FileName != null && IsFree); SaveCommand = new RelayCommand(Save, () => SelectedRML != null && IsFree); } @@ -336,13 +330,13 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { try { - if (LiquidsCalibrationData == null || CCT.ForwardData == null) return; + if (LiquidsCalibrationData == null || CCT.Data == null) return; ConversionInput input = new ConversionInput(); input.ColorSpace = SourceColor.IsLab ? PMR.ColorLab.ColorSpace.Lab : PMR.ColorLab.ColorSpace.Rgb; input.DeltaChroma = DeltaChroma; input.DeltaL = DeltaL; - input.ForwardData = ByteString.CopyFrom(CCT.ForwardData); + input.ForwardData = ByteString.CopyFrom(CCT.Data); input.InputCoordinates = new InputCoordinates(); input.InputCoordinates.Red = (int)SourceColor.Red; @@ -455,36 +449,17 @@ namespace Tango.MachineStudio.ColorLab.ViewModels String file = GetCCTFileOpen(); if (file != null) { - CCT.ForwardFileName = Path.GetFileName(file); - CCT.ForwardData = File.ReadAllBytes(file); - } - } - - private void ImportInverseData() - { - String file = GetCCTFileOpen(); - if (file != null) - { - CCT.InverseFileName = Path.GetFileName(file); - CCT.InverseData = File.ReadAllBytes(file); + CCT.FileName = Path.GetFileName(file); + CCT.Data = File.ReadAllBytes(file); } } private void ExportForwardData() { - String file = GetCCTFileSave(CCT.ForwardFileName); - if (file != null) - { - File.WriteAllBytes(file, CCT.ForwardData); - } - } - - private void ExportInverseData() - { - String file = GetCCTFileSave(CCT.InverseFileName); + String file = GetCCTFileSave(CCT.FileName); if (file != null) { - File.WriteAllBytes(file, CCT.InverseData); + File.WriteAllBytes(file, CCT.Data); } } @@ -573,7 +548,7 @@ namespace Tango.MachineStudio.ColorLab.ViewModels input.ColorSpace = PMR.ColorLab.ColorSpace.Volume; input.DeltaChroma = DeltaChroma; input.DeltaL = DeltaL; - input.ForwardData = ByteString.CopyFrom(CCT.ForwardData); + input.ForwardData = ByteString.CopyFrom(CCT.Data); input.InputCoordinates = new InputCoordinates(); input.ThreadL = 92.1815; //SelectedRML.MediaColor.L; @@ -695,12 +670,12 @@ namespace Tango.MachineStudio.ColorLab.ViewModels } _isNewCCT = false; - CCT = SelectedRML.Ccts.FirstOrDefault(); + CCT = SelectedRML.Cct; if (CCT == null) { CCT = new Cct(); - CCT.Rml = SelectedRML; + SelectedRML.Cct = CCT; _isNewCCT = true; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml index d78424d4e..888945579 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml @@ -148,7 +148,7 @@ <Image Source="../Images/data-table.png" Height="80" Opacity="0.8"></Image> <StackPanel VerticalAlignment="Center" Width="300" Margin="10 0 0 0"> - <TextBox IsReadOnly="False" Margin="0 5 0 0" Text="{Binding CCT.ForwardFileName}" HorizontalContentAlignment="Center"></TextBox> + <TextBox IsReadOnly="False" Margin="0 5 0 0" Text="{Binding CCT.FileName}" HorizontalContentAlignment="Center"></TextBox> <UniformGrid Columns="2" Margin="0 5 0 0" HorizontalAlignment="Right"> <Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Command="{Binding ImportForwardDataCommand}"> <StackPanel Orientation="Horizontal" Margin="0 0 20 0"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs index 58ffddbb0..090d54036 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/CctsViewVM.cs @@ -30,8 +30,8 @@ namespace Tango.MachineStudio.DB.ViewModels { try { - EditEntity.InverseData = File.ReadAllBytes(file); - EditEntity.InverseFileName = Path.GetFileName(file); + //EditEntity.InverseData = File.ReadAllBytes(file); + //EditEntity.InverseFileName = Path.GetFileName(file); } catch (Exception ex) { @@ -47,8 +47,8 @@ namespace Tango.MachineStudio.DB.ViewModels { try { - EditEntity.ForwardData = File.ReadAllBytes(file); - EditEntity.ForwardFileName = Path.GetFileName(file); + //EditEntity.ForwardData = File.ReadAllBytes(file); + //EditEntity.ForwardFileName = Path.GetFileName(file); } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index a865cdc8f..ac5354a74 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1537,9 +1537,9 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); + _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML.Guid).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); - if (_selectedRML.Ccts.Count == 0) + if (_selectedRML.Cct == null) { InvokeUI(() => { 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 ebcfe72fd..7218ef5ea 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 @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -119,7 +120,6 @@ namespace Tango.MachineStudio.RML.ViewModels set { _activeProcessParametersTableView = value; RaisePropertyChangedAuto(); } } - /// <summary> /// Gets or sets the manage RML command. /// </summary> @@ -135,6 +135,10 @@ namespace Tango.MachineStudio.RML.ViewModels /// </summary> public RelayCommand RemoveRmlCommand { get; set; } + public RelayCommand ImportForwardDataCommand { get; set; } + + public RelayCommand ExportForwardDataCommand { get; set; } + public RelayCommand AddProcessParametersTableCommand { get; set; } public RelayCommand<ProcessParametersTable> RemoveProcessParametersTableCommand { get; set; } @@ -165,6 +169,10 @@ namespace Tango.MachineStudio.RML.ViewModels RemoveLiquidFactorCommand = new RelayCommand<LiquidTypesRml>(RemoveLiquidFactor, () => IsFree); CreateCalibrationDataExcelTemplateCommand = new RelayCommand(CreateCalibrationDataExcelTemplate); SaveCommand = new RelayCommand(Save, () => IsFree); + + ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => ActiveRML != null && IsFree); + + ExportForwardDataCommand = new RelayCommand(ExportForwardData, () => ActiveRML != null && ActiveRML.Cct != null && IsFree); } public override void OnApplicationReady() @@ -199,6 +207,7 @@ namespace Tango.MachineStudio.RML.ViewModels .Set(guid) .WithActiveParametersGroup() .WithLiquidFactors() + .WithCCT() .BuildAsync(); if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) @@ -251,6 +260,8 @@ namespace Tango.MachineStudio.RML.ViewModels View.NavigateTo(RmlNavigationView.RmlView); + InvalidateRelayCommands(); + IsFree = true; } } @@ -491,5 +502,62 @@ namespace Tango.MachineStudio.RML.ViewModels View.NavigateTo(RmlNavigationView.RmlsView); LoadRmls(); } + + #region Import / Export Color Conversion Data + + private void ImportForwardData() + { + String file = GetCCTFileOpen(); + if (file != null) + { + if (ActiveRML.Cct == null) + { + Cct cct = new Cct(); + ActiveRML.Cct = cct; + } + + ActiveRML.Cct.FileName = Path.GetFileName(file); + ActiveRML.Cct.Data = File.ReadAllBytes(file); + } + } + + private void ExportForwardData() + { + String file = GetCCTFileSave(ActiveRML.Cct.FileName); + if (file != null) + { + File.WriteAllBytes(file, ActiveRML.Cct.Data); + } + } + + private String GetCCTFileOpen() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select color adjustment file"; + dlg.Filter = "Color Conversion Table|*.cct"; + if (dlg.ShowDialogCenter()) + { + return dlg.FileName; + } + + return null; + } + + private String GetCCTFileSave(String fileName) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Select color adjustment file"; + dlg.Filter = "Color Conversion Table|*.cct"; + dlg.FileName = fileName; + dlg.DefaultExt = ".cct"; + if (dlg.ShowDialogCenter()) + { + return dlg.FileName; + } + + return null; + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index e43c20c3d..962e59291 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -148,7 +148,7 @@ <Image Source="../Images/data-table.png" Height="80" Opacity="0.8"></Image> <StackPanel VerticalAlignment="Center" Width="300" Margin="10 0 0 0"> - <TextBox IsReadOnly="False" Margin="0 5 0 0" Text="{Binding CCT.ForwardFileName}" HorizontalContentAlignment="Center"></TextBox> + <TextBox IsReadOnly="False" Margin="0 5 0 0" Text="{Binding ActiveRML.Cct.FileName}" HorizontalContentAlignment="Center"></TextBox> <UniformGrid Columns="2" Margin="0 5 0 0" HorizontalAlignment="Right"> <Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Command="{Binding ImportForwardDataCommand}"> <StackPanel Orientation="Horizontal" Margin="0 0 20 0"> |
