From 433c24eded5116b7b866e534d7ca8b0696b91c95 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Wed, 12 Mar 2008 17:20:15 +0000
Subject: [PATCH] utilise maintenant setappdata

---
 tsg_util/tsg_initialisation.m | 11 +++++++----
 tsg_util/tsg_preferences.m    |  6 +++++-
 tsgqc_GUI.m                   | 13 ++++++++-----
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m
index b5a60c6..1da7a35 100644
--- a/tsg_util/tsg_initialisation.m
+++ b/tsg_util/tsg_initialisation.m
@@ -1,13 +1,12 @@
-function tsg = tsg_initialisation()
-%function tsg_initialisation(hTsgGUI)
+function tsg_initialisation(hMainFig)
 %
 % Input
 % -----
-% none
+% hMainFig ............ Handel to the main user interface
 %
 % Output
 % ------
-% tsg     ............ tsg structure that contain data 
+% none
 %
 % $Id$
 %
@@ -15,6 +14,7 @@ function tsg = tsg_initialisation()
 % -------------------------------------------------------------------------
 %%              Constants for NetCDF DATA FORMAT TSG
 % -------------------------------------------------------------------------
+tsg = [];
 
 % netcdf file version
 % -------------------
@@ -166,3 +166,6 @@ tsg.DATE_CREATION         =  [date(1:8) date(10:15)];
 tsg.DATE_UPDATE           =  tsg.DATE_CREATION; 
 tsg.REFERENCE_DATE_TIME   =  REFERENCE_DATE_TIME;
 
+% Save tsg structure 
+% ------------------
+setappdata( hMainFig, 'tsg_data', tsg);
diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m
index 1820ace..7ef192b 100644
--- a/tsg_util/tsg_preferences.m
+++ b/tsg_util/tsg_preferences.m
@@ -126,8 +126,12 @@ set(0, 'userdata', root);
  
     % call default tsg_initialisation
     % -------------------------------
-    tsg = tsg_initialisation;
+    tsg_initialisation(hTsgGUI);
   
+    % Get the data from the application GUI
+    % -------------------------------------
+    tsg = getappdata( hTsgGUI, 'tsg_data');
+
     % init root structure to default values
     % -------------------------------------
     root.preference.autoload = 'off';
diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m
index 8a702f1..d127ebe 100644
--- a/tsgqc_GUI.m
+++ b/tsgqc_GUI.m
@@ -101,9 +101,6 @@ hMainFig = figure(...
   'Position',guiLimits, ...
   'Color', get( 0, 'DefaultUIControlBackgroundColor' ));
 
-% Initialize tsg structure
-% ------------------------
-% tsg_initialisation(hMainFig)
 
 %% Initialize tsg structure with tsg_preference function
 % -----------------------------------------------------
@@ -1017,6 +1014,10 @@ end
       % construct valid and full file path
       % -----------------------------------
       fullFileName = strcat(pathname, fileName);
+      
+      % call default tsg_initialisation
+      % -------------------------------
+      tsg_initialisation(hMainFig);
 
       % Read the data
       % -------------
@@ -1085,13 +1086,15 @@ end
         % ---------------------------
         set( hInfoFileText, 'String', strcat(tsg.file.name, tsg.file.ext));
         
-        % update some fields in tsg structure
-        % -----------------------------------
+        % update some fields in tsg structure and restore tsg
+        % ---------------------------------------------------
         updateTsgStruct(hMainFig);
+        tsg = getappdata( hMainFig, 'tsg_data');
         
         % Running average of TSG time series
         % ----------------------------------
         tsg_moveaverage(hMainFig);
+        
 
         % The callback to detect the mouse motion can be set to on
         % --------------------------------------------------------
-- 
GitLab