diff --git a/functions/utilities/exportFigureGUI.m b/functions/utilities/exportFigureGUI.m index a4ab753d8cb504daae74a0fd98401cdfa13c5325..f68017504b458763253f711f0ff106b8a20b2f87 100644 --- a/functions/utilities/exportFigureGUI.m +++ b/functions/utilities/exportFigureGUI.m @@ -46,10 +46,11 @@ figNameField = uieditfield(fig, 'text', 'Position', [150 550 200 30], ... %%% Dropdown menu for departement name uilabel(fig, 'Text', 'IPT Name:', 'Position', [370 550 100 30]); prefixIPTName = {'[]', '[MSA]', '[AER]', '[PRF]', '[RCS]', '[GNC]', '[ARP]', ... - '[SWD]', '[ELC]', '[STR]', '[PRP]', '[LPS]', '[AFD]', '[MMC]', '[ROV]'}; + '[SWD]', '[ELC]', '[STR]', '[RPS]', '[LPS]', '[AFD]', '[MMC]', '[ROV]'}; prefixIPTNameDropDown = uidropdown(fig, 'Items', prefixIPTName, ... 'Value', '[]', ... - 'Position', [455 550 80 30]); + 'Position', [455 550 80 30], ... + 'Tooltip', 'Choose your IPT'); % WHratio Input uilabel(fig, 'Text', 'Width/Height Ratio:', 'Position', [50 170 150 30]); @@ -134,6 +135,7 @@ uilabel(fig, 'Text', 'Select Figure:', 'Position', [50, 500, 100, 30]); figSelectionDropDown = uidropdown(fig, ... 'Items', figNames, ... 'Position', [150, 500, 200, 30], ... + 'Tooltip', 'Select the figure you want to export', ... 'ValueChangedFcn', @(src, event) updatePreview()); % Automatically update preview if only one figure exists @@ -149,12 +151,6 @@ updateButton = uibutton(fig, 'Text', 'Update Figures', ... 'Tooltip', 'Update list of available figures', ... 'ButtonPushedFcn', @(src, event) updateDropdown()); -% Submit Button -exportButton = uibutton(fig, 'Text', 'Export Figure', ... - 'Position', [350 100 100 30], ... - 'BackgroundColor', '#cbffbe', ... - 'ButtonPushedFcn', @(src, event) exportFigureCallback()); - % preview image to export button previewButton = uibutton(fig, 'Text', 'Update preview', ... 'Position', [640, 500, 120, 30], ... @@ -162,22 +158,71 @@ previewButton = uibutton(fig, 'Text', 'Update preview', ... 'Tooltip', 'Click to see a preview of your plot', ... 'ButtonPushedFcn', @(src, event) previewFigureCallback()); -% return to default button +% return to default button only for last 3 fields defaultButton = uibutton(fig, 'Text', 'Reset', ... 'Position', [710, 170, 50, 30], ... 'BackgroundColor', [.7 .7 .7], ... 'Tooltip', 'Return to default values', ... - 'ButtonPushedFcn', @(src, event) resetToDefault()); + 'ButtonPushedFcn', @(src, event) resetToDefaultMini()); % automatically generate a name autoNameButton = uibutton(fig, 'Text', 'Auto name', ... 'Position', [640, 550, 120, 30], ... 'BackgroundColor', [.7 .7 .7], ... - 'Tooltip', 'Generate a automatic name', ... + 'Tooltip', 'Generate a automatic name: "plot"', ... 'ButtonPushedFcn', @(src, event) autoNameGenerator()); +% -------------------- BOTTOM PART --------------------- +% Export Button +exportButton = uibutton(fig, 'Text', 'Export Figure', ... + 'Position', [200 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], ... + 'BackgroundColor', '#cbffbe', ... + 'Tooltip', 'Save your configuration', ... + 'ButtonPushedFcn', @(src, event) saveSettings()); + +% Reset to default settings to start over +allDefaultButton = uibutton(fig, 'Text', 'Reset All', ... + 'Position', [500 100 100 30], ... + 'BackgroundColor', '#e17b4b', ... + 'Tooltip', 'Reset all settings to default', ... + 'ButtonPushedFcn', @(src, event) resetToDefaultAll()); + %% Functions % Function to update dropdown menu with new figures + function saveSettings() + % This function save all the settings in a json file + + settings.addMarkers = addMarkersBox.Value; + settings.changeColors = changeColorsBox.Value; + settings.changeLineStyle = changeLineStyleBox.Value; + settings.gridOption = gridBox.Value; + settings.satelliteMapColors = satelliteMapColorsBox.Value; + + settings.legendLocation = legendLocationDropDown.Value; + settings.legendOrientation = legendOrientationDropDown.Value; + + settings.exportPDF = exportPDFBox.Value; + settings.exportFIG = exportFIGBox.Value; + settings.overwriteFigure = overwriteFigureBox.Value; + + settings.percTextwidth = percTextField.Value; + settings.forcedMarkers = forcedMarkersField.Value; + settings.WHratio = WHratioField.Value; + + encoded = jsonencode(settings,PrettyPrint=true); + nameFile = ['settings_' strrep(figSelectionDropDown.Value,' ','-') '.json']; + fid = fopen(nameFile,'w'); + fprintf(fid,'%s',encoded); + fclose(fid); + end + function autoNameGenerator() figNameField.Value = "plot"; end @@ -202,10 +247,29 @@ autoNameButton = uibutton(fig, 'Text', 'Auto name', ... end end - function resetToDefault() + function resetToDefaultMini() + forcedMarkersField.Value = 0; + WHratioField.Value = 0; + percTextField.Value = 0.75; + end + + function resetToDefaultAll() forcedMarkersField.Value = 0; WHratioField.Value = 0; percTextField.Value = 0.75; + % Flags default settings + addMarkersBox.Value = true; + changeColorsBox.Value = true; + changeLineStyleBox.Value = false; + gridBox.Value = true; + satelliteMapColorsBox.Value = false; + % Legend default settings + legendLocationDropDown.Value = 'southoutside'; + legendOrientationDropDown.Value = 'horizontal'; + % Export default settings + overwriteFigureBox.Value = false; + exportPDFBox.Value = true; + exportFIGBox.Value= false; end function updateDropdown()