From 6d6d407df1c3bdd9fa7e1f5d271d8cd8f4eae446 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Thu, 27 Mar 2008 08:53:27 +0000
Subject: [PATCH] le trace de la clim se fait en recuperant le handle parent
 d'une 'line'

---
 tsg_util/plot_Climatology.m | 60 +++++++++++++++++++++++--------------
 tsg_util/resetAxes.m        |  5 ++--
 tsgqc_GUI.m                 | 13 ++++++++
 3 files changed, 53 insertions(+), 25 deletions(-)

diff --git a/tsg_util/plot_Climatology.m b/tsg_util/plot_Climatology.m
index 5548cab..a3c82b0 100644
--- a/tsg_util/plot_Climatology.m
+++ b/tsg_util/plot_Climatology.m
@@ -71,7 +71,6 @@ ssps = tsg.SSPS( ind );
 %           LATX(80)  = -0.5 et LATX(81)  = 0.5
 %           LONX(180) = -0.5 et LONX(181) = 0.5
 % ----------------
-axes( hPlotAxes(1) );
 mean_sstp = zeros(size(ind));
 mean_ssps = zeros(size(ind));
 std_sstp  = zeros(size(ind));
@@ -85,28 +84,45 @@ for ii=1:length(ind)
   std_ssps(ii)  = tsg.levitus.data.WOA01_STD_SSPS(time_dim,1,ilat,ilon);
 end
 
-% Plot mean salinity climatology
-% ------------------------------
-line(dayd, mean_ssps, ...
-  'Tag', 'TAG_LINE_CLIMATO_MEAN_SSPS', 'Linestyle', '-', 'Color','k');
-
-% Plot with 3 standard deviation
-% ------------------------------
-line(dayd,  mean_ssps + 3 * std_ssps, ...
-  'Tag', 'TAG_LINE_CLIMATO_STDDEV_PLUS_SSPS', 'Linestyle', '-', 'Color','r');
-line(dayd,  mean_ssps - 3 * std_ssps, ...
-  'Tag', 'TAG_LINE_CLIMATO_STDDEV_MINUS_SSPS', 'Linestyle', '-', 'Color','r');
-
-% Plot mean temperature climatology
-% ---------------------------------
-axes(hPlotAxes(2));
-line(dayd, mean_sstp, ...
-  'Tag', 'TAG_LINE_CLIMATO_MEAN_SSTP', 'Linestyle', '-', 'Color','k');
-line(dayd,  mean_sstp + 3 * std_sstp, ...
-  'Tag', 'TAG_LINE_CLIMATO_STDDEV_PLUS_SSTP', 'Linestyle', '-', 'Color','r');
-line(dayd,  mean_sstp - 3 * std_sstp, ...
-  'Tag', 'TAG_LINE_CLIMATO_STDDEV_MINUS_SSTP', 'Linestyle', '-', 'Color','r');
+% get handle of axe when SSPS is plotted
+% --------------------------------------
+hdls = findobj('-regexp','Tag', 'TAG_PLOT\d_LINE_SSPS');
+if ~isempty(hdls)
+  hdl_current_axes = get(hdls(1),'parent');
+  axes( hdl_current_axes );
+
+  % Plot mean salinity climatology
+  % ------------------------------
+  line(dayd, mean_ssps, ...
+    'Tag', 'TAG_LINE_CLIMATO_MEAN_SSPS', 'Linestyle', '-', 'Color','k');
+
+  % Plot with 3 standard deviation
+  % ------------------------------
+  line(dayd,  mean_ssps + 3 * std_ssps, ...
+    'Tag', 'TAG_LINE_CLIMATO_STDDEV_PLUS_SSPS', 'Linestyle', '-', 'Color','r');
+  line(dayd,  mean_ssps - 3 * std_ssps, ...
+    'Tag', 'TAG_LINE_CLIMATO_STDDEV_MINUS_SSPS', 'Linestyle', '-', 'Color','r');
+end
 
+% get handle of axe when SSTP is plotted
+% --------------------------------------
+hdls = findobj('-regexp','Tag', 'TAG_PLOT\d_LINE_SSJT');
+if isempty(hdls)
+  hdls = findobj('-regexp','Tag', 'TAG_PLOT\d_LINE_SSPS');
+end  
+if ~isempty(hdls)
+  hdl_current_axes = get(hdls(1),'parent');
+  axes( hdl_current_axes );
+
+  % Plot mean temperature climatology
+  % ---------------------------------
+  line(dayd, mean_sstp, ...
+    'Tag', 'TAG_LINE_CLIMATO_MEAN_SSTP', 'Linestyle', '-', 'Color','k');
+  line(dayd,  mean_sstp + 3 * std_sstp, ...
+    'Tag', 'TAG_LINE_CLIMATO_STDDEV_PLUS_SSTP', 'Linestyle', '-', 'Color','r');
+  line(dayd,  mean_sstp - 3 * std_sstp, ...
+    'Tag', 'TAG_LINE_CLIMATO_STDDEV_MINUS_SSTP', 'Linestyle', '-', 'Color','r');
+end
 % Store the handle of the bucketline
 % ----------------------------------
 %set( hPlotAxes(1), 'UserData', hLine1 );
diff --git a/tsg_util/resetAxes.m b/tsg_util/resetAxes.m
index e0f3116..a6350d4 100644
--- a/tsg_util/resetAxes.m
+++ b/tsg_util/resetAxes.m
@@ -7,8 +7,7 @@ tsg = getappdata( hMainFig, 'tsg_data');
 % Initialise axis limits
 % ----------------------
 for i = 1 : length( hPlotAxes )
-  set( hPlotAxes(i),...     
-      'Visible', 'off', 'box', 'on', 'XLimMode', 'auto', 'YLimMode', 'auto');
+  set( hPlotAxes(i),...
+    'Visible', 'off', 'box', 'on', 'XLimMode', 'auto', 'YLimMode', 'auto');
 end
 
-end
\ No newline at end of file
diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m
index 2a988b7..0c0af73 100644
--- a/tsgqc_GUI.m
+++ b/tsgqc_GUI.m
@@ -1984,9 +1984,22 @@ end
       % Draw the 3 plots of the validation figure
       % -----------------------------------------
       resetAxes( hMainFig, hPlotAxes )
+      
+          % test if climatology is selected
+      % -------------------------------
+      if strcmp(get(findobj('Tag','PUSHTOOL_CLIM'), 'enable'), 'on')
+        Clim_OffMenuCallback;
+      end
+
       plot_Validation( hMainFig, hPlotAxes, 1, PARA );
       plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
       plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
+      
+      % test if climatology is selected
+      % -------------------------------
+      if strcmp(get(findobj('Tag','PUSHTOOL_CLIM'), 'enable'), 'on')
+        Clim_OnMenuCallback;
+      end
 
     else
       msgbox( ['No ' PARA ' data in the file'], 'Parameter choice', 'warn', 'modal');
-- 
GitLab