Index: trunk/src/uvmat.m
===================================================================
--- trunk/src/uvmat.m	(revision 426)
+++ trunk/src/uvmat.m	(revision 427)
@@ -1625,4 +1625,6 @@
 end
 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
+
+% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
 if CheckFixPair
     if get(handles.scan_i,'Value')==1% case of scanning along index i
@@ -1641,9 +1643,12 @@
         end
     end
+    
+% the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): 
+% the list of existing indices recorded in UvData is used
 else
     UvData=get(handles.uvmat,'UserData');
     ref_i=i1;
     if ~isempty(i2)
-        ref_i=floor((i1+i2)/2);
+        ref_i=floor((i1+i2)/2);% current reference index i
     end
     ref_j=1;
@@ -1651,12 +1656,12 @@
         ref_j=j1;
         if ~isempty(j2)
-            ref_j=floor((j1+j2)/2);
+            ref_j=floor((j1+j2)/2);% current reference index j
         end
     end
     if ~isempty(increment)
         if get(handles.scan_i,'Value')==1% case of scanning along index i
-            ref_i=ref_i+increment;
+            ref_i=ref_i+increment;% increment the current reference index i
         else % case of scanning along index j (burst numbers)
-            ref_j=ref_j+increment;
+            ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used
         end
     else % free increment
@@ -1690,43 +1695,48 @@
         return
     end
-    if get(handles.scan_i,'Value')==1% case of scanning along index i
-        i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:);
-    else
-        i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:);
-    end
+    i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:);
     i1_subseries=i1_subseries(i1_subseries>0);
     if isempty(i1_subseries)
         errormsg='no next file';
         return
-    end
-    i1=i1_subseries(end);
+    else
+        i1=i1_subseries(end);
+    end
     if ~isempty(UvData.i2_series{1})
-        if get(handles.scan_i,'Value')==1% case of scanning along index i
-            i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:);
-        else
-            i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:);
-        end
+        i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:);
         i2_subseries=i2_subseries(i2_subseries>0);
         i2=i2_subseries(end);
     end
     if ~isempty(UvData.j1_series{1})
-        if get(handles.scan_i,'Value')==1% case of scanning along index i
-            j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:);
-        else
-            j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:);
-        end
+        j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:);
         j1_subseries=j1_subseries(j1_subseries>0);
         j1=j1_subseries(end);
     end
     if ~isempty(UvData.j2_series{1})
-        if get(handles.scan_i,'Value')==1% case of scanning along index i
-            j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:);
-        else
-            j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:);
-        end
+        j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:);
         j2_subseries=j2_subseries(j2_subseries>0);
         j2=j2_subseries(end);
-    end
-    
+    end  
+    % case of a second file series
+    if numel(UvData.i1_series)>=2
+        i1_subseries=UvData.i1_series{2}(ref_i+1,ref_j+1,:);
+        i1_subseries=i1_subseries(i1_subseries>0);
+        i1_1=i1_subseries(end);
+        if ~isempty(UvData.i2_series{2})
+            i2_subseries=UvData.i2_series{2}(ref_i+1,ref_j+1,:);
+            i2_subseries=i2_subseries(i2_subseries>0);
+            i2_1=i2_subseries(end);
+        end
+        if ~isempty(UvData.j1_series{2})
+            j1_subseries=UvData.j1_series{2}(ref_i+1,ref_j+1,:);
+            j1_subseries=j1_subseries(j1_subseries>0);
+            j1_1=j1_subseries(end);
+        end
+        if ~isempty(UvData.j2_series{2})
+            j2_subseries=UvData.j2_series{2}(ref_i+1,ref_j+1,:);
+            j2_subseries=j2_subseries(j2_subseries>0);
+            j2_1=j2_subseries(end);
+        end
+    end
 end
 filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2);
@@ -2104,4 +2114,5 @@
     if test_keepdata_1
         Field{2}=UvData.Field_1;% keep the stored field
+        ParamOut_1=UvData.ParamOut_1;
     else
         ParamIn_1.FieldName=FieldName_1;
@@ -2365,4 +2376,5 @@
    [UvData.Field,errormsg]=sub_field(Field{1},Field{2});  
    UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
+   UvData.ParamOut_1=ParamOut_1;
 else
    UvData.Field=Field{1};
@@ -3957,11 +3969,8 @@
 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)}
 plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles);
-Object_out=update_obj(UvData,get(handles.ListObject_1,'Value'),[])
+Object_out=update_obj(UvData,get(handles.ListObject_1,'Value'),[]);
 
 %% display the object parameters if the GUI set_object is already opened
-% hset_object=findobj(allchild(0),'tag','set_object');
-%if ~isempty(hset_object)
 if ~get(handles.ViewObject,'Value')
-%     delete(hset_object)% delete to refesh the content
     ZBounds=0; % default
     if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
@@ -3979,5 +3988,4 @@
 %------------------------------------------------------------------------
 % --- Executes on selection change in ListObject.
-
 function ListObject_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
@@ -3990,5 +3998,4 @@
 hset_object=findobj(allchild(0),'tag','set_object');
 if ~isempty(hset_object)
-%     delete(hset_object)% delete to refesh the content
     ZBounds=0; % default
     if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
@@ -4073,64 +4080,4 @@
 end
 
