From 17450288356e162492f9cfbedf4ecb9ff176ade8 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Thu, 10 Jan 2008 15:44:09 +0000
Subject: [PATCH] maj de DATE_UPDATE, passe tsg.DATA_ACQUISITION et
 tsg.PROCESSING_CENTRE en popupmenu, utilisation de deblank pour supprimer les
 espaces dans les chaines de char des popupmenus

---
 @tsg_nc/tsg_ncattr.csv |  2 +-
 tsg_util/headerForm.m  | 42 ++++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/@tsg_nc/tsg_ncattr.csv b/@tsg_nc/tsg_ncattr.csv
index bb78780..fef310d 100644
--- a/@tsg_nc/tsg_ncattr.csv
+++ b/@tsg_nc/tsg_ncattr.csv
@@ -31,4 +31,4 @@ integer;char;char;char;char;char;integer;integer;integer;char;char;
 26;DATA_CENTRE;DATA CENTRE:;;edit;;;;;right;Code for data center (2 char);
 27;DATA_ACQUISITION;DATA ACQUISITION:;;popupmenu;IRD|GENAVIR|SHOM|CNRS;1;.1;.02;right;Acquisition data centre, ex: SHOM,IRD,GENAVIR,CNRS,...;
 28;PROCESSING_CENTRE;PROCESSING CENTRE:;;popupmenu;ORE-SSS|CORIOLIS/IRD|CORIOLIS/SISMER;1;.1;.02;right;Processing data centre, ex: ORE-SSS,CORIOLIS,SISMER,...;
-29;PROCESSING_STATES;PROCESSING STATES:;;edit;;;;;right;Need to be defined, IRD action,...;
+29;PROCESSING_STATES;PROCESSING STATES:;;popupmenu;0A|1A|2B|2B+|2C|2C+|3B;1;.1;.02;right;0A: DONNEE BRUTE|1A: DONNEE LOCALISEE;
diff --git a/tsg_util/headerForm.m b/tsg_util/headerForm.m
index 25ec461..5eccb1f 100644
--- a/tsg_util/headerForm.m
+++ b/tsg_util/headerForm.m
@@ -28,6 +28,9 @@ inc_y  =  0.03;
 default_height = 0.018;
 default_length = .1;
 
+% get actual date
+% ---------------
+date = datestr(now,30);
 
 % Get global attributes list from class tsg_nc with file 'tsg_ncattr.csv'
 % -----------------------------------------------------------------------
@@ -55,19 +58,29 @@ hHeaderFig = figure(...
 % Display fields from class
 % -------------------------
 for i=1:numel(nca_keys)
+  
   % get key, use {} for cell
+  % ------------------------
   key = nca_keys{i};
+  
   % get all structure for the key
+  % -----------------------------
   s = get(nca, key);
   
+  % set tsg.DATE_UPDATE
+  % -------------------
+  if strcmp(key, 'DATE_UPDATE')
+    tsg.(key) = [date(1:8) date(10:15)];
+  end
+  
   % check for empty field and replace them by default value
   % -------------------------------------------------------
   if isempty(s.length), s.length = default_length; end;
   if isempty(s.height), s.height = default_height; end;
       
-  % display dynamic uicontrol text
-  % use of char function prevent error when field is empty [] => ''
-  % ---------------------------------------------------------------
+  % display dynamically uicontrol text
+  % use of char function to prevent error when field is empty [] => ''
+  % ------------------------------------------------------------------
   uicontrol(...
     'Parent', hHeaderFig, ...
     'Units', 'normalized', ...
@@ -103,8 +116,8 @@ for i=1:numel(nca_keys)
     'Position',[left+.22, bottom, .1, s.height], ...
     'String', char(s.conventions) );
   
-  % set dynamically uicontrol
-  % -------------------------
+  % set dynamically uicontrol from tsg struct
+  % -----------------------------------------
   switch s.uicontrolType
     case 'popupmenu'
       str = cellstr(get(ui,'String'));
@@ -207,15 +220,16 @@ uiwait(hHeaderFig);
     tsg.PROCESSING_CENTRE = get(data.PROCESSING_CENTRE, 'string');
     tsg.PROCESSING_STATES = get(data.PROCESSING_STATES, 'string');
     
-    % for popupmenu only
-    % ------------------
-    tsg.TSG_TYPE          = tsg.TSG_TYPE(get(data.TSG_TYPE, 'value'),:);
-    tsg.TINT_TYPE         = tsg.TINT_TYPE(get(data.TINT_TYPE, 'value'),:);
-    tsg.DATA_MODE         = tsg.DATA_MODE(get(data.DATA_MODE, 'value'),:);
-    tsg.PI_NAME           = tsg.PI_NAME(get(data.PI_NAME, 'value'),:);
-    tsg.DATA_ACQUISITION  = tsg.DATA_ACQUISITION(get(data.DATA_ACQUISITION, 'value'),:);
-    tsg.PROCESSING_CENTRE = tsg.PROCESSING_CENTRE(get(data.PROCESSING_CENTRE, 'value'),:);
-  
+    % for popupmenu only, deblank remove all trailling whitespace char
+    % ----------------------------------------------------------------
+    tsg.TSG_TYPE          = deblank(tsg.TSG_TYPE(get(data.TSG_TYPE, 'value'),:));
+    tsg.TINT_TYPE         = deblank(tsg.TINT_TYPE(get(data.TINT_TYPE, 'value'),:));
+    tsg.DATA_MODE         = deblank(tsg.DATA_MODE(get(data.DATA_MODE, 'value'),:));
+    tsg.PI_NAME           = deblank(tsg.PI_NAME(get(data.PI_NAME, 'value'),:));
+    tsg.DATA_ACQUISITION  = deblank(tsg.DATA_ACQUISITION(get(data.DATA_ACQUISITION, 'value'),:));
+    tsg.PROCESSING_CENTRE = deblank(tsg.PROCESSING_CENTRE(get(data.PROCESSING_CENTRE, 'value'),:));
+    tsg.PROCESSING_STATES = deblank(tsg.PROCESSING_STATES(get(data.PROCESSING_STATES, 'value'),:));
+    
     % Save tsg structure 
     % ------------------
     setappdata( hTsgGUI, 'tsg_data', tsg);
-- 
GitLab