diff --git a/functions/utilities/exportStandardizedFigure/README.md b/functions/utilities/exportStandardizedFigure/README.md index 1f395533aee28a26f31784d38af07ea177d3c436..62cab675b1fe6843761851ec2c39f63720dc120e 100644 --- a/functions/utilities/exportStandardizedFigure/README.md +++ b/functions/utilities/exportStandardizedFigure/README.md @@ -4,12 +4,29 @@ marp: true # Export Standardized Figure GUI +--- +<div style="text-align: center;"> + <img src="doc/GUI_ver_2.0.png" alt="GUI" width="650"> +</div> + --- # General settings --- -On the top part of the GUI you can find: +<div style="text-align: center;"> + <img src="doc/top.png" alt="GUI" width="1100"> +</div> + +--- + +On the first row you can find: * Text box for figure **name**: give the name of your plot but do not add the extension! Export settings will do it for you. +* Dropdown menu for **selecting the ipt**. *This is storngly recomended when wrtiting technical report* +* **Autoname button**: it automatically types in figure name field "plot" for you. This is mandatory because a figure with empty name cannot be exported. + +--- + +On the second row you can find * Dropdown menu with the **list of all figures**: if no figure is opened, it will show *"No figures open"*. Otherwise by clicking on it you would find the list of all opened figures. > **NOTE**: figures with tab will be treated as separated figures! By clicking on the figure which has tabs the GUI will separate them and you will be able to export them separately. @@ -18,13 +35,21 @@ On the top part of the GUI you can find: * Two buttons: * **Update Figures**: this button updates the list of figures if others are opened after the GUI started. * **Update Preview**: this button updates the preview of the graphical changes directly on you figure -> **IMPORTANT**: once you click on the **Update Preview** button you can't modify settings on flag box, but you can still modify other settings like legend and export. - +> **IMPORTANT**: while opening GUI and while pressing Update figure this message will appear in command window: +> ``` +>Temporary .fig available in temp folder +>``` +> This means that in `temp` folder you can find the original figure and you can click it to restore the figure --- ## Flags --- +<div style="text-align: center;"> + <img src="doc/flags.png" alt="GUI" width="1100"> +</div> + +--- There are different types of flags you can select: * **Add Markers**: by default is `true`. it will add by defaul as many markers as many point compose the plotted curve * **Change Colors**: by default is `true`. it will change the colors from Matlab default to Export-standard ones @@ -36,6 +61,12 @@ There are different types of flags you can select: ## Export settings --- +<div style="text-align: center;"> + <img src="doc/export.png" alt="GUI" width="1100"> +</div> + +--- + Default value is `.pdf` format. You can export by choosing `.fig` or `.pdf` format, by respectively choosing **Export PDF** or **Export FIG** flags. If you want to export again a figure, by checking **Overwrite** flag, your figure will be automatically substituted by the new one. @@ -46,6 +77,12 @@ If you don't check **Overwrite** flag, it will be created a new figure or pdf wi ## Legend --- +<div style="text-align: center;"> + <img src="doc/legend.png" alt="GUI" width="1100"> +</div> + +--- + Here you find two dropdown menus in which you can modify the position of the legends itself and of the legend labels. * **Location**: by default is `southwestoutside`. You can choose among the ones below @@ -62,6 +99,11 @@ Here you find two dropdown menus in which you can modify the position of the leg ## Bottom part --- +<div style="text-align: center;"> + <img src="doc/input.png" alt="GUI" width="1100"> +</div> + +--- * **Width/Height Ratio**: by dafault is set to 0. By modifing it you obtain different proportions on your figure. * **Forced Markers**: by default is set to 0. You can set the number of markers you want in your curve *indipendently by the number of elements*. To do so Forced Markers should be true, otherwise you will get a warning and no markers are added. @@ -74,19 +116,49 @@ Here you find two dropdown menus in which you can modify the position of the leg Error using exportStandardizedFigure figure width is larger than the page! ``` - +--- +* **Reset button**: you can reset to default properties of these 3 input fields. To reset all click Reset All (red button below). --- ## Export --- -If you click on **Export Figure** button and everything is okay you would get a succesfull message and you figure will be saved in the **current directory**. +<div style="text-align: center;"> + <img src="doc/bottom.png" alt="GUI" width="1100"> +</div> -This is the line you need to add in *Latex* document to include your figure: -```latex -Figure saved successfully! +--- + +* If you click on **Export Figure** button and everything is okay you would get a succesfull message and you figure will be saved in the **current directory**. -text to copy: - {'\includegraphics[width=0.75\textwidth]{<add figure path>\prova.pdf}'} + This is the line you need to add in *Latex* document to include your figure: + ```latex + Figure saved successfully! + + text to copy: + {'\includegraphics[width=0.75\textwidth]{<add figure path>\prova.pdf}'} + ``` + +--- +* **Save settings** button. If you click it you can save the options you selected into a `.json` file. This file is stored in `settings` folder. +```json +{ + "addMarkers": false, + "changeColors": true, + "changeLineStyle": false, + "gridOption": false, + "satelliteMapColors": true, + "legendLocation": "southoutside", + "legendOrientation": "horizontal", + "exportPDF": true, + "exportFIG": false, + "overwriteFigure": false, + "percTextwidth": 0.75, + "forcedMarkers": 0, + "WHratio": 0 +} ``` +--- +* **Import settings** button. When you click it you can select only `*.json` files from settings folder or whatever folder ypu saved your settings and the options will be applied. +* **Reset All** button. This button resets all properties to default values. The default values are listed in the dedicated sections. diff --git a/functions/utilities/exportStandardizedFigure/README.pdf b/functions/utilities/exportStandardizedFigure/README.pdf deleted file mode 100644 index 40496d63ee7ec2899d29dd03a350f6c96e84b50b..0000000000000000000000000000000000000000 Binary files a/functions/utilities/exportStandardizedFigure/README.pdf and /dev/null differ diff --git a/functions/utilities/exportStandardizedFigure/doc/GUI_ver_2.0.png b/functions/utilities/exportStandardizedFigure/doc/GUI_ver_2.0.png new file mode 100644 index 0000000000000000000000000000000000000000..f1e05c7fc969813c101d20fd4c5faf9bd0e47a96 Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/GUI_ver_2.0.png differ diff --git a/functions/utilities/exportStandardizedFigure/doc/README.pdf b/functions/utilities/exportStandardizedFigure/doc/README.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e5c4f63015454f358ebd38b4659c1c1ba9278719 Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/README.pdf differ diff --git a/functions/utilities/exportStandardizedFigure/doc/bottom.png b/functions/utilities/exportStandardizedFigure/doc/bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..c296041bba35d355868103dc4069898c8a23d64e Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/bottom.png differ diff --git a/functions/utilities/exportStandardizedFigure/doc/export.png b/functions/utilities/exportStandardizedFigure/doc/export.png new file mode 100644 index 0000000000000000000000000000000000000000..5f4538923d7c34799da330beeb8ccc909ca088c3 Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/export.png differ diff --git a/functions/utilities/exportStandardizedFigure/doc/flags.png b/functions/utilities/exportStandardizedFigure/doc/flags.png new file mode 100644 index 0000000000000000000000000000000000000000..3b3e2ad2abc91f32bbbffd844ba7ef858025ef0e Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/flags.png differ diff --git a/functions/utilities/exportStandardizedFigure/doc/input.png b/functions/utilities/exportStandardizedFigure/doc/input.png new file mode 100644 index 0000000000000000000000000000000000000000..5521e9109d86e8c15b688da15b507a4b4d100e1c Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/input.png differ diff --git a/functions/utilities/exportStandardizedFigure/doc/legend.png b/functions/utilities/exportStandardizedFigure/doc/legend.png new file mode 100644 index 0000000000000000000000000000000000000000..271d3f13d13a7f19a3d0650967ec8e20c531749b Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/legend.png differ diff --git a/functions/utilities/exportStandardizedFigure/doc/top.png b/functions/utilities/exportStandardizedFigure/doc/top.png new file mode 100644 index 0000000000000000000000000000000000000000..46fec53a727aef5740828b7a747c878a19a95645 Binary files /dev/null and b/functions/utilities/exportStandardizedFigure/doc/top.png differ diff --git a/functions/utilities/exportStandardizedFigure/fct/updatePreview.m b/functions/utilities/exportStandardizedFigure/fct/updatePreview.m index 0b7940a88cab18b814c8aa6e7e05393e470b7559..1c3d919c4573d410f191bc4e0c89bd6d32c2910c 100644 --- a/functions/utilities/exportStandardizedFigure/fct/updatePreview.m +++ b/functions/utilities/exportStandardizedFigure/fct/updatePreview.m @@ -1,114 +1,114 @@ +function updatePreview(fig, flagsPanel, screen, dropDown, box, inputFields) % Function to update preview - function updatePreview(fig, flagsPanel, screen, dropDown, box, inputFields) - checkboxes = findall(flagsPanel.Children, 'Type', 'uicheckbox'); - set(checkboxes, 'Enable', 'on'); - - figHandles = findFigures(fig); +checkboxes = findall(flagsPanel.Children, 'Type', 'uicheckbox'); +set(checkboxes, 'Enable', 'on'); + +figHandles = findFigures(fig); + +% Get selected figure from dropdown +selectedIdx = dropDown.figSelection.Value; +selectedFig = []; + +for i = 1:length(figHandles) + figSeries = figHandles(i); + + % Set the default figure position + pos = get(figSeries, 'Position'); % gives x left, y bottom, width, height + width = pos(3); + height = pos(4); + leftOffsetNew = screen.width/5; + topOffsetNew = screen.weight/3; + + positionCurrentFig = [screen.width-width-leftOffsetNew, ... + screen.height-height-topOffsetNew, width, height]; + set(figSeries, 'Position', positionCurrentFig); +end + +% Find the selected figure +for i = 1:length(figHandles) + if strcmp(dropDown.figSelection.Items{i}, selectedIdx) + selectedFig = figHandles(i); + break; + end +end +% Move from background to foreground current figure +uistack(selectedFig,'top') - % Get selected figure from dropdown - selectedIdx = dropDown.figSelection.Value; - selectedFig = []; +if isempty(selectedFig) && isscalar(figHandles), selectedFig = figHandles(1); end +if isempty(selectedFig) || ~isvalid(selectedFig), return; end - for i = 1:length(figHandles) - figSeries = figHandles(i); +% Retrieve axes from selected figure +obj = findall(selectedFig, 'Type', 'figure'); - % Set the default figure position - pos = get(figSeries, 'Position'); % gives x left, y bottom, width, height - width = pos(3); - height = pos(4); - leftOffsetNew = screen.screenWidth/5; - topOffsetNew = screen.screenHeight/3; +% Copy the axes informations +check = size(obj.Children); +switch check(1) + case 0 + return; + case 1 + if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end - positionCurrentFig = [screen.screenWidth-width-leftOffsetNew, ... - screen.screenHeight-height-topOffsetNew, width, height]; - set(figSeries, 'Position', positionCurrentFig); - end + newAx = obj.Children; + hold(newAx, 'on'); + case 2 + if isa(obj.Children(1), 'matlab.ui.container.TabGroup') + if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end - % Find the selected figure - for i = 1:length(figHandles) - if strcmp(dropDown.figSelection.Items{i}, selectedIdx) - selectedFig = figHandles(i); - break; - end - end - % Move from background to foreground current figure - uistack(selectedFig,'top') + numTabs = numel(obj.Children(1).Children); % Get number of tabs + originalFigNum = obj.Number; % Get the original figure number - if isempty(selectedFig) && isscalar(figHandles), selectedFig = figHandles(1); end - if isempty(selectedFig) || ~isvalid(selectedFig), return; end + for i = 1:numTabs + newFigName = sprintf('Figure %d - Tab %d', originalFigNum, i); + newFig = figure('Name', newFigName, 'NumberTitle', 'off'); - % Retrieve axes from selected figure - obj = findall(selectedFig, 'Type', 'figure'); + newAx = copyobj(obj.Children(1).Children(i).Children, newFig); - % Copy the axes informations - check = size(obj.Children); - switch check(1) - case 0 - return; - case 1 - if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end - - newAx = obj.Children; + set(newAx, 'Position', get(gca, 'Position')); hold(newAx, 'on'); - case 2 - 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'); - - newAx = copyobj(obj.Children(1).Children(i).Children, newFig); - - set(newAx, 'Position', get(gca, 'Position')); - hold(newAx, 'on'); - end - delete(obj); - else - if strcmp(obj.Children(2).Type, 'geoaxes') - box.satelliteMapColors.Value = true; - else - box.satelliteMapColors.Value = false; - end - newAx = obj.Children(2); - hold(newAx, 'on'); - end - otherwise - if isa(obj.Children(1), 'matlab.graphics.illustration.Legend') - if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end - - newAx = obj.Children(2:end); - hold(newAx(1:check(1)-1), 'on'); - else - if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end - - newAx = obj.Children; - hold(newAx, 'on'); - end - end - - % Apply user settings - linesInPlot = findall(newAx, 'Type', 'line'); - - if box.changeColors.Value, set(newAx, 'ColorOrder', lines(7)); end - if box.changeLineStyle.Value, set(linesInPlot, 'LineStyle', '--'); end - if box.satelliteMapColors.Value, colormap(newAx, 'parula'); end - if inputFields.WHratio.Value > 0, daspect(newAx, [1 inputFields.WHratio.Value 1]); end - - if box.changeLineStyle.Value - for line = linesInPlot' - set(line, 'LineStyle', '--'); end + delete(obj); + else + if strcmp(obj.Children(2).Type, 'geoaxes') + box.satelliteMapColors.Value = true; + else + box.satelliteMapColors.Value = false; + end + newAx = obj.Children(2); + hold(newAx, 'on'); end + otherwise + if isa(obj.Children(1), 'matlab.graphics.illustration.Legend') + if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end - if box.grid.Value - grid(newAx, 'on'); + newAx = obj.Children(2:end); + hold(newAx(1:check(1)-1), 'on'); else - grid(newAx, 'off'); + if box.satelliteMapColors.Value, box.satelliteMapColors.Value = false; end + + newAx = obj.Children; + hold(newAx, 'on'); end +end - hold(newAx, 'off'); +% Apply user settings +linesInPlot = findall(newAx, 'Type', 'line'); + +if box.changeColors.Value, set(newAx, 'ColorOrder', lines(7)); end +if box.changeLineStyle.Value, set(linesInPlot, 'LineStyle', '--'); end +if box.satelliteMapColors.Value, colormap(newAx, 'parula'); end +if inputFields.WHratio.Value > 0, daspect(newAx, [1 inputFields.WHratio.Value 1]); end + +if box.changeLineStyle.Value + for line = linesInPlot' + set(line, 'LineStyle', '--'); end +end + +if box.grid.Value + grid(newAx, 'on'); +else + grid(newAx, 'off'); +end + +hold(newAx, 'off'); +end diff --git a/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m b/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m index 0d3228f5aef240a79fd1130a0afda3cd0109d933..1ab33a39aad78ccb956aab90698bea905cc2fa5b 100644 --- a/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m +++ b/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m @@ -3,28 +3,28 @@ function mainExportStandardizedFigure %% Positioning GUI at screen center % Get the screen size -screenSize = get(0, 'ScreenSize'); % [left, bottom, width, height] +uifig.screenSize = get(0, 'ScreenSize'); % [left, bottom, width, height] % Set the uifigure size -figWidth = 800; -figHeight = 700; - -% Calculate position to center the figure -figX = (screenSize(3) - figWidth) / 10; -figY = (screenSize(4) - figHeight) / 2; - +uifig.width = 800; +uifig.height = 700; % Get the screen size -screenSize = get(0, 'ScreenSize'); -screen.screenWidth = screenSize(3); -screen.screenHeight = screenSize(4); +screen.width = uifig.screenSize(3); +screen.height = uifig.screenSize(4); + +% Calculate position to center the figure +uifig.X = (screen.width - uifig.width) / 10; +uifig.Y = (screen.height - uifig.height) / 2; % Define an offset from the top of the screen -topOffset = figY; -leftOffset = figX; +uifig.topOffset = uifig.Y; +uifig.leftOffset = uifig.X; % Calculate the position for the new figures -positionGui = [leftOffset, screen.screenHeight-figHeight-topOffset, figWidth, figHeight]; +uifig.left = uifig.leftOffset; +uifig.bottom = screen.height-uifig.height-uifig.topOffset; +positionGui = [uifig.left, uifig.bottom, uifig.width, uifig.height]; %% Create main figure window fig = uifigure('Name', 'Export Standardized Figure', 'Position', positionGui);