diff --git a/functions/utilities/exportStandardizedFigure/fct/updatePreview.m b/functions/utilities/exportStandardizedFigure/fct/updatePreview.m index 1b7a09e6725a9a1cd9f8887907511e8cbcbc0644..fb24cf7aadbb59d41e18587abcf67b63ac9562b9 100644 --- a/functions/utilities/exportStandardizedFigure/fct/updatePreview.m +++ b/functions/utilities/exportStandardizedFigure/fct/updatePreview.m @@ -67,9 +67,55 @@ switch check(1) return; case 1 if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end + if isa(obj.Children(1), 'matlab.ui.container.TabGroup') + if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end + + numTabs = numel(obj.Children(1).Children); % Get number of tabs + originalFigNum = obj.Number; % Get the original figure number + + % for i = 1:numTabs + % newFigName = sprintf('Figure %d - Tab %d', originalFigNum, i); + % newFig = figure('Name', newFigName, 'NumberTitle', 'off'); + % + % axesList = obj.Children(1).Children(i).Children; + % numAxes = numel(axesList); + % + % axesList = flipud(axesList); % Maintain visual order + % + % rows = ceil(sqrt(numAxes)); + % cols = ceil(numAxes / rows); + % + % for j = 1:numAxes + % dummyAx = subplot(rows, cols, j, 'Parent', newFig); % Get subplot position + % subplotPos = get(dummyAx, 'Position'); + % + % newAx = copyobj(axesList(j), newFig); % Copy into figure + % set(newAx, 'Position', subplotPos); % Apply subplot position + % + % delete(dummyAx); % Remove placeholder subplot + % end + % end + % a subplot of 2 elements can be organized into 2 elements in the same row, + % so 2 columns (vertical aspect), or the 2 elements can be organized into 2 + % different rows but in the same column (horizontal aspect). + for i = 1:numTabs + newFigName = sprintf('Figure %d - Tab %d', originalFigNum, i); + newFig = figure('Name', newFigName, 'NumberTitle', 'off'); + + axesList = obj.Children(1).Children(i).Children; + axesList = flipud(axesList); % To preserve visual order - newAx = obj.Children; - hold(newAx, 'on'); + for j = 1:numel(axesList) + originalPos = get(axesList(j), 'Position'); % Normalized position + newAx = copyobj(axesList(j), newFig); % Copy to figure + set(newAx, 'Position', originalPos); % Apply original layout + end + end + delete(obj); + else + newAx = obj.Children; + hold(newAx, 'on'); + end case 2 if isa(obj.Children(1), 'matlab.ui.container.TabGroup') if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end