From 338edba081dba2a2aefb634811be1cc84ec93d64 Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Tue, 25 Aug 2020 10:08:01 +0300 Subject: merge --- .../Advanced Installer Projects/FSE Installer.aip | 87 +- .../Controls/WebAppPropertiesControl.xaml.cs | 11 +- .../ColorLib/Tango.ColorLib_v4/ColorCalibrator.cpp | 4 +- .../ColorLib/Tango.ColorLib_v4/ColorConverter.cpp | 1877 +++++-------- .../ColorLib/Tango.ColorLib_v4/ColorConverter.h | 83 +- .../Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj | 6 + .../Tango.ColorLib_v4.vcxproj.filters | 18 + .../ColorLib/Tango.ColorLib_v4/Utils/CT_Header.cpp | 83 + .../ColorLib/Tango.ColorLib_v4/Utils/CT_Header.h | 57 + .../Tango.ColorLib_v4/Utils/ColorTable.cpp | 645 +++++ .../ColorLib/Tango.ColorLib_v4/Utils/ColorTable.h | 76 + .../ColorLib/Tango.ColorLib_v4/Utils/Gradient.cpp | 35 + .../ColorLib/Tango.ColorLib_v4/Utils/Gradient.h | 37 + .../ViewModels/DiagnosticsViewVM.cs | 35 + .../Modules/Tango.FSE.Diagnostics/diagnostics.tdp | 2 +- .../Controls/RemoteDesktopControl.xaml | 2 +- .../Views/RemoteDesktopView.xaml | 7 +- .../Content/VersionHistory/VersionHistory.aml | 33 + .../Content/VersionHistory/v1.0.0.0.aml | 28 + .../Content/Welcome.aml | 111 + .../ContentLayout.content | 8 + .../Help/proc-doc.chm | Bin 0 -> 212099 bytes .../Help/proc-doc.chw | Bin 0 -> 45575 bytes .../Tango.FSE.Procedures.Documentation.shfbproj | 229 ++ .../icons/Help.png | Bin 0 -> 4942 bytes .../icons/machine_48px.png | Bin 0 -> 3171 bytes .../Tango.FSE.Procedures/ArrayParsingStyle.cs | 10 + .../BreakPointRequestEventArgs.cs | 31 + .../Contracts/IProcedureDesignerView.cs | 9 + .../Controls/ObjectInTreeView.xaml | 27 + .../Controls/ObjectInTreeView.xaml.cs | 50 + .../Tango.FSE.Procedures/Controls/TreeNode.cs | 98 + .../FSE/Modules/Tango.FSE.Procedures/DebugNode.cs | 256 ++ .../Dialogs/BreakPointValueDialogView.xaml | 24 + .../Dialogs/BreakPointValueDialogView.xaml.cs | 28 + .../Dialogs/BreakPointValueDialogViewVM.cs | 60 + .../Examples/AddResult/Program.cs | 91 + .../Examples/Connection/Program.cs | 38 + .../Tango.FSE.Procedures/Examples/Csv/Program.cs | 63 + .../Examples/Diagnostics/Program.cs | 44 + .../Examples/RequestUserInputFor/Program.cs | 48 + .../Tango.FSE.Procedures/Examples/Send/Program.cs | 47 + .../Examples/SendContinuous/Program.cs | 66 + .../Tango.FSE.Procedures/Examples/Sql/Program.cs | 78 + .../ExtensionMethods/TreeViewExtensions.cs | 40 + .../Helpers/ProcedureExceptionHelper.cs | 36 + .../Tango.FSE.Procedures/IDialogController.cs | 17 + .../Tango.FSE.Procedures/IProcedureContext.cs | 484 +++- .../Navigation/RunProcedureNavigationObject.cs | 14 + .../Tango.FSE.Procedures/ProcedureContext.cs | 74 +- .../Resources/main_template.csx | 1 - .../FSE/Modules/Tango.FSE.Procedures/Result.cs | 14 + .../FSE/Modules/Tango.FSE.Procedures/ResultType.cs | 12 + .../FSE/Modules/Tango.FSE.Procedures/SqlResult.cs | 19 - .../Tango.FSE.Procedures.csproj | 37 +- .../Tango.FSE.Procedures/Themes/Generic.xaml | 221 ++ .../FSE/Modules/Tango.FSE.Procedures/UserInput.cs | 11 + .../ViewModels/ProcedureDesignerViewVM.cs | 294 +- .../ViewModels/ProcedureRunnerViewVM.cs | 86 +- .../Views/ProcedureDesignerView.xaml | 145 +- .../Views/ProcedureDesignerView.xaml.cs | 126 +- .../ApplicationUpgradeGeneratedViewVM.cs | 5 +- .../ViewModels/FirmwareUpgradeGeneratedViewVM.cs | 46 +- .../Views/ApplicationUpgradeGeneratedView.xaml | 14 +- .../Views/FirmwareUpgradeGeneratedView.xaml | 10 +- .../Views/FirmwareUpgradeView.xaml | 2 +- .../ApplicationStartedAfterCrashException.cs | 16 + .../Connection/IMachineProvider.cs | 3 +- .../Connection/MachineConnectionTypes.cs | 19 + .../Diagnostics/DiagnosticsPackage.cs | 35 +- .../FSEApplication/IFSEApplicationManager.cs | 5 + .../FSE/Tango.FSE.Common/FSESettings.cs | 12 + .../FSE/Tango.FSE.Common/FSEViewModel.cs | 7 + .../FileAssociation/FileAssociationPackage.cs | 14 + .../FileAssociation/IFileAssociationProvider.cs | 14 + .../FileSystem/IFileSystemProvider.cs | 3 +- .../FSE/Tango.FSE.Common/Helpers/LogsHelper.cs | 24 + .../Navigation/INavigationManager.cs | 5 +- .../FSE/Tango.FSE.Common/SQL/IRemoteSqlProvider.cs | 22 + .../FSE/Tango.FSE.Common/SQL/RemoteSqlCommand.cs | 25 + .../Tango.FSE.Common/SQL/RemoteSqlCommandMode.cs | 10 +- .../Tango.FSE.Common/SQL/RemoteSqlCommandResult.cs | 50 +- .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 8 + .../Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs | 106 +- .../BugReporting/DefaultBugReporter.cs | 2 +- .../Connection/DefaultMachineProvider.cs | 5 +- .../Dialogs/MachineConnectionLostViewVM.cs | 11 +- .../Dialogs/MachineWaitForConnectionView.xaml | 2 +- .../Dialogs/MachineWaitForConnectionViewVM.cs | 20 +- .../FSEApplication/DefaultFSEApplicationManager.cs | 20 + .../DefaultFileAssociationProvider.cs | 136 + .../FileSystem/DefaultFileSystemProvider.cs | 14 +- .../Navigation/DefaultNavigationManager.cs | 10 +- .../FSE/Tango.FSE.UI/Panes/LogViewerPane.xaml | 98 +- .../FSE/Tango.FSE.UI/Panes/LogViewerPaneVM.cs | 8 + .../Tango.FSE.UI/Panes/MachineConnectionPaneVM.cs | 41 +- .../FSE/Tango.FSE.UI/Properties/AssemblyInfo.cs | 2 +- .../Tango.FSE.UI/SQL/DefaultRemoteSqlProvider.cs | 2 +- .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 4 + .../Tango.FSE.UI/Tiles/RemoteJob/RemoteJobTile.cs | 7 + .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 4 + .../FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs | 8 + .../Visual_Studio/FSE/Tango.FSE.UI/packages.config | 1 + .../Sandcastle/SHFBInstaller_v2020.3.6.0.zip | Bin 0 -> 48579276 bytes .../Views/MainView.xaml | 31 +- .../Tango.MachineStudio.ColorCapture.csproj | 4 +- .../Views/JobView.xaml | 2 +- .../Views/MachineJobSelectionView.xaml | 2 +- .../Views/MainView.xaml | 7 +- .../ViewModels/MainViewVM.cs | 3 +- .../Tango.MachineStudio.RML/Views/RmlsView.xaml | 2 +- .../Converters/HeadCleaningConverter.cs | 23 - .../Tango.MachineStudio.Statistics.csproj | 1 - .../ViewModels/JobRunsViewVM.cs | 45 +- .../Views/JobRunsView.xaml | 86 +- .../Views/JobRunsView.xaml.cs | 17 + .../Converters/RoleEnumToVisibleConverter.cs | 32 + .../Tango.MachineStudio.UsersAndRoles.csproj | 4 +- .../Views/UserManagementView.xaml | 6 +- .../Resources/MaterialDesign.xaml | 145 +- .../Tango.MachineStudio.UI/App.xaml.cs | 25 + .../Images/remote_connections.png | Bin 0 -> 4186 bytes .../Tango.PPC.Technician.csproj | 11 + .../Tango.PPC.Technician/ViewModelLocator.cs | 12 + .../ViewModels/LoggingViewVM.cs | 8 + .../ViewModels/RemoteConnectionsViewVM.cs | 64 + .../Tango.PPC.Technician/Views/CatalogView.xaml | 12 + .../Tango.PPC.Technician/Views/MainView.xaml | 1 + .../Views/RemoteConnectionsView.xaml | 88 + .../Views/RemoteConnectionsView.xaml.cs | 28 + .../PPC/Tango.PPC.Common/Helpers/LogsHelper.cs | 24 + .../Insights/DefaultInsightsService.cs | 45 + .../Tango.PPC.Common/Insights/IInsightsService.cs | 13 + .../PPC/Tango.PPC.Common/Publish/PPCPublisher.cs | 32 +- .../PPC/Tango.PPC.Common/Publish/PublishOptions.cs | 3 +- .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 1 + .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 7 + .../Tango.PPC.Common/Web/LatestVersionResponse.cs | 1 + .../PPC/Tango.PPC.Publisher.UI/MainWindow.xaml | 10 +- .../PPC/Tango.PPC.Publisher.UI/MainWindowVM.cs | 26 +- .../PPC/Tango.PPC.Shared/SQL/RemoteSqlColumn.cs | 28 + .../SQL/RemoteSqlColumnCollection.cs | 31 + .../PPC/Tango.PPC.Shared/SQL/RemoteSqlDataSet.cs | 35 + .../PPC/Tango.PPC.Shared/SQL/RemoteSqlRow.cs | 55 + .../PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj | 4 + .../Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs | 25 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 3 + .../Tango FSE Procedure Example.zip | Bin 0 -> 6123 bytes .../Scripting/Tango.Scripting.Basic/Project.cs | 194 +- .../Scripting/Tango.Scripting.Core/BreakPoint.cs | 14 + .../Tango.Scripting.Core/ScriptBreakPoint.cs | 23 + .../Tango.Scripting.Core/ScriptBreakPointSymbol.cs | 16 + .../Tango.Scripting.Core.csproj | 3 + .../BreakPointSymbolPressedEventArgs.cs | 16 + .../Editing/BreakPointMargin.cs | 285 ++ .../Highlighting/Resources/CSharp-Mode.xshd | 2 +- .../Images/break_point_arrow.png | Bin 0 -> 453 bytes .../Intellisense/HideIntellisenseAttribute.cs | 12 + .../Intellisense/KnownType.cs | 11 +- .../Tango.Scripting.Editors/ScriptEditor.cs | 302 ++ .../Tango.Scripting.Editors.csproj | 6 + .../Tango.Scripting.Editors_di35u2uj_wpftmp.csproj | 628 +++++ .../Tango.Scripting.Editors/TextEditor.cs | 2343 ++++++++-------- .../Tango.Scripting/Parsing/ScriptParser.cs | 23 + .../Tango.Scripting/Parsing/ScriptSymbol.cs | 4 + .../Tango.BL/Entities/HardwareVersion.cs | 9 + .../Tango.ColorLib.GradientTest.CLI/Program.cs | 41 +- .../Visual_Studio/Tango.Insights/InsightsFrame.cs | 64 + .../Visual_Studio/Tango.Insights/InsightsHelper.cs | 85 + .../Tango.Insights/InsightsListener.cs | 121 + .../Tango.Insights/InsightsManager.cs | 81 + .../Tango.Insights/Properties/AssemblyInfo.cs | 7 + .../Tango.Insights/Tango.Insights.csproj | 80 + .../ExternalBridge/ExternalBridgeReceiver.cs | 12 +- .../ExternalBridge/ExternalBridgeService.cs | 18 + .../ExternalBridge/IExternalBridgeService.cs | 6 + .../Tango.Logging/GlobalExceptionTrapper.cs | 50 +- Software/Visual_Studio/Tango.Logging/LogManager.cs | 9 + Software/Visual_Studio/Tango.Logging/LogSafe.cs | 39 + .../Tango.Logging/Tango.Logging.csproj | 3 +- .../Visual_Studio/Tango.PMR/Common/ErrorCode.cs | 19 +- .../Tango.PMR/Insights/InsightsMonitors.cs | 2936 ++++++++++++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 3 +- .../Tango.SharedUI/Components/SelectedObject.cs | 6 +- .../Controls/AllSelectedCheckboxList.cs | 144 + .../Controls/PopupWithKeyboardFocus.cs | 42 - .../Tango.SharedUI/Controls/SearchComboBox.cs | 317 +-- .../Tango.SharedUI/Tango.SharedUI.csproj | 2 +- Software/Visual_Studio/Tango.sln | 45 + .../Analysis/AnalyzerResultBase.cs | 2 + .../Analysis/IAnalyzer.cs | 2 +- .../Analysis/IAnalyzerResult.cs | 4 +- .../Analyzers/DynamicSealingAnalyzer.cs | 2 +- .../Analyzers/FlowAnalyser.cs | 34 +- .../Analyzers/PressureBuildUpAnalyser.cs | 2 +- .../Analyzers/PrimingAnalyzer.cs | 2 +- .../Analyzers/SealingAnalyzer.cs | 2 +- .../Tango.DispenserAnalyzer.UI/App.xaml.cs | 13 +- .../Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs | 22 +- .../Tango.DispenserAnalyzer.UI.csproj | 2 +- .../ViewModels/MainWindowVM.cs | 146 +- .../Utilities/Tango.PMRGenerator.CLI/Program.cs | 31 +- .../Controllers/FSEController.cs | 2 +- .../Controllers/PPCController.cs | 5 +- .../Properties/AssemblyInfo.cs | 2 +- 205 files changed, 12987 insertions(+), 3332 deletions(-) create mode 100644 Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.cpp create mode 100644 Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.h create mode 100644 Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.cpp create mode 100644 Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.h create mode 100644 Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.cpp create mode 100644 Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.h create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Content/VersionHistory/VersionHistory.aml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Content/VersionHistory/v1.0.0.0.aml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Content/Welcome.aml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/ContentLayout.content create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chw create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/icons/Help.png create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/icons/machine_48px.png create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/BreakPointRequestEventArgs.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Controls/ObjectInTreeView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Controls/ObjectInTreeView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Controls/TreeNode.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/DebugNode.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Dialogs/BreakPointValueDialogView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Dialogs/BreakPointValueDialogView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Dialogs/BreakPointValueDialogViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/AddResult/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Connection/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Csv/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Diagnostics/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/RequestUserInputFor/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Send/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/SendContinuous/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Sql/Program.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ExtensionMethods/TreeViewExtensions.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Helpers/ProcedureExceptionHelper.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Navigation/RunProcedureNavigationObject.cs delete mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/SqlResult.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/ApplicationStartedAfterCrashException.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/FileAssociationPackage.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/IFileAssociationProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Helpers/LogsHelper.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs create mode 100644 Software/Visual_Studio/Installers/Sandcastle/SHFBInstaller_v2020.3.6.0.zip delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/HeadCleaningConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/Converters/RoleEnumToVisibleConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/remote_connections.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/RemoteConnectionsView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Helpers/LogsHelper.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/IInsightsService.cs create mode 100644 Software/Visual_Studio/Project Templates/Tango FSE Procedure Example.zip create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Core/BreakPoint.cs create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Core/ScriptBreakPoint.cs create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Core/ScriptBreakPointSymbol.cs create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/BreakPointSymbolPressedEventArgs.cs create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Editing/BreakPointMargin.cs create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Images/break_point_arrow.png create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/HideIntellisenseAttribute.cs create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors_di35u2uj_wpftmp.csproj create mode 100644 Software/Visual_Studio/Tango.Insights/InsightsFrame.cs create mode 100644 Software/Visual_Studio/Tango.Insights/InsightsHelper.cs create mode 100644 Software/Visual_Studio/Tango.Insights/InsightsListener.cs create mode 100644 Software/Visual_Studio/Tango.Insights/InsightsManager.cs create mode 100644 Software/Visual_Studio/Tango.Insights/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.Insights/Tango.Insights.csproj create mode 100644 Software/Visual_Studio/Tango.Logging/LogSafe.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Insights/InsightsMonitors.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Controls/AllSelectedCheckboxList.cs delete mode 100644 Software/Visual_Studio/Tango.SharedUI/Controls/PopupWithKeyboardFocus.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip index 44331055f..901fd1a05 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip @@ -24,10 +24,10 @@ - + - + @@ -267,7 +267,7 @@ - + @@ -310,16 +310,20 @@ + + + + + + - - @@ -649,35 +653,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + @@ -689,7 +679,7 @@ - + @@ -776,8 +766,6 @@ - - @@ -822,6 +810,12 @@ + + + + + + @@ -1081,15 +1075,23 @@ - - - + + + + + + + + + + + @@ -1145,6 +1147,12 @@ + + + + + + @@ -1168,6 +1176,13 @@ + + + + + + + diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs index 129550d14..aab9361f8 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs @@ -1,6 +1,7 @@ using Microsoft.Azure.Management.AppService.Fluent; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -99,6 +100,11 @@ namespace Tango.AzureUtils.UI.Controls { IsBusy = true; + TangoVersion = null; + MachineStudioVersion = null; + FseVersion = null; + MachineServiceVersion = null; + HostNames = app.HostNames.Select(x => x).ToList(); Settings = await app.GetMachineServiceSettingsAsync(false); @@ -112,7 +118,10 @@ namespace Tango.AzureUtils.UI.Controls FtpManager ftpManager = new FtpManager(azure); MachineServiceVersion = await ftpManager.GetMachineServiceVersion(app); } - catch { } + catch (Exception ex) + { + Debug.WriteLine(ex); + } finally { IsBusy = false; diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorCalibrator.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorCalibrator.cpp index 2f53f4ae2..3d66f2d1e 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorCalibrator.cpp +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorCalibrator.cpp @@ -182,7 +182,7 @@ void Tango::ColorLib::ColorCalibrator::InitData(const CalibrationMeasurement** m m_targetVal[1] = targeta; m_targetVal[2] = targetb; - int m_CalIndex = 0; + m_CalIndex = 0; if (m_inkChannel == 2) m_CalIndex = 2; } @@ -395,7 +395,7 @@ void Tango::ColorLib::ColorCalibrator::LinearizationInitData(const Linearizatio m_targetVal[1] = targeta; m_targetVal[2] = targetb; - int m_CalIndex = 0; + m_CalIndex = 0; if (m_inkChannel == 2) m_CalIndex = 2; } diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp index e34a276ed..096d85bce 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp @@ -59,53 +59,20 @@ #define GradientEndThr 0.95 -Tango::ColorLib::ColorConverter::ColorConverter() : m_A2BTransform(NULL), m_B2ATransform(NULL), -m_GBD(NULL), m_A2BRTransform(NULL), m_B2ARTransform(NULL), -m_GBDR(NULL), m_CalibCurves(NULL), m_Conv02(NULL), m_GamutRegionMaxLim(NULL), -m_maxNlPerCM(NULL), m_nA2BnSepIn(0), m_nA2BnSepOut(0), m_nB2AnSepIn(0), m_nB2AnSepOut(0), -m_nInks(0), m_nVolumes(0), m_nGamutRegions(0), m_LinCurves(NULL), -m_nProcessRanges(0), m_ProcessRangesMaxP(NULL), m_GradStops(NULL), m_nGradStops(0), m_NormFactor(-1.0), -m_InvNormFactor(-1.0), m_TableVersion(1) -//m_ProcessRangesMinInkUptake(NULL),m_ProcessRangesMinP(NULL), -//m_ProcessRangesMaxInkUptake(NULL) +Tango::ColorLib::ColorConverter::ColorConverter() : + m_CalibCurves(NULL), m_Conv02(NULL), +m_maxNlPerCM(NULL), +m_nInks(0), m_nVolumes(0), + m_GradStops(NULL), m_nGradStops(0), m_colortable(NULL), m_ProcessRangesMaxP(NULL), + m_nProcessRanges(0), m_NormGamutRegionMaxLim(NULL) { m_whitepointLab.Set(-1, -1, -1); m_whitepointXYZ_Strip.Set(-1, -1, -1); - m_whitepointXYZ_CT.Set(-1, -1, -1); + m_WP.Set(-1, -1, -1); } Tango::ColorLib::ColorConverter::~ColorConverter() { - if (m_A2BTransform != NULL) - { - delete m_A2BTransform; - m_A2BTransform = NULL; - } - if (m_B2ATransform != NULL) - { - delete m_B2ATransform; - m_B2ATransform = NULL; - } - if (m_GBD != NULL) - { - delete m_GBD; - m_GBD = NULL; - } - if (m_A2BRTransform != NULL) - { - delete m_A2BRTransform; - m_A2BRTransform = NULL; - } - if (m_B2ARTransform != NULL) - { - delete m_B2ARTransform; - m_B2ARTransform = NULL; - } - if (m_GBDR != NULL) - { - delete m_GBDR; - m_GBDR = NULL; - } if (m_Conv02 != NULL) { delete m_Conv02; @@ -116,26 +83,26 @@ Tango::ColorLib::ColorConverter::~ColorConverter() delete[] m_CalibCurves; m_CalibCurves = NULL; } - if (m_GamutRegionMaxLim != NULL) + if(m_GradStops != NULL) + { + delete [] m_GradStops; + m_GradStops = NULL; + } + if (m_colortable != NULL) { - delete[] m_GamutRegionMaxLim; - m_GamutRegionMaxLim = NULL; + delete m_colortable; + m_colortable = NULL; } - if (m_LinCurves != NULL) + if (m_NormGamutRegionMaxLim != NULL) { - delete m_LinCurves; - m_LinCurves = NULL; + delete[] m_NormGamutRegionMaxLim; + m_NormGamutRegionMaxLim = NULL; } if (m_ProcessRangesMaxP != NULL) { delete[] m_ProcessRangesMaxP; m_ProcessRangesMaxP = NULL; } - if (m_GradStops != NULL) - { - delete[] m_GradStops; - m_GradStops = NULL; - } /* if (m_ProcessRangesMinP != NULL) { delete[] m_ProcessRangesMinP; @@ -172,6 +139,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(ConversionInput *conv hue = 0.0; else hue = atan2(Lab(2), Lab(1)); + double d1 = dC; double de = 0; MatrixXd Lab1(nHive, 3); @@ -229,7 +197,6 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(ConversionInput *conv //double *tmpRGB = DBG_NEW double[3]; double *InkOut = new double[m_nInks]; //double *InkOut = DBG_NEW double[m_nInks]; - int *GamutRegion = new int[nHive + 1]; //int *GamutRegion = DBG_NEW int[nHive + 1]; double *Lab1P = new double[3]; @@ -240,7 +207,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(ConversionInput *conv //double * LabInFinal1 = DBG_NEW double[3]; double * LabInFinal2 = new double[3]; double * LabOnGamut = new double[3]; - double *InkOutP = new double[m_nB2AnSepOut]; + double *InkOutP = new double[m_nInks]; bool InGamut = true; for (int i = 0; i < nHive; ++i) { @@ -257,19 +224,19 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(ConversionInput *conv */ // ColConv.ChangeWP(Lab1P, Lab1P, m_WP, m_whitepointXYZ_CT); //to Relative ColConv.ChangeWP(Lab1P, Lab1P, m_WP, m_whitepointXYZ_Strip); //to Relative - m_B2ATransform->evalLab2InkP(Lab1P, InkOut, GamutRegion[i]); //InkOut is in units of 16 bits - for (int i = 0; i < m_nB2AnSepOut; ++i) + m_colortable->m_B2ATransform->evalLab2InkP(Lab1P, InkOut, GamutRegion[i]); //InkOut is in units of 16 bits + for (int i = 0; i GetNormFactor(); + if (InkOut[i] <= m_NormGamutRegionMaxLim[0]) { - m_LinCurves->m_InterpCurves[i].Eval(InkOut[i] * 655.35, InkOut[i]); + m_colortable->m_LinCurves->m_InterpCurves[i].Eval(InkOut[i] * 655.35, InkOut[i]); InkOut[i] /= 655.35; } } InGamut = IsInGamut(Lab1P, sur, CS, LabOnGamut); LimitLab(LabOnGamut); - VectorXd NLInkOut(m_nB2AnSepOut); + VectorXd NLInkOut(m_nInks); ConvertToNLInks(DoubleToVector(InkOut, m_nInks), NLInkOut); //Limit inks based on m_maxNlpercm @@ -469,9 +436,6 @@ void Tango::ColorLib::ColorConverter::ArrangeHiveData(MatrixXd LabHive, MatrixX } - - - void Tango::ColorLib::ColorConverter::fillVolume(OutputCoordinates *&outputCoords, VectorXd Volume) { int i = 0; @@ -528,8 +492,8 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* bool has_forwarddata = conversionInput->has_forwarddata; uint8_t *data = conversionInput->forwarddata.data; int nprocessranges = conversionInput->n_processranges; - readColorTables(has_forwarddata, data, nprocessranges); - + m_colortable->InitColorTables(has_forwarddata, data, nprocessranges); + SetNumberofInks(m_colortable->GetnA2BnSepOut()); } void Tango::ColorLib::ColorConverter::SetStripWhitepoint(double threadl, double threada, double threadb) @@ -543,293 +507,6 @@ void Tango::ColorLib::ColorConverter::SetStripWhitepoint(double threadl, double m_whitepointXYZ_Strip.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z()); } -void Tango::ColorLib::ColorConverter::readColorTables(bool has_data, uint8_t * data, int nprocessranges) -{ - //parse Color Tansformations, placed in forward data - int bytesread = 0; - NumConversions conv; - int tag_count = 0; - if (has_data) - { - //Read Header - CT_Header header = read_header(data, bytesread); - SetnGamutRegions((int)header.nGamutRegions); - SetTableVersion((int)header.Version[0]); - if (m_nGamutRegions != nprocessranges) - { - throw std::exception("Number of gamut regions in table does not match STRIP\0"); - return; - } - m_GamutRegionMaxLim = new double[m_nGamutRegions]; - for (int i = 0; i < m_nGamutRegions; ++i) - m_GamutRegionMaxLim[i] = header.GRegMaxLim[i]; - m_nProcessRanges = (int)(nprocessranges); - - /* for (int i = 0; i < m_nGamutRegions; ++i) - { - if (abs(m_GamutRegionMaxLim[i] - conversionInput->processranges[i]->maxinkuptake)> eps) - throw std::exception(" Gamut Region Limit does not match MaxInkUptake in STRIP\0"); - } - */ - if (header.GRegMaxLim != NULL) - { - delete[]header.GRegMaxLim; - header.GRegMaxLim = NULL; - } - - - uint32_t tmp; - uint8_t *buff =data; - tmp = conv.ByteToInt(buff, bytesread); - tag_count = (int)tmp; - bytesread += 4; - //read Tag Table - char **TagNames = new char*[tag_count]; - //char **TagNames = DBG_NEW char*[tag_count]; - int **TagSize = new int*[tag_count]; - //int **TagSize = DBG_NEW int*[tag_count]; - char *tmpC = NULL; - int n = 0; - int i, j; - for (i = 0; i < tag_count; ++i) - { - TagSize[i] = new int[3]; - //TagSize[i] = DBG_NEW int[3]; - tmp = conv.ByteToInt(buff, bytesread); - n = sizeof((char*)&tmp); - delete[] tmpC; - tmpC = NULL; - tmpC = new char[n]; - //tmpC = DBG_NEW char[n]; - conv.getchar(tmp, n, tmpC); - //TagNames[i] = DBG_NEW char[n]; - TagNames[i] = new char[n]; - for (j = 0; j < n; ++j) - TagNames[i][j] = tmpC[j]; - bytesread += 4; - TagSize[i][0] = conv.ByteToInt(buff, bytesread); - bytesread += 4; - TagSize[i][1] = conv.ByteToInt(buff, bytesread); - bytesread += 4; - } - delete[] tmpC; - int *TList = new int[tag_count]; - //int *TList = DBG_NEW int[tag_count]; - for (int k = 0; k < tag_count; ++k) - { - if (strncmp(TagNames[k], "A2B ", 4) == 0) - TList[k] = A2B; - else if (strncmp(TagNames[k], "A2BR", 4) == 0) - TList[k] = A2BR; - else if (strncmp(TagNames[k], "B2A ", 4) == 0) - TList[k] = B2A; - else if (strncmp(TagNames[k], "B2AR ", 4) == 0) - TList[k] = B2AR; - else if (strncmp(TagNames[k], "wtpt", 4) == 0) - TList[k] = wtpt; - else if (strncmp(TagNames[k], "desc", 4) == 0) - TList[k] = desc; - else if (strncmp(TagNames[k], "gbd ", 4) == 0) - TList[k] = gbd; - else if (strncmp(TagNames[k], "gbdR", 4) == 0) - TList[k] = gbdR; - else if (strncmp(TagNames[k], "cprt", 4) == 0) - TList[k] = cprt; - else if (strncmp(TagNames[k], "lcrv", 4) == 0) - TList[k] = lcrv; - // else if (strncmp(TagNames[k], "GReg", 2) == 0) - // TList[k] = GReg; - else - throw std::exception("Unknown Tag in Color Tables"); - } - for (int k = 0; k < tag_count; ++k) - { - switch (TList[k]) - { - case A2B: - { - uint8_t *A2BLUT = &(data[TagSize[k][0]]); - int A2BLutsize = TagSize[k][1]; - m_A2BTransform = new ColorTransf(); - //m_A2BTransform = DBG_NEW ColorTransf(); - m_A2BTransform->InitData(A2BLUT, A2BLutsize); - break; - } - case A2BR: - { - uint8_t *A2BRLUT = &(data[TagSize[k][0]]); - int A2BRLutsize = TagSize[k][1]; - m_A2BRTransform = new ColorTransf(); - //m_A2BTransform = DBG_NEW ColorTransf(); - m_A2BRTransform->InitData(A2BRLUT, A2BRLutsize); - break; - } - case B2A: - { - uint8_t *B2ALUT = &(data[TagSize[k][0]]); - int B2ALutsize = TagSize[k][1]; - m_B2ATransform = new ColorTransf(); - //m_B2ATransform = DBG_NEW ColorTransf(); - m_B2ATransform->InitData(B2ALUT, B2ALutsize); - break; - } - case B2AR: - { - uint8_t *B2ARLUT = &(data[TagSize[k][0]]); - int B2ARLutsize = TagSize[k][1]; - m_B2ARTransform = new ColorTransf(); - //m_B2ATransform = DBG_NEW ColorTransf(); - m_B2ARTransform->InitData(B2ARLUT, B2ARLutsize); - break; - } - /* case GReg: - { - uint8_t *GRegLUT = &(conversionInput->forwarddata.data[TagSize[k][0]]); - int GRegLutsize = TagSize[k][1]; - m_GRegTransform = new ColorTransf(); - //m_B2ATransform = DBG_NEW ColorTransf(); - m_GRegTransform->InitData(GRegLUT, GRegLutsize); - break; - } */ - case gbd: - { - uint8_t *GBDList = &(data[TagSize[k][0]]); - m_GBD = new GBD(); - //m_GBD = DBG_NEW GBD(); - int GBDSize = TagSize[k][1]; - m_GBD->InitData(GBDList, GBDSize); - break; - } - case gbdR: - { - uint8_t *GBDRList = &(data[TagSize[k][0]]); - m_GBDR = new GBD(); - //m_GBD = DBG_NEW GBD(); - int GBDRSize = TagSize[k][1]; - m_GBDR->InitData(GBDRList, GBDRSize); - break; - } - case lcrv: - { - uint8_t *CurvesData = &(data[TagSize[k][0]]); - m_LinCurves = new Curves(); - int CurvesSize = TagSize[k][1]; - m_LinCurves->InitData(CurvesData, CurvesSize); - break; - } - case wtpt: - { - read_xyz_type(TagSize[k][0], TagSize[k][1], &m_whitepointXYZ_CT, data); - - break; - } - case cprt: - { - std::string textstr; - read_text_type(TagSize[k][0], TagSize[k][1], &textstr, data); - break; - } - case desc: - { - std::string textdescstr; - read_text_description_type(TagSize[k][0], TagSize[k][1], textdescstr, data); - break; - } - default: - { - throw std::exception("Unresolved Tag in Color Tables"); - return; - } - - } - } - if (TagNames != NULL) - { - for (int i = 0; i < tag_count; ++i) - { - delete[] TagNames[i]; - TagNames[i] = NULL; - } - delete[]TagNames; - TagNames = NULL; - } - if (TagSize != NULL) - { - for (int i = 0; i < tag_count; ++i) - { - delete[] TagSize[i]; - TagSize[i] = NULL; - } - delete[]TagSize; - TagSize = NULL; - } - if (TList != NULL) - { - delete[] TList; - TList = NULL; - } - - if (header.ColorSpace != NULL) - { - delete header.ColorSpace; - header.ColorSpace = NULL; - } - if (header.ConnectionSpace != NULL) - { - delete header.ConnectionSpace; - header.ConnectionSpace = NULL; - } - if (header.DeviceManufacturer != NULL) - { - delete header.DeviceManufacturer; - header.DeviceManufacturer = NULL; - } - } - - - //Verify all relevant tags had been read - if (m_A2BTransform == NULL) - { - throw std::exception("Missing Forward Transform in Color Tables"); - return; - } - if (m_A2BRTransform == NULL) - { - throw std::exception("Missing Reduced Forward Transform in Color Tables"); - return; - } - if (m_B2ATransform == NULL) - { - throw std::exception("Missing Inverse Transform in Color Tables"); - return; - } - if (m_B2ARTransform == NULL) - { - throw std::exception("Missing Reduced Inverse Transform in Color Tables"); - return; - } - if (m_GBD == NULL) - { - throw std::exception("Missing Gamut Boundary Descriptor in Color Tables"); - return; - } - if (m_GBDR == NULL) - { - throw std::exception("Missing Reduced Gamut Boundary Descriptor in Color Tables"); - return; - } - if ((m_whitepointXYZ_CT.Get_x() == -1) && (m_whitepointXYZ_CT.Get_y() == -1) && (m_whitepointXYZ_CT.Get_z() == -1)) - { - throw std::exception("Missing Whitepoint in Color Tables"); - return; - } - if (m_LinCurves == NULL) - { - throw std::exception("Missing Linear Curves in Color Tables"); - return; - } - return; // OK -} void Tango::ColorLib::ColorConverter::readCalibrationTables(InputLiquid **inputliquid, int n_inputliquid) @@ -909,286 +586,281 @@ void Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibrationD return; } -void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(InputCoordinates* inputcoordinates, ColorSpace colorspace, +void Tango::ColorLib::ColorConverter:: ConvertLabColorToLinearInks(InputCoordinates* inputcoordinates, VectorXd &InkOut, VectorXd &RGBOut, - VectorXd &LabOut, int &GamutRegion, bool &InGamut) + VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS) { - size_t nInks = 0; - - C_RGB_XYZ_Lab DataLab; - SURROUND sur = m_Conv02->getSurround(); - CAM02CS CS = m_Conv02->getCAM02CS(); - switch (colorspace) + // Basic assumption: Lab data has the same whitepoint as the STRIP thread. + //The workflow is a follows: + //1. Convert Lab to Relative colorimetric. check if there is a match between STRIP and Color Tables + //2. Convert Lab to Inks (B2A tables), Inks to Volume + //3. Map the Lab value onto the gamut surface, if it is out of gamut + //4. Convert Lab to Absolute colorimetric taking into account the Strip and CT whitepoints + //5. Use the Relative Colorimetric Lab to obtain RGB + double *LabIn = new double[3]; + //double *LabIn = DBG_NEW double[3]; + LabIn[0] = inputcoordinates->l; //Absolute Colorimetric + LabIn[1] = inputcoordinates->a; + LabIn[2] = inputcoordinates->b; + //the assumption is that the color space has illumination that matches the whitepoint of the Strip + ColorConvert CConvertD65(D65, D65); //Destination, source + // double *LabInFinal1 = new double[3]; + //double *LabInFinal1 = DBG_NEW double[3]; + // for (int i = 0; i < 3; ++i) + // LabInFinal1[i] = LabIn[i]; + //LabInFinal1 = LabIn; + // Lab is assumed to match the color of the STRIP, however the tables could have a different WP + //Check if Color Tables and Strip whitepoints are the same, otherwise convert +/* +if (m_AdaptWP) { - case (COLOR_SPACE__RGB): + CConvertD65.ChangeWP(LabInFinal1, LabInFinal1, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); //to Color Tables + for (int i = 0; i < 3; ++i) + LabIn[i] = LabInFinal1[i]; + } + */ + double *LabInFinal2 = new double[3]; + double *LabOnGamut = new double[3]; + //double *LabInFinal2 = DBG_NEW double[3]; + // CConvertD65.ChangeWP(LabIn, LabInFinal2, m_WP, m_whitepointXYZ_CT); //LabInFinal2 is in Relative Colorimetric Space + CConvertD65.ChangeWP(LabIn, LabInFinal2, m_WP, m_whitepointXYZ_Strip); //LabInFinal2 is in Relative Colorimetric Space + InGamut = IsInGamut(LabInFinal2, sur, CS, LabOnGamut); + LimitLab(LabOnGamut); + + //convert to Inks + double *InkOutP = new double[m_nInks]; + //double *InkOutP = DBG_NEW double[m_nB2AnSepOut]; + m_colortable->m_B2ATransform->evalLab2InkP(LabOnGamut, InkOutP, GamutRegion); //InkOut is in units of 16 bits + //Convert Inks to Lab to get the Gamut Mapped Lab +//m_A2BTransform->evalInkP2Lab(InkOutP, LabIn, GamutRegion); +//LabOut = DoubleToVector(LabIn, 3); +//Convert InkOutP to linear in the m_GamutRegionMaxLim[0] range + for (int i = 0; i < m_nInks; ++i) { - // Basic assumption: if data is given in RGB space, conversion should be in relative colorimetric, - //We expect that [255,255,255](white) will be mapped to the thread white, meaning all inks should be zero - // and the coverted RGB will refect the color of the thread, but will be shown in Relative Colorimetric to the user - //The workflow is a follows: - //1. Convert RGB to Lab (Whitepoint is D65, same as tables) - //2. Convert Lab to Inks (B2A tables), Inks to Volume - //3. Convert Inks to Lab (A2B tables) to get the in/on Gamut Lab - //4. Convert Lab to Absolute colorimetric taking into account the Strip and Color Table whitepoints - //5. Use the Relative Colorimetric Lab to obtain RGB - - RGBOut(0) = inputcoordinates->red; - RGBOut(1) = inputcoordinates->green; - RGBOut(2) = inputcoordinates->blue; - //convert to Lab - ColorConvert CConvertD65(D65, D65); //Destination, source - double *LabIn = new double[3]; - double *RGBOutP = new double[3]; - //double *LabIn = DBG_NEW double[3]; - //double *RGBOutP = DBG_NEW double[3]; - VectorToDouble(RGBOut, RGBOutP); - //RGB to Lab - CConvertD65.RGBtoLab(RGBOutP, LabIn); //Values are in Relative Colorimetric, D65 - LimitLab(LabIn); - //Is In Gamut? - double *LabInFinal = new double[3]; - double *LabOnGamut = new double[3]; - InGamut = IsInGamut(LabIn, sur, CS, LabOnGamut); - LimitLab(LabOnGamut); - - //convert to inks - int GamutRegion; - double *InkOutP = new double[m_nB2AnSepOut]; - //double *InkOutP = DBG_NEW double[m_nB2AnSepOut]; - //LabInFinal is in Relative Colorimetric, just like the Color Tables - m_B2ATransform->evalLab2InkP(LabOnGamut, InkOutP, GamutRegion); //InkOut is inthe [0-100] interval - - //Convert to Lab to get the actual in Gamut Lab - //double *LabInP = new double[3]; - //double *LabInP = DBG_NEW double[3]; - //m_A2BTransform->evalInkP2Lab(InkOutP, LabInP, GamutRegion); //Lab is in Relative Colorimetric - //Convert InkOut to Linear via initial calibration Tables - //Initial calibration tables are the ones that were included in the color table - for (int i = 0; i < m_nB2AnSepOut; ++i) + InkOutP[i] *= m_colortable->GetNormFactor(); + if (InkOutP[i] <= m_NormGamutRegionMaxLim[0]) { - InkOutP[i] *= m_NormFactor; - if (InkOutP[i] <= m_GamutRegionMaxLim[0]) - { - m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); - InkOutP[i] /= 655.35; - } + m_colortable->m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); + InkOutP[i] /= 655.35; } - InkOut = DoubleToVector(InkOutP, m_nInks); - - //Convert to CT thread, LabOnGamut is in Relative Colorimetric Space - //CConvertD65.ChangeWP(LabOnGamut, LabInFinal, m_whitepointXYZ_CT, m_WP); - CConvertD65.ChangeWP(LabOnGamut, LabInFinal, m_whitepointXYZ_Strip, m_WP); - //check if the thread to be used is the same as the one in the color tables - /* + } + InkOut = DoubleToVector(InkOutP, m_nInks); + double *LabOutFinal = new double[3]; + //double *LabOutFinal = DBG_NEW double[3]; + for (int i = 0; i < 3; ++i) + LabOutFinal[i] = LabOnGamut[i]; + //LabOutFinal is in Relative Colorimetric + //Reverse the conversion process to bring back Lab to STRIP white point + // CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_CT, m_WP); + CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_Strip, m_WP); +/* if (m_AdaptWP) { - //Convert to Strip White Point - CConvertD65.ChangeWP(LabInFinal, LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); } */ - LabOut = DoubleToVector(LabInFinal, 3); - CConvertD65.SetReferenceWhite(D65); - double *RGBOutP1 = new double[3]; - //double *RGBOutP1 = DBG_NEW double[3]; - CConvertD65.LabtoRGB(LabOnGamut, RGBOutP1); - //CConvertD65.LabtoRGB(LabInP, RGBOutP1); - RGBOut = DoubleToVector(RGBOutP1, 3); - if (LabOnGamut != NULL) - { - delete[] LabOnGamut; - LabOnGamut = NULL; - } - if (InkOutP != NULL) - { - delete[] InkOutP; - InkOutP = NULL; - } - if (LabIn != NULL) - { - delete[] LabIn; - LabIn = NULL; - } - if (RGBOutP != NULL) - { - delete[] RGBOutP; - RGBOutP = NULL; - } - if (RGBOutP1 != NULL) - { - delete[] RGBOutP1; - RGBOutP1 = NULL; - } - if (LabInFinal != NULL) - { - delete[] LabInFinal; - LabInFinal = NULL; - } - break; + LabOut = DoubleToVector(LabOutFinal, 3); + CConvertD65.SetReferenceWhite(D65); + //Convert to RGB + double *RGBOutP = new double[3]; + // double *RGBOutP = DBG_NEW double[3]; + //Use Relative colorimetric to get RGB + CConvertD65.LabtoRGB(LabOnGamut, RGBOutP); + //CConvertD65.LabtoRGB(LabIn, RGBOutP); + RGBOut = DoubleToVector(RGBOutP, 3); + if (LabOnGamut != NULL) + { + delete[] LabOnGamut; + LabOnGamut = NULL; } - case (COLOR_SPACE__LAB): + if (InkOutP != NULL) { - // Basic assumption: Lab data has the same whitepoint as the STRIP thread. + delete[] InkOutP; + InkOutP = NULL; + } + if (LabIn != NULL) + { + delete[] LabIn; + LabIn = NULL; + } + /* if (LabInFinal1 != NULL) + { + delete[]LabInFinal1; + LabInFinal1 = NULL; + } + */ + if (LabInFinal2 != NULL) + { + delete[]LabInFinal2; + LabInFinal2 = NULL; + } + if (LabOutFinal != NULL) + { + delete[]LabOutFinal; + LabOutFinal = NULL; + } + + if (RGBOutP != NULL) + { + delete[] RGBOutP; + RGBOutP = NULL; + } +} + + +void Tango::ColorLib::ColorConverter::ConvertRGBColorToLinearInks(InputCoordinates* inputcoordinates, + VectorXd &InkOut, VectorXd &RGBOut, + VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS) +{ + // Basic assumption: if data is given in RGB space, conversion should be in relative colorimetric, + //We expect that [255,255,255](white) will be mapped to the thread white, meaning all inks should be zero + // and the coverted RGB will refect the color of the thread, but will be shown in Relative Colorimetric to the user //The workflow is a follows: - //1. Convert Lab to Relative colorimetric. check if there is a match between STRIP and Color Tables + //1. Convert RGB to Lab (Whitepoint is D65, same as tables) //2. Convert Lab to Inks (B2A tables), Inks to Volume - //3. Map the Lab value onto the gamut surface, if it is out of gamut - //4. Convert Lab to Absolute colorimetric taking into account the Strip and CT whitepoints + //3. Convert Inks to Lab (A2B tables) to get the in/on Gamut Lab + //4. Convert Lab to Absolute colorimetric taking into account the Strip and Color Table whitepoints //5. Use the Relative Colorimetric Lab to obtain RGB - double *LabIn = new double[3]; - //double *LabIn = DBG_NEW double[3]; - LabIn[0] = inputcoordinates->l; //Absolute Colorimetric - LabIn[1] = inputcoordinates->a; - LabIn[2] = inputcoordinates->b; - //the assumption is that the color space has illumination that matches the whitepoint of the Strip - ColorConvert CConvertD65(D65, D65); //Destination, source - // double *LabInFinal1 = new double[3]; - //double *LabInFinal1 = DBG_NEW double[3]; - // for (int i = 0; i < 3; ++i) - // LabInFinal1[i] = LabIn[i]; - //LabInFinal1 = LabIn; - // Lab is assumed to match the color of the STRIP, however the tables could have a different WP - //Check if Color Tables and Strip whitepoints are the same, otherwise convert - /* - if (m_AdaptWP) - { - CConvertD65.ChangeWP(LabInFinal1, LabInFinal1, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); //to Color Tables - for (int i = 0; i < 3; ++i) - LabIn[i] = LabInFinal1[i]; - } - */ - double *LabInFinal2 = new double[3]; - double *LabOnGamut = new double[3]; - //double *LabInFinal2 = DBG_NEW double[3]; -// CConvertD65.ChangeWP(LabIn, LabInFinal2, m_WP, m_whitepointXYZ_CT); //LabInFinal2 is in Relative Colorimetric Space - CConvertD65.ChangeWP(LabIn, LabInFinal2, m_WP, m_whitepointXYZ_Strip); //LabInFinal2 is in Relative Colorimetric Space - InGamut = IsInGamut(LabInFinal2, sur, CS, LabOnGamut); - LimitLab(LabOnGamut); - //convert to Inks - int GamutRegion; - double *InkOutP = new double[m_nB2AnSepOut]; - //double *InkOutP = DBG_NEW double[m_nB2AnSepOut]; - m_B2ATransform->evalLab2InkP(LabOnGamut, InkOutP, GamutRegion); //InkOut is in units of 16 bits - //Convert Inks to Lab to get the Gamut Mapped Lab - //m_A2BTransform->evalInkP2Lab(InkOutP, LabIn, GamutRegion); - //LabOut = DoubleToVector(LabIn, 3); - //Convert InkOutP to linear in the m_GamutRegionMaxLim[0] range - for (int i = 0; i < m_nB2AnSepOut; ++i) - { - InkOutP[i] *= m_NormFactor; - if (InkOutP[i] <= m_GamutRegionMaxLim[0]) - { - m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); - InkOutP[i] /= 655.35; - } - } - InkOut = DoubleToVector(InkOutP, m_nInks); - double *LabOutFinal = new double[3]; - //double *LabOutFinal = DBG_NEW double[3]; - for (int i = 0; i < 3; ++i) - LabOutFinal[i] = LabOnGamut[i]; - //LabOutFinal is in Relative Colorimetric - //Reverse the conversion process to bring back Lab to STRIP white point -// CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_CT, m_WP); - CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_Strip, m_WP); -/* - if (m_AdaptWP) - { - CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); - } - */ - LabOut = DoubleToVector(LabOutFinal, 3); - CConvertD65.SetReferenceWhite(D65); - //Convert to RGB - double *RGBOutP = new double[3]; - // double *RGBOutP = DBG_NEW double[3]; - //Use Relative colorimetric to get RGB - CConvertD65.LabtoRGB(LabOnGamut, RGBOutP); - //CConvertD65.LabtoRGB(LabIn, RGBOutP); - RGBOut = DoubleToVector(RGBOutP, 3); - if (LabOnGamut != NULL) - { - delete[] LabOnGamut; - LabOnGamut = NULL; - } - if (InkOutP != NULL) - { - delete[] InkOutP; - InkOutP = NULL; - } - if (LabIn != NULL) - { - delete[] LabIn; - LabIn = NULL; - } -/* if (LabInFinal1 != NULL) - { - delete[]LabInFinal1; - LabInFinal1 = NULL; - } - */ - if (LabInFinal2 != NULL) - { - delete[]LabInFinal2; - LabInFinal2 = NULL; - } - if (LabOutFinal != NULL) + RGBOut(0) = inputcoordinates->red; + RGBOut(1) = inputcoordinates->green; + RGBOut(2) = inputcoordinates->blue; + //convert to Lab + ColorConvert CConvertD65(D65, D65); //Destination, source + double *LabIn = new double[3]; + double *RGBOutP = new double[3]; + //double *LabIn = DBG_NEW double[3]; + //double *RGBOutP = DBG_NEW double[3]; + VectorToDouble(RGBOut, RGBOutP); + //RGB to Lab + CConvertD65.RGBtoLab(RGBOutP, LabIn); //Values are in Relative Colorimetric, D65 + LimitLab(LabIn); + //Is In Gamut? + double *LabInFinal = new double[3]; + double *LabOnGamut = new double[3]; + InGamut = IsInGamut(LabIn, sur, CS, LabOnGamut); + LimitLab(LabOnGamut); + + //convert to inks + + double *InkOutP = new double[m_nInks]; + //double *InkOutP = DBG_NEW double[m_nB2AnSepOut]; + //LabInFinal is in Relative Colorimetric, just like the Color Tables + m_colortable->m_B2ATransform->evalLab2InkP(LabOnGamut, InkOutP, GamutRegion); //InkOut is inthe [0-100] interval + + //Convert to Lab to get the actual in Gamut Lab + //double *LabInP = new double[3]; + //double *LabInP = DBG_NEW double[3]; + //m_A2BTransform->evalInkP2Lab(InkOutP, LabInP, GamutRegion); //Lab is in Relative Colorimetric + //Convert InkOut to Linear via initial calibration Tables + //Initial calibration tables are the ones that were included in the color table + for (int i = 0; i < m_nInks; ++i) + { + InkOutP[i] *= m_colortable->GetNormFactor(); + if (InkOutP[i] <= m_NormGamutRegionMaxLim[0]) { - delete[]LabOutFinal; - LabOutFinal = NULL; + m_colortable->m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); + InkOutP[i] /= 655.35; } + } + InkOut = DoubleToVector(InkOutP, m_nInks); - if (RGBOutP != NULL) - { - delete[] RGBOutP; - RGBOutP = NULL; - } - break; + //Convert to CT thread, LabOnGamut is in Relative Colorimetric Space + //CConvertD65.ChangeWP(LabOnGamut, LabInFinal, m_whitepointXYZ_CT, m_WP); + CConvertD65.ChangeWP(LabOnGamut, LabInFinal, m_whitepointXYZ_Strip, m_WP); + //check if the thread to be used is the same as the one in the color tables +/* + if (m_AdaptWP) + { + //Convert to Strip White Point + CConvertD65.ChangeWP(LabInFinal, LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + } + */ + LabOut = DoubleToVector(LabInFinal, 3); + CConvertD65.SetReferenceWhite(D65); + double *RGBOutP1 = new double[3]; + //double *RGBOutP1 = DBG_NEW double[3]; + CConvertD65.LabtoRGB(LabOnGamut, RGBOutP1); + //CConvertD65.LabtoRGB(LabInP, RGBOutP1); + RGBOut = DoubleToVector(RGBOutP1, 3); + if (LabOnGamut != NULL) + { + delete[] LabOnGamut; + LabOnGamut = NULL; + } + if (InkOutP != NULL) + { + delete[] InkOutP; + InkOutP = NULL; + } + if (LabIn != NULL) + { + delete[] LabIn; + LabIn = NULL; + } + if (RGBOutP != NULL) + { + delete[] RGBOutP; + RGBOutP = NULL; + } + if (RGBOutP1 != NULL) + { + delete[] RGBOutP1; + RGBOutP1 = NULL; + } + if (LabInFinal != NULL) + { + delete[] LabInFinal; + LabInFinal = NULL; + } } - case(COLOR_SPACE__CMYK): - {//no conversion +void Tango::ColorLib::ColorConverter::ConvertCMYKColorToLinearInks(InputCoordinates* inputcoordinates, + VectorXd &InkOut, VectorXd &RGBOut, + VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS) +{ + //no conversion //missing from structure light inks or special colors // just convert Lab for rgb display - double *outData = new double[m_nA2BnSepIn]; - //double *outData = DBG_NEW double[m_nA2BnSepIn]; - size_t CountSep = 0; - outData[0] = (double)(inputcoordinates->cyan); - outData[1] = (double)(inputcoordinates->magenta); - outData[2] = (double)(inputcoordinates->yellow); - outData[3] = (double)(inputcoordinates->key); - CountSep = 4; - - if (CountSep != m_nA2BnSepIn) - { - //mismatch between table and sent data - throw std::exception("Mismatch between table and sent data"); - return; - } - //Convert to RGB - int GamutRegion = 0; - double *InkOutP = new double[m_nA2BnSepIn]; - //double *InkOutP = DBG_NEW double[m_nA2BnSepIn]; - for (int i = 0; i < m_nA2BnSepIn; ++i) - InkOutP[i] = outData[i]; - double *LabOutP = new double[3]; - //double *LabOutP = DBG_NEW double[3]; - m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); - InkOut = DoubleToVector(InkOutP, m_nInks); - //LabOut is in relative colorimetric - ColorConvert CConvertD65(D65, D65); - double *LabOutFinal1 = new double[3]; - //double *LabOutFinal1 = DBG_NEW double[3]; - for (int i = 0; i < 3; ++i) - LabOutFinal1[i] = LabOutP[i]; - double *LabOutFinal2 = new double[3]; - //double *LabOutFinal2 = DBG_NEW double[3]; - for (int i = 0; i < 3; ++i) - LabOutFinal2[i] = LabOutP[i]; - InGamut = true; - //Check if white points match + + double *outData = new double[m_nInks]; + //double *outData = DBG_NEW double[m_nA2BnSepIn]; + size_t CountSep = 0; + outData[0] = (double)(inputcoordinates->cyan); + outData[1] = (double)(inputcoordinates->magenta); + outData[2] = (double)(inputcoordinates->yellow); + outData[3] = (double)(inputcoordinates->key); + CountSep = 4; + + if (CountSep != m_nInks) + { + //mismatch between table and sent data + throw std::exception("Mismatch between table and sent data"); + return; + } + //Convert to RGB + double *InkOutP = new double[m_nInks]; + //double *InkOutP = DBG_NEW double[m_nA2BnSepIn]; + for (int i = 0; i < m_nInks; ++i) + InkOutP[i] = outData[i]; + double *LabOutP = new double[3]; + //double *LabOutP = DBG_NEW double[3]; + m_colortable->m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); + InkOut = DoubleToVector(InkOutP, m_nInks); + //LabOut is in relative colorimetric + ColorConvert CConvertD65(D65, D65); + double *LabOutFinal1 = new double[3]; + //double *LabOutFinal1 = DBG_NEW double[3]; + for (int i = 0; i < 3; ++i) + LabOutFinal1[i] = LabOutP[i]; + double *LabOutFinal2 = new double[3]; + //double *LabOutFinal2 = DBG_NEW double[3]; + for (int i = 0; i < 3; ++i) + LabOutFinal2[i] = LabOutP[i]; + InGamut = true; + //Check if white points match // CConvertD65.ChangeWP(LabOutFinal1, LabOutFinal1, m_whitepointXYZ_CT, m_WP); //To Absolute - CConvertD65.ChangeWP(LabOutFinal1, LabOutFinal1, m_whitepointXYZ_Strip, m_WP); //To Absolute + CConvertD65.ChangeWP(LabOutFinal1, LabOutFinal1, m_whitepointXYZ_Strip, m_WP); //To Absolute /* if (m_AdaptWP) { CConvertD65.ChangeWP(LabOutFinal1, LabOutFinal2, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); @@ -1196,45 +868,75 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(InputCoordinates* LabOutFinal1[i] = LabOutFinal2[i]; } */ - LabOut = DoubleToVector(LabOutFinal1, 3); - CConvertD65.SetReferenceWhite(D65); - //Get RGB - double *RGBOutP = new double[3]; - //double *RGBOutP = DBG_NEW double[3]; - CConvertD65.LabtoRGB(LabOutP, RGBOutP); - //CConvertD65.LabtoRGB(LabOutP, RGBOutP); - RGBOut = DoubleToVector(RGBOutP, 3); + LabOut = DoubleToVector(LabOutFinal1, 3); + CConvertD65.SetReferenceWhite(D65); + //Get RGB + double *RGBOutP = new double[3]; + //double *RGBOutP = DBG_NEW double[3]; + CConvertD65.LabtoRGB(LabOutP, RGBOutP); + //CConvertD65.LabtoRGB(LabOutP, RGBOutP); + RGBOut = DoubleToVector(RGBOutP, 3); - if (outData != NULL) - { - delete[] outData; - outData = NULL; - } - if (LabOutP != NULL) - { - delete[] LabOutP; - LabOutP = NULL; - } - if (InkOutP != NULL) - { - delete[] InkOutP; - InkOutP = NULL; - } - if (RGBOutP != NULL) - { - delete[] RGBOutP; - RGBOutP = NULL; - } - if (LabOutFinal1 != NULL) - { - delete[] LabOutFinal1; - LabOutFinal1 = NULL; - } - if (LabOutFinal2 != NULL) - { - delete[] LabOutFinal2; - LabOutFinal2 = NULL; - } + if (outData != NULL) + { + delete[] outData; + outData = NULL; + } + if (LabOutP != NULL) + { + delete[] LabOutP; + LabOutP = NULL; + } + if (InkOutP != NULL) + { + delete[] InkOutP; + InkOutP = NULL; + } + if (RGBOutP != NULL) + { + delete[] RGBOutP; + RGBOutP = NULL; + } + if (LabOutFinal1 != NULL) + { + delete[] LabOutFinal1; + LabOutFinal1 = NULL; + } + if (LabOutFinal2 != NULL) + { + delete[] LabOutFinal2; + LabOutFinal2 = NULL; + } +} +void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(InputCoordinates* inputcoordinates, ColorSpace colorspace, + VectorXd &InkOut, VectorXd &RGBOut, + VectorXd &LabOut, int &GamutRegion, bool &InGamut) +{ + size_t nInks = 0; + + C_RGB_XYZ_Lab DataLab; + SURROUND sur = m_Conv02->getSurround(); + CAM02CS CS = m_Conv02->getCAM02CS(); + switch (colorspace) + { + case (COLOR_SPACE__RGB): + { + ConvertRGBColorToLinearInks(inputcoordinates, + InkOut, RGBOut, LabOut, GamutRegion, InGamut, sur, CS); + break; + } + case (COLOR_SPACE__LAB): + { + ConvertLabColorToLinearInks(inputcoordinates, + InkOut, RGBOut, LabOut, GamutRegion, InGamut, sur, CS); + break; + } + + case(COLOR_SPACE__CMYK): + { + ConvertCMYKColorToLinearInks(inputcoordinates, + InkOut, RGBOut, LabOut, GamutRegion, InGamut, sur, CS); + break; } case(COLOR_SPACE__Catalog): @@ -1267,7 +969,7 @@ void Tango::ColorLib::ColorConverter::ConvertToNLInks(VectorXd InkIn, VectorXd { for (int i = 0; i < m_nVolumes; ++i) { - if (InkIn(i) <= m_GamutRegionMaxLim[0]) + if (InkIn(i) <= m_NormGamutRegionMaxLim[0]) m_CalibCurves[i].m_InvLinearInterp->Eval(InkIn(i), InkOut(i)); else InkOut(i) = InkIn(i); @@ -1386,7 +1088,7 @@ void Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd &V RVolNorm(i) = round(Volume(i)*ROUNDINGTol) / ROUNDINGTol; RsumNorm += RVolNorm(i); } - if (RsumNorm > m_GamutRegionMaxLim[m_nProcessRanges - 1] || abs(sumNorm - RsumNorm) >= 1 / ROUNDINGTol) + if (RsumNorm > m_NormGamutRegionMaxLim[m_nProcessRanges - 1] || abs(sumNorm - RsumNorm) >= 1 / ROUNDINGTol) { VectorXd dd(m_nInks); double maxdd = -1; @@ -1516,22 +1218,22 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates for (int i = 0; i < m_nVolumes; ++i) Volume(i) = inputcoordinates->inputliquids[i]->volume; //volume is given in % - GamutRegion = GetGamutRegion(Volume, m_GamutRegionMaxLim); + GamutRegion = GetGamutRegion(Volume, m_NormGamutRegionMaxLim); VolumeToNLInkP(Volume, NLInkP); //Limit Inks - double *InkOutP = new double[m_nA2BnSepIn]; + double *InkOutP = new double[m_nInks]; VectorToDouble(NLInkP, InkOutP); //for (int i = 0; i < m_nA2BnSepIn; ++i) // InkOutP[i] = NLInkP(i); - double *LinInkP = new double[m_nA2BnSepIn]; + double *LinInkP = new double[m_nInks]; //Reflect the Calibration Curves of the thread in Catalog Items if (colorspace == COLOR_SPACE__Catalog) { - for (int i = 0; i < m_nB2AnSepOut; ++i) + for (int i = 0; i < m_nInks; ++i) { - if (NLInkP(i) <= m_GamutRegionMaxLim[0]) + if (NLInkP(i) <= m_NormGamutRegionMaxLim[0]) { - m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); + m_colortable->m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); InkOutP[i] /= 655.35; NLInkP(i) = InkOutP[i]; } @@ -1539,7 +1241,7 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates } for (int i = 0; i < (int)(m_nVolumes); ++i) { - if (NLInkP(i) <= m_GamutRegionMaxLim[0]) + if (NLInkP(i) <= m_NormGamutRegionMaxLim[0]) { m_CalibCurves[i].m_InvLinearInterp->Eval(InkOutP[i], InkOutP[i]); NLInkP(i) = InkOutP[i]; @@ -1560,15 +1262,15 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates //Convert to RGB //GamutRegion = 0; //Convert to Lab - - double *LabOutP = new double[m_nA2BnSepOut]; + + double *LabOutP = new double[3]; //double *InkOutP = DBG_NEW double[m_nA2BnSepIn]; //double *LabOutP = DBG_NEW double[m_nA2BnSepOut]; //InkOutP has to be normalized to match the transform units - for (int i = 0; i < m_nB2AnSepOut; ++i) - InkOutP[i] *= m_InvNormFactor; + for (int i = 0; i < m_nInks; ++i) + InkOutP[i] *= m_colortable->GetInverseNormFactor(); - m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); + m_colortable->m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); //LabOutP is in Relative Colorimetric ColorConvert CConvertD65(D65, D65); @@ -1716,7 +1418,13 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i m_WP.Set(0.9505, 1.00, 1.0888); //D65 //count number if inks // int numofInks = CountNumberofInks(conversionInput); + m_colortable = new ColorTable(); readColorTransformations(conversionInput); + m_nProcessRanges = conversionInput->n_processranges; + m_NormGamutRegionMaxLim = new double[m_nProcessRanges]; + double *tmpVal = m_colortable->GetNormGamutRegionMaxLim(); + for (int i = 0; i < m_nProcessRanges; ++i) + m_NormGamutRegionMaxLim[i] = tmpVal[i]; //read calibration tables and store them in m_CalibCurves InputLiquid **inputliquids = conversionInput->inputcoordinates->inputliquids; int n_inputliquids = conversionInput->inputcoordinates->n_inputliquids; @@ -1726,46 +1434,38 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i Illum IL = D65; SURROUND sur = average; CAM02CS CS = UCS; - m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); + if(m_Conv02 ==NULL) + m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); //m_Conv02 = DBG_NEW ColorConvert(IL, IL, Y_b, L_A, sur, CS); - SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn()); - SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut()); - SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn()); - SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut()); - - SetNumberOfInks(m_nB2AnSepOut); + // Compare Strip White point to Color Table White Point //CompareWhitePoints(); - if (numofInks != m_nB2AnSepOut) + if (numofInks != m_nInks) throw std::exception("Number of available inks does not match ink tables\0"); //Tables have been filled //Set Process Ranges - m_ProcessRangesMaxP = new double[m_nProcessRanges]; + if(m_ProcessRangesMaxP == NULL) + m_ProcessRangesMaxP = new double[m_nProcessRanges]; for (int i = 0; i < m_nProcessRanges; ++i) { m_ProcessRangesMaxP[i] = conversionInput->processranges[i]->maxinkuptake; } - NormGamutRegionMaxLim(); - if (m_NormFactor <= 0.0) - { - SetNormFactor(); - SetInverseNormFactor(); - } - VectorXd InkOut(m_nB2AnSepOut); + + VectorXd InkOut(m_nInks); VectorXd RGBOut(3); VectorXd LabOut(3); - VectorXd NLInkOut(m_nB2AnSepOut); - VectorXd Volume(m_nB2AnSepOut); - VectorXd VolumeOut(m_nB2AnSepOut); + VectorXd NLInkOut(m_nInks); + VectorXd Volume(m_nInks); + VectorXd VolumeOut(m_nInks); //set maxNlPerCM - VectorXd NlperCM(m_nB2AnSepOut); + VectorXd NlperCM(m_nInks); NlperCM.setZero(); m_maxNlPerCM = NlperCM; - for (int i = 0; i < m_nB2AnSepOut; ++i) + for (int i = 0; i < m_nInks; ++i) SetMaxNLperCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter, i); - m_nVolumes = m_nB2AnSepOut; + m_nVolumes = m_nInks; int GamutRegion = 0; //Convert input data to linear inks if (conversionInput->colorspace == COLOR_SPACE__Volume || conversionInput->colorspace == COLOR_SPACE__Catalog) @@ -1786,7 +1486,7 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i //Limit inks based on m_maxNlpercm //Inks are limited in their nonlinear form //Output Volume is in % - double *InkOutP = new double[m_nB2AnSepOut]; + double *InkOutP = new double[m_nInks]; LimitInks(NLInkOut, InkOutP); NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Volume); GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); @@ -2038,7 +1738,7 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur, CA } double ctr[3]; - C_RGB_XYZ_Lab center = m_GBD->getCenter(); + C_RGB_XYZ_Lab center = m_colortable->m_GBD->getCenter(); VectorXd JInLab(3); JInLab << InLab[0], InLab[1], InLab[2]; VectorXd JLab = m_Conv02->LabToJab(JInLab, sur); @@ -2049,7 +1749,7 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur, CA //double *dJLab = DBG_NEW double[3]; VectorToDouble(JLab, dJLab); bool intersect = false; - m_GBD->TriangleRayIntersection(dJLab, ctr, intersect, xCoord); + m_colortable->m_GBD->TriangleRayIntersection(dJLab, ctr, intersect, xCoord); if (intersect) { VectorXd V1(3); @@ -2090,92 +1790,7 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur, CA } -Tango::CT_Header Tango::ColorLib::ColorConverter::read_header(uint8_t *data, int &bytesread) -{ - //CT_Header *Header = new CT_Header; - //CT_Header *Header = DBG_NEW CT_Header; - CT_Header Header; - - // unsigned int tmp = (buffer[2 * i + 1] << 8) | buffer[2 * i]; - uint8_t *ColorTable =data; - //File Size - NumConversions Conv; - Header.TblSIze = Conv.ByteToInt(ColorTable, bytesread); - bytesread = 4; - uint8_t versionBCT[2]; - versionBCT[0] = (unsigned int)ColorTable[bytesread]; - bytesread += 1; - versionBCT[1] = (unsigned int)ColorTable[bytesread]; - - Header.Version[0] = versionBCT[0]; - Header.Version[1] = versionBCT[1] << 4; - Header.Version[2] = versionBCT[1] & 15; - bytesread += 1; - uint32_t tmp = Conv.ByteToInt(ColorTable, bytesread); - int n = sizeof((char*)&tmp); - //char *tmpC = DBG_NEW char[n]; - char *tmpC = new char[n]; - Conv.getchar(tmp, n, tmpC); - //Header.ColorSpace = DBG_NEW char[n]; - Header.ColorSpace = new char[n]; - memcpy_s(Header.ColorSpace, n + 1, tmpC, n); - - // strncpy_s(Header->ColorSpace, n+1, tmpC, n); - //Header->ColorSpace = tmpC; - bytesread += 4; - tmp = Conv.ByteToInt(ColorTable, bytesread); - Conv.getchar(tmp, n, tmpC); - //Header.ConnectionSpace = DBG_NEW char[n]; - Header.ConnectionSpace = new char[n]; - memcpy_s(Header.ConnectionSpace, n + 1, tmpC, n); - - bytesread += 4; - - bytesread += 12; - tmp = Conv.ByteToInt(ColorTable, bytesread); - Conv.getchar(tmp, n, tmpC); - //Header.DeviceManufacturer = DBG_NEW char[n]; - Header.DeviceManufacturer = new char[n]; - memcpy_s(Header.DeviceManufacturer, n + 1, tmpC, n); - // strncpy_s(Header->DeviceManufacturer, n + 1, tmpC, n); - //Header->DeviceManufacturer = tmpC; - if (tmpC != NULL) - { - delete[]tmpC; - tmpC = NULL; - } - - bytesread += 4; - //read illuminant - double xyz[3]; - for (int j = 0; j < 3; ++j) - { - tmp = Conv.ByteToInt(ColorTable, bytesread); - xyz[j] = (double)(tmp) / 65536; - bytesread += 4; - } - Header.Illuminant.Set(xyz[0], xyz[1], xyz[2]); - //Read Number of Gamut Regions and Max Limits per Region - Header.nGamutRegions = ColorTable[bytesread]; - bytesread++; - Header.GRegMaxLim = new double[Header.nGamutRegions]; - for (int i = 0; i < Header.nGamutRegions; ++i) - { - tmp = Conv.ByteToShort(ColorTable, bytesread); - bytesread += 2; - Header.GRegMaxLim[i] = (double)tmp; - } - - if (bytesread < 128) - { - bytesread = 128; - return(Header); - } - else - { - throw std::exception("could not read Color table Header"); - } -} + void Tango::ColorLib::ColorConverter::read_lut_type(int offset, int data_size, ColorTransf *Transf, ConversionInput* conversionInput) { @@ -2203,166 +1818,11 @@ void Tango::ColorLib::ColorConverter::read_lut_type(int offset, int data_size, C return; } -void Tango::ColorLib::ColorConverter::read_xyz_type(int offset, int data_size, C_RGB_XYZ_Lab *XYZ, uint8_t *data) -{ - // 0 - 3 'XYZ ' - //4 - 7 reserved, must be 0 - // 8 - n array of XYZ numbers - - if (data_size < 8) - { - throw std::exception("not enough data to read xyz"); - } - uint8_t *buff = &(data[offset]); - NumConversions Conv; - int bytesread = 0; - int tmpxyz = Conv.ByteToInt(buff, bytesread); - - int n = sizeof(tmpxyz); - //char* tmpC = DBG_NEW char[n]; - char* tmpC = new char[n]; - Conv.getchar(tmpxyz, n, tmpC); - - char *xyztype = new char[n + 1]; - //char *xyztype = DBG_NEW char[n + 1]; - strncpy_s(xyztype, n + 1, tmpC, n); - if (strncmp(xyztype, "XYZ ", n) != 0) - { - throw std::exception("Wrong Tag Type"); - return; - } - if (xyztype != NULL) - { - delete[] xyztype; - xyztype = NULL; - } - if (tmpC != NULL) - { - delete[] tmpC; - tmpC = NULL; - } - bytesread = 8; - int num_values = (data_size - 8) / 4; - if (floor((double)(num_values) / 3) * 3 != num_values) - { - throw std::exception("not enough Data to read xyz"); - return; - } - double xyz[3]; - int tmp; - for (int j = 0; j < 3; ++j) - { - tmp = Conv.ByteToInt(buff, bytesread); - xyz[j] = (double)(tmp) / 65536; - bytesread += 4; - } - XYZ->Set(xyz[0], xyz[1], xyz[2]); - return; -} - -void Tango::ColorLib::ColorConverter::read_text_type(int offset, int data_size, std::string *textstr, uint8_t *data) -{ - // 0 - 3 'text' - //4 - 7 reserved, must be 0 - //8 - string of(data_size - 8) 7 - bit ASCII characters, including NULL - std::stringstream strstr; - if (data_size < 8) - { - throw std::exception("invalid Tag Name"); - strstr << ""; - *textstr = strstr.str(); - return; - } - uint8_t *buff = &(data[offset]); - int bytesread = 0; - NumConversions Conv; - int tmp = Conv.ByteToInt(buff, bytesread); - int n = sizeof((char*)&tmp); - //char *tmpC = DBG_NEW char[n]; - char *tmpC = new char[n]; - Conv.getchar(tmp, n, tmpC); - char *tagtype = new char[n + 1]; - //char *tagtype = DBG_NEW char[n + 1]; - strncpy_s(tagtype, n + 1, tmpC, n); - if (strcmp(tagtype, "text") != 0) - { - throw std::exception("invalid Tag Name"); - strstr << ""; - *textstr = strstr.str(); - return; - } - if (tagtype != NULL) - { - delete[] tagtype; - tagtype = NULL; - } - if (tmpC != NULL) - { - delete[]tmpC; - tmpC = NULL; - } - bytesread += 8; - uint8_t tmp1; - for (int i = bytesread; i < data_size; ++i) - { - tmp1 = buff[i]; - strstr.put(tmp1); - } - *textstr = strstr.str(); - return; -} -void Tango::ColorLib::ColorConverter::read_text_description_type(int offset, int data_size, std::string textdescstr, uint8_t *data) -{ - // 0 - 3 'desc' - // 4 - 7 reserved, must be 0 - // 8 - 11 ASCII invariant description count, including terminating NULL - // 12 - ASCII invariant description - uint8_t *buff = &(data[offset]); - int bytesread = 0; - NumConversions Conv; - int tmp = Conv.ByteToInt(buff, bytesread); - int n = sizeof((char*)&tmp); - //char *tmpC= DBG_NEW char[n]; - char *tmpC = new char[n]; - Conv.getchar(tmp, n, tmpC); - char *tagtype = new char[n + 1]; - //char *tagtype = DBG_NEW char[n + 1]; - strncpy_s(tagtype, n + 1, tmpC, n); - std::stringstream strstr; - if (strcmp(tagtype, "desc") != 0) - { - throw std::exception("invalid Tag Name"); - strstr << ""; - textdescstr = strstr.str(); - return; - } - if (tagtype != NULL) - { - delete[] tagtype; - tagtype = NULL; - } - if (tmpC != NULL) - { - delete[]tmpC; - tmpC = NULL; - } - bytesread += 8; - int count = Conv.ByteToInt(buff, bytesread); - bytesread += 4; - uint8_t tmp1; - for (int i = 0; i < count - 1; ++i) - { - tmp1 = buff[bytesread + i]; - strstr << tmp1; - } - textdescstr = strstr.str(); - return; -} /*void Tango::ColorLib::ColorConverter::CompareWhitePoints() { @@ -2602,23 +2062,18 @@ size_t Tango::ColorLib::ColorConverter::P_IsInGamut(uint8_t * input_buffer, size CAM02CS CS = UCS; m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); //m_Conv02 = DBG_NEW ColorConvert(IL, IL, Y_b, L_A, sur, CS); - SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn()); - SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut()); - SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn()); - SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut()); - SetNumberOfInks(m_nB2AnSepOut); // Compare Strip White point to Color Table White Point //CompareWhitePoints(); - if (numofInks != m_nB2AnSepOut) + if (numofInks != m_nInks) throw std::exception("Number of available inks does not match ink tables"); - VectorXd InkOut(m_nB2AnSepOut); + VectorXd InkOut(m_nInks); VectorXd RGBOut(3); VectorXd LabOut(3); - VectorXd NLInkOut(m_nB2AnSepOut); - VectorXd Volume(m_nB2AnSepOut); + VectorXd NLInkOut(m_nInks); + VectorXd Volume(m_nInks); C_RGB_XYZ_Lab DataLab; //SURROUND sur = m_Conv02->getSurround(); @@ -2779,6 +2234,7 @@ size_t Tango::ColorLib::ColorConverter::GenerateGradient(uint8_t * input_buffer, conversionOutput->has_haserror = false; //Get segment length... double segmentLength = conversionInput->segmentlength; + m_colortable = new ColorTable(); PrepareGradient(conversionInput, conversionOutput); //Get liquid types info... /* InputLiquid* cyan = NULL; @@ -2824,23 +2280,27 @@ size_t Tango::ColorLib::ColorConverter::GenerateGradient(uint8_t * input_buffer, void Tango::ColorLib::ColorConverter::fillGradientStops(GradientConversionInput *conversionInput) { + C_RGB_XYZ_Lab RGB; + C_RGB_XYZ_Lab Lab; for (int i = 0; i < m_nGradStops; ++i) { switch (conversionInput->stops[i]->colorspace) { case COLOR_SPACE__RGB: //Case RGB - m_GradStops[i].RGB.Set(conversionInput->stops[i]->red, conversionInput->stops[i]->green, conversionInput->stops[i]->blue); - m_GradStops[i].colorspace = COLOR_SPACE__RGB; - m_GradStops[i].offset = conversionInput->stops[i]->offset; + RGB = C_RGB_XYZ_Lab(conversionInput->stops[i]->red, conversionInput->stops[i]->green, conversionInput->stops[i]->blue); + m_GradStops[i].Set_RGB(RGB); + m_GradStops[i].Set_ColorSpace(COLOR_SPACE__RGB); + m_GradStops[i].Set_Offset(conversionInput->stops[i]->offset); break; case COLOR_SPACE__LAB: //Case LAB - m_GradStops[i].Lab.Set(conversionInput->stops[i]->l, conversionInput->stops[i]->a, conversionInput->stops[i]->b); - m_GradStops[i].colorspace = COLOR_SPACE__LAB; - m_GradStops[i].offset = conversionInput->stops[i]->offset; + Lab = C_RGB_XYZ_Lab(conversionInput->stops[i]->l, conversionInput->stops[i]->a, conversionInput->stops[i]->b); + m_GradStops[i].Set_Lab(Lab); + m_GradStops[i].Set_ColorSpace(COLOR_SPACE__LAB); + m_GradStops[i].Set_Offset(conversionInput->stops[i]->offset); break; case COLOR_SPACE__Volume: //Case Volume - m_GradStops[i].colorspace = COLOR_SPACE__Volume; - m_GradStops[i].offset = conversionInput->stops[i]->offset; + m_GradStops[i].Set_ColorSpace(COLOR_SPACE__Volume); + m_GradStops[i].Set_Offset(conversionInput->stops[i]->offset); for (int j = 0; j < (int)conversionInput->stops[i]->n_liquidvolumes; j++) { LiquidVolume* liquidVolume = conversionInput->stops[i]->liquidvolumes[j]; @@ -2848,16 +2308,16 @@ void Tango::ColorLib::ColorConverter::fillGradientStops(GradientConversionInput switch (liquidVolume->liquidtype) { case LIQUID_TYPE__Cyan: - m_GradStops[i].Volume[0] = liquidVolume->volume; + m_GradStops[i].SetVolumeValue(liquidVolume->volume,0); break; case LIQUID_TYPE__Magenta: - m_GradStops[i].Volume[1] = liquidVolume->volume; + m_GradStops[i].SetVolumeValue(liquidVolume->volume, 1); break; case LIQUID_TYPE__Yellow: - m_GradStops[i].Volume[2] = liquidVolume->volume; + m_GradStops[i].SetVolumeValue(liquidVolume->volume, 2); break; case LIQUID_TYPE__Black: - m_GradStops[i].Volume[3] = liquidVolume->volume; + m_GradStops[i].SetVolumeValue(liquidVolume->volume, 3); break; default: throw std::exception("could not fill all volumes"); @@ -2869,12 +2329,12 @@ void Tango::ColorLib::ColorConverter::fillGradientStops(GradientConversionInput } -void Tango::ColorLib::ColorConverter::findStops(GradStruct m_GradStop1, GradStruct m_GradStop2, double dEThr, int ninterstops, +void Tango::ColorLib::ColorConverter::findStops(Gradient &GradStop1, Gradient &GradStop2, double dEThr, int ninterstops, int &nOut, double **VecRGBOut, double **VecLabOut, double *posOut) { ColorConvert CConvertD65(D65, D65); - C_RGB_XYZ_Lab RGBStart = m_GradStop1.RGB; - C_RGB_XYZ_Lab RGBEnd = m_GradStop2.RGB; + C_RGB_XYZ_Lab RGBStart = GradStop1.Get_RGB(); + C_RGB_XYZ_Lab RGBEnd = GradStop2.Get_RGB(); C_RGB_XYZ_Lab LowLab(0, -128, -128); C_RGB_XYZ_Lab HighLab(100, 127, 127); C_RGB_XYZ_Lab LowRGB(0, 0, 0); @@ -2895,7 +2355,7 @@ void Tango::ColorLib::ColorConverter::findStops(GradStruct m_GradStop1, GradStru // make a matching Lab vector; VecRGBOut_tmp[0] = C_RGB_XYZ_Lab(RGBStart); - VecLabOut_tmp[0] = C_RGB_XYZ_Lab(m_GradStop1.Lab); + VecLabOut_tmp[0] = C_RGB_XYZ_Lab(GradStop1.Get_Lab()); for (int i = 1; i <= nsubdiv; ++i) { @@ -3011,10 +2471,10 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* size_t nInks = 0; C_RGB_XYZ_Lab DataLab; - VectorXd InkOut(m_nB2AnSepOut); + VectorXd InkOut(m_nInks); double normFactor = 1; if (!same_regions) - normFactor = m_NormFactor; + normFactor = m_colortable->GetNormFactor(); if (colorspace ==COLOR_SPACE__RGB) { @@ -3036,20 +2496,20 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* //convert to inks int GamutRegion; - double *InkOutP = new double[m_nB2AnSepOut]; + double *InkOutP = new double[m_nInks]; if(same_regions) - m_B2ARTransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in units of 16 bits + m_colortable->m_B2ARTransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in units of 16 bits else - m_B2ATransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in units of 16 bits + m_colortable->m_B2ATransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in units of 16 bits //Convert InkOut to Linear via initial calibration Tables //Initial calibration tables are the ones that were included in the color table - for (int i = 0; i < m_nB2AnSepOut; ++i) + for (int i = 0; i < m_nInks; ++i) { InkOutP[i] *= normFactor; - if (InkOutP[i] <= m_GamutRegionMaxLim[0]) + if (InkOutP[i] <= m_NormGamutRegionMaxLim[0]) { - m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); + m_colortable->m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); InkOutP[i] /= 655.35; } } @@ -3082,18 +2542,18 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* //convert to Inks int GamutRegion; - double *InkOutP = new double[m_nB2AnSepOut]; + double *InkOutP = new double[m_nInks]; if(same_regions) - m_B2ARTransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in the [0-100] interval + m_colortable->m_B2ARTransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in the [0-100] interval else - m_B2ATransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in the [0-100] interval + m_colortable->m_B2ATransform->evalLab2InkP(LabIn, InkOutP, GamutRegion); //InkOut is in the [0-100] interval - for (int i = 0; i < m_nB2AnSepOut; ++i) + for (int i = 0; i < m_nInks; ++i) { InkOutP[i] *= normFactor; - if (InkOutP[i] <= m_GamutRegionMaxLim[0]) + if (InkOutP[i] <= m_NormGamutRegionMaxLim[0]) { - m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); + m_colortable->m_LinCurves->m_InterpCurves[i].Eval(InkOutP[i] * 655.35, InkOutP[i]); InkOutP[i] /= 655.35; } } @@ -3115,9 +2575,9 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* throw std::exception("Unsupported Color Space"); return; } - VectorXd NLInkOut(m_nB2AnSepOut); - VectorXd VolumeOut(m_nB2AnSepOut); - double *InkOutL = new double[m_nB2AnSepOut]; + VectorXd NLInkOut(m_nInks); + VectorXd VolumeOut(m_nInks); + double *InkOutL = new double[m_nInks]; ConvertToNLInks(InkOut, NLInkOut); LimitInks(NLInkOut, InkOutL); NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); @@ -3132,32 +2592,25 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* return; } -void Tango::ColorLib::ColorConverter::SetNormFactor() -{ - m_NormFactor = m_GamutRegionMaxLim[m_nProcessRanges - 1] / m_GamutRegionMaxLim[0]; -} - -void Tango::ColorLib::ColorConverter::SetInverseNormFactor() -{ - if (m_NormFactor <= 0) - m_InvNormFactor = -1; - else - m_InvNormFactor = 1.0 / m_NormFactor; -} void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* conversionInput, GradientConversionOutput *conversionOutput) { //fill input stops... + m_nGradStops = conversionInput->n_stops; - m_GradStops = new GradStruct[m_nGradStops]; + int nInks = conversionInput->n_inputliquids; + m_nVolumes = nInks; + m_GradStops = new Gradient[m_nGradStops]; + for (int i = 0; i < m_nGradStops; ++i) + m_GradStops[i].SetVolumeSize(nInks); + InputCoordinates **inputcoordinates = (InputCoordinates**)malloc(sizeof(InputCoordinates*)*m_nGradStops); - double *InkOutL = new double[m_nB2AnSepOut]; for (int i = 0; i < m_nGradStops; ++i) { inputcoordinates[i] = (InputCoordinates*)malloc(sizeof(InputCoordinates)); input_coordinates__init(inputcoordinates[i]); } - m_nVolumes = conversionInput->stops[0]->n_liquidvolumes; + fillGradientStops(conversionInput); GradInput2InputCoords(conversionInput, inputcoordinates); @@ -3165,13 +2618,17 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c SetStripWhitepoint(conversionInput->threadl, conversionInput->threada, conversionInput->threadb); bool has_forwarddata = conversionInput->has_forwarddata; uint8_t *data = conversionInput->forwarddata.data; - int nprocessranges = conversionInput->n_processranges; - readColorTables(has_forwarddata, data, nprocessranges); - + m_nProcessRanges = conversionInput->n_processranges; + m_colortable->InitColorTables(has_forwarddata, data, m_nProcessRanges); + SetNumberofInks(m_colortable->GetnA2BnSepOut()); + m_NormGamutRegionMaxLim = new double[m_nProcessRanges]; + double *tmpVal = m_colortable->GetNormGamutRegionMaxLim(); + for (int i = 0; i < m_nProcessRanges; ++i) + m_NormGamutRegionMaxLim[i] = tmpVal[i]; int n_inputliquids = conversionInput->n_inputliquids; InputLiquid **inputliquid = conversionInput->inputliquids; readCalibrationTables(inputliquid, n_inputliquids); - if (m_TableVersion <= 1) + if (m_colortable->GetTableVersion() <= 1) { throw std::exception("Color Table Version does not support gradients\0"); } @@ -3193,128 +2650,55 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c Illum IL = D65; SURROUND sur = average; CAM02CS CS = UCS; - m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); - SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn()); - SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut()); - SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn()); - SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut()); - SetNumberOfInks(m_nB2AnSepOut); + if (m_Conv02 == NULL) + m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); + // Compare Strip White point to Color Table White Point //CompareWhitePoints(); ColorConvert CConvertD65(D65, D65); //Destination, source if (n_inputliquids != m_nInks) throw std::exception("Number of available inks does not match ink tables\0"); - //Convert maxInkUptake to percentages - if(m_ProcessRangesMaxP == NULL) + if (m_ProcessRangesMaxP == NULL) m_ProcessRangesMaxP = new double[m_nProcessRanges]; for (int i = 0; i < m_nProcessRanges; ++i) { m_ProcessRangesMaxP[i] = conversionInput->processranges[i]->maxinkuptake; } - NormGamutRegionMaxLim(); - if (m_NormFactor <= 0.0) - { - SetNormFactor(); - SetInverseNormFactor(); - } - VectorXd InkOut(m_nB2AnSepOut); + + VectorXd InkOut(m_nInks); VectorXd RGBOut(3); VectorXd LabOut(3); - VectorXd NLInkOut(m_nB2AnSepOut); - VectorXd Volume(m_nB2AnSepOut); - VectorXd VolumeOut(m_nB2AnSepOut); + VectorXd NLInkOut(m_nInks); + VectorXd Volume(m_nInks); + VectorXd VolumeOut(m_nInks); //set maxNlPerCM - VectorXd NlperCM(m_nB2AnSepOut); - double *LabOutV = new double[3]; - double *LabOutFinal = new double[3]; + VectorXd NlperCM(m_nInks); NlperCM.setZero(); m_maxNlPerCM = NlperCM; - for (int i = 0; i < m_nB2AnSepOut; ++i) + for (int i = 0; i < m_nInks; ++i) SetMaxNLperCM(conversionInput->inputliquids[i]->maxnanoliterpercentimeter, i); - m_nVolumes = m_nB2AnSepOut; + //m_nVolumes = m_nB2AnSepOut; int GamutRegion = 0; - for (int i = 0; i < m_nGradStops; ++i) - { - if (m_GradStops[i].colorspace == COLOR_SPACE__Volume || m_GradStops[i].colorspace == COLOR_SPACE__Catalog) - { //Convert volume to Lab - //Convert lab to rgb - ConvertVolumeToRGBDisplay(inputcoordinates[i], m_nProcessRanges, m_GradStops[i].colorspace, Volume, RGBOut, LabOut, GamutRegion); - //store data - m_GradStops[i].Lab.Set(LabOut(0), LabOut(1), LabOut(2)); - m_GradStops[i].RGB.Set(RGBOut(0), RGBOut(1), RGBOut(2)); - m_GradStops[i].GamutRegion = GamutRegion; - m_GradStops[i].InGamut = true; - } - else - { - ConvertColorToLinearInks(inputcoordinates[i], m_GradStops[i].colorspace, InkOut, RGBOut, LabOut, GamutRegion, InGamut); - //Inks are in Linear Space , convert to nonlinear by using Calibration Tables, - // Right now calibration is in the [0-100] range, values exceeding [0-100] are not transformed - - ConvertToNLInks(InkOut, NLInkOut); - LimitInks(NLInkOut, InkOutL); - NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); - GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); - NLcmtoPercentage(Volume, Volume); - - //fill data - //fill volume - //allocate m_GradStops[i].Volume - m_GradStops[i].Volume = new double[m_nB2AnSepOut]; - for (int j = 0; j < m_nB2AnSepOut; ++j) - m_GradStops[i].Volume[j] = Volume[j]; - m_GradStops[i].GamutRegion = GamutRegion; - m_GradStops[i].InGamut = InGamut; - //LabOut and RGBOut might be different if the input was out of gamut - m_GradStops[i].Lab.Set(LabOut(0), LabOut(1), LabOut(2)); - m_GradStops[i].RGB.Set(RGBOut(0), RGBOut(1), RGBOut(2)); - } - //Convert Lab Values to Relative Colorimetric. These values will be used in the Gradient Volume calculation. - VectorToDouble(LabOut, LabOutV); -/* if (m_AdaptWP) - { - CConvertD65.ChangeWP(LabOutV, LabOutV, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); //to Color Tables - } - */ - //double *LabInFinal2 = DBG_NEW double[3]; -// CConvertD65.ChangeWP(LabOutV, LabOutFinal, m_WP, m_whitepointXYZ_CT); //LabInFinal is in Relative Colorimetric Space - CConvertD65.ChangeWP(LabOutV, LabOutFinal, m_WP, m_whitepointXYZ_Strip); //LabInFinal is in Relative Colorimetric Space - m_GradStops[i].Lab.Set(LabOutFinal[0], LabOutFinal[1], LabOutFinal[2]); - } - //free vectors - if (LabOutV == NULL) - { - delete[] LabOutV; - LabOutV = NULL; - } - if (LabOutFinal == NULL) - { - delete[] LabOutFinal; - LabOutFinal = NULL; - } - if (InkOutL == NULL) - { - delete[] InkOutL; - InkOutL = NULL; - } + ProcessGradientStops(inputcoordinates); //are all stops in the same region? int maxreg = -10; int minreg = 10; for (int i = 0; i < m_nGradStops; ++i) { - maxreg = std::max(maxreg, m_GradStops[i].GamutRegion); - minreg = std::min(minreg, m_GradStops[i].GamutRegion); + GamutRegion = m_GradStops[i].Get_GamutRegion(); + maxreg = std::max(maxreg, GamutRegion); + minreg = std::min(minreg, GamutRegion); } //Choose Gamut Region for Gradient calculation - + bool same_regions = true; - if ((maxreg != minreg) & (maxreg>0)) + if ((maxreg != minreg) & (maxreg > 0)) same_regions = false; double dEThr = 0.8; //find intermediate points - int ninterstops = 300; + int ninterstops = 300; double **VecRGBOut = new double*[ninterstops]; double **VecLabOut = new double*[ninterstops]; double *posOut = new double[ninterstops]; @@ -3336,71 +2720,72 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c AllRGBOut_tmp[i] = new double[3]; AllLabOut_tmp[i] = new double[3]; } - AllRGBOut_tmp[0][0] = m_GradStops[0].RGB.Get_x(); - AllRGBOut_tmp[0][1] = m_GradStops[0].RGB.Get_y(); - AllRGBOut_tmp[0][2] = m_GradStops[0].RGB.Get_z(); - AllLabOut_tmp[0][0] = m_GradStops[0].Lab.Get_x(); - AllLabOut_tmp[0][1] = m_GradStops[0].Lab.Get_y(); - AllLabOut_tmp[0][2] = m_GradStops[0].Lab.Get_z(); - AllPos_tmp[0] = m_GradStops[0].offset; + AllRGBOut_tmp[0][0] = m_GradStops[0].Get_RGB().Get_x(); + AllRGBOut_tmp[0][1] = m_GradStops[0].Get_RGB().Get_y(); + AllRGBOut_tmp[0][2] = m_GradStops[0].Get_RGB().Get_z(); + AllLabOut_tmp[0][0] = m_GradStops[0].Get_Lab().Get_x(); + AllLabOut_tmp[0][1] = m_GradStops[0].Get_Lab().Get_y(); + AllLabOut_tmp[0][2] = m_GradStops[0].Get_Lab().Get_z(); + AllPos_tmp[0] = m_GradStops[0].Get_Offset(); int ncountStops = 0; int nPosStops = 0; double dOffset = 0; GradOffset OffsetType = EqSpaced; - for (int i = 0; i < m_nGradStops - 1; ++i) + + for (int iStop = 0; iStop < m_nGradStops - 1; ++iStop) { - findStops(m_GradStops[i], m_GradStops[i + 1], dEThr, ninterstops, nOut, VecRGBOut, VecLabOut, posOut); + findStops(m_GradStops[iStop], m_GradStops[iStop + 1], dEThr, ninterstops, nOut, VecRGBOut, VecLabOut, posOut); switch (OffsetType) { case EqSpaced: - if (i == m_nGradStops - 2) - dOffset = (m_GradStops[i + 1].offset - m_GradStops[i].offset)*GradientEndThr / (nOut - 1); + if (iStop == m_nGradStops - 2) + dOffset = (m_GradStops[iStop + 1].Get_Offset() - m_GradStops[iStop].Get_Offset())*GradientEndThr / (nOut - 1); else - dOffset = (m_GradStops[i + 1].offset - m_GradStops[i].offset) / (nOut - 1); - for (int j = 1; j < nOut; ++j) + dOffset = (m_GradStops[iStop + 1].Get_Offset() - m_GradStops[iStop].Get_Offset()) / (nOut - 1); + for (int jPos = 1; jPos < nOut; ++jPos) { nPosStops++; - AllPos_tmp[nPosStops] = m_GradStops[i].offset + dOffset * j; + AllPos_tmp[nPosStops] = m_GradStops[iStop].Get_Offset() + dOffset * jPos; } break; case dESpaced: - if (i == m_nGradStops - 2) - dOffset = (m_GradStops[i + 1].offset - m_GradStops[i].offset)*GradientEndThr / posOut[nOut - 1]; + if (iStop == m_nGradStops - 2) + dOffset = (m_GradStops[iStop + 1].Get_Offset() - m_GradStops[iStop].Get_Offset())*GradientEndThr / posOut[nOut - 1]; else - dOffset = (m_GradStops[i + 1].offset - m_GradStops[i].offset) / posOut[nOut - 1]; - for (int j = 0; j < nOut; ++j) + dOffset = (m_GradStops[iStop + 1].Get_Offset() - m_GradStops[iStop].Get_Offset()) / posOut[nOut - 1]; + for (int jPos = 0; jPos < nOut; ++jPos) { nPosStops++; - AllPos_tmp[nPosStops] = m_GradStops[i].offset + dOffset * posOut[j]; + AllPos_tmp[nPosStops] = m_GradStops[iStop].Get_Offset() + dOffset * posOut[jPos]; } break; } //store the stops in temporary vector - for (int i = 1; i < nOut; ++i) + for (int iCount = 1; iCount < nOut; ++iCount) { ncountStops++; - for (int j = 0; j < 3; ++j) + for (int jCS = 0; jCS < 3; ++jCS) { - AllRGBOut_tmp[ncountStops][j] = VecRGBOut[i][j]; - AllLabOut_tmp[ncountStops][j] = VecLabOut[i][j]; + AllRGBOut_tmp[ncountStops][jCS] = VecRGBOut[iCount][jCS]; + AllLabOut_tmp[ncountStops][jCS] = VecLabOut[iCount][jCS]; } } } if (VecRGBOut != NULL) { - for (int i = 0; i < nOut; ++i) + for (int i = 0; i < ninterstops; ++i) delete[]VecRGBOut[i]; delete[]VecRGBOut; } if (VecLabOut != NULL) { - for (int i = 0; i < nOut; ++i) + for (int i = 0; i < ninterstops; ++i) delete[]VecLabOut[i]; delete[]VecLabOut; VecLabOut = NULL; } - if (VecLabOut != NULL) + if (posOut != NULL) { delete[]posOut; posOut = NULL; @@ -3414,94 +2799,90 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c InputCoordinates **SubStops = (InputCoordinates**)malloc(sizeof(InputCoordinates*)*nTotalStops); //Calculate and store - for (int i = 0; i < nTotalStops; ++i) + for (int iTStops = 0; iTStops < nTotalStops; ++iTStops) { - SubStops[i] = (InputCoordinates*)malloc(sizeof(InputCoordinates)); - input_coordinates__init(SubStops[i]); - SubStops[i]->l = AllLabOut_tmp[i][0]; - SubStops[i]->a = AllLabOut_tmp[i][1]; - SubStops[i]->b = AllLabOut_tmp[i][2]; - SubStops[i]->red = (int)round(AllRGBOut_tmp[i][0]); - SubStops[i]->green = (int)round(AllRGBOut_tmp[i][1]); - SubStops[i]->blue = (int)round(AllRGBOut_tmp[i][2]); - } - -GradientOutputStop** outputStops = (GradientOutputStop**)malloc(sizeof(GradientOutputStop*) * nTotalStops); -conversionOutput->stops = outputStops; -conversionOutput->n_stops = nTotalStops; - -ColorSpace SubStopsCS = COLOR_SPACE__LAB; -//double NormFactor = m_ProcessRangesMaxP[m_nProcessRanges - 1] / 100.0; -VectorXd VolumeStop(m_nB2AnSepOut); -MatrixXd MatVolume(ncountStops, m_nB2AnSepOut); -for (int i = 0; i < ncountStops; ++i) -{ - GradientOutputStop *stop = (GradientOutputStop*)malloc(sizeof(GradientOutputStop)); - gradient_output_stop__init(stop); - ConvertGradStoptoVolume(SubStops[i], SubStopsCS, - VolumeStop, GamutRegion, same_regions); - //start filling Output - fillStop(stop, VolumeStop, GamutRegion, AllPos_tmp[i]); - MatVolume.row(i) = VolumeStop; - outputStops[i] = stop; -} -//Smooth Volumes -VectorXd VIn(ncountStops); -VectorXd VOut(ncountStops); -int FilterWidth = 7; -for (int i = 0; i < m_nB2AnSepOut; ++i) -{ - for (int j = 0; j < ncountStops; ++j) - VIn(j) = MatVolume(j, i); - SmoothCurveData(VIn, VOut, FilterWidth); - for (int j = 0; j < ncountStops; ++j) - outputStops[j]->outputliquids[i]->volume = VOut(j); -} -//Temp Output -/*for (int i = 0; i < ncountStops; ++i) -{ - fprintf(stdout, "%d\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\n", i, outputStops[i]->offset, outputStops[i]->outputliquids[0]->volume, - outputStops[i]->outputliquids[1]->volume, outputStops[i]->outputliquids[2]->volume, outputStops[i]->outputliquids[3]->volume); -}*/ -//release memory -if(AllLabOut_tmp != NULL) -{ - for (int i = 0; i < nmaxstops; ++i) - delete[] AllLabOut_tmp[i]; - delete[] AllLabOut_tmp; - AllLabOut_tmp = NULL; -} -if (AllRGBOut_tmp != NULL) -{ - for (int i = 0; i < nmaxstops; ++i) - delete[] AllRGBOut_tmp[i]; - delete[] AllRGBOut_tmp; - AllRGBOut_tmp = NULL; -} -if (AllPos_tmp != NULL) -{ - delete[] AllPos_tmp; - AllPos_tmp = NULL; -} + SubStops[iTStops] = (InputCoordinates*)malloc(sizeof(InputCoordinates)); + input_coordinates__init(SubStops[iTStops]); + SubStops[iTStops]->l = AllLabOut_tmp[iTStops][0]; + SubStops[iTStops]->a = AllLabOut_tmp[iTStops][1]; + SubStops[iTStops]->b = AllLabOut_tmp[iTStops][2]; + SubStops[iTStops]->red = (int)round(AllRGBOut_tmp[iTStops][0]); + SubStops[iTStops]->green = (int)round(AllRGBOut_tmp[iTStops][1]); + SubStops[iTStops]->blue = (int)round(AllRGBOut_tmp[iTStops][2]); + } + + GradientOutputStop** outputStops = (GradientOutputStop**)malloc(sizeof(GradientOutputStop*) * nTotalStops); + conversionOutput->stops = outputStops; + conversionOutput->n_stops = nTotalStops; + + ColorSpace SubStopsCS = COLOR_SPACE__LAB; + //double NormFactor = m_ProcessRangesMaxP[m_nProcessRanges - 1] / 100.0; + VectorXd VolumeStop(m_nInks); + MatrixXd MatVolume(ncountStops, m_nInks); + for (int iS = 0; iS < ncountStops; ++iS) + { + GradientOutputStop *stop = (GradientOutputStop*)malloc(sizeof(GradientOutputStop)); + gradient_output_stop__init(stop); + ConvertGradStoptoVolume(SubStops[iS], SubStopsCS, + VolumeStop, GamutRegion, same_regions); + //start filling Output + fillStop(stop, VolumeStop, GamutRegion, AllPos_tmp[iS]); + MatVolume.row(iS) = VolumeStop; + outputStops[iS] = stop; + } + //Smooth Volumes + VectorXd VIn(ncountStops); + VectorXd VOut(ncountStops); + int FilterWidth = 7; + for (int iSep = 0; iSep < m_nInks; ++iSep) + { + for (int jStop = 0; jStop < ncountStops; ++jStop) + VIn(jStop) = MatVolume(jStop, iSep); + SmoothCurveData(VIn, VOut, FilterWidth); + for (int jS = 0; jS < ncountStops; ++jS) + outputStops[jS]->outputliquids[iSep]->volume = VOut(jS); + } + //Temp Output + /*for (int i = 0; i < ncountStops; ++i) + { + fprintf(stdout, "%d\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\n", i, outputStops[i]->offset, outputStops[i]->outputliquids[0]->volume, + outputStops[i]->outputliquids[1]->volume, outputStops[i]->outputliquids[2]->volume, outputStops[i]->outputliquids[3]->volume); + }*/ + //release memory + if (AllLabOut_tmp != NULL) + { + for (int i = 0; i < nmaxstops; ++i) + delete[] AllLabOut_tmp[i]; + delete[] AllLabOut_tmp; + AllLabOut_tmp = NULL; + } + if (AllRGBOut_tmp != NULL) + { + for (int i = 0; i < nmaxstops; ++i) + delete[] AllRGBOut_tmp[i]; + delete[] AllRGBOut_tmp; + AllRGBOut_tmp = NULL; + } + if (AllPos_tmp != NULL) + { + delete[] AllPos_tmp; + AllPos_tmp = NULL; + } -for (int i=0; i< m_nGradStops; ++i) - input_coordinates__free_unpacked(inputcoordinates[i], NULL); -free(inputcoordinates); -inputcoordinates = NULL; -for (int i = 0; i < nTotalStops; ++i) - input_coordinates__free_unpacked(SubStops[i], NULL); -free(SubStops); -SubStops = NULL; + for (int i = 0; i < m_nGradStops; ++i) + input_coordinates__free_unpacked(inputcoordinates[i], NULL); + free(inputcoordinates); + inputcoordinates = NULL; + for (int i = 0; i < nTotalStops; ++i) + input_coordinates__free_unpacked(SubStops[i], NULL); + free(SubStops); + SubStops = NULL; } -void Tango::ColorLib::ColorConverter::NormGamutRegionMaxLim() -{ - double GamutRegionMaxLim0 = m_GamutRegionMaxLim[0]; - for (int i = 0; i < m_nProcessRanges; ++i) - m_GamutRegionMaxLim[i] = 100 * m_GamutRegionMaxLim[i] / GamutRegionMaxLim0; -} + + void Tango::ColorLib::ColorConverter::fillStop(GradientOutputStop *&stop, VectorXd Volume, int GamutRegion, double Position) { @@ -3557,28 +2938,41 @@ void Tango::ColorLib::ColorConverter::GradInput2InputCoords(GradientConversionI inputcoordinates[i]->has_a = true; inputcoordinates[i]->has_b = true; break; - case COLOR_SPACE__Volume: //Case Volume - for (int j = 0; j < (int)conversionInput->stops[i]->n_liquidvolumes; j++) + case COLOR_SPACE__Volume: //Case Volume + int size= (int)conversionInput->stops[i]->n_liquidvolumes; + InputLiquid** InputLiquidsIC = (InputLiquid**)malloc(sizeof(InputLiquid*) *size); + for (int j = 0; j < size; j++) + { + InputLiquidsIC[j] = (InputLiquid*)malloc(sizeof(InputLiquid)); + input_liquid__init(InputLiquidsIC[j]); + } + for (size_t j= 0; j< (int)conversionInput->stops[i]->n_liquidvolumes; j++) { LiquidVolume* liquidVolume = conversionInput->stops[i]->liquidvolumes[j]; - switch (liquidVolume->liquidtype) { case LIQUID_TYPE__Cyan: - inputcoordinates[i]->inputliquids[0]->liquidtype = LIQUID_TYPE__Cyan; - inputcoordinates[i]->inputliquids[0]->volume = liquidVolume->volume; +// inputcoordinates[i]->inputliquids[0]->volume = liquidVolume->volume; + InputLiquidsIC[0]->volume = liquidVolume->volume; + InputLiquidsIC[0]->liquidtype = LIQUID_TYPE__Cyan; + break; case LIQUID_TYPE__Magenta: - inputcoordinates[i]->inputliquids[1]->liquidtype = LIQUID_TYPE__Magenta; - inputcoordinates[i]->inputliquids[1]->volume = liquidVolume->volume; + InputLiquidsIC[1]->volume = liquidVolume->volume; + InputLiquidsIC[1]->liquidtype = LIQUID_TYPE__Magenta; + break; case LIQUID_TYPE__Yellow: - inputcoordinates[i]->inputliquids[2]->liquidtype = LIQUID_TYPE__Yellow; - inputcoordinates[i]->inputliquids[2]->volume = liquidVolume->volume; + InputLiquidsIC[2]->volume = liquidVolume->volume; + InputLiquidsIC[2]->liquidtype = LIQUID_TYPE__Yellow; + break; case LIQUID_TYPE__Black: - inputcoordinates[i]->inputliquids[3]->liquidtype = LIQUID_TYPE__Black; - inputcoordinates[i]->inputliquids[3]->volume = liquidVolume->volume; + InputLiquidsIC[3]->volume = liquidVolume->volume; + InputLiquidsIC[3]->liquidtype = LIQUID_TYPE__Black; + break; } + } - break; + inputcoordinates[i]->inputliquids = InputLiquidsIC; + inputcoordinates[i]->n_inputliquids = size; } } } @@ -3603,7 +2997,7 @@ int Tango::ColorLib::ColorConverter::GetGamutRegion(VectorXd Volume, double *Ga int GamutRegion = 0; for (int i = 0; i < m_nInks; ++i) TotalVolume += Volume(i); - for (int i=0; iGetnGamutRegions(); ++i) { if (TotalVolume > GamutLimits[i]) GamutRegion++; @@ -3626,4 +3020,89 @@ void Tango::ColorLib::ColorConverter::SmoothCurveData(VectorXd VIn, VectorXd &VO } for (int j = 0; j < Vlength; ++j) VOut(j) = VIn(j); +} + +void Tango::ColorLib::ColorConverter::ProcessGradientStops(InputCoordinates **inputcoordinates) +{ + VectorXd Volume(m_nInks); + VectorXd RGBOut(m_nInks); + VectorXd LabOut(m_nInks); + VectorXd InkOut(m_nInks); + VectorXd NLInkOut(m_nInks); + double * InkOutL = new double[m_nInks]; + double * LabOutV = new double[3]; + double * LabOutFinal = new double[3]; + + ColorConvert CConvertD65(D65, D65); + + bool InGamut = true; + int GamutRegion = 0; + for (int i = 0; i < m_nGradStops; ++i) + { + if (m_GradStops[i].Get_ColorSpace() == COLOR_SPACE__Volume || m_GradStops[i].Get_ColorSpace() == COLOR_SPACE__Catalog) + { //Convert volume to Lab + //Convert lab to rgb + ConvertVolumeToRGBDisplay(inputcoordinates[i], m_nProcessRanges, m_GradStops[i].Get_ColorSpace(), Volume, RGBOut, LabOut, GamutRegion); + //store data + C_RGB_XYZ_Lab Lab(LabOut); + C_RGB_XYZ_Lab RGB(RGBOut); + m_GradStops[i].Set_Lab(LabOut); + m_GradStops[i].Set_RGB(RGBOut); + m_GradStops[i].Set_GamutRegion( GamutRegion); + m_GradStops[i].SetInGamut (true); + } + else + { + ConvertColorToLinearInks(inputcoordinates[i], m_GradStops[i].Get_ColorSpace(), InkOut, RGBOut, LabOut, GamutRegion, InGamut); + //Inks are in Linear Space , convert to nonlinear by using Calibration Tables, + // Right now calibration is in the [0-100] range, values exceeding [0-100] are not transformed + + ConvertToNLInks(InkOut, NLInkOut); + LimitInks(NLInkOut, InkOutL); + NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); + GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); + NLcmtoPercentage(Volume, Volume); + + //fill data + //fill volume + //allocate m_GradStops[i].Volume + C_RGB_XYZ_Lab Lab(LabOut); + C_RGB_XYZ_Lab RGB(RGBOut); + for (int j = 0; j < m_nInks; ++j) + m_GradStops[i].SetVolumeValue(Volume[j], j); + m_GradStops[i].Set_GamutRegion(GamutRegion); + m_GradStops[i].SetInGamut(InGamut); + //LabOut and RGBOut might be different if the input was out of gamut + m_GradStops[i].Set_Lab(LabOut); + m_GradStops[i].Set_RGB(RGBOut); + } + //Convert Lab Values to Relative Colorimetric. These values will be used in the Gradient Volume calculation. + VectorToDouble(LabOut, LabOutV); + /* if (m_AdaptWP) + { + CConvertD65.ChangeWP(LabOutV, LabOutV, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); //to Color Tables + } + */ + //double *LabInFinal2 = DBG_NEW double[3]; + // CConvertD65.ChangeWP(LabOutV, LabOutFinal, m_WP, m_whitepointXYZ_CT); //LabInFinal is in Relative Colorimetric Space + CConvertD65.ChangeWP(LabOutV, LabOutFinal, m_WP, m_whitepointXYZ_Strip); //LabInFinal is in Relative Colorimetric Space + C_RGB_XYZ_Lab LabOut1(LabOutFinal[0], LabOutFinal[1], LabOutFinal[2]); + m_GradStops[i].Set_Lab(LabOut1); + } + //free vectors + if (LabOutV != NULL) + { + delete[] LabOutV; + LabOutV = NULL; + } + if (LabOutFinal != NULL) + { + delete[] LabOutFinal; + LabOutFinal = NULL; + } + if (InkOutL != NULL) + { + delete[] InkOutL; + InkOutL = NULL; + } } \ No newline at end of file diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h index 4563a2627..7aec6d993 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h @@ -8,6 +8,7 @@ #include "ColorTransf.h" #include "ColorConvert.h" #include "GBD.h" +#include "CT_Header.h" #include "ConversionOutput.pb-c.h" #include "CalibrationData.pb-c.h" #include "ConversionInput.pb-c.h" @@ -17,11 +18,13 @@ #include "GradientConversionOutput.pb-c.h" #include "Interp.h" #include "Curves.h" +#include "Gradient.h" +#include "ColorTable.h" #pragma once namespace Tango { - typedef struct +/* typedef struct { unsigned int TblSIze = 0; unsigned int Version[3] = { 0,0,0 }; @@ -31,9 +34,9 @@ namespace Tango C_RGB_XYZ_Lab Illuminant; unsigned char nGamutRegions=0; double *GRegMaxLim; - } CT_Header; + } CT_Header; */ - typedef struct +/* typedef struct { C_RGB_XYZ_Lab Lab; C_RGB_XYZ_Lab RGB; @@ -42,7 +45,7 @@ namespace Tango int GamutRegion; double offset; ColorSpace colorspace; - }GradStruct; + }GradStruct;*/ /*typedef enum { XYZ, @@ -56,19 +59,7 @@ namespace Tango dESpaced }GradOffset; - typedef enum { - A2B, - A2BR, - B2A, - B2AR, - cprt, - gbd, - gbdR, - wtpt, - desc, - lcrv -// GReg - }TagList; + namespace ColorLib { @@ -95,57 +86,33 @@ namespace Tango void SetMaxNLperCM(double maxNlPerCM, int i); size_t P_IsInGamut(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); private: - ColorTransf *m_B2ATransform; - ColorTransf *m_A2BTransform; - ColorTransf *m_B2ARTransform; - ColorTransf *m_A2BRTransform; -// ColorTransf *m_GRegTransform; - GBD *m_GBD; - GBD *m_GBDR; - Curves *m_LinCurves; + ColorTable *m_colortable; ColorConvert *m_Conv02; // Interp *m_LinInterp; // Interp *m_InvLinInterp; C_RGB_XYZ_Lab m_whitepointLab; C_RGB_XYZ_Lab m_whitepointXYZ_Strip; - C_RGB_XYZ_Lab m_whitepointXYZ_CT; + double *m_NormGamutRegionMaxLim; + double *m_ProcessRangesMaxP; + int m_nProcessRanges; void LimitLab(double* LabIn); - int m_nGamutRegions; int m_nGradStops; - GradStruct *m_GradStops; - double *m_GamutRegionMaxLim; - int m_nB2AnSepIn; - int m_nB2AnSepOut; - int m_nA2BnSepIn; - int m_nA2BnSepOut; + Gradient *m_GradStops; bool same_regions; // bool m_AdaptWP; CalibData *m_CalibCurves; int m_nInks; int m_nVolumes; - int m_nProcessRanges; - //double *m_ProcessRangesMinP; - double *m_ProcessRangesMaxP; - double m_NormFactor; - int m_TableVersion; - double m_InvNormFactor; //double *m_ProcessRangesMaxInkUptake; //double *m_ProcessRangesMinInkUptake; C_RGB_XYZ_Lab m_WP; VectorXd m_maxNlPerCM; - void SetnB2AnSepIn(int nB2AnSepIn) { m_nB2AnSepIn = nB2AnSepIn; }; - void SetnB2AnSepOut(int nB2AnSepOut) { m_nB2AnSepOut = nB2AnSepOut; }; - void SetnA2BnSepIn(int nA2BnSepIn) { m_nA2BnSepIn = nA2BnSepIn; }; - void SetnA2BnSepOut(int nA2BnSepOut) { m_nA2BnSepOut = nA2BnSepOut; }; - void SetnGamutRegions(int nGamutRegions) { m_nGamutRegions = nGamutRegions; }; - void SetTableVersion(int TableVersion) { m_TableVersion = TableVersion; }; void readColorTransformations(ConversionInput* conversionInput); - void readColorTables(bool has_rddata, uint8_t *data, int nprocessranges); +// void readColorTables(bool has_rddata, uint8_t *data, int nprocessranges); void readCalibrationTables(InputLiquid **inputliquids, int n_inputliquids); void SetCalibData(CalibrationData* calibrationData, int i, CalibData *tmpCurve); void SetNumberofInks(int nInks) { m_nInks = nInks; }; void SetNumberOfVolumes(int nVol) { m_nVolumes = nVol; }; - void SetNumberOfInks(int nInks) { m_nInks = nInks; }; // void InitInterpolations(int numofInks, Interp *linearInterp, Interp *InvLinearInterp); void fillRGB(OutputCoordinates *outputCoords, VectorXd RGBOut); void fillLab(OutputCoordinates *outputCoords, VectorXd LabOut); @@ -165,24 +132,26 @@ namespace Tango VectorXd DoubleToVector(double *doub, int nSize); void CompareWhitePoints(); bool IsInGamut(double *InLab, SURROUND sur, CAM02CS CS, double *LabCoord); - CT_Header read_header(uint8_t* data, int &bytesread); +// CT_Header *read_header(uint8_t* data, int &bytesread); void read_lut_type(int offset, int data_size, ColorTransf *Transf, ConversionInput* conversionInput); - void read_xyz_type(int offset, int data_size, C_RGB_XYZ_Lab *xyz, uint8_t *data); - void read_text_type(int offset, int data_size, std::string *textstr, - uint8_t *data); - void read_text_description_type(int offset, int data_size, std::string textdescstr, - uint8_t *data); - void findStops(GradStruct m_GradStops1, GradStruct m_GradStops2, double dEThr, int ninterstops, int &nOut, + void findStops(Gradient& m_GradStops1, Gradient& m_GradStops2, double dEThr, int ninterstops, int &nOut, double **VecRGBOut, double **VecLabOut, double *posOut); - void SetNormFactor(); - void SetInverseNormFactor(); - void NormGamutRegionMaxLim(); void GradInput2InputCoords(GradientConversionInput *conversionInput, InputCoordinates **inputcoordinates); + void ProcessGradientStops(InputCoordinates **inputcoordinates); void PrepareGradient(GradientConversionInput* conversionInput, GradientConversionOutput *conversionOutput); void LimitInks(VectorXd inInks, double *BoundedInks); void NLcmtoPercentage(VectorXd InVolume, VectorXd &OutVolume); int GetGamutRegion(VectorXd Volume, double *GamutLimits); void SmoothCurveData(VectorXd VIn, VectorXd &VOut, int FilterWidth); + void ConvertRGBColorToLinearInks(InputCoordinates* inputcoordinates, + VectorXd &InkOut, VectorXd &RGBOut, + VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS); + void ConvertLabColorToLinearInks(InputCoordinates* inputcoordinates, + VectorXd &InkOut, VectorXd &RGBOut, + VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS); + void ConvertCMYKColorToLinearInks(InputCoordinates* inputcoordinates, + VectorXd &InkOut, VectorXd &RGBOut, + VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS); }; } } diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj index 5c9365f84..e12055f28 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj @@ -192,10 +192,13 @@ + + + @@ -229,10 +232,13 @@ + + + diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj.filters b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj.filters index 3c6c1330d..5ebaedebc 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj.filters +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Tango.ColorLib_v4.vcxproj.filters @@ -141,6 +141,15 @@ PMR + + Utils + + + Utils + + + Utils + @@ -248,5 +257,14 @@ PMR + + Utils + + + Utils + + + Utils + \ No newline at end of file diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.cpp new file mode 100644 index 000000000..5e419f711 --- /dev/null +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.cpp @@ -0,0 +1,83 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif +#include "CT_Header.h" +#include +#include +#include + +CT_Header::CT_Header() : + m_Version(NULL), m_ColorSpace(NULL), m_ConnectionSpace(NULL), m_TblSize(0), + m_DeviceManufacturer(NULL), m_Illuminant(0), m_nGamutRegions(0), m_GRegMaxLim(NULL) +{ + +} + +CT_Header::~CT_Header() +{ + if (m_Version != NULL) + { + delete[]m_Version; + m_Version = NULL; + } + if (m_ColorSpace != NULL) + { + delete m_ColorSpace; + m_ColorSpace = NULL; + } + if (m_ConnectionSpace != NULL) + { + delete m_ConnectionSpace; + m_ConnectionSpace = NULL; + } + if (m_DeviceManufacturer != NULL) + { + delete m_DeviceManufacturer; + m_DeviceManufacturer = NULL; + } + if (m_GRegMaxLim != NULL) + { + delete[]m_GRegMaxLim; + m_GRegMaxLim = NULL; + } +} + +void CT_Header::SetTableVersion(unsigned int *Version) +{ + m_Version = new unsigned int[3]; + for (int i = 0; i < 3; ++i) + m_Version[i] = Version[i]; +} + +C_RGB_XYZ_Lab CT_Header::GetIlluminant() { + return(m_Illuminant); +}; + +void CT_Header::SetColorSpace(char *ColorSPace) +{ + int nsize = sizeof(ColorSPace); + m_ColorSpace = new char[nsize]; + strcpy(m_ColorSpace, ColorSPace); +} + +void CT_Header :: SetConnectionSpace(char *ConnectionSpace) +{ + int nsize = sizeof(ConnectionSpace); + m_ConnectionSpace = new char[nsize]; + strcpy(m_ConnectionSpace, ConnectionSpace); +} + +void CT_Header::SetDeviceManufacturer(char *DeviceManufacturer) +{ + int nsize = sizeof(DeviceManufacturer); + m_DeviceManufacturer = new char[nsize]; + strcpy(m_DeviceManufacturer, DeviceManufacturer); +} + +void CT_Header::SetGamutRegionsMaxLimit(double *GRegMaxLim) +{ + if (m_GRegMaxLim == NULL) + m_GRegMaxLim = new double[m_nGamutRegions]; + for (int i = 0; i < m_nGamutRegions; ++i) + m_GRegMaxLim[i] = GRegMaxLim[i]; +} diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.h new file mode 100644 index 000000000..6476a82cc --- /dev/null +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/CT_Header.h @@ -0,0 +1,57 @@ +#ifndef _CT_HEADER_H_ +#define _CT_HEADER_H_ +#pragma once +#include +#include "C_RGB_XYZ_Lab.h" + +class CT_Header { +public: + CT_Header(); + ~CT_Header(); + unsigned int GetTableSize() { return(m_TblSize); }; + void SetTableSize(unsigned int TableSize) { + m_TblSize = TableSize; + }; + unsigned int *GetTableVersion() { return(m_Version); }; + void SetTableVersion(unsigned int *version); + char* GetColorSpace() { + return(m_ColorSpace); + }; + void SetColorSpace(char *ColorSPace); + char* GetConnectionSpace() { + return(m_ConnectionSpace); + }; + void SetConnectionSpace(char *ConnectionSpace); + + char* GetDeviceManufacturer() { + return(m_DeviceManufacturer); + }; + void SetDeviceManufacturer(char *DeviceManufacturer); + + C_RGB_XYZ_Lab GetIlluminant(); + + void SetIlluminant(C_RGB_XYZ_Lab Illuminant) { + m_Illuminant = Illuminant; + }; + + void SetNGamutRegions(unsigned char GamutRegions) { + m_nGamutRegions = GamutRegions; + }; + unsigned char GetNGamutRegions() { + return(m_nGamutRegions); + }; + void SetGamutRegionsMaxLimit(double *GRegMaxLim); + double *GetGamutRegionsMaxLimit() { return(m_GRegMaxLim); }; + +private: + unsigned int *m_Version; + char *m_ColorSpace; + char * m_ConnectionSpace; + char * m_DeviceManufacturer; + C_RGB_XYZ_Lab m_Illuminant; + unsigned char m_nGamutRegions ; + double *m_GRegMaxLim; + unsigned int m_TblSize; +}; + +#endif \ No newline at end of file diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.cpp new file mode 100644 index 000000000..9bdadeb3f --- /dev/null +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.cpp @@ -0,0 +1,645 @@ +#include "ColorTable.h" +#include "NumConversions.h" + +using namespace std; + +//Constructor +ColorTable::ColorTable() : + m_B2ATransform(NULL), m_A2BTransform(NULL), +m_B2ARTransform(NULL), m_A2BRTransform(NULL), +m_GBD(NULL), m_GBDR(NULL), m_LinCurves(NULL), +m_nB2AnSepIn(0), m_nB2AnSepOut(0), +m_nA2BnSepIn(0), m_nA2BnSepOut(0), +m_TableVersion(0), m_NormFactor(0.0), m_InvNormFactor(1.0), +m_nGamutRegions(0), m_nProcessRanges(0), +m_GamutRegionMaxLim(NULL), m_whitepointXYZ_CT(0.0) +{ +} + +ColorTable::~ColorTable() +{ + if (m_B2ATransform != NULL) + { + delete m_B2ATransform; + m_B2ATransform = NULL; + } + if (m_B2ARTransform != NULL) + { + delete m_B2ARTransform; + m_B2ARTransform = NULL; + } + if (m_A2BTransform != NULL) + { + delete m_A2BTransform; + m_A2BTransform = NULL; + } + if (m_A2BRTransform != NULL) + { + delete m_A2BRTransform; + m_A2BRTransform = NULL; + } + if (m_GBD != NULL) + { + delete m_GBD; + m_GBD = NULL; + } + if (m_GBDR != NULL) + { + delete m_GBDR; + m_GBDR = NULL; + } + if (m_LinCurves != NULL) + { + delete m_LinCurves; + m_LinCurves = NULL; + } + if (m_GamutRegionMaxLim != NULL) + { + delete[] m_GamutRegionMaxLim; + m_GamutRegionMaxLim = NULL; + } +} +void ColorTable::InitColorTables(bool has_rddata, uint8_t *data, int nprocessranges) +{ + readColorTables(has_rddata, data, nprocessranges); + SetNormFactor(); + SetInverseNormFactor(); + NormGamutRegionMaxLim(); +} +void ColorTable::readColorTables(bool has_data, uint8_t * data, int nprocessranges) +{ + //parse Color Tansformations, placed in forward data + int bytesread = 0; + NumConversions conv; + int tag_count = 0; + int TblVer = 0; + if (has_data) + { + //Read Header + CT_Header *header = read_header(data, bytesread); + SetnGamutRegions((int)(header->GetNGamutRegions())); + TblVer = (int)header->GetTableVersion()[0]; + SetTableVersion(TblVer); + if (m_nGamutRegions != nprocessranges) + { + throw std::exception("Number of gamut regions in table does not match STRIP\0"); + return; + } + double *tmpGamutRegionsLim = header->GetGamutRegionsMaxLimit(); + m_GamutRegionMaxLim = new double[m_nGamutRegions]; + for (int i = 0; i < m_nGamutRegions; ++i) + m_GamutRegionMaxLim[i] = tmpGamutRegionsLim[i]; + + m_nProcessRanges = (int)(nprocessranges); + + uint32_t tmp; + uint8_t *buff = data; + tmp = conv.ByteToInt(buff, bytesread); + tag_count = (int)tmp; + bytesread += 4; + //read Tag Table + char **TagNames = new char*[tag_count]; + //char **TagNames = DBG_NEW char*[tag_count]; + int **TagSize = new int*[tag_count]; + //int **TagSize = DBG_NEW int*[tag_count]; + char *tmpC = new char[80]; + int n = 0; + int i, j; + for (i = 0; i < tag_count; ++i) + { + TagSize[i] = new int[2]; + //TagSize[i] = DBG_NEW int[3]; + tmp = conv.ByteToInt(buff, bytesread); + n = sizeof((char*)&tmp); + //tmpC = DBG_NEW char[n]; + conv.getchar(tmp, n, tmpC); + //TagNames[i] = DBG_NEW char[n]; + TagNames[i] = new char[n]; + for (j = 0; j < n; ++j) + TagNames[i][j] = tmpC[j]; + bytesread += 4; + TagSize[i][0] = conv.ByteToInt(buff, bytesread); + bytesread += 4; + TagSize[i][1] = conv.ByteToInt(buff, bytesread); + bytesread += 4; + } + if (tmpC != NULL) + { + delete[] tmpC; + tmpC = NULL; + } + + + int *TList = new int[tag_count]; + //int *TList = DBG_NEW int[tag_count]; + for (int k = 0; k < tag_count; ++k) + { + if (strncmp(TagNames[k], "A2B ", 4) == 0) + TList[k] = A2B; + else if (strncmp(TagNames[k], "A2BR", 4) == 0) + TList[k] = A2BR; + else if (strncmp(TagNames[k], "B2A ", 4) == 0) + TList[k] = B2A; + else if (strncmp(TagNames[k], "B2AR ", 4) == 0) + TList[k] = B2AR; + else if (strncmp(TagNames[k], "wtpt", 4) == 0) + TList[k] = wtpt; + else if (strncmp(TagNames[k], "desc", 4) == 0) + TList[k] = desc; + else if (strncmp(TagNames[k], "gbd ", 4) == 0) + TList[k] = gbd; + else if (strncmp(TagNames[k], "gbdR", 4) == 0) + TList[k] = gbdR; + else if (strncmp(TagNames[k], "cprt", 4) == 0) + TList[k] = cprt; + else if (strncmp(TagNames[k], "lcrv", 4) == 0) + TList[k] = lcrv; + // else if (strncmp(TagNames[k], "GReg", 2) == 0) + // TList[k] = GReg; + else + throw std::exception("Unknown Tag in Color Tables"); + } + + if (TagNames != NULL) + { + for (int i = 0; i < tag_count; ++i) + { + delete[] TagNames[i]; + TagNames[i] = NULL; + } + delete[]TagNames; + TagNames = NULL; + } + for (int k = 0; k < tag_count; ++k) + { + switch (TList[k]) + { + case A2B: + { + uint8_t *A2BLUT = &(data[TagSize[k][0]]); + int A2BLutsize = TagSize[k][1]; + m_A2BTransform = new ColorTransf(); + //m_A2BTransform = DBG_NEW ColorTransf(); + m_A2BTransform->InitData(A2BLUT, A2BLutsize); + m_nA2BnSepIn = m_A2BTransform->GetSeparationsIn(); + m_nA2BnSepOut = m_A2BTransform->GetSeparationsOut(); + break; + } + case A2BR: + { + uint8_t *A2BRLUT = &(data[TagSize[k][0]]); + int A2BRLutsize = TagSize[k][1]; + m_A2BRTransform = new ColorTransf(); + //m_A2BTransform = DBG_NEW ColorTransf(); + m_A2BRTransform->InitData(A2BRLUT, A2BRLutsize); + break; + } + case B2A: + { + uint8_t *B2ALUT = &(data[TagSize[k][0]]); + int B2ALutsize = TagSize[k][1]; + m_B2ATransform = new ColorTransf(); + //m_B2ATransform = DBG_NEW ColorTransf(); + m_B2ATransform->InitData(B2ALUT, B2ALutsize); + m_nB2AnSepIn = m_B2ATransform->GetSeparationsIn(); + m_nB2AnSepOut = m_B2ATransform->GetSeparationsOut(); + break; + } + case B2AR: + { + uint8_t *B2ARLUT = &(data[TagSize[k][0]]); + int B2ARLutsize = TagSize[k][1]; + m_B2ARTransform = new ColorTransf(); + //m_B2ATransform = DBG_NEW ColorTransf(); + m_B2ARTransform->InitData(B2ARLUT, B2ARLutsize); + break; + } + /* case GReg: + { + uint8_t *GRegLUT = &(conversionInput->forwarddata.data[TagSize[k][0]]); + int GRegLutsize = TagSize[k][1]; + m_GRegTransform = new ColorTransf(); + //m_B2ATransform = DBG_NEW ColorTransf(); + m_GRegTransform->InitData(GRegLUT, GRegLutsize); + break; + } */ + case gbd: + { + uint8_t *GBDList = &(data[TagSize[k][0]]); + m_GBD = new GBD(); + //m_GBD = DBG_NEW GBD(); + int GBDSize = TagSize[k][1]; + m_GBD->InitData(GBDList, GBDSize); + break; + } + case gbdR: + { + uint8_t *GBDRList = &(data[TagSize[k][0]]); + m_GBDR = new GBD(); + //m_GBD = DBG_NEW GBD(); + int GBDRSize = TagSize[k][1]; + m_GBDR->InitData(GBDRList, GBDRSize); + break; + } + case lcrv: + { + uint8_t *CurvesData = &(data[TagSize[k][0]]); + m_LinCurves = new Curves(); + int CurvesSize = TagSize[k][1]; + m_LinCurves->InitData(CurvesData, CurvesSize); + break; + } + case wtpt: + { + read_xyz_type(TagSize[k][0], TagSize[k][1], &m_whitepointXYZ_CT, data); + + break; + } + case cprt: + { + std::string textstr; + read_text_type(TagSize[k][0], TagSize[k][1], &textstr, data); + break; + } + case desc: + { + std::string textdescstr; + read_text_description_type(TagSize[k][0], TagSize[k][1], textdescstr, data); + break; + } + default: + { + throw std::exception("Unresolved Tag in Color Tables"); + return; + } + + } + } + + if (TagSize != NULL) + { + for (int i = 0; i < tag_count; ++i) + { + delete[] TagSize[i]; + TagSize[i] = NULL; + } + delete[]TagSize; + TagSize = NULL; + } + if (TList != NULL) + { + delete[] TList; + TList = NULL; + } + if (header != NULL) + { + delete header; + header = NULL; + } + } + + + //Verify all relevant tags had been read + if (m_A2BTransform == NULL) + { + throw std::exception("Missing Forward Transform in Color Tables"); + return; + } + if (m_A2BRTransform == NULL) + { + throw std::exception("Missing Reduced Forward Transform in Color Tables"); + return; + } + if (m_B2ATransform == NULL) + { + throw std::exception("Missing Inverse Transform in Color Tables"); + return; + } + if (m_B2ARTransform == NULL) + { + throw std::exception("Missing Reduced Inverse Transform in Color Tables"); + return; + } + if (m_GBD == NULL) + { + throw std::exception("Missing Gamut Boundary Descriptor in Color Tables"); + return; + } + if (m_GBDR == NULL) + { + throw std::exception("Missing Reduced Gamut Boundary Descriptor in Color Tables"); + return; + } + if ((m_whitepointXYZ_CT.Get_x() == -1) && (m_whitepointXYZ_CT.Get_y() == -1) && (m_whitepointXYZ_CT.Get_z() == -1)) + { + throw std::exception("Missing Whitepoint in Color Tables"); + return; + } + if (m_LinCurves == NULL) + { + throw std::exception("Missing Linear Curves in Color Tables"); + return; + } + return; // OK +} + +CT_Header *ColorTable::read_header(uint8_t *data, int &bytesread) +{ + //CT_Header *Header = new CT_Header; + //CT_Header *Header = DBG_NEW CT_Header; + CT_Header *Header = new CT_Header; + + // unsigned int tmp = (buffer[2 * i + 1] << 8) | buffer[2 * i]; + uint8_t *ColorTableData = data; + //File Size + NumConversions Conv; + unsigned int TblSize = Conv.ByteToInt(ColorTableData, bytesread); + Header->SetTableSize(TblSize); + bytesread = 4; + uint8_t versionBCT[2]; + versionBCT[0] = (unsigned int)ColorTableData[bytesread]; + bytesread += 1; + versionBCT[1] = (unsigned int)ColorTableData[bytesread]; + unsigned int TVersion[3]; + TVersion[0] = versionBCT[0]; + TVersion[1] = versionBCT[1] << 4; + TVersion[2] = versionBCT[1] & 15; + Header->SetTableVersion(TVersion); + + bytesread += 1; + uint32_t tmp = Conv.ByteToInt(ColorTableData, bytesread); + int n = sizeof((char*)&tmp); + //char *tmpC = DBG_NEW char[n]; + char *tmpC_CS = new char[n]; + Conv.getchar(tmp, n, tmpC_CS); + //Header.ColorSpace = DBG_NEW char[n]; + Header->SetColorSpace(tmpC_CS); + if (tmpC_CS != NULL) + { + delete [] tmpC_CS; + tmpC_CS = NULL; + } + bytesread += 4; + tmp = Conv.ByteToInt(ColorTableData, bytesread); + n = sizeof((char*)&tmp); + char *tmp_connectionspace = new char[n]; + Conv.getchar(tmp, n, tmp_connectionspace); + //Header.ConnectionSpace = DBG_NEW char[n]; + Header->SetConnectionSpace(tmp_connectionspace); + if (tmp_connectionspace != NULL) + { + delete[] tmp_connectionspace; + tmp_connectionspace = NULL; + } + + bytesread += 4; + + bytesread += 12; + tmp = Conv.ByteToInt(ColorTableData, bytesread); + n = sizeof((char*)&tmp); + char *tmp_DM = new char[n]; + Conv.getchar(tmp, n, tmp_DM); + //Header.DeviceManufacturer = DBG_NEW char[n]; + Header->SetDeviceManufacturer(tmp_DM); + // strncpy_s(Header->DeviceManufacturer, n + 1, tmpC, n); + //Header->DeviceManufacturer = tmpC; + if (tmp_DM != NULL) + { + delete [] tmp_DM; + tmp_DM = NULL; + } + + bytesread += 4; + //read illuminant + double xyz[3]; + for (int j = 0; j < 3; ++j) + { + tmp = Conv.ByteToInt(ColorTableData, bytesread); + xyz[j] = (double)(tmp) / 65536; + bytesread += 4; + } + C_RGB_XYZ_Lab XYZIllum(xyz[0], xyz[1], xyz[2]); + Header->SetIlluminant(XYZIllum); + //Read Number of Gamut Regions and Max Limits per Region + Header->SetNGamutRegions(ColorTableData[bytesread]); + bytesread++; + int nsize = Header->GetNGamutRegions(); + double *GRegMaxLim = new double[nsize]; + for (int i = 0; i < nsize; ++i) + { + tmp = Conv.ByteToShort(ColorTableData, bytesread); + bytesread += 2; + GRegMaxLim[i] = (double)tmp; + } + Header->SetGamutRegionsMaxLimit(GRegMaxLim); + if (GRegMaxLim != NULL) + { + delete[] GRegMaxLim; + GRegMaxLim = NULL; + } + + if (bytesread < 128) + { + bytesread = 128; + return(Header); + } + else + { + throw std::exception("could not read Color table Header"); + } +} + +void ColorTable::read_xyz_type(int offset, int data_size, C_RGB_XYZ_Lab *XYZ, uint8_t *data) +{ + // 0 - 3 'XYZ ' + //4 - 7 reserved, must be 0 + // 8 - n array of XYZ numbers + + if (data_size < 8) + { + throw std::exception("not enough data to read xyz"); + } + uint8_t *buff = &(data[offset]); + NumConversions Conv; + int bytesread = 0; + int tmpxyz = Conv.ByteToInt(buff, bytesread); + + int n = sizeof(tmpxyz); + //char* tmpC = DBG_NEW char[n]; + char* tmpC = new char[n]; + Conv.getchar(tmpxyz, n, tmpC); + + char *xyztype = new char[n + 1]; + //char *xyztype = DBG_NEW char[n + 1]; + strncpy_s(xyztype, n + 1, tmpC, n); + if (strncmp(xyztype, "XYZ ", n) != 0) + { + if (xyztype != NULL) + { + delete[] xyztype; + xyztype = NULL; + } + if (tmpC != NULL) + { + delete[] tmpC; + tmpC = NULL; + } + throw std::exception("Wrong Tag Type"); + return; + } + else + { + if (xyztype != NULL) + { + delete[] xyztype; + xyztype = NULL; + } + if (tmpC != NULL) + { + delete[] tmpC; + tmpC = NULL; + } + } + bytesread = 8; + int num_values = (data_size - 8) / 4; + if (floor((double)(num_values) / 3) * 3 != num_values) + { + throw std::exception("not enough Data to read xyz"); + return; + } + double xyz[3]; + int tmp; + for (int j = 0; j < 3; ++j) + { + tmp = Conv.ByteToInt(buff, bytesread); + xyz[j] = (double)(tmp) / 65536; + bytesread += 4; + } + XYZ->Set(xyz[0], xyz[1], xyz[2]); + return; +} + +void ColorTable::read_text_type(int offset, int data_size, std::string *textstr, uint8_t *data) +{ + // 0 - 3 'text' + //4 - 7 reserved, must be 0 + //8 - string of(data_size - 8) 7 - bit ASCII characters, including NULL + + std::stringstream strstr; + if (data_size < 8) + { + throw std::exception("invalid Tag Name"); + strstr << ""; + *textstr = strstr.str(); + return; + } + + uint8_t *buff = &(data[offset]); + int bytesread = 0; + NumConversions Conv; + int tmp = Conv.ByteToInt(buff, bytesread); + int n = sizeof((char*)&tmp); + //char *tmpC = DBG_NEW char[n]; + char *tmpC = new char[n]; + Conv.getchar(tmp, n, tmpC); + char *tagtype = new char[n + 1]; + //char *tagtype = DBG_NEW char[n + 1]; + strncpy_s(tagtype, n + 1, tmpC, n); + if (strcmp(tagtype, "text") != 0) + { + throw std::exception("invalid Tag Name"); + strstr << ""; + *textstr = strstr.str(); + return; + } + if (tagtype != NULL) + { + delete[] tagtype; + tagtype = NULL; + } + if (tmpC != NULL) + { + delete[]tmpC; + tmpC = NULL; + } + bytesread += 8; + uint8_t tmp1; + for (int i = bytesread; i < data_size; ++i) + { + tmp1 = buff[i]; + strstr.put(tmp1); + } + *textstr = strstr.str(); + return; +} + +void ColorTable::read_text_description_type(int offset, int data_size, std::string textdescstr, uint8_t *data) +{ + // 0 - 3 'desc' + // 4 - 7 reserved, must be 0 + // 8 - 11 ASCII invariant description count, including terminating NULL + // 12 - ASCII invariant description + + uint8_t *buff = &(data[offset]); + int bytesread = 0; + NumConversions Conv; + int tmp = Conv.ByteToInt(buff, bytesread); + int n = sizeof((char*)&tmp); + //char *tmpC= DBG_NEW char[n]; + char *tmpC = new char[n]; + Conv.getchar(tmp, n, tmpC); + char *tagtype = new char[n + 1]; + //char *tagtype = DBG_NEW char[n + 1]; + strncpy_s(tagtype, n + 1, tmpC, n); + std::stringstream strstr; + if (strcmp(tagtype, "desc") != 0) + { + throw std::exception("invalid Tag Name"); + strstr << ""; + textdescstr = strstr.str(); + return; + } + if (tagtype != NULL) + { + delete[] tagtype; + tagtype = NULL; + } + if (tmpC != NULL) + { + delete[]tmpC; + tmpC = NULL; + } + bytesread += 8; + int count = Conv.ByteToInt(buff, bytesread); + bytesread += 4; + uint8_t tmp1; + for (int i = 0; i < count - 1; ++i) + { + tmp1 = buff[bytesread + i]; + strstr << tmp1; + } + textdescstr = strstr.str(); + return; +} + +void ColorTable::SetNormFactor() +{ + m_NormFactor = m_GamutRegionMaxLim[m_nProcessRanges - 1] / m_GamutRegionMaxLim[0]; +} + +void ColorTable::SetInverseNormFactor() +{ + if (m_NormFactor <= 0) + m_InvNormFactor = -1; + else + m_InvNormFactor = 1.0 / m_NormFactor; +} + +void ColorTable::NormGamutRegionMaxLim() +{ + double GamutRegionMaxLim0 = m_GamutRegionMaxLim[0]; + for (int i = 0; i < m_nProcessRanges; ++i) + m_GamutRegionMaxLim[i] = 100 * m_GamutRegionMaxLim[i] / GamutRegionMaxLim0; +} + + diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.h new file mode 100644 index 000000000..9538a4011 --- /dev/null +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorTable.h @@ -0,0 +1,76 @@ +#ifndef _COLORTABLE_H_ +#define _COLORTABLE_H_ + +#include "C_RGB_XYZ_Lab.h" +#include "ColorSpace.pb-c.h" +#include "ColorTransf.h" +#include "CT_Header.h" +#include "GBD.h" +#include "Curves.h" + +typedef enum { + A2B, + A2BR, + B2A, + B2AR, + cprt, + gbd, + gbdR, + wtpt, + desc, + lcrv + // GReg +}TagList; +class ColorTable { +public: + ColorTable(); + ~ColorTable(); + void InitColorTables(bool has_rddata, uint8_t *data, int nprocessranges); + + int GetnB2AnSepIn( ){ return(m_nB2AnSepIn); }; + int GetnB2AnSepOut() { return(m_nB2AnSepOut); }; + int GetnA2BnSepIn() { return(m_nA2BnSepIn); }; + int GetnA2BnSepOut() { return(m_nA2BnSepOut); }; + int GetnGamutRegions() { return(m_nGamutRegions); }; + double GetNormFactor() { return(m_NormFactor); }; + double GetInverseNormFactor() { return(m_InvNormFactor); }; + double *GetNormGamutRegionMaxLim() { return(m_GamutRegionMaxLim); }; + int GetTableVersion() { return(m_TableVersion); }; + ColorTransf *m_B2ATransform; + ColorTransf *m_A2BTransform; + ColorTransf *m_B2ARTransform; + ColorTransf *m_A2BRTransform; + GBD *m_GBD; + GBD *m_GBDR; + Curves *m_LinCurves; +private: + void readColorTables(bool has_rddata, uint8_t *data, int nprocessranges); + void SetNormFactor(); + void SetInverseNormFactor(); + void NormGamutRegionMaxLim(); + int m_nB2AnSepIn; + int m_nB2AnSepOut; + int m_nA2BnSepIn; + int m_nA2BnSepOut; + int m_nGamutRegions; + int m_nProcessRanges; + int m_TableVersion; + double m_NormFactor; + double m_InvNormFactor; + double *m_GamutRegionMaxLim; + C_RGB_XYZ_Lab m_whitepointXYZ_CT; + void SetnB2AnSepIn(int nB2AnSepIn) { m_nB2AnSepIn = nB2AnSepIn; }; + void SetnB2AnSepOut(int nB2AnSepOut) { m_nB2AnSepOut = nB2AnSepOut; }; + void SetnA2BnSepIn(int nA2BnSepIn) { m_nA2BnSepIn = nA2BnSepIn; }; + void SetnA2BnSepOut(int nA2BnSepOut) { m_nA2BnSepOut = nA2BnSepOut; }; + void SetnGamutRegions(int nGamutRegions) { m_nGamutRegions = nGamutRegions; }; + void SetTableVersion(int TableVersion) { m_TableVersion = TableVersion; }; + CT_Header *read_header(uint8_t* data, int &bytesread); + void read_xyz_type(int offset, int data_size, C_RGB_XYZ_Lab *xyz, uint8_t *data); + void read_text_type(int offset, int data_size, std::string *textstr, + uint8_t *data); + void read_text_description_type(int offset, int data_size, std::string textdescstr, + uint8_t *data); +}; + +#endif \ No newline at end of file diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.cpp new file mode 100644 index 000000000..0066db6b3 --- /dev/null +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.cpp @@ -0,0 +1,35 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "Gradient.h" + +using namespace std; +Gradient::Gradient() : + m_Lab(0), m_RGB(0), + m_Volume(NULL), m_GamutRegion(0), m_Offset(0.0), m_colorspace(COLOR_SPACE__RGB), + m_InGamut(true) +{ + +} + + +Gradient::~Gradient() +{ + if (m_Volume != NULL) + { + delete[] m_Volume; + m_Volume = NULL; + } + +} + +void Gradient::SetVolumeSize(int nchannels) +{ + m_Volume = new double[nchannels]; +} + +void Gradient::SetVolumeValue(double val, int ind) +{ + m_Volume[ind] = val; +} diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.h new file mode 100644 index 000000000..278b3469d --- /dev/null +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/Gradient.h @@ -0,0 +1,37 @@ +#ifndef _GRADIENT_H_ +#define _GRADIENT_H_ + +#include "C_RGB_XYZ_Lab.h" +#include "ColorSpace.pb-c.h" +class Gradient { +public: + Gradient(); + ~Gradient(); + int Get_GamutRegion() { return(m_GamutRegion); }; + double Get_Offset() { return(m_Offset); }; + ColorSpace Get_ColorSpace() {return(m_colorspace);}; + C_RGB_XYZ_Lab Get_Lab() { return(m_Lab); }; + C_RGB_XYZ_Lab Get_RGB() { return(m_RGB); }; + bool Get_InGamut() { return(m_InGamut); }; + void Set_GamutRegion(int GamutRegion) { m_GamutRegion = GamutRegion; }; + void Set_Lab(C_RGB_XYZ_Lab Lab) { m_Lab = Lab; }; + void Set_RGB(C_RGB_XYZ_Lab RGB) { m_RGB = RGB; }; + void Set_Offset(double Offset) { m_Offset = Offset; }; + void Set_ColorSpace(ColorSpace colorspace) { m_colorspace = colorspace; }; + void SetVolumeSize(int nchannels); + void SetVolumeValue(double val, int ind); + void SetInGamut(bool InGamut) { m_InGamut = InGamut; }; + + +private: + C_RGB_XYZ_Lab m_Lab; + C_RGB_XYZ_Lab m_RGB; + double *m_Volume; + int m_GamutRegion; + double m_Offset; + ColorSpace m_colorspace; + bool m_InGamut; + +}; + +#endif \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/ViewModels/DiagnosticsViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/ViewModels/DiagnosticsViewVM.cs index ac9279ab8..8a89fbc8f 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/ViewModels/DiagnosticsViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/ViewModels/DiagnosticsViewVM.cs @@ -15,8 +15,10 @@ using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.FSE.Common; using Tango.FSE.Common.Diagnostics; +using Tango.FSE.Common.FileAssociation; using Tango.FSE.Common.Notifications; using Tango.FSE.Diagnostics.Project; +using Tango.FSE.Diagnostics.Views; using Tango.PMR.Diagnostics; namespace Tango.FSE.Diagnostics.ViewModels @@ -403,6 +405,8 @@ namespace Tango.FSE.Diagnostics.ViewModels { base.OnApplicationStarted(); DiagnosticsProvider.FrameReceived += DiagnosticsProvider_FrameReceived; + + FileAssociationProvider.RegisterFileAssociationHandler("diagnostics", HandleDiagnosticsFileAssociation); } public async override void OnApplicationReady() @@ -781,5 +785,36 @@ namespace Tango.FSE.Diagnostics.ViewModels } #endregion + + #region File Association + + private async void HandleDiagnosticsFileAssociation(FileAssociationPackage package) + { + if (!CurrentUser.HasPermission(Permissions.FSE_EditDiagnosticsProject)) + { + await NotificationProvider.ShowError("Current user profile does not allow loading custom diagnostics projects."); + return; + } + + if (File.Exists(package.File)) + { + try + { + LogManager.Log("Opening diagnostics project from file association..."); + await NavigationManager.NavigateTo(true, nameof(DiagnosticsView)); + using (NotificationProvider.PushTaskItem("Loading diagnostics project...")) + { + await Task.Delay(2000); + await LoadProject(package.File); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred while trying to handle the diagnostics file association."); + } + } + } + + #endregion } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/diagnostics.tdp b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/diagnostics.tdp index 9c75729b6..d5a250f16 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/diagnostics.tdp +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/diagnostics.tdp @@ -2442,7 +2442,7 @@ }, { "$type": "Tango.FSE.Diagnostics.Project.Widgets.Output.OutputWidget, Tango.FSE.Diagnostics", - "IO": "GPO_TFEED_BREAK_1", + "IO": "GPO_LED4", "EnableComponentSelection": false, "ID": "419fa0da-9c51-49fc-82cf-83707c03a44a", "Column": 10, diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml index 77b977b65..4e6959e5b 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml @@ -43,7 +43,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml index 95e4b4a52..012c16c64 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml @@ -6,6 +6,7 @@ xmlns:global="clr-namespace:Tango.FSE.PPCConsole" xmlns:vm="clr-namespace:Tango.FSE.PPCConsole.ViewModels" xmlns:local="clr-namespace:Tango.FSE.PPCConsole.Views" + xmlns:auth="clr-namespace:Tango.FSE.Common.Authorization;assembly=Tango.FSE.Common" xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:win="clr-namespace:Tango.FSE.Common.WindowsManager;assembly=Tango.FSE.Common" @@ -153,11 +154,11 @@ -