Index: trunk/src/get_field.m
===================================================================
--- trunk/src/get_field.m	(revision 701)
+++ trunk/src/get_field.m	(revision 747)
@@ -34,5 +34,5 @@
 function varargout = get_field(varargin)
 
-% Last Modified by GUIDE v2.5 23-Oct-2013 23:44:17
+% Last Modified by GUIDE v2.5 21-Apr-2014 15:03:19
 
 % Begin initialization code - DO NOT EDIT
@@ -86,5 +86,5 @@
 Field.Display=Field;
 Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value
-NbVar=numel(Field.VarDimName);
+NbVar=numel(Field.VarDimName);%nbre of variables in the input data
 for ilist=1:NbVar
     if ischar(Field.VarDimName{ilist})
@@ -92,5 +92,5 @@
     end
     NbDim=numel(Field.VarDimName{ilist});
-    check_singleton=false(1,NbDim);
+    check_singleton=false(1,NbDim);%  check singleton, false by default
     for idim=1:NbDim
         dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions
@@ -101,5 +101,4 @@
     Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions
     end
-    %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons
 end
 if ~isfield(Field,'VarAttribute')
@@ -109,10 +108,11 @@
     Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute));
 end
-% Field.Display = list of variables and corresponding properties obtained after removal of singletons
-Field.Display.ListVarName=Field.ListVarName(~Field.Check0D);
+% Field.Display = list of variables and corresponding properties obtained after removal of variables with a single value and singleton dimensions
+Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value
 Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D);
 Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D);
-Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);
-Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);
+Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names
+Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values
+
 
 %% analyse the input field cells
@@ -159,12 +159,12 @@
 set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components
 set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components
-set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
+set(handles.vector_z,'String',Field.Display.ListVarName)% fill the menu of y vector components
 set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
 set(handles.scalar,'Value',1)% fill the menu of y vector components
-set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu of y vector components
+set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar
 set(handles.ordinate,'Value',1)% fill the menu of y vector components
-set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y vector components
+set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots
 if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
-    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})
+    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata
 else
     set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'})
@@ -238,26 +238,14 @@
 set(hObject,'Position',pos_view_field)
 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
+
+%% set z coordinate menu if relevant
+if Field.MaxDim>=3
+    set(handles.Check3D,'Value',1)
+else
+    set(handles.Check3D,'Value',0)
+end
+Check3D_Callback(hObject, eventdata, handles)
 drawnow
 uiwait(handles.get_field);
-
-return
-
-%% set z coordinate menu if relevant
-if Field.MaxDim>=3
-    set(handles.vector_z,'Visible','on')
-    set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D))
-    set(handles.Coord_z,'Visible','on')
-    set(handles.SwitchVarIndexZ,'Visible','on')
-    set(handles.Z_title,'Visible','on')
-else
-    set(handles.vector_z,'Visible','off')
-    set(handles.Coord_z,'Visible','off')
-    set(handles.Z_title,'Visible','off')
-end
-
-%% make selections according to ParamIn
-if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y')
-    
-end
 
 %------------------------------------------------------------------------
@@ -431,5 +419,5 @@
             end
         end
-        scalar_index=find(~test_coord,1);%get the first variable not a coordiante
+        scalar_index=find(~test_coord,1);%get the first variable not a coordinate
         if isempty(scalar_index)
             set(handles.scalar,'Value',1)
@@ -589,7 +577,5 @@
 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
 dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable
-CheckDimensionX=get(handles.CheckDimensionX,'Value');
-CheckDimensionY=get(handles.CheckDimensionY,'Value');
-if ~CheckDimensionX  || ~CheckDimensionY
+if ~get(handles.CheckDimensionX,'Value')  || ~get(handles.CheckDimensionY,'Value')
     %look for coordinate variables among the other variables
     for ilist=1:numel(Field.Display.VarDimName)
@@ -616,12 +602,5 @@
     SwitchVarIndexTime_Callback([], [], handles)
 end
-% if numel(var_component)<2
-%     if numel(test_coord)<2
-%         ListCoord={''};
-%     else
-%         set(handles.Coord_x,'Value',2)
-%         set(handles.Coord_y,'Value',1)
-%     end
-% else
+
 coord_val=[0 0];
 % look for labelled unstructured coordinates