-%------------------------------------------------------------------------
-% --- Executes on button press in ViewObject.
-function ViewObject_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-check_view=get(handles.ViewObject,'Value');
-
-if check_view %activate set_object    
-    IndexObj=get(handles.ListObject,'Value');
-    list_object=get(handles.ListObject,'String');
-    UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
-    UvData.Object{IndexObj}.Name=list_object{IndexObj};
-    if numel(UvData.Object)<IndexObj;% error in UvData
-        msgbox_uvmat('ERROR','invalid object list')
-        return
-    end
-    ZBounds=0; % default
-    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
-        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
-        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
-    end
-%     set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion
-    data=UvData.Object{IndexObj};
-    if ~isfield(data,'Type')% default plane
-        data.Type='plane';
-    end
-    if isfield(UvData,'Field')
-        Field=UvData.Field;
-        if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
-            data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
-            if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
-                data.RangeY=UvData.Field.Mesh;
-            else
-                data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
-            end
-            data.DX=UvData.Field.Mesh;
-            data.DY=UvData.Field.Mesh;
-        end
-        if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
-            data.Coord=[0 0 0]; %default
-        end
-        if isfield(Field,'CoordUnit')
-            data.CoordUnit=Field.CoordUnit;
-        end
-    end
-    hset_object=set_object(data,[],ZBounds);
-    hhset_object=guidata(hset_object);
-    if get(handles.edit_object,'Value')% edit mode
-        set(hhset_object.PLOT,'Enable','on')
-        set(get(hset_object,'children'),'enable','on')
-    else
-        set(hhset_object.PLOT,'Enable','off')
-        set(get(hset_object,'children'),'enable','off')
-    end
-else
-    hset_object=findobj(allchild(0),'tag','set_object');
-    if ~isempty(hset_object)
-        delete(hset_object)% delete existing version of set_object
-    end
-end
-  
 %-------------------------------------------------------------------
 % --- Executes on selection change in edit_object.
@@ -4169,4 +4116,67 @@
 end
 
+
+%------------------------------------------------------------------------
+% --- Executes on button press in ViewObject.
+function ViewObject_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
+check_view=get(handles.ViewObject,'Value');
+
+if check_view %activate set_object    
+    IndexObj=get(handles.ListObject,'Value');
+    list_object=get(handles.ListObject,'String');
+    UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
+    UvData.Object{IndexObj}.Name=list_object{IndexObj};
+    if numel(UvData.Object)<IndexObj;% error in UvData
+        msgbox_uvmat('ERROR','invalid object list')
+        return
+    end
+    ZBounds=0; % default
+    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
+        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
+        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
+    end
+%     set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion
+    data=UvData.Object{IndexObj};
+    if ~isfield(data,'Type')% default plane
+        data.Type='plane';
+    end
+    if isfield(UvData,'Field')
+        Field=UvData.Field;
+        if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
+            data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
+            if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
+                data.RangeY=UvData.Field.Mesh;
+            else
+                data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
+            end
+            data.DX=UvData.Field.Mesh;
+            data.DY=UvData.Field.Mesh;
+        end
+        if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
+            data.Coord=[0 0 0]; %default
+        end
+        if isfield(Field,'CoordUnit')
+            data.CoordUnit=Field.CoordUnit;
+        end
+    end
+    hset_object=set_object(data,[],ZBounds);
+    hhset_object=guidata(hset_object);
+    if get(handles.edit_object,'Value')% edit mode
+        set(hhset_object.PLOT,'Enable','on')
+        set(get(hset_object,'children'),'enable','on')
+    else
+        set(hhset_object.PLOT,'Enable','off')
+        set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE
+        set(hhset_object.SAVE,'Enable','on')
+    end
+else
+    hset_object=findobj(allchild(0),'tag','set_object');
+    if ~isempty(hset_object)
+        delete(hset_object)% delete existing version of set_object
+    end
+end
+  
+
 %------------------------------------------------------------------------
 % --- Executes on button press in ViewField.
@@ -4176,5 +4186,4 @@
 
 if check_view
-%     set(handles.ViewObject,'Value',0)% unselect ViewObject_1 
     IndexObj=get(handles.ListObject,'Value');
     UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
@@ -4194,13 +4203,4 @@
     list_object=get(handles.ListObject,'String');
     UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)};
-%     hset_object=set_object(UvData.Object{IndexObj(end)},[],ZBounds);
-%     hhset_object=guidata(hset_object);
-%     if get(handles.edit_object,'Value')% edit mode
-%         set(hhset_object.PLOT,'Enable','on')
-%         set(get(hset_object,'children'),'enable','on')
-%     else
-%         set(hhset_object.PLOT,'Enable','off')
-%         set(get(hset_object,'children'),'enable','inactive')
-%     end
     
     %% show the second plot (on view_field)
@@ -4226,5 +4226,4 @@
 IndexObj=get(handles.ListObject,'Value');
 IndexObj_1=get(handles.ListObject_1,'Value');
-
 if IndexObj>1 && ~isequal(IndexObj,IndexObj_1)
     delete_object(IndexObj)
@@ -4513,14 +4512,14 @@
 %read the file
 data=xml2struct(fileinput);
-data.enable_plot=1;
-[tild,data.Name]=fileparts(FileName);
-hset_object=findobj(allchild(0),'tag','set_object');
-if ~isempty(hset_object)
-    delete(hset_object)% delete existing version of set_object
-end
-set_object(data);% call the set_object interface
+% data.enable_plot=1;
+[tild,data.Name]=fileparts(FileName);% object name set as file name
+% hset_object=findobj(allchild(0),'tag','set_object');
+% if ~isempty(hset_object)
+%     delete(hset_object)% delete existing version of set_object
+% end
+hset_object=set_object(data);% call the set_object interface
+set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object
 set(handles.edit_object,'Value',0); %suppress the object edit mode
 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])  
-%set(handles.MenuObject,'checked','on')
 set(handles.delete_object,'Visible','on')
 
