From 45bddee9eba007c095d19c3059acab06fe4c73c2 Mon Sep 17 00:00:00 2001 From: giuliaghirardini <giulia.ghirardini@skywarder.eu> Date: Thu, 27 Mar 2025 17:53:09 +0100 Subject: [PATCH] [fixes] Added possibility to automatically save figures --- .gitignore | 1 + .../mainExportStandardizedFigure.m | 40 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e0838cb..074bcf7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.asv *.f *.json +*.fig diff --git a/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m b/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m index 9e89274..2645b10 100644 --- a/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m +++ b/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m @@ -140,6 +140,7 @@ figSelectionDropDown = uidropdown(fig, ... % Automatically update preview if only one figure exists if isscalar(figHandles) + saveTemporaryFigure(); updateDropdown(); updatePreview(); end @@ -318,7 +319,7 @@ allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... figNames = getFigureNames(figHandles); figSelectionDropDown.Items = figNames; - + saveTemporaryFigure(); % Automatically update preview if only one valid figure exists if isscalar(figHandles) updatePreview(); @@ -553,6 +554,43 @@ allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... % checkboxes = findall(flagsPanel.Children, 'Type', 'uicheckbox'); % set(checkboxes, 'Enable', 'off'); end + + function saveTemporaryFigure() + % Force to save fig + exportPDFBox.Value = false; + exportFIGBox.Value= true; + + % retrieve local path to save temp fig in temp folder + tempPath = [pwd '\temp']; + if ~isfolder(tempPath) + error('Not such a directory'); + end + + % Get values from the GUI components + exportPDF = false; + addMarkers = false; + exportFIG = true; + changeColors = false; + percTextwidth = percTextField.Value; + overwriteFigure = true; + + % Call the exportStandardizedFigure function + % selectedIdx = figSelectionDropDown.Value; + % figToExp = figHandles(strcmp(figSelectionDropDown.Items, selectedIdx)); + % name = getFigureNames(figToExp); + + figToExp = findFigures(fig); + names = getFigureNames(figToExp); + + for i=1:length(names) + filename = [tempPath '\' char(names(i))]; + savefig(figToExp(i), filename) + end + disp('Temporary .fig available in temp folder'); + + % checkboxes = findall(flagsPanel.Children, 'Type', 'uicheckbox'); + % set(checkboxes, 'Enable', 'off'); + end end function figHandles = findFigures(fig) -- GitLab