@@ -644,5 +623,5 @@
     end
 end
-if  CheckDimensionX
+if  get(handles.CheckDimensionX,'Value')
     set(handles.Coord_x,'Value',2)
     set(handles.Coord_x,'String',dim_var')
@@ -651,5 +630,5 @@
     set(handles.Coord_x,'String',ListCoord)
 end
-if  CheckDimensionY
+if  get(handles.CheckDimensionY,'Value')
     set(handles.Coord_y,'Value',1)
     set(handles.Coord_y,'String',dim_var')
@@ -657,4 +636,11 @@
     set(handles.Coord_y,'Value',coord_val(2))
     set(handles.Coord_y,'String',ListCoord)
+end
+if  get(handles.CheckDimensionZ,'Value')
+    set(handles.Coord_z,'Value',1)
+    set(handles.Coord_z,'String',dim_var')
+else
+    set(handles.Coord_z,'Value',coord_val(2))
+    set(handles.Coord_z,'String',ListCoord)
 end
 
@@ -860,4 +846,5 @@
 % --- Executes on selection change in SwitchVarIndexTime.
 %------------------------------------------------------------------------
+
 function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
 
@@ -891,15 +878,21 @@
     case 'variable'% TimeName menu represents the available variables
         set(handles.TimeName, 'Visible','on')
-        TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time)
-        List=get(handles.TimeName,'String');
-        option=List{get(handles.TimeName,'Value')};
-        ind=find(strcmp(option,TimeVarName));
-        if isempty(ind)
-            set(handles.TimeName, 'Value',1);
-        else
-            set(handles.TimeName, 'Value',ind);
-        end
-        set(handles.TimeName, 'String',TimeVarName)
-    case 'matrix_index'% TimeName menu represents the available dimensions
+        VarNbDim=cellfun('length',Field.Display.VarDimName); % check the nbre of dimensions of each input variable
+        TimeVarName=Field.Display.ListVarName(VarNbDim==1);% list of variables with a single dimension (candidate for time)
+        List=get(handles.TimeName,'String');% list of names on the menu for time
+        if isempty(List)
+            ind=1;
+        else
+            option=List{get(handles.TimeName,'Value')};% previous selected option
+            ind=find(strcmp(option,TimeVarName)); %check whether the previous selection is available in the newlist
+            if isempty(ind)
+                ind=1;
+            end
+        end
+        if ~isempty(TimeVarName)
+            set(handles.TimeName, 'Value',ind);% select first value in the menu if the option is not found
+            set(handles.TimeName, 'String',TimeVarName)% update the menu for time name
+        end
+    case 'matrix index'% TimeName menu represents the available dimensions
         set(handles.TimeName, 'Visible','on')     
         set(handles.TimeName, 'Value',1);
@@ -966,7 +959,41 @@
     case 'vectors'
 end
-% hObject    handle to CheckDimensionY (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hint: get(hObject,'Value') returns toggle state of CheckDimensionY
+
+
+% --- Executes on button press in CheckDimensionZ.
+function CheckDimensionZ_Callback(hObject, eventdata, handles)
+FieldList=get(handles.FieldOption,'String');
+FieldOption=FieldList{get(handles.FieldOption,'Value')};
+switch FieldOption
+    case '1D plot'
+        
+    case 'scalar'
+       scalar_Callback(hObject, eventdata, handles)
+    case 'vectors'
+end
+
+% --- Executes on selection change in TimeName.
+function TimeName_Callback(hObject, eventdata, handles)
+index=get(handles.SwitchVarIndexTime,'Value');
+if index==3 ; % TimeName is used to chose a variable
+    index=get(handles.TimeName,'Value');
+    string=get(handles.TimeName,'String');
+    VarName=string{index};
+end
+update_field(handles,VarName)
+
+
+% --- Executes on button press in Check3D.
+function Check3D_Callback(hObject, eventdata, handles)
+if get(handles.Check3D,'Value')
+    status='on';
+else
+    status='off';
+end
+set(handles.Coord_z,'Visible',status)
+set(handles.CheckDimensionZ,'Visible',status)
+set(handles.Z_title,'Visible',status)
+set(handles.vector_z,'Visible',status)
+set(handles.W_title,'Visible',status)   
+
+
