Skip to content
Snippets Groups Projects
Commit 7826dc83 authored by Giulia Ghirardini's avatar Giulia Ghirardini Committed by Marco Luigi Gaibotti
Browse files

[fixes][utilities] Added import settings button. Now both save settings and...

[fixes][utilities] Added import settings button. Now both save settings and export functions open a dialog window in which choose the folder
parent a9d36b10
No related branches found
No related tags found
1 merge request!15Export standardized figure
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment