From c7e7487d32a5ac8438cde2c41d1bcee26af69706 Mon Sep 17 00:00:00 2001
From: giuliaghirardini <giulia.ghirardini@skywarder.eu>
Date: Tue, 25 Feb 2025 15:15:02 +0100
Subject: [PATCH] [fixes][utilities] Modified default satellite color setting

---
 functions/utilities/exportFigureGUI.m | 76 +++++++++++++++------------
 1 file changed, 43 insertions(+), 33 deletions(-)

diff --git a/functions/utilities/exportFigureGUI.m b/functions/utilities/exportFigureGUI.m
index 5d72888..f0ef540 100644
--- a/functions/utilities/exportFigureGUI.m
+++ b/functions/utilities/exportFigureGUI.m
@@ -64,20 +64,15 @@ flagsPanel = uipanel(fig, ...
 
 % Checkboxes for optional parameters
 addMarkersBox = uicheckbox(flagsPanel, 'Text', 'Add Markers', 'Value', true, ...
-    'Position', [10 10 150 20], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [10 10 150 20]);
 changeColorsBox = uicheckbox(flagsPanel, 'Text', 'Change Colors', 'Value', true, ...
-    'Position', [120 10 150 20], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [120 10 150 20]);
 changeLineStyleBox = uicheckbox(flagsPanel, 'Text', 'Change Line Style', 'Value', false, ...
-    'Position', [240 10 150 20], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [240 10 150 20]);
 gridBox = uicheckbox(flagsPanel, 'Text', 'Show Grid', 'Value', true, ...
-    'Position', [370 10 150 20], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [370 10 150 20]);
 satelliteMapColorsBox = uicheckbox(flagsPanel, 'Text', 'Satellite Map Colors', 'Value', false, ...
-    'Position', [480 10 150 20], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [480 10 150 20]);
 
 %%% Create a panel to group export settings
 exportPanel = uipanel(fig, ...
@@ -111,15 +106,13 @@ legendPositions = {'north', 'south', 'east', 'west', ...
     'best', 'bestoutside'};
 legendLocationDropDown = uidropdown(legendPanel, 'Items', legendPositions, ...
     'Value', 'southoutside', ...
-    'Position', [80 10 150 22], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [80 10 150 22]);
 
 uilabel(legendPanel, 'Text', 'Orientation:', 'Position', [250 10 70 20]);
 legendOrientations = {'horizontal', 'vertical'};
 legendOrientationDropDown = uidropdown(legendPanel, 'Items', legendOrientations, ...
     'Value', 'horizontal', ...
-    'Position', [330 10 150 22], ...
-    'ValueChangedFcn', @(src, event) updatePreview());
+    'Position', [330 10 150 22]);
 
 %% Preview content
 % Find all open figures (excluding this GUI)
@@ -208,7 +201,6 @@ previewButton = uibutton(fig, 'Text', 'Update preview', ...
         updateDropdown();
 
         if isempty(selectedFig) && isscalar(figHandles), selectedFig = figHandles(1); end
-
         if isempty(selectedFig) || ~isvalid(selectedFig), return; end
         
         % Retrieve axes from selected figure
@@ -217,11 +209,19 @@ previewButton = uibutton(fig, 'Text', 'Update preview', ...
         % Copy the axes informations
         check = size(obj.Children);
         if check(1) == 1
+            if satelliteMapColorsBox.Value
+                satelliteMapColorsBox.Value = false;
+            end
+
             newAx = obj.Children;
             hold(newAx, 'on');
         end
         if check(1) == 2 % geoplots or 3d plots or tabfigures
             if isa(obj.Children(1), 'matlab.ui.container.TabGroup')
+                if satelliteMapColorsBox.Value
+                    satelliteMapColorsBox.Value = false;
+                end
+
                 numTabs = numel(obj.Children(1).Children);  % Get number of tabs
                 originalFigNum = obj.Number;  % Get the original figure number
 
@@ -236,42 +236,52 @@ previewButton = uibutton(fig, 'Text', 'Update preview', ...
                 end
                 delete(obj);
             else
+                if strcmp(obj.Children(2).Type, 'geoaxes')
+                    satelliteMapColorsBox.Value = true;
+                end
                 newAx = obj.Children(2);
                 hold(newAx, 'on');
             end
         end
         if check(1) > 2
             if isa(obj.Children(1), 'matlab.graphics.illustration.Legend')
+                if satelliteMapColorsBox.Value
+                    satelliteMapColorsBox.Value = false;
+                end
                 newAx = obj.Children(2:end);
                 hold(newAx(1:check(1)-1), 'on');
             else
+                if satelliteMapColorsBox.Value
+                    satelliteMapColorsBox.Value = false;
+                end
                 newAx = obj.Children;
                 hold(newAx, 'on');
             end
         end
 
         % Apply user settings
-        % linesInPlot = findall(newAx, 'Type', 'line');
-        
-        if addMarkersBox.Value
-            addMarkersBox.ValueChangedFcn = @(src, event) previewFigureCallback();
-        end
-        if changeColorsBox.Value
-            changeColorsBox.ValueChangedFcn = @(src, event) previewFigureCallback();
-        end
-        if gridBox.Value
-            gridBox.ValueChangedFcn = @(src, event) previewFigureCallback();
-        end
+        linesInPlot = findall(newAx, 'Type', 'line');
+
+        % if addMarkersBox.Value
+        %     for line = linesInPlot'
+        %         set(line, 'Marker', 'o', 'MarkerSize', 4);
+        %     end
+        % end
+
+        if changeColorsBox.Value, set(newAx, 'ColorOrder', lines(7)); end
+        grid(newAx, 'on' * gridBox.Value + 'off' * ~gridBox.Value);
+        if changeLineStyleBox.Value, set(linesInPlot, 'LineStyle', '--'); end
+        if satelliteMapColorsBox.Value, colormap(newAx, 'parula'); end
+
         if changeLineStyleBox.Value
-            changeLineStyleBox.ValueChangedFcn = @(src, event) previewFigureCallback();
-        end
-        if satelliteMapColorsBox.Value
-            satelliteMapColorsBox.ValueChangedFcn = @(src, event) previewFigureCallback();
-        end
-        if WHratioField.Value > 0
-            WHratioField.ValueChangedFcn = @(src, event) previewFigureCallback();
+            for line = linesInPlot'
+                set(line, 'LineStyle', '--');
+            end
         end
 
+        if satelliteMapColorsBox.Value, colormap(newAx, 'parula'); end
+        if WHratioField.Value > 0, daspect(newAx, [1 WHratioField.Value 1]); end
+
         % Ensure preview updates on checkbox change
         addMarkersBox.ValueChangedFcn = @(src, event) updatePreview();
         changeColorsBox.ValueChangedFcn = @(src, event) updatePreview();
-- 
GitLab