Index: trunk/src/uvmat.m
===================================================================
--- trunk/src/uvmat.m	(revision 77)
+++ trunk/src/uvmat.m	(revision 81)
@@ -628,8 +628,41 @@
 update_rootinfo(hObject,eventdata,handles)
 
-
-
-
-
+%-------------------------------------------------------------------
+%-- called by action in FileIndex edit box
+%-------------------------------------------------------------------
+function FileIndex_Callback(hObject, eventdata, handles)
+FileIndices=get(handles.FileIndex,'String');
+if isempty(str2num(FileIndices))
+    [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
+else
+    str1=FileIndices;
+    str2='';
+    str_a='';
+    str_b='';
+end
+set(handles.i1,'String',str1);
+set(handles.i2,'String',str2);
+set(handles.j1,'String',str_a);
+set(handles.j2,'String',str_b);
+run0_Callback(hObject, eventdata, handles)
+
+%-------------------------------------------------------------------
+%-- called by action in FileIndex_1 edit box
+%-------------------------------------------------------------------
+function FileIndex_1_Callback(hObject, eventdata, handles)
+% FileIndices=get(handles.FileIndex_1,'String');
+% if isempty(str2num(FileIndices))
+%     [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices)
+% else
+%     str1=FileIndices;
+%     str2='';
+%     str_a='';
+%     str_b='';
+% end
+% set(handles.i1,'String',str1);
+% set(handles.i2,'String',str2);
+% set(handles.j1,'String',str_a);
+% set(handles.j2,'String',str_b);
+run0_Callback(hObject, eventdata, handles)
 
 %-------------------------------------------------------------------
@@ -644,5 +677,5 @@
 UvData.NewSeries=1; %flag for run0: begin a new series
 UvData.TestInputFile=1;
-set(handles.fix_pair,'Value',0) % desactivate by default the comp_input '-'input window
+set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
 %FileIndex_Callback(hObject, eventdata, handles)% update field counters
 
@@ -860,16 +893,19 @@
 function set_scan_options(hObject, eventdata, handles)
 
-%  set the corresponding index navigation options (TO CHECK WITH THE SECOND FIELD)
-NomType=get(handles.FileIndex,'UserData');
+%  set the corresponding index navigation options 
+NomType=get(handles.FileIndex,'UserData');       
 NomType_1=get(handles.FileIndex_1,'UserData');
+last_i_str=get(handles.last_i,'String');
+nbfield=str2num(last_i_str{1});
+if numel(last_i_str)==2
+    nbfield=min(nbfield,str2num(last_i_str{2}));
+end  
 state_j='off'; %default
-scan_option='i';
+scan_option='i';%default
 switch NomType
     case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
         state_j='on';
-        if exist('nbfield','var') && isequal(nbfield,1)
-            scan_option='j'; 
-        else
-            scan_option='i';                
+        if isequal(nbfield,1)
+            scan_option='j';                 
         end 
 end
@@ -878,9 +914,7 @@
         case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
             state_j='on';
-            if exist('nbfield','var') && isequal(nbfield,1)
-                scan_option='j'; 
-            else
-                scan_option='i';                
-            end 
+            if isequal(nbfield,1)
+                scan_option='j';                 
+            end           
     end
 end
@@ -1073,5 +1107,5 @@
     end
 end
-set(handles.FileIndex,'UserData',NomType_1);
+set(handles.FileIndex_1,'UserData',NomType_1);
 
 % make visible and fill the second raw of edit boxes
@@ -1290,10 +1324,11 @@
     set(handles.scan_i,'BackgroundColor',[1 1 0])
     set(handles.scan_j,'Value',0)
-    set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
+%     set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
 else
     set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
     set(handles.scan_j,'Value',1)
-    set(handles.scan_j,'BackgroundColor',[1 1 0])
-end
+%     set(handles.scan_j,'BackgroundColor',[1 1 0])
+end
+scan_j_Callback(hObject, eventdata, handles)
 
 %-------------------------------------------------------------------
@@ -1305,8 +1340,16 @@
     set(handles.scan_i,'Value',0)
     set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
+    NomType=get(handles.FileIndex,'UserData');
+    switch NomType
+    case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
+        set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
+    otherwise
+        set(handles.fix_pair,'Visible','off')
+    end 
 else
     set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
     set(handles.scan_i,'Value',1)
     set(handles.scan_i,'BackgroundColor',[1 1 0])
+    set(handles.fix_pair,'Visible','off')
 end
 
@@ -1588,11 +1631,8 @@
 
 %-------------------------------------------------------------------
-%Executes on button press in runmin: make one step backward and call
-%run0. The step backward is along the fields series 1 or 2 depending on 
-%the scan_i and scan_j check box (exclusive each other)
-%-------------------------------------------------------------------
-function RunMovie_Callback(hObject, eventdata, handles)
+% -- Executes on button press in Movie: make a series of +> steps
+function Movie_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------
-set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
+set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
 drawnow
 increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
@@ -1600,9 +1640,9 @@
 set(handles.speed,'Visible','on')
 set(handles.speed_txt,'Visible','on')
-set(handles.RunMovie,'BusyAction','queue')
+set(handles.Movie,'BusyAction','queue')
 testavi=0;
 UvData=get(handles.uvmat,'UserData');
 
-while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
+while get(handles.speed,'Value')~=0 & isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
         errormsg=runpm(hObject,eventdata,handles,increment);
         if ~isempty(errormsg)
@@ -1615,5 +1655,32 @@
    set(handles.uvmat,'UserData',UvData);
 end
-set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
+set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
+
+%-------------------------------------------------------------------
+% -- Executes on button press in Movie: make a series of <- steps
+function MovieBackward_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------
+set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
+drawnow
+increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
+set(handles.STOP,'Visible','on')
+set(handles.speed,'Visible','on')
+set(handles.speed_txt,'Visible','on')
+set(handles.MovieBackward,'BusyAction','queue')
+testavi=0;
+UvData=get(handles.uvmat,'UserData');
+
+while get(handles.speed,'Value')~=0 & isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
+        errormsg=runpm(hObject,eventdata,handles,increment);
+        if ~isempty(errormsg)
+            return
+        end
+        pause(1.02-get(handles.speed,'Value'))% wait for next image
+end
+if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
+    UvData.aviobj=close(UvData.aviobj);
+   set(handles.uvmat,'UserData',UvData);
+end
+set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
 
 %-------------------------------------------------------------------
@@ -1622,5 +1689,6 @@
 set(handles.movie_pair,'BusyAction','Cancel')
 set(handles.movie_pair,'value',0)
-set(handles.RunMovie,'BusyAction','Cancel')
+set(handles.Movie,'BusyAction','Cancel')
+set(handles.MovieBackward,'BusyAction','Cancel')
 set(handles.MenuExportMovie,'BusyAction','Cancel')
 
@@ -1658,8 +1726,8 @@
 
 comp_input=get(handles.fix_pair,'Value');
-if isequal(NomType,'_i1-i2')||isequal(NomType,'_i1-i2_j')
-    comp_input=1; %impose a fixed pair 
-    set(handles.fix_pair,'Value',1)
-end
+% if isequal(NomType,'_i1-i2')||isequal(NomType,'_i1-i2_j')
+%     comp_input=1; %impose a fixed pair 
+%     set(handles.fix_pair,'Value',1)
+% end
 
 %case of scanning along the first direction (rootfile numbers)
@@ -1709,5 +1777,5 @@
     [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
     set(handles.FileIndex,'String',indices);
-    if sub_value 
+    if ~isempty(filename_1) 
          indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
          set(handles.FileIndex_1,'String',indices_1);
@@ -1897,4 +1965,5 @@
 function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
 %------------------------------------------------------------------------
+
 %initialisation
 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
@@ -1926,5 +1995,4 @@
 FileType=[];%default
 if ~isempty(filename)
-%     [filename,RootPath,filebase,xx,Ext]=read_file_boxes(handles);
     if ~exist(filename,'file')
         errormsg=['input file ' filename ' does not exist'];
@@ -2421,9 +2489,6 @@
     if NbDim==3
         nbpoints=UvData.Field.DimValue(DimIndex(1));
-        %Zvar=DimVarIndex(DimIndex(1));
-         %Zvar=DimVarIndex(1);
-%          Zvar=VarType{imax}.coord_3;
         if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
-            ZName=UvData.Field.ListVarName{VarType{imax}.coord_3}
+            ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
             eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
             eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
@@ -3075,5 +3140,5 @@
     set(handles.npx,'Visible','on')
     set(handles.npy,'Visible','on')
-    set(handles.fix_pair,'Value',0)
+%     set(handles.fix_pair,'Value',0)
 else
     set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
@@ -3081,5 +3146,5 @@
     set(handles.npx,'Visible','off')
     set(handles.npy,'Visible','off')
-    set(handles.fix_pair,'Value',1)
+%     set(handles.fix_pair,'Value',1)
 end
 setfield(handles);% update the field structure ('civ1'....)
@@ -3246,5 +3311,5 @@
     set(handles.npx,'Visible','on')
     set(handles.npy,'Visible','on')
-    set(handles.fix_pair,'Value',0)
+%     set(handles.fix_pair,'Value',0)
 else
     set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
@@ -3252,5 +3317,5 @@
     set(handles.npx,'Visible','off')
     set(handles.npy,'Visible','off')
-    set(handles.fix_pair,'Value',1)
+%     set(handles.fix_pair,'Value',1)
 end
 if isequal(field,'velocity')|isequal(field_1,'velocity');
@@ -4415,5 +4480,5 @@
 set(handles.speed,'Visible','on')
 set(handles.speed_txt,'Visible','on')
-set(handles.RunMovie,'BusyAction','queue')
+set(handles.Movie,'BusyAction','queue')
 
 imin=str2num(get(handles.i1,'String'));
@@ -4759,5 +4824,5 @@
 end
 UvData=get(handles.uvmat,'UserData');
-% [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
+[hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
 % %position the set_object GUI with respect to uvmat
 % pos_uvmat=get(handles.uvmat,'Position');
@@ -4866,2 +4931,6 @@
     
 
+
+
+
+
