From 331266b13685e16520ae5baa8a7aff50789c31df Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 13 Nov 2024 05:12:21 +0200 Subject: Inks Extension Support. --- .../Controls/RangeProgressBar.cs | 10 +- .../FSE/Tango.FSE.Common/Controls/MachineView.xaml | 15 +- .../Converters/LiquidTypeToColorConverter.cs | 2 + .../ViewModels/MainViewVM.cs | 25 +- .../Views/JobView.xaml | 4 +- ...go.MachineStudio.Logging_dfcch3km_wpftmp.csproj | 224 +++++++++++++ .../ViewModels/MainViewVM.cs | 44 ++- .../Views/ConfigurationView.xaml | 1 + .../ViewModels/ColorConversionViewVM.cs | 12 + .../ViewModels/MainViewVM.cs | 26 +- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 46 ++- .../Dialogs/ColorSelectionView.xaml | 43 ++- .../Dialogs/ColorSelectionViewVM.cs | 61 +--- .../Dialogs/VectorFineTuningDialogVM.cs | 43 ++- .../Tango.PPC.JobsV2/Models/BrushStopModel.cs | 349 ++++++-------------- .../Tango.PPC.JobsV2/Models/LiquidVolumeModel.cs | 144 +++++++++ .../Models/LiquidVolumesCollection.cs | 123 +++++++ .../Tango.PPC.JobsV2/Models/SegmentModel.cs | 195 +++++------ .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 4 +- .../ViewModels/JobProgressViewVM.cs | 2 + .../Tango.PPC.JobsV2/ViewModels/JobViewVM.cs | 18 +- .../Tango.PPC.JobsV2/Views/JobEurekaView.xaml | 45 ++- .../Tango.PPC.JobsV2/Views/JobProgressView.xaml | 47 ++- .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml | 45 ++- .../Converters/LiquidTypeToBrushConverter.cs | 2 + .../RemoteJob/DefaultRemoteJobService.cs | 23 +- .../RemoteJob/IRemoteJobInputOutputProvider.cs | 9 +- .../RemoteJob/LiquidOutputModel.cs | 27 ++ .../PPC/Tango.PPC.Common/Resources/Colors.xaml | 2 + .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 3 +- .../Converters/LiquidTypeToBrushConverter.cs | 2 + .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 2 +- .../Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 83 +++-- .../PPC/Tango.PPC.UI/Views/MachineStatusView.xaml | 100 +++--- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.BL/DTO/ColorMeasurementDTO.cs | 14 + .../Tango.BL/DTO/ColorMeasurementDTOBase.cs | 89 +++++ Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs | 40 +++ .../Tango.BL/Entities/ColorMeasurement.cs | 17 + .../Tango.BL/Entities/ColorMeasurementBase.cs | 341 ++++++++++++++++++++ .../Visual_Studio/Tango.BL/Entities/LiquidType.cs | 7 + Software/Visual_Studio/Tango.BL/Entities/Rml.cs | 34 ++ .../Visual_Studio/Tango.BL/Entities/RmlBase.cs | 190 +++++++++++ .../Enumerations/CMYKVPredictionMethods.cs | 21 ++ .../Tango.BL/Enumerations/CMYKVPredictionTypes.cs | 23 ++ .../Visual_Studio/Tango.BL/ObservablesContext.cs | 8 + .../ObservablesEntitiesAdapterExtension.cs | 38 +++ .../ObservablesStaticCollectionsExtension.cs | 38 +++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 8 +- .../CMYKV/CMYKVColorConverter.cs | 97 ++---- .../CMYKV/CMYKVMeasurement.cs | 4 +- .../Tango.ColorConversion/CMYKV/DemoData.cs | 4 +- .../CMYKV/ExtensionMethods.cs | 21 ++ .../CMYKV/IColorPrediction.cs | 11 + .../CMYKV/KNearestNeighborsPrediction.cs | 145 ++++----- .../CMYKV/LinearInterpolationPrediction.cs | 174 +++++++--- .../CMYKV/LinearRegressionPrediction.cs | 181 +++++------ .../CMYKV/PredictionMethod.cs | 10 - .../CMYKV/SplineInterpolationPrediction.cs | 20 +- .../Tango.ColorConversion/DefaultColorConverter.cs | 208 +++++++++++- .../ExtensionMethods/ConversionInputExtensions.cs | 30 ++ .../Tango.ColorConversion.csproj | 4 +- .../Tango.DAL.Remote/DB/COLOR_MEASUREMENTS.cs | 29 ++ Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 5 + .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 66 ++++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 179 ++++++----- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 5 +- .../Tango.PMR/ColorLab/ColorMeasurement.cs | 357 +++++++++++++++++++++ .../Tango.PMR/ColorLab/ConversionInput.cs | 197 +++++++++++- Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 3 +- .../TouchColorPickerCMYKControl.cs | 12 + .../TouchColorPickerControl.cs | 12 + .../TouchColorPickerControl.xaml | 1 + .../TouchColorPickerSlider.cs | 50 +++ Software/Visual_Studio/Tango.sln | 115 ++++++- .../Tango.ColorMeasurementsGenerator/App.config | 24 ++ .../Tango.ColorMeasurementsGenerator/Program.cs | 104 ++++++ .../Properties/AssemblyInfo.cs | 36 +++ .../Tango.ColorMeasurementsGenerator.csproj | 83 +++++ .../packages.config | 4 + 81 files changed, 3722 insertions(+), 1121 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging_dfcch3km_wpftmp.csproj create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/LiquidVolumeModel.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/LiquidVolumesCollection.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/LiquidOutputModel.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTO.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTOBase.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/ColorMeasurement.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/ColorMeasurementBase.cs create mode 100644 Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionMethods.cs create mode 100644 Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionTypes.cs create mode 100644 Software/Visual_Studio/Tango.ColorConversion/CMYKV/ExtensionMethods.cs create mode 100644 Software/Visual_Studio/Tango.ColorConversion/CMYKV/IColorPrediction.cs delete mode 100644 Software/Visual_Studio/Tango.ColorConversion/CMYKV/PredictionMethod.cs create mode 100644 Software/Visual_Studio/Tango.ColorConversion/ExtensionMethods/ConversionInputExtensions.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_MEASUREMENTS.cs create mode 100644 Software/Visual_Studio/Tango.PMR/ColorLab/ColorMeasurement.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs index cfa0eaa4e..948081a05 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Statistics/Controls/RangeProgressBar.cs @@ -75,7 +75,15 @@ namespace Tango.FSE.Statistics.Controls private void PlaceInnerBorder() { - _innerBorder.Margin = new Thickness(LowerValue / Maximum * _outerBorder.ActualWidth, 0, _outerBorder.ActualWidth - (UpperValue / Maximum * _outerBorder.ActualWidth), 0); + try + { + _innerBorder.Margin = new Thickness(LowerValue / Maximum * _outerBorder.ActualWidth, 0, _outerBorder.ActualWidth - (UpperValue / Maximum * _outerBorder.ActualWidth), 0); + } + catch + { + + + } } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml index 25fc3f88e..9db3fc735 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml @@ -88,17 +88,18 @@ - + - + + - + @@ -144,7 +145,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -338,13 +329,13 @@ - + - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml index 038c4af0f..02ff30d24 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -137,33 +137,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs index 3b10b7bdf..da9afc2c7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs @@ -55,6 +55,8 @@ namespace Tango.PPC.Maintenance.Converters return Application.Current.Resources["TangoLightMagentaInkBrush"] as Brush; case BL.Enumerations.LiquidTypes.LightYellow: return Application.Current.Resources["TangoLightYellowInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Violet: + return Application.Current.Resources["TangoVioletInkBrush"] as Brush; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/DefaultRemoteJobService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/DefaultRemoteJobService.cs index 00b4f5ad1..b42a3206c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/DefaultRemoteJobService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/DefaultRemoteJobService.cs @@ -180,10 +180,14 @@ namespace Tango.PPC.Common.RemoteJob switch (colorSpace) { case BL.Enumerations.ColorSpaces.Volume: - inputOutput.Input.Add(new Tuple("C", i.CurrentBrushStop.Cyan.ToString("0.00"))); - inputOutput.Input.Add(new Tuple("M", i.CurrentBrushStop.Magenta.ToString("0.00"))); - inputOutput.Input.Add(new Tuple("Y", i.CurrentBrushStop.Yellow.ToString("0.00"))); - inputOutput.Input.Add(new Tuple("K", i.CurrentBrushStop.Black.ToString("0.00"))); + if (i.CurrentBrushStop.LiquidVolumes != null) + { + foreach (var input in i.CurrentBrushStop.LiquidVolumesOrderedPigmentedForStandardUser.ToList()) + { + inputOutput.Input.Add(new Tuple(input.IdsPack.LiquidType.ShortName, input.Volume.ToString())); + } + } + break; case BL.Enumerations.ColorSpaces.RGB: inputOutput.Input.Add(new Tuple("R", i.CurrentBrushStop.Red.ToString())); @@ -205,13 +209,10 @@ namespace Tango.PPC.Common.RemoteJob try { - inputOutput.Output.Add(new Tuple("C", i.CyanOutput.ToString())); - inputOutput.Output.Add(new Tuple("LC", i.LightCyanOutput.ToString())); - inputOutput.Output.Add(new Tuple("M", i.MagentaOutput.ToString())); - inputOutput.Output.Add(new Tuple("LM", i.LightMagentaOutput.ToString())); - inputOutput.Output.Add(new Tuple("Y", i.YellowOutput.ToString())); - inputOutput.Output.Add(new Tuple("LY", i.LightYellowOutput.ToString())); - inputOutput.Output.Add(new Tuple("K", i.BlackOutput.ToString())); + foreach (var output in i.LiquidOutputs) + { + inputOutput.Output.Add(new Tuple(output.LiquidType.ShortName, output.Volume.ToString())); + } } catch { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/IRemoteJobInputOutputProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/IRemoteJobInputOutputProvider.cs index cc98bd419..85dd66f7c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/IRemoteJobInputOutputProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/IRemoteJobInputOutputProvider.cs @@ -10,13 +10,6 @@ namespace Tango.PPC.Common.RemoteJob public interface IRemoteJobInputOutputProvider { BrushStop CurrentBrushStop { get; } - - double CyanOutput { get; } - double MagentaOutput { get; } - double YellowOutput { get; } - double BlackOutput { get; } - double LightCyanOutput { get; } - double LightMagentaOutput { get; } - double LightYellowOutput { get; } + List LiquidOutputs { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/LiquidOutputModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/LiquidOutputModel.cs new file mode 100644 index 000000000..113d11ddc --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteJob/LiquidOutputModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core; + +namespace Tango.PPC.Common.RemoteJob +{ + public class LiquidOutputModel : ExtendedObject + { + private LiquidType _liquidType; + public LiquidType LiquidType + { + get { return _liquidType; } + set { _liquidType = value; RaisePropertyChangedAuto(); } + } + + private double _volume; + public double Volume + { + get { return _volume; } + set { _volume = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Colors.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Colors.xaml index 816d72de3..acd4c7406 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Colors.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Colors.xaml @@ -9,6 +9,8 @@ + #7F00FF + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 08ad6ec1c..97a89b082 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -224,6 +224,7 @@ + @@ -643,7 +644,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs index 75846431f..0dbbdfd3c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs @@ -32,6 +32,8 @@ namespace Tango.PPC.UI.Converters return Application.Current.Resources["TangoCyanInkBrush"] as Brush; case BL.Enumerations.LiquidTypes.Magenta: return Application.Current.Resources["TangoMagentaInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Violet: + return Application.Current.Resources["TangoVioletInkBrush"] as Brush; case BL.Enumerations.LiquidTypes.LightCyan: return Application.Current.Resources["TangoLightCyanInkBrush"] as Brush; case BL.Enumerations.LiquidTypes.LightMagenta: diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 35620b261..c920fdbad 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -1004,7 +1004,7 @@ if $(ConfigurationName) == Eureka copy /Y "$(ProjectDir)Intro.wmv" "$(TargetDir) - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs index c7ba2e24d..afb536c58 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -180,6 +180,8 @@ namespace Tango.PPC.UI.ViewModels // if (_currentBrushStop != value) { _currentBrushStop = value; + + OnUpdateCurrentBrush(); RaisePropertyChangedAuto(); } @@ -188,41 +190,6 @@ namespace Tango.PPC.UI.ViewModels public JobBrushStop JobBrushStop { get; set; } - public double CyanOutput - { - get { return GetVolumeLiquidType(LiquidTypes.Cyan); } - } - - public double MagentaOutput - { - get { return GetVolumeLiquidType(LiquidTypes.Magenta); } - } - - public double YellowOutput - { - get { return GetVolumeLiquidType(LiquidTypes.Yellow); } - } - - public double BlackOutput - { - get { return GetVolumeLiquidType(LiquidTypes.Black); } - } - - public double LightCyanOutput - { - get { return GetVolumeLiquidType(LiquidTypes.LightCyan); } - } - - public double LightMagentaOutput - { - get { return GetVolumeLiquidType(LiquidTypes.LightMagenta); } - } - - public double LightYellowOutput - { - get { return GetVolumeLiquidType(LiquidTypes.LightYellow); } - } - //public double TransparentInkOutput //{ // get { return GetVolumeLiquidType(LiquidTypes.TransparentInk); } @@ -372,6 +339,12 @@ namespace Tango.PPC.UI.ViewModels } } + private List _liquidOutputs; + public List LiquidOutputs + { + get { return _liquidOutputs; } + set { _liquidOutputs = value; RaisePropertyChangedAuto(); } + } #endregion @@ -635,6 +608,22 @@ namespace Tango.PPC.UI.ViewModels { _handler = e.JobHandler; Job = e.Job; + + List outputs = new List(); + + var idsPacks = MachineProvider.Machine.Configuration.GetSupportedIdsPacks(Job.Rml); + + foreach (var idsPack in idsPacks.Where(x => x.LiquidType.HasPigment)) + { + outputs.Add(new LiquidOutputModel() + { + LiquidType = idsPack.LiquidType, + Volume = 0, + }); + } + + LiquidOutputs = outputs; + try { ResumeModel = JobResumeManager.GetJobResumeModel(Job.Guid); @@ -703,7 +692,14 @@ namespace Tango.PPC.UI.ViewModels { if (_runningJobStatus.CurrentSegment.IsInterSegment) { - CurrentBrushStop = _runningJobStatus.CurrentSegment.BrushStops.FirstOrDefault(); + var brush = _runningJobStatus.CurrentSegment.BrushStops.FirstOrDefault(); + if (brush != null) + { + brush = brush.CloneBrush(); + } + + CurrentBrushStop = brush; + JobBrushStop = null; } else @@ -731,7 +727,7 @@ namespace Tango.PPC.UI.ViewModels JobBrushStop = _handler.JobTicket.Segments[Job.OrderedSegments.IndexOf(segment)].BrushStops.First(); } } - CurrentBrushStop = RunningJobStatus.CurrentSegment.FirstBrushStop; + CurrentBrushStop = RunningJobStatus.CurrentSegment.FirstBrushStop.CloneBrush(); } } } @@ -920,13 +916,12 @@ namespace Tango.PPC.UI.ViewModels protected void OnUpdateCurrentBrush() { - RaisePropertyChanged(nameof(CyanOutput)); - RaisePropertyChanged(nameof(LightCyanOutput)); - RaisePropertyChanged(nameof(MagentaOutput)); - RaisePropertyChanged(nameof(LightMagentaOutput)); - RaisePropertyChanged(nameof(YellowOutput)); - RaisePropertyChanged(nameof(LightYellowOutput)); - RaisePropertyChanged(nameof(BlackOutput)); + CurrentBrushStop.SetLiquidVolumes(MachineProvider.Machine.Configuration, Job.Rml, MachineProvider.MachineOperator.CurrentProcessParameters); + + foreach (var output in LiquidOutputs) + { + output.Volume = GetVolumeLiquidType(output.LiquidType.Type); + } } private void HideJobOutline() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml index c567421aa..74db8e471 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml @@ -45,28 +45,22 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -101,12 +95,12 @@ - + - + @@ -910,12 +904,12 @@ - + - + @@ -989,43 +983,23 @@ - - - - C - - - - - LC - - - - - M - - - - - LM - - - - - Y - - - - - LY - - - - - K - - - + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTO.cs new file mode 100644 index 000000000..276b34408 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTO.cs @@ -0,0 +1,14 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.DTO +{ + public class ColorMeasurementDTO : ColorMeasurementDTOBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTOBase.cs new file mode 100644 index 000000000..bb67290ac --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/ColorMeasurementDTOBase.cs @@ -0,0 +1,89 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.BL.DTO +{ + public abstract class ColorMeasurementDTOBase : ObservableEntityDTO + { + + /// + /// c + /// + public Double C + { + get; set; + } + + /// + /// m + /// + public Double M + { + get; set; + } + + /// + /// y + /// + public Double Y + { + get; set; + } + + /// + /// k + /// + public Double K + { + get; set; + } + + /// + /// v + /// + public Double V + { + get; set; + } + + /// + /// l + /// + public Double L + { + get; set; + } + + /// + /// a + /// + public Double A + { + get; set; + } + + /// + /// b + /// + public Double B + { + get; set; + } + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs index e3b9f676c..2b842f59b 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs @@ -437,5 +437,45 @@ namespace Tango.BL.DTO get; set; } + /// + /// cmykv prediction type + /// + public Int32 CmykvPredictionType + { + get; set; + } + + /// + /// cmykv prediction method + /// + public Int32 CmykvPredictionMethod + { + get; set; + } + + /// + /// cmykv hue threshold + /// + public Double CmykvHueThreshold + { + get; set; + } + + /// + /// k nearest k + /// + public Int32 KNearestK + { + get; set; + } + + /// + /// simple rgb preview factor + /// + public Double SimpleRgbPreviewFactor + { + get; set; + } + } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/ColorMeasurement.cs b/Software/Visual_Studio/Tango.BL/Entities/ColorMeasurement.cs new file mode 100644 index 000000000..e9035d38d --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/ColorMeasurement.cs @@ -0,0 +1,17 @@ +using ColorMine.ColorSpaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.Entities +{ + public class ColorMeasurement : ColorMeasurementBase + { + public override string ToString() + { + return $"{C},{M},{Y},{K},{V} | {L},{A},{B} | dE = {new Cmyk(C, M, Y, K).Compare(new Lab(L, A, B), new ColorMine.ColorSpaces.Comparisons.CieDe2000Comparison())}"; + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/ColorMeasurementBase.cs b/Software/Visual_Studio/Tango.BL/Entities/ColorMeasurementBase.cs new file mode 100644 index 000000000..0610a37eb --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/ColorMeasurementBase.cs @@ -0,0 +1,341 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.Linq; +using Tango.DAL.Remote.DB; +using Tango.Core; +using System.ComponentModel; +using Tango.Core.CustomAttributes; + +namespace Tango.BL.Entities +{ + [Table("COLOR_MEASUREMENTS")] + public abstract class ColorMeasurementBase : ObservableEntity + { + + public event EventHandler CChanged; + + public event EventHandler MChanged; + + public event EventHandler YChanged; + + public event EventHandler KChanged; + + public event EventHandler VChanged; + + public event EventHandler LChanged; + + public event EventHandler AChanged; + + public event EventHandler BChanged; + + protected Double _c; + + /// + /// Gets or sets the colormeasurementbase c. + /// + + [Column("C")] + + public Double C + { + get + { + return _c; + } + + set + { + if (_c != value) + { + _c = value; + + OnCChanged(value); + + } + } + } + + protected Double _m; + + /// + /// Gets or sets the colormeasurementbase m. + /// + + [Column("M")] + + public Double M + { + get + { + return _m; + } + + set + { + if (_m != value) + { + _m = value; + + OnMChanged(value); + + } + } + } + + protected Double _y; + + /// + /// Gets or sets the colormeasurementbase y. + /// + + [Column("Y")] + + public Double Y + { + get + { + return _y; + } + + set + { + if (_y != value) + { + _y = value; + + OnYChanged(value); + + } + } + } + + protected Double _k; + + /// + /// Gets or sets the colormeasurementbase k. + /// + + [Column("K")] + + public Double K + { + get + { + return _k; + } + + set + { + if (_k != value) + { + _k = value; + + OnKChanged(value); + + } + } + } + + protected Double _v; + + /// + /// Gets or sets the colormeasurementbase v. + /// + + [Column("V")] + + public Double V + { + get + { + return _v; + } + + set + { + if (_v != value) + { + _v = value; + + OnVChanged(value); + + } + } + } + + protected Double _l; + + /// + /// Gets or sets the colormeasurementbase l. + /// + + [Column("L")] + + public Double L + { + get + { + return _l; + } + + set + { + if (_l != value) + { + _l = value; + + OnLChanged(value); + + } + } + } + + protected Double _a; + + /// + /// Gets or sets the colormeasurementbase a. + /// + + [Column("A")] + + public Double A + { + get + { + return _a; + } + + set + { + if (_a != value) + { + _a = value; + + OnAChanged(value); + + } + } + } + + protected Double _b; + + /// + /// Gets or sets the colormeasurementbase b. + /// + + [Column("B")] + + public Double B + { + get + { + return _b; + } + + set + { + if (_b != value) + { + _b = value; + + OnBChanged(value); + + } + } + } + + /// + /// Called when the C has changed. + /// + protected virtual void OnCChanged(Double c) + { + CChanged?.Invoke(this, c); + RaisePropertyChanged(nameof(C)); + } + + /// + /// Called when the M has changed. + /// + protected virtual void OnMChanged(Double m) + { + MChanged?.Invoke(this, m); + RaisePropertyChanged(nameof(M)); + } + + /// + /// Called when the Y has changed. + /// + protected virtual void OnYChanged(Double y) + { + YChanged?.Invoke(this, y); + RaisePropertyChanged(nameof(Y)); + } + + /// + /// Called when the K has changed. + /// + protected virtual void OnKChanged(Double k) + { + KChanged?.Invoke(this, k); + RaisePropertyChanged(nameof(K)); + } + + /// + /// Called when the V has changed. + /// + protected virtual void OnVChanged(Double v) + { + VChanged?.Invoke(this, v); + RaisePropertyChanged(nameof(V)); + } + + /// + /// Called when the L has changed. + /// + protected virtual void OnLChanged(Double l) + { + LChanged?.Invoke(this, l); + RaisePropertyChanged(nameof(L)); + } + + /// + /// Called when the A has changed. + /// + protected virtual void OnAChanged(Double a) + { + AChanged?.Invoke(this, a); + RaisePropertyChanged(nameof(A)); + } + + /// + /// Called when the B has changed. + /// + protected virtual void OnBChanged(Double b) + { + BChanged?.Invoke(this, b); + RaisePropertyChanged(nameof(B)); + } + + /// + /// Initializes a new instance of the class. + /// + public ColorMeasurementBase() : base() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs b/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs index ce09d72ac..d7b0f4f58 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/LiquidType.cs @@ -25,6 +25,13 @@ namespace Tango.BL.Entities get { return Core.Helpers.ColorHelper.IntegerToColor(Color); } } + [NotMapped] + [JsonIgnore] + public SolidColorBrush LiquidTypeBrush + { + get { return new SolidColorBrush(LiquidTypeColor); } + } + [NotMapped] [JsonIgnore] public LiquidTypes Type diff --git a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs index fdeb8f05e..9c672fd3b 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs @@ -342,5 +342,39 @@ namespace Tango.BL.Entities } #endregion + + #region CMYKV + + [NotMapped] + [JsonIgnore] + public CMYKVPredictionTypes PredictionType + { + get + { + return (CMYKVPredictionTypes)CmykvPredictionType; + } + set + { + CmykvPredictionType = value.ToInt32(); + RaisePropertyChangedAuto(); + } + } + + [NotMapped] + [JsonIgnore] + public CMYKVPredictionMethods PredictionMethod + { + get + { + return (CMYKVPredictionMethods)CmykvPredictionMethod; + } + set + { + CmykvPredictionMethod = value.ToInt32(); + RaisePropertyChangedAuto(); + } + } + + #endregion } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs index 17b29d691..ec34e0254 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs @@ -109,6 +109,16 @@ namespace Tango.BL.Entities public event EventHandler BtsrTensionErrorChanged; + public event EventHandler CmykvPredictionTypeChanged; + + public event EventHandler CmykvPredictionMethodChanged; + + public event EventHandler CmykvHueThresholdChanged; + + public event EventHandler KNearestKChanged; + + public event EventHandler SimpleRgbPreviewFactorChanged; + public event EventHandler BtsrApplicationTypeChanged; public event EventHandler BtsrYarnTypeChanged; @@ -1540,6 +1550,141 @@ namespace Tango.BL.Entities } } + protected Int32 _cmykvpredictiontype; + + /// + /// Gets or sets the rmlbase cmykv prediction type. + /// + + [Column("CMYKV_PREDICTION_TYPE")] + + public Int32 CmykvPredictionType + { + get + { + return _cmykvpredictiontype; + } + + set + { + if (_cmykvpredictiontype != value) + { + _cmykvpredictiontype = value; + + OnCmykvPredictionTypeChanged(value); + + } + } + } + + protected Int32 _cmykvpredictionmethod; + + /// + /// Gets or sets the rmlbase cmykv prediction method. + /// + + [Column("CMYKV_PREDICTION_METHOD")] + + public Int32 CmykvPredictionMethod + { + get + { + return _cmykvpredictionmethod; + } + + set + { + if (_cmykvpredictionmethod != value) + { + _cmykvpredictionmethod = value; + + OnCmykvPredictionMethodChanged(value); + + } + } + } + + protected Double _cmykvhuethreshold; + + /// + /// Gets or sets the rmlbase cmykv hue threshold. + /// + + [Column("CMYKV_HUE_THRESHOLD")] + + public Double CmykvHueThreshold + { + get + { + return _cmykvhuethreshold; + } + + set + { + if (_cmykvhuethreshold != value) + { + _cmykvhuethreshold = value; + + OnCmykvHueThresholdChanged(value); + + } + } + } + + protected Int32 _knearestk; + + /// + /// Gets or sets the rmlbase k nearest k. + /// + + [Column("K_NEAREST_K")] + + public Int32 KNearestK + { + get + { + return _knearestk; + } + + set + { + if (_knearestk != value) + { + _knearestk = value; + + OnKNearestKChanged(value); + + } + } + } + + protected Double _simplergbpreviewfactor; + + /// + /// Gets or sets the rmlbase simple rgb preview factor. + /// + + [Column("SIMPLE_RGB_PREVIEW_FACTOR")] + + public Double SimpleRgbPreviewFactor + { + get + { + return _simplergbpreviewfactor; + } + + set + { + if (_simplergbpreviewfactor != value) + { + _simplergbpreviewfactor = value; + + OnSimpleRgbPreviewFactorChanged(value); + + } + } + } + protected BtsrApplicationType _btsrapplicationtype; /// @@ -2461,6 +2606,51 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(BtsrTensionError)); } + /// + /// Called when the CmykvPredictionType has changed. + /// + protected virtual void OnCmykvPredictionTypeChanged(Int32 cmykvpredictiontype) + { + CmykvPredictionTypeChanged?.Invoke(this, cmykvpredictiontype); + RaisePropertyChanged(nameof(CmykvPredictionType)); + } + + /// + /// Called when the CmykvPredictionMethod has changed. + /// + protected virtual void OnCmykvPredictionMethodChanged(Int32 cmykvpredictionmethod) + { + CmykvPredictionMethodChanged?.Invoke(this, cmykvpredictionmethod); + RaisePropertyChanged(nameof(CmykvPredictionMethod)); + } + + /// + /// Called when the CmykvHueThreshold has changed. + /// + protected virtual void OnCmykvHueThresholdChanged(Double cmykvhuethreshold) + { + CmykvHueThresholdChanged?.Invoke(this, cmykvhuethreshold); + RaisePropertyChanged(nameof(CmykvHueThreshold)); + } + + /// + /// Called when the KNearestK has changed. + /// + protected virtual void OnKNearestKChanged(Int32 knearestk) + { + KNearestKChanged?.Invoke(this, knearestk); + RaisePropertyChanged(nameof(KNearestK)); + } + + /// + /// Called when the SimpleRgbPreviewFactor has changed. + /// + protected virtual void OnSimpleRgbPreviewFactorChanged(Double simplergbpreviewfactor) + { + SimpleRgbPreviewFactorChanged?.Invoke(this, simplergbpreviewfactor); + RaisePropertyChanged(nameof(SimpleRgbPreviewFactor)); + } + /// /// Called when the BtsrApplicationType has changed. /// diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionMethods.cs b/Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionMethods.cs new file mode 100644 index 000000000..0b97b34bf --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionMethods.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.Enumerations +{ + public enum CMYKVPredictionMethods + { + [Description("K-Nearest Neighbors (KNN)")] + KNearestNeighbors = 0, + [Description("Linear Interpolation")] + LinearInterpolation = 1, + [Description("Linear Regression")] + LinearRegression = 2, + [Description("Spline Interpolation")] + SplineInterpolation = 3 + } +} diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionTypes.cs b/Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionTypes.cs new file mode 100644 index 000000000..7d83e1f63 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Enumerations/CMYKVPredictionTypes.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.Enumerations +{ + public enum CMYKVPredictionTypes + { + [Description("None")] + None = 0, + [Description("Predict CMYKV")] + Predict_CMYKV = 1, + [Description("Predict RGB")] + Predict_RGB = 2, + [Description("Predict All")] + PredictAll = 3, + [Description("Simple RGB Preview")] + SimpleRGBPreview = 4, + } +} diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs index 259205160..3cabae68c 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs @@ -358,6 +358,14 @@ namespace Tango.BL get; set; } + /// + /// Gets or sets the ColorMeasurements. + /// + public DbSet ColorMeasurements + { + get; set; + } + /// /// Gets or sets the ColorProcessInkUptake. /// diff --git a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs index 7a5a28050..cd082dae7 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs @@ -1529,6 +1529,42 @@ namespace Tango.BL } + private ObservableCollection _colormeasurements; + /// + /// Gets or sets the ColorMeasurements. + /// + public ObservableCollection ColorMeasurements + { + get + { + return _colormeasurements; + } + + set + { + _colormeasurements = value; RaisePropertyChanged(nameof(ColorMeasurements)); + } + + } + + private ICollectionView _colormeasurementsViewSource; + /// + /// Gets or sets the ColorMeasurements View Source. + /// + public ICollectionView ColorMeasurementsViewSource + { + get + { + return _colormeasurementsViewSource; + } + + set + { + _colormeasurementsViewSource = value; RaisePropertyChanged(nameof(ColorMeasurementsViewSource)); + } + + } + private ObservableCollection _colorprocessinkuptake; /// /// Gets or sets the ColorProcessInkUptake. @@ -4499,6 +4535,8 @@ namespace Tango.BL ColorCatalogsItemsRecipesViewSource = CreateCollectionView(ColorCatalogsItemsRecipes); + ColorMeasurementsViewSource = CreateCollectionView(ColorMeasurements); + ColorProcessInkUptakeViewSource = CreateCollectionView(ColorProcessInkUptake); ColorSpacesViewSource = CreateCollectionView(ColorSpaces); diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs index 45743d391..c996f09b7 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs @@ -1529,6 +1529,42 @@ namespace Tango.BL } + private ObservableCollection _colormeasurements; + /// + /// Gets or sets the ColorMeasurements. + /// + public ObservableCollection ColorMeasurements + { + get + { + return _colormeasurements; + } + + set + { + _colormeasurements = value; RaisePropertyChanged(nameof(ColorMeasurements)); + } + + } + + private ICollectionView _colormeasurementsViewSource; + /// + /// Gets or sets the ColorMeasurements View Source. + /// + public ICollectionView ColorMeasurementsViewSource + { + get + { + return _colormeasurementsViewSource; + } + + set + { + _colormeasurementsViewSource = value; RaisePropertyChanged(nameof(ColorMeasurementsViewSource)); + } + + } + private ObservableCollection _colorprocessinkuptake; /// /// Gets or sets the ColorProcessInkUptake. @@ -4499,6 +4535,8 @@ namespace Tango.BL ColorCatalogsItemsRecipesViewSource = CreateCollectionView(ColorCatalogsItemsRecipes); + ColorMeasurementsViewSource = CreateCollectionView(ColorMeasurements); + ColorProcessInkUptakeViewSource = CreateCollectionView(ColorProcessInkUptake); ColorSpacesViewSource = CreateCollectionView(ColorSpaces); diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 83e4bf3ea..9fc04b814 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -180,6 +180,8 @@ + + @@ -413,6 +415,8 @@ + + @@ -582,6 +586,8 @@ + + @@ -833,7 +839,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVColorConverter.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVColorConverter.cs index 153d4caa7..bcb12602f 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVColorConverter.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVColorConverter.cs @@ -1,97 +1,64 @@ using System; using System.Collections.Generic; using System.Linq; +using Tango.BL.Enumerations; namespace Tango.ColorConversion { public class CMYKVColorConverter { - private IColorConverter colorConverter = new DefaultColorConverter(); + public List Measurements = new List(); + private int _k; - private List measurements = new List(); + public CMYKVColorConverter(int k = 5) + { + _k = k; + } public void AddMeasurement(CMYKV cmykv, LAB lab) { - measurements.Add(new CMYKVMeasurement { CMYKVValue = cmykv, LABValue = lab }); + Measurements.Add(new CMYKVMeasurement { CMYKV = cmykv, LAB = lab }); } - public CMYKV ConvertRGBToCMYKV(RGB rgb, PredictionMethod method) + public CMYKV ConvertRGBToCMYKV(RGB rgb, CMYKVPredictionMethods method) { - // Step 1: Convert RGB to LAB (Perceptual color space) - var LAB = new ColorMine.ColorSpaces.Rgb(rgb.R, rgb.G, rgb.B).ToLabUsingColorful(); - LAB lab = new LAB(LAB.L, LAB.A, LAB.B); - - // Step 2: Use LAB to predict the appropriate CMYKV values based on the chosen method - CMYKV predictedCMYKV = PredictCMYKV(lab, method); - - return predictedCMYKV; + IColorPrediction predictionMethod = GetPredictionMethod(method); + return predictionMethod.ConvertRGBToCMYKV(rgb); } - private CMYKV PredictCMYKV(LAB lab, PredictionMethod method) + public CMYKV ConvertLABToCMYKV(LAB lab, CMYKVPredictionMethods method) { - CMYKV predictedCMYKV; - - // Use the selected prediction method to find the best CMYKV values from LAB - switch (method) - { - case PredictionMethod.LinearInterpolation: - predictedCMYKV = new LinearInterpolationPrediction().PredictFromLAB(lab, measurements); - break; - case PredictionMethod.LinearRegression: - predictedCMYKV = new LinearRegressionPrediction().PredictFromLAB(lab, measurements); - break; - case PredictionMethod.KNearestNeighbors: - predictedCMYKV = new KNearestNeighborsPrediction(5).PredictFromLAB(lab, measurements); - break; - case PredictionMethod.SplineInterpolation: - predictedCMYKV = new SplineInterpolationPrediction().PredictFromLAB(lab, measurements); - break; - default: - throw new ArgumentException("Invalid prediction method"); - } - - return predictedCMYKV; + IColorPrediction predictionMethod = GetPredictionMethod(method); + return predictionMethod.PredictLABToCMYKV(lab); } - public RGB ConvertCMYKVToRGB(CMYKV cmykv, Func CMYKToRGB, PredictionMethod method) + public RGB ConvertCMYKVToRGB(CMYKV cmykv, CMYKVPredictionMethods method) { - // Step 1: Convert CMYK part to RGB using the existing CMYKToRGB method - RGB rgbFromCMYK = CMYKToRGB(new CMYK { C = cmykv.C, M = cmykv.M, Y = cmykv.Y, K = cmykv.K }); - - // Step 2: Use the prediction method to get LAB values (which will account for Violet ink) - LAB predictedLAB = PredictLAB(cmykv, method); - - // Step 3: Convert LAB (with Violet) back to RGB - var rgb = new ColorMine.ColorSpaces.Lab(predictedLAB.L, predictedLAB.A, predictedLAB.B).ToRgbUsingColorful(); - RGB adjustedRGB = new RGB(rgb.R, rgb.G, rgb.B); - - // Step 4: Combine the CMYK-based RGB with the Violet-adjusted RGB for final output - RGB finalRGB = MergeRGB(rgbFromCMYK, adjustedRGB); + IColorPrediction predictionMethod = GetPredictionMethod(method); + return predictionMethod.PredictCMYKVToRGB(cmykv); + } - return finalRGB; + public LAB ConvertCMYKVToLAB(CMYKV cmykv, CMYKVPredictionMethods method) + { + IColorPrediction predictionMethod = GetPredictionMethod(method); + return predictionMethod.PredictCMYKVToLAB(cmykv); } - private LAB PredictLAB(CMYKV cmykv, PredictionMethod method) + private IColorPrediction GetPredictionMethod(CMYKVPredictionMethods method) { - LAB predictedLAB; switch (method) { - case PredictionMethod.LinearInterpolation: - predictedLAB = new LinearInterpolationPrediction().Predict(cmykv, measurements); - break; - case PredictionMethod.LinearRegression: - predictedLAB = new LinearRegressionPrediction().Predict(cmykv, measurements); - break; - case PredictionMethod.KNearestNeighbors: - predictedLAB = new KNearestNeighborsPrediction(5).Predict(cmykv, measurements); - break; - case PredictionMethod.SplineInterpolation: - predictedLAB = new SplineInterpolationPrediction().Predict(cmykv, measurements); - break; + case CMYKVPredictionMethods.KNearestNeighbors: + return new KNearestNeighborsPrediction(Measurements, _k); + case CMYKVPredictionMethods.LinearInterpolation: + return new LinearInterpolationPrediction(Measurements); + case CMYKVPredictionMethods.LinearRegression: + return new LinearRegressionPrediction(Measurements); + //case CMYKVPredictionMethods.SplineInterpolation: + //return new SplineInterpolationPrediction(measurements); default: - throw new ArgumentException("Invalid prediction method"); + throw new System.Exception("Unsupported prediction method"); } - return predictedLAB; } private RGB MergeRGB(RGB baseRGB, RGB violetAdjustedRGB) diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVMeasurement.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVMeasurement.cs index 90e5b863b..533ca0cc2 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVMeasurement.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/CMYKVMeasurement.cs @@ -2,7 +2,7 @@ namespace Tango.ColorConversion { public class CMYKVMeasurement { - public CMYKV CMYKVValue { get; set; } - public LAB LABValue { get; set; } + public CMYKV CMYKV { get; set; } + public LAB LAB { get; set; } } } diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/DemoData.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/DemoData.cs index acd66b14d..ea0c91c1c 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/DemoData.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/DemoData.cs @@ -36,8 +36,8 @@ namespace Tango.ColorConversion data.Add(new CMYKVMeasurement { - CMYKVValue = new CMYKV { C = C, M = M, Y = Y, K = K, V = V }, - LABValue = new LAB { L = L, A = A, B = B } + CMYKV = new CMYKV { C = C, M = M, Y = Y, K = K, V = V }, + LAB = new LAB { L = L, A = A, B = B } }); } diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/ExtensionMethods.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/ExtensionMethods.cs new file mode 100644 index 000000000..4aa4c477a --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/ExtensionMethods.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.ColorConversion; + +public static class ExtensionMethods +{ + public static RGB ToRGB(this LAB lab) + { + var rgb = new ColorMine.ColorSpaces.Lab(lab.L, lab.A, lab.B).To(); + return new RGB(rgb.R, rgb.G, rgb.B); + } + + public static LAB ToLAB(this RGB rgb) + { + var lab = new ColorMine.ColorSpaces.Rgb(rgb.R, rgb.G, rgb.B).To(); + return new LAB(lab.L, lab.A, lab.B); + } +} diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/IColorPrediction.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/IColorPrediction.cs new file mode 100644 index 000000000..c2ec22132 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/IColorPrediction.cs @@ -0,0 +1,11 @@ + +namespace Tango.ColorConversion +{ + public interface IColorPrediction + { + CMYKV ConvertRGBToCMYKV(RGB rgb); + CMYKV PredictLABToCMYKV(LAB lab); + RGB PredictCMYKVToRGB(CMYKV cmykv); + LAB PredictCMYKVToLAB(CMYKV cmykv); + } +} diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/KNearestNeighborsPrediction.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/KNearestNeighborsPrediction.cs index 4e9e85554..5ceb4b63a 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/KNearestNeighborsPrediction.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/KNearestNeighborsPrediction.cs @@ -4,119 +4,94 @@ using System.Linq; namespace Tango.ColorConversion { - public class KNearestNeighborsPrediction + public class KNearestNeighborsPrediction : IColorPrediction { + private List measurements; private int k; - public KNearestNeighborsPrediction(int k) + public KNearestNeighborsPrediction(List measurements, int k = 3) { + this.measurements = measurements; this.k = k; } - public LAB Predict(CMYKV cmykv, List measurements) + // Predict CMYKV from RGB by first converting RGB to LAB + public CMYKV ConvertRGBToCMYKV(RGB rgb) { - // K-Nearest Neighbors logic: Find the k closest measurements and average their LAB values - if (measurements.Count < k) - throw new InvalidOperationException($"Not enough measurements for KNN (requires at least {k})"); + // Convert RGB to LAB + LAB lab = rgb.ToLAB(); - // Calculate distances and take the k nearest measurements - var nearest = measurements - .OrderBy(m => GetDistance(m.CMYKVValue, cmykv)) + // Now predict CMYKV using the LAB prediction method + return PredictLABToCMYKV(lab); + } + + // Predict CMYKV from LAB (directly use LAB measurements) + public CMYKV PredictLABToCMYKV(LAB lab) + { + var nearestNeighbors = measurements + .OrderBy(m => EuclideanDistanceLAB(lab, m.LAB)) .Take(k) - .ToArray(); + .ToList(); - // Average their LAB values - var avgL = nearest.Average(m => m.LABValue.L); - var avgA = nearest.Average(m => m.LABValue.A); - var avgB = nearest.Average(m => m.LABValue.B); + return AverageCMYKV(nearestNeighbors); + } + + // Predict RGB from CMYKV by first predicting LAB, then converting LAB to RGB + public RGB PredictCMYKVToRGB(CMYKV cmykv) + { + // Predict LAB from CMYKV + LAB lab = PredictCMYKVToLAB(cmykv); - return new LAB { L = avgL, A = avgA, B = avgB }; + // Convert LAB to RGB + return lab.ToRGB(); } - public CMYKV PredictFromLAB(LAB lab, List measurements) + // Predict LAB from CMYKV using nearest neighbors + public LAB PredictCMYKVToLAB(CMYKV cmykv) { - // Find the k-nearest neighbors based on LAB distances - var nearest = measurements - .OrderBy(m => CalculateLABDistance(m.LABValue, lab)) + var nearestNeighbors = measurements + .OrderBy(m => EuclideanDistanceCMYKV(cmykv, m.CMYKV)) .Take(k) - .ToArray(); - - // Average the CMYKV values of the nearest neighbors - double avgC = nearest.Average(m => m.CMYKVValue.C); - double avgM = nearest.Average(m => m.CMYKVValue.M); - double avgY = nearest.Average(m => m.CMYKVValue.Y); - double avgK = nearest.Average(m => m.CMYKVValue.K); - double avgV = nearest.Average(m => m.CMYKVValue.V); - - // Return the predicted CMYKV value - return new CMYKV - { - C = avgC, - M = avgM, - Y = avgY, - K = avgK, - V = avgV - }; + .ToList(); + + return AverageLAB(nearestNeighbors); } - private double CalculateLABDistance(LAB lab1, LAB lab2) + // Calculate Euclidean distance for LAB + private double EuclideanDistanceLAB(LAB lab1, LAB lab2) { - // Calculate Euclidean distance in LAB color space - return Math.Sqrt(Math.Pow(lab1.L - lab2.L, 2) + - Math.Pow(lab1.A - lab2.A, 2) + - Math.Pow(lab1.B - lab2.B, 2)); + return Math.Sqrt(Math.Pow(lab1.L - lab2.L, 2) + Math.Pow(lab1.A - lab2.A, 2) + Math.Pow(lab1.B - lab2.B, 2)); } - private double GetDistance(CMYKV m1, CMYKV m2) + // Calculate Euclidean distance for CMYKV + private double EuclideanDistanceCMYKV(CMYKV cmykv1, CMYKV cmykv2) { - return Math.Sqrt(Math.Pow(m1.C - m2.C, 2) + - Math.Pow(m1.M - m2.M, 2) + - Math.Pow(m1.Y - m2.Y, 2) + - Math.Pow(m1.K - m2.K, 2) + - Math.Pow(m1.V - m2.V, 2)); + return Math.Sqrt(Math.Pow(cmykv1.C - cmykv2.C, 2) + Math.Pow(cmykv1.M - cmykv2.M, 2) + + Math.Pow(cmykv1.Y - cmykv2.Y, 2) + Math.Pow(cmykv1.K - cmykv2.K, 2) + + Math.Pow(cmykv1.V - cmykv2.V, 2)); } - public static int FindBestK(List data, int maxK) + // Helper method to average CMYKV values from the k nearest neighbors + private CMYKV AverageCMYKV(List neighbors) { - // Split the data into training and validation sets - var trainingSet = data.Take(80).ToList(); // 80% training - var validationSet = data.Skip(80).Take(20).ToList(); // 20% validation - - double bestError = double.MaxValue; - int bestK = 1; - - // Iterate over possible values of k - for (int k = 1; k <= maxK; k++) - { - double totalError = 0; - - // For each point in the validation set, predict using the KNN model - foreach (var validationPoint in validationSet) - { - var predictedLAB = new KNearestNeighborsPrediction(k).Predict(validationPoint.CMYKVValue, trainingSet); - totalError += CalculateError(predictedLAB, validationPoint.LABValue); - } - - double averageError = totalError / validationSet.Count; - - // Select the k with the smallest validation error - if (averageError < bestError) - { - bestError = averageError; - bestK = k; - } - } - - return bestK; + double C = neighbors.Average(m => m.CMYKV.C); + double M = neighbors.Average(m => m.CMYKV.M); + double Y = neighbors.Average(m => m.CMYKV.Y); + double K = neighbors.Average(m => m.CMYKV.K); + double V = neighbors.Average(m => m.CMYKV.V); + + return new CMYKV { C = C, M = M, Y = Y, K = K, V = V }; } - private static double CalculateError(LAB predicted, LAB actual) + // Helper method to average LAB values from the k nearest neighbors + private LAB AverageLAB(List neighbors) { - // Calculate Euclidean distance in LAB space as error - return Math.Sqrt(Math.Pow(predicted.L - actual.L, 2) + - Math.Pow(predicted.A - actual.A, 2) + - Math.Pow(predicted.B - actual.B, 2)); - } + double L = neighbors.Average(m => m.LAB.L); + double A = neighbors.Average(m => m.LAB.A); + double B = neighbors.Average(m => m.LAB.B); + return new LAB { L = L, A = A, B = B }; + } } + } diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearInterpolationPrediction.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearInterpolationPrediction.cs index b47fa6305..3db69bb9c 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearInterpolationPrediction.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearInterpolationPrediction.cs @@ -4,78 +4,152 @@ using System.Linq; namespace Tango.ColorConversion { - public class LinearInterpolationPrediction + public class LinearInterpolationPrediction : IColorPrediction { - public LAB Predict(CMYKV cmykv, List measurements) + private List measurements; + + public LinearInterpolationPrediction(List measurements) { - // Linear interpolation logic: Find the two closest points and interpolate between them. + this.measurements = measurements; + } - if (measurements.Count < 2) - throw new InvalidOperationException("Not enough measurements for interpolation"); + // Predict CMYKV from RGB by first converting RGB to LAB and then interpolating + public CMYKV ConvertRGBToCMYKV(RGB rgb) + { + // Convert RGB to LAB + LAB lab = rgb.ToLAB(); - // Calculate the Euclidean distance between the input and each measurement's CMYKV values - var closest = measurements - .OrderBy(m => GetDistance(m.CMYKVValue, cmykv)) - .Take(2) - .ToArray(); + // Interpolate based on LAB + return PredictLABToCMYKV(lab); + } - // Perform interpolation between the two closest points - var weight1 = GetDistance(closest[1].CMYKVValue, cmykv); - var weight2 = GetDistance(closest[0].CMYKVValue, cmykv); - var totalWeight = weight1 + weight2; + // Predict CMYKV from LAB using linear interpolation + public CMYKV PredictLABToCMYKV(LAB lab) + { + // Find the two closest measurements based on LAB distance + var lowerBound = FindLowerBoundLAB(lab); + var upperBound = FindUpperBoundLAB(lab); - return new LAB - { - L = (closest[0].LABValue.L * weight2 + closest[1].LABValue.L * weight1) / totalWeight, - A = (closest[0].LABValue.A * weight2 + closest[1].LABValue.A * weight1) / totalWeight, - B = (closest[0].LABValue.B * weight2 + closest[1].LABValue.B * weight1) / totalWeight - }; + // Calculate interpolation factor 't' + double t = CalculateInterpolationFactorLAB(lab, lowerBound.LAB, upperBound.LAB); + + // Perform linear interpolation between the two closest CMYKV values + return InterpolateCMYKV(lowerBound.CMYKV, upperBound.CMYKV, t); } - private double GetDistance(CMYKV m1, CMYKV m2) + // Predict RGB from CMYKV by first predicting LAB, then converting LAB to RGB + public RGB PredictCMYKVToRGB(CMYKV cmykv) { - return Math.Sqrt(Math.Pow(m1.C - m2.C, 2) + - Math.Pow(m1.M - m2.M, 2) + - Math.Pow(m1.Y - m2.Y, 2) + - Math.Pow(m1.K - m2.K, 2) + - Math.Pow(m1.V - m2.V, 2)); + // Predict LAB using linear interpolation + LAB lab = PredictCMYKVToLAB(cmykv); + + // Convert LAB to RGB + return lab.ToRGB(); } - public CMYKV PredictFromLAB(LAB lab, List measurements) + // Predict LAB from CMYKV using linear interpolation + public LAB PredictCMYKVToLAB(CMYKV cmykv) { - if (measurements.Count < 2) - throw new InvalidOperationException("Not enough measurements for interpolation"); + // Find the two closest measurements based on CMYKV distance + var lowerBound = FindLowerBoundCMYKV(cmykv); + var upperBound = FindUpperBoundCMYKV(cmykv); - // Find the two closest measurements in LAB space based on distance - var closest = measurements - .OrderBy(m => CalculateLABDistance(m.LABValue, lab)) - .Take(2) - .ToArray(); + // Calculate interpolation factor 't' + double t = CalculateInterpolationFactorCMYKV(cmykv, lowerBound.CMYKV, upperBound.CMYKV); - // Perform linear interpolation between the two closest points - double distance1 = CalculateLABDistance(closest[0].LABValue, lab); - double distance2 = CalculateLABDistance(closest[1].LABValue, lab); - double totalDistance = distance1 + distance2; + // Perform linear interpolation between the two closest LAB values + return InterpolateLAB(lowerBound.LAB, upperBound.LAB, t); + } - // Interpolate CMYKV values based on the distances - double weight1 = distance2 / totalDistance; - double weight2 = distance1 / totalDistance; + // Find the two closest LAB measurements below and above the input LAB + private CMYKVMeasurement FindLowerBoundLAB(LAB lab) + { + return measurements + .Where(m => EuclideanDistanceLAB(m.LAB, lab) <= 0) + .OrderBy(m => EuclideanDistanceLAB(m.LAB, lab)) + .FirstOrDefault(); + } + + private CMYKVMeasurement FindUpperBoundLAB(LAB lab) + { + return measurements + .Where(m => EuclideanDistanceLAB(m.LAB, lab) >= 0) + .OrderBy(m => EuclideanDistanceLAB(m.LAB, lab)) + .FirstOrDefault(); + } + // Find the two closest CMYKV measurements below and above the input CMYKV + private CMYKVMeasurement FindLowerBoundCMYKV(CMYKV cmykv) + { + return measurements + .Where(m => EuclideanDistanceCMYKV(m.CMYKV, cmykv) <= 0) + .OrderBy(m => EuclideanDistanceCMYKV(m.CMYKV, cmykv)) + .FirstOrDefault(); + } + + private CMYKVMeasurement FindUpperBoundCMYKV(CMYKV cmykv) + { + return measurements + .Where(m => EuclideanDistanceCMYKV(m.CMYKV, cmykv) >= 0) + .OrderBy(m => EuclideanDistanceCMYKV(m.CMYKV, cmykv)) + .FirstOrDefault(); + } + + // Calculate the interpolation factor for LAB + private double CalculateInterpolationFactorLAB(LAB input, LAB lower, LAB upper) + { + double distInputToLower = EuclideanDistanceLAB(input, lower); + double distLowerToUpper = EuclideanDistanceLAB(lower, upper); + + return distInputToLower / distLowerToUpper; + } + + // Calculate the interpolation factor for CMYKV + private double CalculateInterpolationFactorCMYKV(CMYKV input, CMYKV lower, CMYKV upper) + { + double distInputToLower = EuclideanDistanceCMYKV(input, lower); + double distLowerToUpper = EuclideanDistanceCMYKV(lower, upper); + + return distInputToLower / distLowerToUpper; + } + + // Interpolate between two CMYKV values using factor t + private CMYKV InterpolateCMYKV(CMYKV lower, CMYKV upper, double t) + { return new CMYKV { - C = closest[0].CMYKVValue.C * weight1 + closest[1].CMYKVValue.C * weight2, - M = closest[0].CMYKVValue.M * weight1 + closest[1].CMYKVValue.M * weight2, - Y = closest[0].CMYKVValue.Y * weight1 + closest[1].CMYKVValue.Y * weight2, - K = closest[0].CMYKVValue.K * weight1 + closest[1].CMYKVValue.K * weight2, - V = closest[0].CMYKVValue.V * weight1 + closest[1].CMYKVValue.V * weight2 + C = lower.C + t * (upper.C - lower.C), + M = lower.M + t * (upper.M - lower.M), + Y = lower.Y + t * (upper.Y - lower.Y), + K = lower.K + t * (upper.K - lower.K), + V = lower.V + t * (upper.V - lower.V) }; } - private double CalculateLABDistance(LAB lab1, LAB lab2) + // Interpolate between two LAB values using factor t + private LAB InterpolateLAB(LAB lower, LAB upper, double t) { - return Math.Sqrt(Math.Pow(lab1.L - lab2.L, 2) + - Math.Pow(lab1.A - lab2.A, 2) + - Math.Pow(lab1.B - lab2.B, 2)); + return new LAB + { + L = lower.L + t * (upper.L - lower.L), + A = lower.A + t * (upper.A - lower.A), + B = lower.B + t * (upper.B - lower.B) + }; + } + + // Calculate Euclidean distance for LAB + private double EuclideanDistanceLAB(LAB lab1, LAB lab2) + { + return Math.Sqrt(Math.Pow(lab1.L - lab2.L, 2) + Math.Pow(lab1.A - lab2.A, 2) + Math.Pow(lab1.B - lab2.B, 2)); + } + + // Calculate Euclidean distance for CMYKV + private double EuclideanDistanceCMYKV(CMYKV cmykv1, CMYKV cmykv2) + { + return Math.Sqrt(Math.Pow(cmykv1.C - cmykv2.C, 2) + Math.Pow(cmykv1.M - cmykv2.M, 2) + + Math.Pow(cmykv1.Y - cmykv2.Y, 2) + Math.Pow(cmykv1.K - cmykv2.K, 2) + + Math.Pow(cmykv1.V - cmykv2.V, 2)); } } + } diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearRegressionPrediction.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearRegressionPrediction.cs index b0ecb3362..bf69f273a 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearRegressionPrediction.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/LinearRegressionPrediction.cs @@ -1,121 +1,104 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; namespace Tango.ColorConversion { - public class LinearRegressionPrediction + using MathNet.Numerics.LinearAlgebra; + + public class LinearRegressionPrediction : IColorPrediction { - public LAB Predict(CMYKV cmykv, List measurements) + private List measurements; + private double[,] coefficients; + + public LinearRegressionPrediction(List measurements) { - // Simple linear regression to fit LAB as a function of CMYKV + this.measurements = measurements; + coefficients = ComputeCoefficients(); + } - var n = measurements.Count; - if (n == 0) - throw new InvalidOperationException("No measurements for regression"); + public CMYKV ConvertRGBToCMYKV(RGB rgb) + { + var lab = rgb.ToLAB(); + return PerformLinearRegression(new double[] { lab.L, lab.A, lab.B }); + } - double sumC = 0, sumM = 0, sumY = 0, sumK = 0, sumV = 0; - double sumL = 0, sumA = 0, sumB = 0; + public CMYKV PredictLABToCMYKV(LAB lab) + { + return PerformLinearRegression(new double[] { lab.L, lab.A, lab.B }); + } - // Sum up the CMYKV and LAB components - foreach (var m in measurements) - { - sumC += m.CMYKVValue.C; - sumM += m.CMYKVValue.M; - sumY += m.CMYKVValue.Y; - sumK += m.CMYKVValue.K; - sumV += m.CMYKVValue.V; - - sumL += m.LABValue.L; - sumA += m.LABValue.A; - sumB += m.LABValue.B; - } - - // Compute the averages - var avgC = sumC / n; - var avgM = sumM / n; - var avgY = sumY / n; - var avgK = sumK / n; - var avgV = sumV / n; - - var avgL = sumL / n; - var avgA = sumA / n; - var avgB = sumB / n; - - // Predict LAB by applying the linear model (this is a simple averaging model) - return new LAB - { - L = avgL, - A = avgA, - B = avgB - }; + public RGB PredictCMYKVToRGB(CMYKV cmykv) + { + // First predict LAB, then convert to RGB + LAB lab = PerformInverseRegressionLAB(cmykv); + return lab.ToRGB(); } - public CMYKV PredictFromLAB(LAB lab, List measurements) + public LAB PredictCMYKVToLAB(CMYKV cmykv) { - // Perform linear regression using the LAB values as the independent variables - // (L, A, B) -> (C, M, Y, K, V) + return PerformInverseRegressionLAB(cmykv); + } - double sumL = 0, sumA = 0, sumB = 0; - double sumC = 0, sumM = 0, sumY = 0, sumK = 0, sumV = 0; - double sumLC = 0, sumLM = 0, sumLY = 0, sumLK = 0, sumLV = 0; - double sumAC = 0, sumAM = 0, sumAY = 0, sumAK = 0, sumAV = 0; - double sumBC = 0, sumBM = 0, sumBY = 0, sumBK = 0, sumBV = 0; + private CMYKV PerformLinearRegression(double[] input) + { + double C = coefficients[0, 0] + coefficients[0, 1] * input[0] + coefficients[0, 2] * input[1] + coefficients[0, 3] * input[2]; + double M = coefficients[1, 0] + coefficients[1, 1] * input[0] + coefficients[1, 2] * input[1] + coefficients[1, 3] * input[2]; + double Y = coefficients[2, 0] + coefficients[2, 1] * input[0] + coefficients[2, 2] * input[1] + coefficients[2, 3] * input[2]; + double K = coefficients[3, 0]; + double V = coefficients[4, 0]; + return new CMYKV { C = C, M = M, Y = Y, K = K, V = V }; + } + + // Inverse regression for LAB prediction from CMYKV + private LAB PerformInverseRegressionLAB(CMYKV cmykv) + { + // Use CMYKV values to predict LAB using the regression coefficients + double L = coefficients[0, 0] + coefficients[0, 1] * cmykv.C + coefficients[0, 2] * cmykv.M + coefficients[0, 3] * cmykv.Y; + double A = coefficients[1, 0] + coefficients[1, 1] * cmykv.C + coefficients[1, 2] * cmykv.M + coefficients[1, 3] * cmykv.Y; + double B = coefficients[2, 0] + coefficients[2, 1] * cmykv.C + coefficients[2, 2] * cmykv.M + coefficients[2, 3] * cmykv.Y; + + return new LAB { L = L, A = A, B = B }; + } + + // Now implementing the least-squares regression method based on LAB as input + private double[,] ComputeCoefficients() + { int n = measurements.Count; - if (n < 1) - throw new InvalidOperationException("No measurements for regression"); - foreach (var m in measurements) + // Create matrix X (n x 4) for input values (LAB values plus intercept term) + Matrix X = Matrix.Build.Dense(n, 4, (i, j) => { - sumL += m.LABValue.L; - sumA += m.LABValue.A; - sumB += m.LABValue.B; - - sumC += m.CMYKVValue.C; - sumM += m.CMYKVValue.M; - sumY += m.CMYKVValue.Y; - sumK += m.CMYKVValue.K; - sumV += m.CMYKVValue.V; - - sumLC += m.LABValue.L * m.CMYKVValue.C; - sumLM += m.LABValue.L * m.CMYKVValue.M; - sumLY += m.LABValue.L * m.CMYKVValue.Y; - sumLK += m.LABValue.L * m.CMYKVValue.K; - sumLV += m.LABValue.L * m.CMYKVValue.V; - - sumAC += m.LABValue.A * m.CMYKVValue.C; - sumAM += m.LABValue.A * m.CMYKVValue.M; - sumAY += m.LABValue.A * m.CMYKVValue.Y; - sumAK += m.LABValue.A * m.CMYKVValue.K; - sumAV += m.LABValue.A * m.CMYKVValue.V; - - sumBC += m.LABValue.B * m.CMYKVValue.C; - sumBM += m.LABValue.B * m.CMYKVValue.M; - sumBY += m.LABValue.B * m.CMYKVValue.Y; - sumBK += m.LABValue.B * m.CMYKVValue.K; - sumBV += m.LABValue.B * m.CMYKVValue.V; - } - - double avgL = sumL / n; - double avgA = sumA / n; - double avgB = sumB / n; - - double avgC = sumC / n; - double avgM = sumM / n; - double avgY = sumY / n; - double avgK = sumK / n; - double avgV = sumV / n; - - // Linear regression to predict C, M, Y, K, V from L, A, B - return new CMYKV + if (j == 0) return measurements[i].LAB.L; // LAB input as the available property + if (j == 1) return measurements[i].LAB.A; + if (j == 2) return measurements[i].LAB.B; + return 1.0; // Intercept term + }); + + // Create matrix Y (n x 5) for CMYKV values + Matrix Y = Matrix.Build.Dense(n, 5, (i, j) => { - C = (sumLC / sumL) + avgC, - M = (sumLM / sumL) + avgM, - Y = (sumLY / sumL) + avgY, - K = (sumLK / sumL) + avgK, - V = (sumLV / sumL) + avgV - }; + if (j == 0) return measurements[i].CMYKV.C; + if (j == 1) return measurements[i].CMYKV.M; + if (j == 2) return measurements[i].CMYKV.Y; + if (j == 3) return measurements[i].CMYKV.K; + return measurements[i].CMYKV.V; + }); + + // Compute the least-squares solution for the coefficients: β = (X^T X)^{-1} X^T Y + Matrix Xt = X.Transpose(); + Matrix XtX = Xt * X; + Matrix XtX_inv = XtX.Inverse(); + Matrix XtY = Xt * Y; + Matrix B = XtX_inv * XtY; + + // Convert the result to a double[,] array for easy access in the model + return B.ToArray(); } } + + + + } diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/PredictionMethod.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/PredictionMethod.cs deleted file mode 100644 index 200368571..000000000 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/PredictionMethod.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Tango.ColorConversion -{ - public enum PredictionMethod - { - LinearInterpolation, - LinearRegression, - KNearestNeighbors, - SplineInterpolation - } -} diff --git a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/SplineInterpolationPrediction.cs b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/SplineInterpolationPrediction.cs index 9249b2aa8..3b66d5d6c 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/CMYKV/SplineInterpolationPrediction.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/CMYKV/SplineInterpolationPrediction.cs @@ -10,10 +10,10 @@ namespace Tango.ColorConversion public LAB Predict(CMYKV cmykv, List measurements) { // Spline interpolation logic: Perform cubic spline interpolation - var cValues = measurements.Select(m => m.CMYKVValue.C).ToArray(); - var lValues = measurements.Select(m => m.LABValue.L).ToArray(); - var aValues = measurements.Select(m => m.LABValue.A).ToArray(); - var bValues = measurements.Select(m => m.LABValue.B).ToArray(); + var cValues = measurements.Select(m => m.CMYKV.C).ToArray(); + var lValues = measurements.Select(m => m.LAB.L).ToArray(); + var aValues = measurements.Select(m => m.LAB.A).ToArray(); + var bValues = measurements.Select(m => m.LAB.B).ToArray(); var lSpline = CubicSpline.InterpolateNatural(cValues, lValues); var aSpline = CubicSpline.InterpolateNatural(cValues, aValues); @@ -30,12 +30,12 @@ namespace Tango.ColorConversion public CMYKV PredictFromLAB(LAB lab, List measurements) { // Extract L values and corresponding CMYKV values for spline interpolation - var lValues = measurements.Select(m => m.LABValue.L).ToArray(); - var cValues = measurements.Select(m => m.CMYKVValue.C).ToArray(); - var mValues = measurements.Select(m => m.CMYKVValue.M).ToArray(); - var yValues = measurements.Select(m => m.CMYKVValue.Y).ToArray(); - var kValues = measurements.Select(m => m.CMYKVValue.K).ToArray(); - var vValues = measurements.Select(m => m.CMYKVValue.V).ToArray(); + var lValues = measurements.Select(m => m.LAB.L).ToArray(); + var cValues = measurements.Select(m => m.CMYKV.C).ToArray(); + var mValues = measurements.Select(m => m.CMYKV.M).ToArray(); + var yValues = measurements.Select(m => m.CMYKV.Y).ToArray(); + var kValues = measurements.Select(m => m.CMYKV.K).ToArray(); + var vValues = measurements.Select(m => m.CMYKV.V).ToArray(); // Create cubic splines for each component var cSpline = CubicSpline.InterpolateNatural(lValues, cValues); diff --git a/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs b/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs index dc9f1bd07..bff01dd83 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs @@ -35,6 +35,13 @@ namespace Tango.ColorConversion #region Color Conversion + private static List _measurements = new List(); + + public static void SetMeasurements(List measurements) + { + _measurements = measurements; + } + public ConversionOutput Convert(ConversionInput conversionInput, int version) { if (version < 1) version = 1; @@ -55,27 +62,81 @@ namespace Tango.ColorConversion NativePMR nativePMR = new NativePMR(convert); ConversionOutput output = nativePMR.Invoke(conversionInput); - if (conversionInput.ColorSpace == PMR.ColorLab.ColorSpace.Volume) + if (conversionInput.GetPredictionType() != CMYKVPredictionTypes.None) { - var violetInput = conversionInput.InputCoordinates.InputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Violet); + CMYKVColorConverter cmykvConverter = new CMYKVColorConverter((int)conversionInput.CMYKVK); - //conversionInput.GenerateHive + //Custom Measurements + if (conversionInput.ColorMeasurements.Count > 0) + { + foreach (var m in conversionInput.ColorMeasurements) + { + cmykvConverter.AddMeasurement(new CMYKV() { C = m.C, M = m.M, Y = m.Y, K = m.K, V = m.V }, new LAB(m.L, m.A, m.B)); + } + } + else //Global Measurements + { + foreach (var m in _measurements) + { + cmykvConverter.AddMeasurement(new CMYKV() { C = m.C, M = m.M, Y = m.Y, K = m.K, V = m.V }, new LAB(m.L, m.A, m.B)); + } + } - //Blend violet to best match color. - if (violetInput != null && violetInput.Volume > 0) + + if (conversionInput.ColorSpace == PMR.ColorLab.ColorSpace.Volume) { - var color = BlendWithViolet(output.SingleCoordinates.Red, output.SingleCoordinates.Green, output.SingleCoordinates.Blue, (float)(violetInput.Volume / 100d)); - output.SingleCoordinates.Red = color.R; - output.SingleCoordinates.Green = color.G; - output.SingleCoordinates.Blue = color.B; + var violetInput = conversionInput.InputCoordinates.InputLiquids.FirstOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Violet); + + if (violetInput != null && violetInput.Volume > 0) + { + if (conversionInput.GetPredictionType() == CMYKVPredictionTypes.SimpleRGBPreview) + { + //Blend violet to best match color. + + if (conversionInput.SimpleRGBPreviewFactor == 0) conversionInput.SimpleRGBPreviewFactor = 1; + + var color = BlendWithViolet(output.SingleCoordinates.Red, output.SingleCoordinates.Green, output.SingleCoordinates.Blue, (float)((violetInput.Volume * Math.Max(conversionInput.SimpleRGBPreviewFactor, 0.01)) / 100d)); + output.SingleCoordinates.Red = (int)color.R; + output.SingleCoordinates.Green = (int)color.G; + output.SingleCoordinates.Blue = (int)color.B; + } + else if (cmykvConverter.Measurements.Count > 0 && (conversionInput.GetPredictionType() == CMYKVPredictionTypes.Predict_RGB || conversionInput.GetPredictionType() == CMYKVPredictionTypes.PredictAll)) + { + RGB rgb = cmykvConverter.ConvertCMYKVToRGB(CreateCMYKVFromConversionInput(conversionInput), conversionInput.GetPredictionMethod()); + output.SingleCoordinates.Red = (int)rgb.R; + output.SingleCoordinates.Green = (int)rgb.G; + output.SingleCoordinates.Blue = (int)rgb.B; + } + } + } + else if (conversionInput.ColorSpace == PMR.ColorLab.ColorSpace.Rgb && cmykvConverter.Measurements.Count > 0) + { + if (conversionInput.GetPredictionType() == CMYKVPredictionTypes.Predict_CMYKV || conversionInput.GetPredictionType() == CMYKVPredictionTypes.PredictAll) + { + var rgb = new RGB(conversionInput.InputCoordinates.Red, conversionInput.InputCoordinates.Green, conversionInput.InputCoordinates.Blue); + if (cmykvConverter.ShouldUseViolet(rgb, conversionInput.CMYKVHueThreshhold)) + { + var cmykv = cmykvConverter.ConvertRGBToCMYKV(rgb, conversionInput.GetPredictionMethod()); + SetCMYKVToConversionOutput(cmykv, output); + } + else + { + ResetVioletVolume(output); + } + } + else + { + ResetVioletVolume(output); + } + } + else + { + ResetVioletVolume(output); } } - else + else if (conversionInput.ColorSpace != PMR.ColorLab.ColorSpace.Volume) { - var violetOutput = new OutputLiquid() { LiquidType = PMR.ColorLab.LiquidType.Violet, Volume = 0 }; - output.SingleCoordinates.OutputLiquids.Add(violetOutput); - - output.HiveCoordinates.ToList().ForEach(x => x.OutputLiquids.Add(violetOutput)); + ResetVioletVolume(output); } bool result = NativeMethods.FreeLibrary(pDll); @@ -185,6 +246,13 @@ namespace Tango.ColorConversion conversionInput.VMax = rml.VMax; + //CMYKV + conversionInput.SetPredictionType(rml.PredictionType); + conversionInput.SetPredictionMethod(rml.PredictionMethod); + conversionInput.CMYKVHueThreshhold = rml.CmykvHueThreshold; + conversionInput.CMYKVK = rml.KNearestK; + conversionInput.SimpleRGBPreviewFactor = rml.SimpleRgbPreviewFactor; + conversionInput.ForwardData = ByteString.CopyFrom(rml.Cct.Data); if (rml.Gbd != null) @@ -1016,7 +1084,7 @@ namespace Tango.ColorConversion private static Color Violet = Color.FromRgb(127, 0, 255); - public static Color BlendWithViolet(int r, int g, int b, float violetFactor) + public static RGB BlendWithViolet(int r, int g, int b, float violetFactor) { // Ensure violetFactor is between 0.0 and 1.0 violetFactor = violetFactor.Clamp(0.0f, 1.0f); @@ -1036,7 +1104,115 @@ namespace Tango.ColorConversion blendedG = blendedG.Clamp(0, 255); blendedB = blendedB.Clamp(0, 255); - return Color.FromRgb((byte)blendedR, (byte)blendedG, (byte)blendedB); + return new RGB(blendedR, blendedG, blendedB); + } + + private CMYKV CreateCMYKVFromConversionInput(ConversionInput input) + { + CMYKV cmykv = new CMYKV(); + + foreach (var liquid in input.InputCoordinates.InputLiquids) + { + switch (liquid.LiquidType) + { + case PMR.ColorLab.LiquidType.Cyan: + cmykv.C = liquid.Volume; + break; + case PMR.ColorLab.LiquidType.Magenta: + cmykv.M = liquid.Volume; + break; + case PMR.ColorLab.LiquidType.Yellow: + cmykv.Y = liquid.Volume; + break; + case PMR.ColorLab.LiquidType.Black: + cmykv.K = liquid.Volume; + break; + case PMR.ColorLab.LiquidType.Violet: + cmykv.V = liquid.Volume; + break; + default: + break; + } + } + + return cmykv; + } + + private RGB CreateRGBFromConversionOutput(ConversionOutput output) + { + return new RGB(output.SingleCoordinates.Red, output.SingleCoordinates.Green, output.SingleCoordinates.Blue); + } + + private void ResetVioletVolume(ConversionOutput output) + { + var violetOutput = new OutputLiquid() { LiquidType = PMR.ColorLab.LiquidType.Violet, Volume = 0 }; + output.SingleCoordinates.OutputLiquids.Add(violetOutput); + + output.HiveCoordinates.ToList().ForEach(x => x.OutputLiquids.Add(violetOutput)); + } + + private void SetCMYKVToConversionOutput(CMYKV cmykv, ConversionOutput output) + { + var violetOutput = new OutputLiquid() { LiquidType = PMR.ColorLab.LiquidType.Violet, Volume = 0 }; + output.SingleCoordinates.OutputLiquids.Add(violetOutput); + + foreach (var liquid in output.SingleCoordinates.OutputLiquids) + { + switch (liquid.LiquidType) + { + case PMR.ColorLab.LiquidType.Cyan: + liquid.Volume = cmykv.C; + break; + case PMR.ColorLab.LiquidType.Magenta: + liquid.Volume = cmykv.M; + break; + case PMR.ColorLab.LiquidType.Yellow: + liquid.Volume = cmykv.Y; + break; + case PMR.ColorLab.LiquidType.Black: + liquid.Volume = cmykv.K; + break; + case PMR.ColorLab.LiquidType.Violet: + liquid.Volume = cmykv.V; + break; + default: + break; + } + } + + if (output.HiveCoordinates.Count > 0) + { + var vOutput = new OutputLiquid() { LiquidType = PMR.ColorLab.LiquidType.Violet, Volume = 0 }; + + foreach (var cell in output.HiveCoordinates) + { + cell.OutputLiquids.Add(vOutput); + + foreach (var liquid in cell.OutputLiquids) + { + switch (liquid.LiquidType) + { + case PMR.ColorLab.LiquidType.Cyan: + liquid.Volume = cmykv.C; + break; + case PMR.ColorLab.LiquidType.Magenta: + liquid.Volume = cmykv.M; + break; + case PMR.ColorLab.LiquidType.Yellow: + liquid.Volume = cmykv.Y; + break; + case PMR.ColorLab.LiquidType.Black: + liquid.Volume = cmykv.K; + break; + case PMR.ColorLab.LiquidType.Violet: + liquid.Volume = cmykv.V; + break; + default: + break; + } + } + } + } } #endregion diff --git a/Software/Visual_Studio/Tango.ColorConversion/ExtensionMethods/ConversionInputExtensions.cs b/Software/Visual_Studio/Tango.ColorConversion/ExtensionMethods/ConversionInputExtensions.cs new file mode 100644 index 000000000..252a77fe2 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorConversion/ExtensionMethods/ConversionInputExtensions.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; +using Tango.PMR.ColorLab; + +public static class ConversionInputExtensions +{ + public static CMYKVPredictionTypes GetPredictionType(this ConversionInput conversionInput) + { + return (CMYKVPredictionTypes)conversionInput.CMYKVPredictionType; + } + + public static CMYKVPredictionMethods GetPredictionMethod(this ConversionInput conversionInput) + { + return (CMYKVPredictionMethods)conversionInput.CMYKVPredictionMethod; + } + + public static void SetPredictionType(this ConversionInput conversionInput, CMYKVPredictionTypes predictionType) + { + conversionInput.CMYKVPredictionType = predictionType.ToInt32(); + } + + public static void SetPredictionMethod(this ConversionInput conversionInput, CMYKVPredictionMethods predictionMethod) + { + conversionInput.CMYKVPredictionMethod = predictionMethod.ToInt32(); + } +} diff --git a/Software/Visual_Studio/Tango.ColorConversion/Tango.ColorConversion.csproj b/Software/Visual_Studio/Tango.ColorConversion/Tango.ColorConversion.csproj index 5a583058f..bb1659381 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/Tango.ColorConversion.csproj +++ b/Software/Visual_Studio/Tango.ColorConversion/Tango.ColorConversion.csproj @@ -56,17 +56,19 @@ + + - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_MEASUREMENTS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_MEASUREMENTS.cs new file mode 100644 index 000000000..2531147db --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_MEASUREMENTS.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class COLOR_MEASUREMENTS + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public double C { get; set; } + public double M { get; set; } + public double Y { get; set; } + public double K { get; set; } + public double V { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index b1f71c687..90225e5f2 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -82,6 +82,11 @@ namespace Tango.DAL.Remote.DB public string BTSR_APPLICATION_TYPE_GUID { get; set; } public string BTSR_YARN_TYPE_GUID { get; set; } public double BTSR_TENSION_ERROR { get; set; } + public int CMYKV_PREDICTION_TYPE { get; set; } + public int CMYKV_PREDICTION_METHOD { get; set; } + public double CMYKV_HUE_THRESHOLD { get; set; } + public int K_NEAREST_K { get; set; } + public double SIMPLE_RGB_PREVIEW_FACTOR { get; set; } public virtual BTSR_APPLICATION_TYPES BTSR_APPLICATION_TYPES { get; set; } public virtual BTSR_YARN_TYPES BTSR_YARN_TYPES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index b611a0972..80f0a256f 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -67,6 +67,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet COLOR_CATALOGS_GROUPS { get; set; } public virtual DbSet COLOR_CATALOGS_ITEMS { get; set; } public virtual DbSet COLOR_CATALOGS_ITEMS_RECIPES { get; set; } + public virtual DbSet COLOR_MEASUREMENTS { get; set; } public virtual DbSet COLOR_PROCESS_INK_UPTAKE { get; set; } public virtual DbSet COLOR_SPACES { get; set; } public virtual DbSet CONFIGURATIONS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 61d68c102..56b40d608 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -251,6 +251,22 @@ + + + + + + + + + + + + + + + + @@ -1384,6 +1400,11 @@ + + + + + @@ -3624,6 +3645,7 @@ + @@ -4398,6 +4420,7 @@ + @@ -5892,6 +5915,22 @@ + + + + + + + + + + + + + + + + @@ -6957,6 +6996,11 @@ + + + + + @@ -9417,6 +9461,23 @@ + + + + + + + + + + + + + + + + + @@ -10366,6 +10427,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 66a74fb5e..c0d3bd959 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,102 +5,103 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 2357e9720..bbba7651f 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -114,6 +114,9 @@ RemoteADO.tt + + RemoteADO.tt + RemoteADO.tt @@ -497,7 +500,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.PMR/ColorLab/ColorMeasurement.cs b/Software/Visual_Studio/Tango.PMR/ColorLab/ColorMeasurement.cs new file mode 100644 index 000000000..f11849c1f --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/ColorLab/ColorMeasurement.cs @@ -0,0 +1,357 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ColorMeasurement.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.ColorLab { + + /// Holder for reflection information generated from ColorMeasurement.proto + public static partial class ColorMeasurementReflection { + + #region Descriptor + /// File descriptor for ColorMeasurement.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ColorMeasurementReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChZDb2xvck1lYXN1cmVtZW50LnByb3RvEhJUYW5nby5QTVIuQ29sb3JMYWIi", + "agoQQ29sb3JNZWFzdXJlbWVudBIJCgFDGAEgASgBEgkKAU0YAiABKAESCQoB", + "WRgDIAEoARIJCgFLGAQgASgBEgkKAVYYBSABKAESCQoBTBgKIAEoARIJCgFB", + "GAsgASgBEgkKAUIYDCABKAFCHgocY29tLnR3aW5lLnRhbmdvLnBtci5jb2xv", + "cmxhYmIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ColorMeasurement), global::Tango.PMR.ColorLab.ColorMeasurement.Parser, new[]{ "C", "M", "Y", "K", "V", "L", "A", "B" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ColorMeasurement : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ColorMeasurement()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.ColorLab.ColorMeasurementReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ColorMeasurement() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ColorMeasurement(ColorMeasurement other) : this() { + c_ = other.c_; + m_ = other.m_; + y_ = other.y_; + k_ = other.k_; + v_ = other.v_; + l_ = other.l_; + a_ = other.a_; + b_ = other.b_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ColorMeasurement Clone() { + return new ColorMeasurement(this); + } + + /// Field number for the "C" field. + public const int CFieldNumber = 1; + private double c_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double C { + get { return c_; } + set { + c_ = value; + } + } + + /// Field number for the "M" field. + public const int MFieldNumber = 2; + private double m_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double M { + get { return m_; } + set { + m_ = value; + } + } + + /// Field number for the "Y" field. + public const int YFieldNumber = 3; + private double y_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double Y { + get { return y_; } + set { + y_ = value; + } + } + + /// Field number for the "K" field. + public const int KFieldNumber = 4; + private double k_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double K { + get { return k_; } + set { + k_ = value; + } + } + + /// Field number for the "V" field. + public const int VFieldNumber = 5; + private double v_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double V { + get { return v_; } + set { + v_ = value; + } + } + + /// Field number for the "L" field. + public const int LFieldNumber = 10; + private double l_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double L { + get { return l_; } + set { + l_ = value; + } + } + + /// Field number for the "A" field. + public const int AFieldNumber = 11; + private double a_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double A { + get { return a_; } + set { + a_ = value; + } + } + + /// Field number for the "B" field. + public const int BFieldNumber = 12; + private double b_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double B { + get { return b_; } + set { + b_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ColorMeasurement); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ColorMeasurement other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (C != other.C) return false; + if (M != other.M) return false; + if (Y != other.Y) return false; + if (K != other.K) return false; + if (V != other.V) return false; + if (L != other.L) return false; + if (A != other.A) return false; + if (B != other.B) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (C != 0D) hash ^= C.GetHashCode(); + if (M != 0D) hash ^= M.GetHashCode(); + if (Y != 0D) hash ^= Y.GetHashCode(); + if (K != 0D) hash ^= K.GetHashCode(); + if (V != 0D) hash ^= V.GetHashCode(); + if (L != 0D) hash ^= L.GetHashCode(); + if (A != 0D) hash ^= A.GetHashCode(); + if (B != 0D) hash ^= B.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (C != 0D) { + output.WriteRawTag(9); + output.WriteDouble(C); + } + if (M != 0D) { + output.WriteRawTag(17); + output.WriteDouble(M); + } + if (Y != 0D) { + output.WriteRawTag(25); + output.WriteDouble(Y); + } + if (K != 0D) { + output.WriteRawTag(33); + output.WriteDouble(K); + } + if (V != 0D) { + output.WriteRawTag(41); + output.WriteDouble(V); + } + if (L != 0D) { + output.WriteRawTag(81); + output.WriteDouble(L); + } + if (A != 0D) { + output.WriteRawTag(89); + output.WriteDouble(A); + } + if (B != 0D) { + output.WriteRawTag(97); + output.WriteDouble(B); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (C != 0D) { + size += 1 + 8; + } + if (M != 0D) { + size += 1 + 8; + } + if (Y != 0D) { + size += 1 + 8; + } + if (K != 0D) { + size += 1 + 8; + } + if (V != 0D) { + size += 1 + 8; + } + if (L != 0D) { + size += 1 + 8; + } + if (A != 0D) { + size += 1 + 8; + } + if (B != 0D) { + size += 1 + 8; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ColorMeasurement other) { + if (other == null) { + return; + } + if (other.C != 0D) { + C = other.C; + } + if (other.M != 0D) { + M = other.M; + } + if (other.Y != 0D) { + Y = other.Y; + } + if (other.K != 0D) { + K = other.K; + } + if (other.V != 0D) { + V = other.V; + } + if (other.L != 0D) { + L = other.L; + } + if (other.A != 0D) { + A = other.A; + } + if (other.B != 0D) { + B = other.B; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 9: { + C = input.ReadDouble(); + break; + } + case 17: { + M = input.ReadDouble(); + break; + } + case 25: { + Y = input.ReadDouble(); + break; + } + case 33: { + K = input.ReadDouble(); + break; + } + case 41: { + V = input.ReadDouble(); + break; + } + case 81: { + L = input.ReadDouble(); + break; + } + case 89: { + A = input.ReadDouble(); + break; + } + case 97: { + B = input.ReadDouble(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs b/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs index 1b6c796c5..1d85f4c7c 100644 --- a/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs +++ b/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs @@ -24,24 +24,29 @@ namespace Tango.PMR.ColorLab { string.Concat( "ChVDb252ZXJzaW9uSW5wdXQucHJvdG8SElRhbmdvLlBNUi5Db2xvckxhYhoW", "SW5wdXRDb29yZGluYXRlcy5wcm90bxoQQ29sb3JTcGFjZS5wcm90bxoSUHJv", - "Y2Vzc1JhbmdlLnByb3RvGhRDb252ZXJzaW9uVHlwZS5wcm90byKOBAoPQ29u", - "dmVyc2lvbklucHV0Eg8KB1RocmVhZEwYASABKAESDwoHVGhyZWFkQRgCIAEo", - "ARIPCgdUaHJlYWRCGAMgASgBEjIKCkNvbG9yU3BhY2UYBCABKA4yHi5UYW5n", - "by5QTVIuQ29sb3JMYWIuQ29sb3JTcGFjZRI+ChBJbnB1dENvb3JkaW5hdGVz", - "GAUgASgLMiQuVGFuZ28uUE1SLkNvbG9yTGFiLklucHV0Q29vcmRpbmF0ZXMS", - "EwoLRm9yd2FyZERhdGEYBiABKAwSEwoLSW52ZXJzZURhdGEYByABKAwSFQoN", - "U2VnbWVudExlbmd0aBgIIAEoARITCgtEZWx0YUNocm9tYRgJIAEoARIOCgZE", - "ZWx0YUwYCiABKAESNwoNUHJvY2Vzc1JhbmdlcxgLIAMoCzIgLlRhbmdvLlBN", - "Ui5Db2xvckxhYi5Qcm9jZXNzUmFuZ2USFAoMR2VuZXJhdGVIaXZlGAwgASgI", - "EhQKDFVzZUxpZ2h0SW5rcxgNIAEoCBIMCgRWTWF4GA4gASgBEg8KB0diZERh", - "dGEYDyABKAwSDwoHTHViRGF0YRgQIAEoDBIdChVVc2VMdWJyaWNhbnRUcmFu", - "c2Zvcm0YESABKAgSOgoOQ29udmVyc2lvblR5cGUYEiABKA4yIi5UYW5nby5Q", - "TVIuQ29sb3JMYWIuQ29udmVyc2lvblR5cGVCHgocY29tLnR3aW5lLnRhbmdv", - "LnBtci5jb2xvcmxhYmIGcHJvdG8z")); + "Y2Vzc1JhbmdlLnByb3RvGhRDb252ZXJzaW9uVHlwZS5wcm90bxoWQ29sb3JN", + "ZWFzdXJlbWVudC5wcm90byLYBQoPQ29udmVyc2lvbklucHV0Eg8KB1RocmVh", + "ZEwYASABKAESDwoHVGhyZWFkQRgCIAEoARIPCgdUaHJlYWRCGAMgASgBEjIK", + "CkNvbG9yU3BhY2UYBCABKA4yHi5UYW5nby5QTVIuQ29sb3JMYWIuQ29sb3JT", + "cGFjZRI+ChBJbnB1dENvb3JkaW5hdGVzGAUgASgLMiQuVGFuZ28uUE1SLkNv", + "bG9yTGFiLklucHV0Q29vcmRpbmF0ZXMSEwoLRm9yd2FyZERhdGEYBiABKAwS", + "EwoLSW52ZXJzZURhdGEYByABKAwSFQoNU2VnbWVudExlbmd0aBgIIAEoARIT", + "CgtEZWx0YUNocm9tYRgJIAEoARIOCgZEZWx0YUwYCiABKAESNwoNUHJvY2Vz", + "c1JhbmdlcxgLIAMoCzIgLlRhbmdvLlBNUi5Db2xvckxhYi5Qcm9jZXNzUmFu", + "Z2USFAoMR2VuZXJhdGVIaXZlGAwgASgIEhQKDFVzZUxpZ2h0SW5rcxgNIAEo", + "CBIMCgRWTWF4GA4gASgBEg8KB0diZERhdGEYDyABKAwSDwoHTHViRGF0YRgQ", + "IAEoDBIdChVVc2VMdWJyaWNhbnRUcmFuc2Zvcm0YESABKAgSOgoOQ29udmVy", + "c2lvblR5cGUYEiABKA4yIi5UYW5nby5QTVIuQ29sb3JMYWIuQ29udmVyc2lv", + "blR5cGUSGwoTQ01ZS1ZQcmVkaWN0aW9uVHlwZRgTIAEoBRIdChVDTVlLVlBy", + "ZWRpY3Rpb25NZXRob2QYFCABKAUSGgoSQ01ZS1ZIdWVUaHJlc2hob2xkGBUg", + "ASgBEg8KB0NNWUtWX0sYFiABKAESHgoWU2ltcGxlUkdCUHJldmlld0ZhY3Rv", + "chgXIAEoARI/ChFDb2xvck1lYXN1cmVtZW50cxgYIAMoCzIkLlRhbmdvLlBN", + "Ui5Db2xvckxhYi5Db2xvck1lYXN1cmVtZW50Qh4KHGNvbS50d2luZS50YW5n", + "by5wbXIuY29sb3JsYWJiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Tango.PMR.ColorLab.InputCoordinatesReflection.Descriptor, global::Tango.PMR.ColorLab.ColorSpaceReflection.Descriptor, global::Tango.PMR.ColorLab.ProcessRangeReflection.Descriptor, global::Tango.PMR.ColorLab.ConversionTypeReflection.Descriptor, }, + new pbr::FileDescriptor[] { global::Tango.PMR.ColorLab.InputCoordinatesReflection.Descriptor, global::Tango.PMR.ColorLab.ColorSpaceReflection.Descriptor, global::Tango.PMR.ColorLab.ProcessRangeReflection.Descriptor, global::Tango.PMR.ColorLab.ConversionTypeReflection.Descriptor, global::Tango.PMR.ColorLab.ColorMeasurementReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionInput), global::Tango.PMR.ColorLab.ConversionInput.Parser, new[]{ "ThreadL", "ThreadA", "ThreadB", "ColorSpace", "InputCoordinates", "ForwardData", "InverseData", "SegmentLength", "DeltaChroma", "DeltaL", "ProcessRanges", "GenerateHive", "UseLightInks", "VMax", "GbdData", "LubData", "UseLubricantTransform", "ConversionType" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionInput), global::Tango.PMR.ColorLab.ConversionInput.Parser, new[]{ "ThreadL", "ThreadA", "ThreadB", "ColorSpace", "InputCoordinates", "ForwardData", "InverseData", "SegmentLength", "DeltaChroma", "DeltaL", "ProcessRanges", "GenerateHive", "UseLightInks", "VMax", "GbdData", "LubData", "UseLubricantTransform", "ConversionType", "CMYKVPredictionType", "CMYKVPredictionMethod", "CMYKVHueThreshhold", "CMYKVK", "SimpleRGBPreviewFactor", "ColorMeasurements" }, null, null, null) })); } #endregion @@ -90,6 +95,12 @@ namespace Tango.PMR.ColorLab { lubData_ = other.lubData_; useLubricantTransform_ = other.useLubricantTransform_; conversionType_ = other.conversionType_; + cMYKVPredictionType_ = other.cMYKVPredictionType_; + cMYKVPredictionMethod_ = other.cMYKVPredictionMethod_; + cMYKVHueThreshhold_ = other.cMYKVHueThreshhold_; + cMYKVK_ = other.cMYKVK_; + simpleRGBPreviewFactor_ = other.simpleRGBPreviewFactor_; + colorMeasurements_ = other.colorMeasurements_.Clone(); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -294,6 +305,71 @@ namespace Tango.PMR.ColorLab { } } + /// Field number for the "CMYKVPredictionType" field. + public const int CMYKVPredictionTypeFieldNumber = 19; + private int cMYKVPredictionType_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CMYKVPredictionType { + get { return cMYKVPredictionType_; } + set { + cMYKVPredictionType_ = value; + } + } + + /// Field number for the "CMYKVPredictionMethod" field. + public const int CMYKVPredictionMethodFieldNumber = 20; + private int cMYKVPredictionMethod_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CMYKVPredictionMethod { + get { return cMYKVPredictionMethod_; } + set { + cMYKVPredictionMethod_ = value; + } + } + + /// Field number for the "CMYKVHueThreshhold" field. + public const int CMYKVHueThreshholdFieldNumber = 21; + private double cMYKVHueThreshhold_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double CMYKVHueThreshhold { + get { return cMYKVHueThreshhold_; } + set { + cMYKVHueThreshhold_ = value; + } + } + + /// Field number for the "CMYKV_K" field. + public const int CMYKVKFieldNumber = 22; + private double cMYKVK_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double CMYKVK { + get { return cMYKVK_; } + set { + cMYKVK_ = value; + } + } + + /// Field number for the "SimpleRGBPreviewFactor" field. + public const int SimpleRGBPreviewFactorFieldNumber = 23; + private double simpleRGBPreviewFactor_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double SimpleRGBPreviewFactor { + get { return simpleRGBPreviewFactor_; } + set { + simpleRGBPreviewFactor_ = value; + } + } + + /// Field number for the "ColorMeasurements" field. + public const int ColorMeasurementsFieldNumber = 24; + private static readonly pb::FieldCodec _repeated_colorMeasurements_codec + = pb::FieldCodec.ForMessage(194, global::Tango.PMR.ColorLab.ColorMeasurement.Parser); + private readonly pbc::RepeatedField colorMeasurements_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField ColorMeasurements { + get { return colorMeasurements_; } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ConversionInput); @@ -325,6 +401,12 @@ namespace Tango.PMR.ColorLab { if (LubData != other.LubData) return false; if (UseLubricantTransform != other.UseLubricantTransform) return false; if (ConversionType != other.ConversionType) return false; + if (CMYKVPredictionType != other.CMYKVPredictionType) return false; + if (CMYKVPredictionMethod != other.CMYKVPredictionMethod) return false; + if (CMYKVHueThreshhold != other.CMYKVHueThreshhold) return false; + if (CMYKVK != other.CMYKVK) return false; + if (SimpleRGBPreviewFactor != other.SimpleRGBPreviewFactor) return false; + if(!colorMeasurements_.Equals(other.colorMeasurements_)) return false; return true; } @@ -349,6 +431,12 @@ namespace Tango.PMR.ColorLab { if (LubData.Length != 0) hash ^= LubData.GetHashCode(); if (UseLubricantTransform != false) hash ^= UseLubricantTransform.GetHashCode(); if (ConversionType != 0) hash ^= ConversionType.GetHashCode(); + if (CMYKVPredictionType != 0) hash ^= CMYKVPredictionType.GetHashCode(); + if (CMYKVPredictionMethod != 0) hash ^= CMYKVPredictionMethod.GetHashCode(); + if (CMYKVHueThreshhold != 0D) hash ^= CMYKVHueThreshhold.GetHashCode(); + if (CMYKVK != 0D) hash ^= CMYKVK.GetHashCode(); + if (SimpleRGBPreviewFactor != 0D) hash ^= SimpleRGBPreviewFactor.GetHashCode(); + hash ^= colorMeasurements_.GetHashCode(); return hash; } @@ -428,6 +516,27 @@ namespace Tango.PMR.ColorLab { output.WriteRawTag(144, 1); output.WriteEnum((int) ConversionType); } + if (CMYKVPredictionType != 0) { + output.WriteRawTag(152, 1); + output.WriteInt32(CMYKVPredictionType); + } + if (CMYKVPredictionMethod != 0) { + output.WriteRawTag(160, 1); + output.WriteInt32(CMYKVPredictionMethod); + } + if (CMYKVHueThreshhold != 0D) { + output.WriteRawTag(169, 1); + output.WriteDouble(CMYKVHueThreshhold); + } + if (CMYKVK != 0D) { + output.WriteRawTag(177, 1); + output.WriteDouble(CMYKVK); + } + if (SimpleRGBPreviewFactor != 0D) { + output.WriteRawTag(185, 1); + output.WriteDouble(SimpleRGBPreviewFactor); + } + colorMeasurements_.WriteTo(output, _repeated_colorMeasurements_codec); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -485,6 +594,22 @@ namespace Tango.PMR.ColorLab { if (ConversionType != 0) { size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) ConversionType); } + if (CMYKVPredictionType != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(CMYKVPredictionType); + } + if (CMYKVPredictionMethod != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(CMYKVPredictionMethod); + } + if (CMYKVHueThreshhold != 0D) { + size += 2 + 8; + } + if (CMYKVK != 0D) { + size += 2 + 8; + } + if (SimpleRGBPreviewFactor != 0D) { + size += 2 + 8; + } + size += colorMeasurements_.CalculateSize(_repeated_colorMeasurements_codec); return size; } @@ -548,6 +673,22 @@ namespace Tango.PMR.ColorLab { if (other.ConversionType != 0) { ConversionType = other.ConversionType; } + if (other.CMYKVPredictionType != 0) { + CMYKVPredictionType = other.CMYKVPredictionType; + } + if (other.CMYKVPredictionMethod != 0) { + CMYKVPredictionMethod = other.CMYKVPredictionMethod; + } + if (other.CMYKVHueThreshhold != 0D) { + CMYKVHueThreshhold = other.CMYKVHueThreshhold; + } + if (other.CMYKVK != 0D) { + CMYKVK = other.CMYKVK; + } + if (other.SimpleRGBPreviewFactor != 0D) { + SimpleRGBPreviewFactor = other.SimpleRGBPreviewFactor; + } + colorMeasurements_.Add(other.colorMeasurements_); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -633,6 +774,30 @@ namespace Tango.PMR.ColorLab { conversionType_ = (global::Tango.PMR.ColorLab.ConversionType) input.ReadEnum(); break; } + case 152: { + CMYKVPredictionType = input.ReadInt32(); + break; + } + case 160: { + CMYKVPredictionMethod = input.ReadInt32(); + break; + } + case 169: { + CMYKVHueThreshhold = input.ReadDouble(); + break; + } + case 177: { + CMYKVK = input.ReadDouble(); + break; + } + case 185: { + SimpleRGBPreviewFactor = input.ReadDouble(); + break; + } + case 194: { + colorMeasurements_.AddEntriesFrom(input, _repeated_colorMeasurements_codec); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index b5ea1877c..bd2c306f8 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -56,6 +56,7 @@ + @@ -527,7 +528,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerCMYKControl.cs b/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerCMYKControl.cs index ba94ed30f..77fb82898 100644 --- a/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerCMYKControl.cs +++ b/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerCMYKControl.cs @@ -41,6 +41,18 @@ namespace Tango.Touch.Controls } } + + + public bool EnableViolet + { + get { return (bool)GetValue(EnableVioletProperty); } + set { SetValue(EnableVioletProperty, value); } + } + public static readonly DependencyProperty EnableVioletProperty = + DependencyProperty.Register("EnableViolet", typeof(bool), typeof(TouchColorPickerCMYKControl), new PropertyMetadata(false)); + + + public double ThumbHeight { get { return (double)GetValue(ThumbHeightProperty); } diff --git a/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.cs b/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.cs index ae94cf9ac..e2e717183 100644 --- a/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.cs +++ b/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.cs @@ -41,6 +41,18 @@ namespace Tango.Touch.Controls } + + public bool AutoThumbColor + { + get { return (bool)GetValue(AutoThumbColorProperty); } + set { SetValue(AutoThumbColorProperty, value); } + } + public static readonly DependencyProperty AutoThumbColorProperty = + DependencyProperty.Register("AutoThumbColor", typeof(bool), typeof(TouchColorPickerControl), new PropertyMetadata(false)); + + + + public double MinValue { get { return (double)GetValue(MinValueProperty); } diff --git a/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.xaml b/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.xaml index 503b9188a..0bdbf4009 100644 --- a/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.xaml +++ b/Software/Visual_Studio/Tango.Touch/TouchColorPickerControls/TouchColorPickerControl.xaml @@ -26,6 +26,7 @@ /// The selected color property /// @@ -155,6 +164,11 @@ namespace Tango.Touch.Controls args.RoutedEvent = TouchColorPickerSlider.PickerSliderValueChangedEvent; RaiseEvent(args); } + + if (AutoThumbColor && SliderBackground is LinearGradientBrush background) + { + SelectedColor = GetRelativeColor(background.GradientStops, GetOffset(newValue, Minimum, Maximum)); + } } #endregion @@ -175,6 +189,7 @@ namespace Tango.Touch.Controls } #endregion + #region Methods public void SetValueAnotherControl(double newValue) @@ -187,6 +202,41 @@ namespace Tango.Touch.Controls } } + public static Color GetRelativeColor(GradientStopCollection gsc, double offset) + { + var point = gsc.SingleOrDefault(f => f.Offset == offset); + if (point != null) return point.Color; + + GradientStop before = gsc.Where(w => w.Offset == gsc.Min(m => m.Offset)).First(); + GradientStop after = gsc.Where(w => w.Offset == gsc.Max(m => m.Offset)).First(); + + foreach (var gs in gsc) + { + if (gs.Offset < offset && gs.Offset > before.Offset) + { + before = gs; + } + if (gs.Offset > offset && gs.Offset < after.Offset) + { + after = gs; + } + } + + var color = new Color(); + + color.ScA = (float)((offset - before.Offset) * (after.Color.ScA - before.Color.ScA) / (after.Offset - before.Offset) + before.Color.ScA); + color.ScR = (float)((offset - before.Offset) * (after.Color.ScR - before.Color.ScR) / (after.Offset - before.Offset) + before.Color.ScR); + color.ScG = (float)((offset - before.Offset) * (after.Color.ScG - before.Color.ScG) / (after.Offset - before.Offset) + before.Color.ScG); + color.ScB = (float)((offset - before.Offset) * (after.Color.ScB - before.Color.ScB) / (after.Offset - before.Offset) + before.Color.ScB); + + return color; + } + + public static double GetOffset(double value, double minValue, double maxValue) + { + return ((value - minValue) / (maxValue - minValue)); + } + #endregion //Methods } } diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 2acf08f84..9feb6fc7e 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -485,6 +485,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.ColorLib_v6", "ColorL EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FSE.Statistics", "FSE\Modules\Tango.FSE.Statistics\Tango.FSE.Statistics.csproj", "{7A30B35F-94DC-4A9C-B9D2-CB5CAA735788}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.ColorMeasurementsGenerator", "Utilities\Tango.ColorMeasurementsGenerator\Tango.ColorMeasurementsGenerator.csproj", "{04FCA0BA-A64B-4C6A-A011-A94CE335D616}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -21490,6 +21492,106 @@ Global {7A30B35F-94DC-4A9C-B9D2-CB5CAA735788}.TS|x64.Build.0 = TS|Any CPU {7A30B35F-94DC-4A9C-B9D2-CB5CAA735788}.TS|x86.ActiveCfg = TS|Any CPU {7A30B35F-94DC-4A9C-B9D2-CB5CAA735788}.TS|x86.Build.0 = TS|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.AppVeyor|x86.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|ARM.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|ARM.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|ARM64.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|x64.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|x64.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|x86.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Debug|x86.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|Any CPU.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|ARM.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|ARM.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|ARM64.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|ARM64.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|x64.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|x64.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|x86.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka_Debug|x86.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Eureka|x86.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.0|x86.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.5|x86.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release 4.6.1|x86.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.Release|x86.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|Any CPU.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|ARM.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|ARM.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|ARM64.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|ARM64.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|x64.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|x64.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|x86.ActiveCfg = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS_Debug|x86.Build.0 = Debug|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|Any CPU.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|Any CPU.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|ARM.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|ARM.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|ARM64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|ARM64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|x64.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|x64.Build.0 = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|x86.ActiveCfg = Release|Any CPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616}.TS|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -21663,14 +21765,15 @@ Global {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {D74E49AA-4C6B-4427-BEFF-D7CE2690D059} = {7181F9DE-0760-46B7-AD8F-BDBCAEDEF1B7} {7A30B35F-94DC-4A9C-B9D2-CB5CAA735788} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} + {04FCA0BA-A64B-4C6A-A011-A94CE335D616} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_UpdateFileVersion = False - BuildVersion_StartDate = 2000/1/1 - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs BuildVersion_UseGlobalSettings = False + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_StartDate = 2000/1/1 + BuildVersion_UpdateFileVersion = False + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} EndGlobalSection EndGlobal diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config new file mode 100644 index 000000000..4ef5218a0 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config @@ -0,0 +1,24 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs new file mode 100644 index 000000000..96b5023ec --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.ColorConversion; + +namespace Tango.ColorMeasurementsGenerator +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Generating Colors..."); + Console.WriteLine(); + + var colors = RGBGenerator.GenerateRGBValues(1000); + + List measurements = new List(); + + for (int i = 0; i < colors.Count; i++) + { + var color = colors[i]; + //color = DefaultColorConverter.BlendWithViolet((int)color.R, (int)color.G, (int)color.B, ((float)i) / 100f); + var rgb = new ColorMine.ColorSpaces.Rgb(color.R, color.G, color.B); + var cmyk = rgb.To(); + var lab = rgb.To(); + + ColorMeasurement m = new ColorMeasurement(); + m.C = cmyk.C * 100; + m.M = cmyk.M * 100; + m.Y = cmyk.Y * 100; + m.K = cmyk.K * 100; + m.V = 0; + m.L = lab.L; + m.A = lab.A; + m.B = lab.B; + + measurements.Add(m); + + Console.WriteLine(m.ToString()); + } + + Console.WriteLine(); + + using (var db = ObservablesContext.CreateDefault()) + { + Console.WriteLine("Clearing previous color measurements..."); + db.Database.ExecuteSqlCommand("DELETE FROM COLOR_MEASUREMENTS"); + } + + using (var db = ObservablesContext.CreateDefault()) + { + foreach (var m in measurements) + { + db.ColorMeasurements.Add(m); + } + + Console.WriteLine("Adding new measurements to database..."); + + db.SaveChanges(); + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine(); + Console.WriteLine("Done!"); + Console.ReadKey(); + Environment.Exit(0); + } + } + + public class RGBGenerator + { + public static List GenerateRGBValues(int numberOfColors) + { + List colors = new List(); + int colorRange = (int)Math.Ceiling(Math.Pow(numberOfColors, 1.0 / 3.0)); + + for (int r = 0; r < colorRange; r++) + { + for (int g = 0; g < colorRange; g++) + { + for (int b = 0; b < colorRange; b++) + { + int red = (int)(r * 255.0 / (colorRange - 1)); + int green = (int)(g * 255.0 / (colorRange - 1)); + int blue = (int)(b * 255.0 / (colorRange - 1)); + + colors.Add(new RGB(red, green, blue)); + + if (colors.Count >= numberOfColors) + { + return colors; + } + } + } + } + + return colors; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..150cfb8d4 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.ColorMeasurementsGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.ColorMeasurementsGenerator")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("04fca0ba-a64b-4c6a-a011-a94ce335d616")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj new file mode 100644 index 000000000..89062149c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616} + Exe + Tango.ColorMeasurementsGenerator + Tango.ColorMeasurementsGenerator + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + {37e4ceab-b54b-451f-b535-04cf7da9c459} + ColorMine + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {b4fe6485-4161-4b36-bc08-67e0b53d01b7} + Tango.ColorConversion + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1