diff --git a/functions/utilities/exportFigureGUI.m b/functions/utilities/exportFigureGUI.m index f68017504b458763253f711f0ff106b8a20b2f87..a4fa852a4e58a233f0baf4eb16f57988cd17e5f3 100644 --- a/functions/utilities/exportFigureGUI.m +++ b/functions/utilities/exportFigureGUI.m @@ -175,27 +175,61 @@ autoNameButton = uibutton(fig, 'Text', 'Auto name', ... % -------------------- BOTTOM PART --------------------- % Export Button exportButton = uibutton(fig, 'Text', 'Export Figure', ... - 'Position', [200 100 100 30], ... + 'Position', [130 100 100 30], ... 'BackgroundColor', '#cbffbe', ... 'Tooltip', 'Click to export', ... 'ButtonPushedFcn', @(src, event) exportFigureCallback()); % Save settings Button settingsSaveButton = uibutton(fig, 'Text', 'Save settings', ... - 'Position', [350 100 100 30], ... + 'Position', [270 100 100 30], ... 'BackgroundColor', '#cbffbe', ... - 'Tooltip', 'Save your configuration', ... + 'Tooltip', 'Save your configuration in .json file', ... 'ButtonPushedFcn', @(src, event) saveSettings()); +% Import settings Button +settingsImportButton = uibutton(fig, 'Text', 'Import settings', ... + 'Position', [410 100 100 30], ... + 'BackgroundColor', '#9fc9eb', ... + 'Tooltip', 'Import settings from .json file', ... + 'ButtonPushedFcn', @(src, event) importSettings()); + % Reset to default settings to start over allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... - 'Position', [500 100 100 30], ... - 'BackgroundColor', '#e17b4b', ... + 'Position', [550 100 100 30], ... + 'BackgroundColor', '#d99779', ... 'Tooltip', 'Reset all settings to default', ... 'ButtonPushedFcn', @(src, event) resetToDefaultAll()); %% Functions % Function to update dropdown menu with new figures + function importSettings() + [fileSettings, pathSettings] = uigetfile('*.json'); + fileName = fullfile(pathSettings,fileSettings); + fid = fopen(fileName); + str = char(fread(fid,inf)'); + fclose(fid); + settings = jsondecode(str); + + % Apply values + addMarkersBox.Value = settings.addMarkers; + changeColorsBox.Value = settings.changeColors; + changeLineStyleBox.Value = settings.changeLineStyle; + gridBox.Value = settings.gridOption; + satelliteMapColorsBox.Value = settings.satelliteMapColors; + + legendLocationDropDown.Value = settings.legendLocation; + legendOrientationDropDown.Value = settings.legendOrientation; + + exportPDFBox.Value = settings.exportPDF; + exportFIGBox.Value = settings.exportFIG; + overwriteFigureBox.Value = settings.overwriteFigure; + + percTextField.Value = settings.percTextwidth; + forcedMarkersField.Value = settings.forcedMarkers; + WHratioField.Value = settings.WHratio; + end + function saveSettings() % This function save all the settings in a json file @@ -216,9 +250,13 @@ allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... settings.forcedMarkers = forcedMarkersField.Value; settings.WHratio = WHratioField.Value; + filter = '*.json'; + [fileName, location] = uiputfile(filter); + encoded = jsonencode(settings,PrettyPrint=true); - nameFile = ['settings_' strrep(figSelectionDropDown.Value,' ','-') '.json']; - fid = fopen(nameFile,'w'); + name = ['settings_' fileName]; + fullNameFile = fullfile(location, name); + fid = fopen(fullNameFile,'w'); fprintf(fid,'%s',encoded); fclose(fid); end @@ -254,6 +292,8 @@ allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... end function resetToDefaultAll() + prefixIPTNameDropDown.Value = '[]'; + figNameField.Value = ''; forcedMarkersField.Value = 0; WHratioField.Value = 0; percTextField.Value = 0.75; @@ -440,6 +480,9 @@ allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... return; end + % Figure path + figurePath = uigetdir; + % Try to export figure try % Call the exportStandardizedFigure function @@ -456,6 +499,7 @@ allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... 'exportPDF', exportPDF, ... 'exportFIG', exportFIG, ... 'satelliteMapColors', satelliteMapColors, ... + 'figurePath', figurePath, ... 'WHratio', WHratio, ... 'overwriteFigure', overwriteFigure); uialert(fig, 'Figure exported successfully!', 'Success', 'Icon', 'success');