Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 223)
+++ /trunk/src/civ.m	(revision 224)
@@ -182,5 +182,5 @@
 elseif isequal(ind_opening,4)
     set(handles.CIV2,'Value',1)
-    enable_civ2(handles,1)
+    enable_civ2(handles,'on')
 elseif isequal(ind_opening,5)
     set(handles.FIX2,'Value',1)
@@ -424,5 +424,5 @@
 elseif isequal(ind_opening,4)
     set(handles.CIV2,'Value',1)
-    enable_civ2(handles,1)
+    enable_civ2(handles,'on')
 elseif isequal(ind_opening,5)
     enable_pair1(handles,'off')
@@ -1710,5 +1710,5 @@
     end
     if isfield(sparam,'CivBin')
-        if ~exist(sparam.CivBin,'file')
+        if ~exist(sparam.CivBin,'file')||~isequal(which(sparam.CivBin),sparam.CivBin)% if path defined as relative to uvmat
             CivBin=sparam.CivBin;
             sparam.CivBin=fullfile(path_UVMAT,sparam.CivBin);
@@ -1720,9 +1720,9 @@
     end
     if isfield(sparam,'Civ1Bin')
-        if ~exist(sparam.Civ1Bin,'file')
-            CivBin=sparam.Civ1Bin;
+        if ~exist(sparam.Civ1Bin,'file')||~isequal(which(sparam.Civ1Bin),sparam.Civ1Bin)% if path defined as relative to uvmat
+%             CivBin=sparam.Civ1Bin;
             sparam.Civ1Bin=fullfile(path_UVMAT,sparam.Civ1Bin);
-            if ~exist(sparam.CivBin,'file')
-                 msgbox_uvmat('ERROR',['civ1 binary ' CivBin ' defined in PARAM.xm does not exist'])
+            if ~exist(sparam.Civ1Bin,'file')
+                 msgbox_uvmat('ERROR',['civ1 binary ' sparam.Civ1Bin ' defined in PARAM.xm does not exist'])
                  return
             end
@@ -1730,9 +1730,9 @@
     end
     if isfield(sparam,'Civ2Bin')
-        CivBin=sparam.Civ2Bin;
-        if ~exist(sparam.Civ2Bin,'file')
+%         CivBin=sparam.Civ2Bin;
+        if ~exist(sparam.Civ2Bin,'file')||~isequal(which(sparam.Civ2Bin),sparam.Civ2Bin)% if path defined as relative to uvmat
             sparam.Civ2Bin=fullfile(path_UVMAT,sparam.Civ2Bin);
             if ~exist(sparam.Civ2Bin,'file')
-                 msgbox_uvmat('ERROR',['civ2 binary ' CivBin ' defined in PARAM.xm does not exist'])
+                 msgbox_uvmat('ERROR',['civ2 binary ' sparam.Civ2Bin ' defined in PARAM.xm does not exist'])
                  return
             end
@@ -1740,10 +1740,10 @@
     end
     if  isfield(sparam,'PatchBin')
-        if ~exist(sparam.PatchBin,'file')
+        if ~exist(sparam.PatchBin,'file')||~isequal(which(sparam.PatchBin),sparam.PatchBin)% if path defined as relative to uvmat
             sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin);
         end
     end
     if isfield(sparam,'FixBin')
-        if ~exist(sparam.FixBin,'file')
+        if ~exist(sparam.FixBin,'file')||~isequal(which(sparam.FixBin),sparam.FixBin)% if path defined as relative to uvmat
             sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin);
         end
@@ -2980,5 +2980,5 @@
     %     npx=npxy(2);
     if box_test(1)==1 %if civ1 is performed
-        h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar
+        h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
         for ifile=1:nbfield
             waitbar(ifile/nbfield);
@@ -3027,5 +3027,5 @@
 function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin)
 %------------------------------------------------------------------------
-namelog=[filename_nc([1:end-3]) '_patch.log'];
+namelog=[filename_nc(1:end-3) '_patch.log'];
 if test_interp==0
     if isunix
@@ -3045,5 +3045,5 @@
 function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)
 %------------------------------------------------------------------------
-namelog=[filename_nc([1:end-3]) '_stinterp.log'];
+namelog=[filename_nc(1:end-3) '_stinterp.log'];
 cmd=[stinterpBin ' -f1 ' filename_A_nc  ' -f2 ' filename_B_nc ' -f  ' filename_nc ...
     ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB '  -xy  x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file
@@ -3644,10 +3644,4 @@
 function enable_civ1(handles,state)
 %------------------------------------------------------------------------
-if isequal(state,0)
-    state='off';
-end
-if isequal(state,1)
-    state='on';
-end
 if isequal(state,'on')
     set(handles.frame_civ1,'BackgroundColor',[1 1 0])
@@ -3698,4 +3692,6 @@
 set(handles.shift_title,'Visible',state)
 set(handles.rho_title,'Visible',state)
+set(handles.TestCiv1,'Visible',state)
+%set(handles.CivAll,'Visible',state)
 
 %------------------------------------------------------------------------
@@ -3731,10 +3727,11 @@
 function enable_patch1(handles)
 %------------------------------------------------------------------------
-global patch_newBin
 set(handles.frame_patch1,'BackgroundColor',[1 1 0])
 set(handles.rho_patch1,'Visible','on')
 set(handles.rho_text1,'Visible','on')
-set(handles.thresh_patch1,'Visible','on')
-set(handles.thresh_text1,'Visible','on')
+if get(handles.CivAll,'Value')
+    set(handles.thresh_patch1,'Visible','on')
+    set(handles.thresh_text1,'Visible','on')
+end
 set(handles.subdomain_patch1,'Visible','on')
 set(handles.subdomain_text1,'Visible','on')
@@ -3744,5 +3741,5 @@
 set(handles.ny_patch1_title,'Visible','on')
 % if ~isempty(patch_newBin)
-%     set(handles.test_interp,'Visible','on');
+set(handles.test_interp,'Visible','off');
 % end
 set(handles.get_gridpatch1,'Visible','on')
@@ -4583,22 +4580,44 @@
 end
 
-
+%------------------------------------------------------------------------
 % --- Executes on button press in TestCiv1.
 function TestCiv1_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 test_civ1=get(handles.TestCiv1,'Value');
 if test_civ1
-[filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
-    set_civ_filenames(handles,[1 0 0 0 0 0]);
-Data.ListVarName={'ny','nx','A'};
-Data.VarDimName={'ny','nx',{'ny','nx'}};
-Data.A=imread(filecell.ima1.civ1{1});
-Data.ny=[size(Data.A,1) 1];
-Data.nx=[1 size(Data.A,2)];
-hh=view_field(Data);
-ViewData=get(hh,'UserData');
-ViewData.axes3.B=imread(filecell.ima2.civ1{1});
-set(hh,'UserData',ViewData)
-end
-
+    [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
+        set_civ_filenames(handles,[1 0 0 0 0 0]);
+    Data.ListVarName={'ny','nx','A'};
+    Data.VarDimName={'ny','nx',{'ny','nx'}};
+    Data.A=imread(filecell.ima1.civ1{1});
+    Data.ny=[size(Data.A,1) 1];
+    Data.nx=[1 size(Data.A,2)];
+    hh=view_field(Data);
+    ViewData=get(hh,'UserData');
+    ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field
+    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
+    if isempty(corrfig)
+        corrfig=figure;
+        set(corrfig,'tag','corrfig')
+        set(corrfig,'name','image correlation')
+        set(corrfig,'DeleteFcn',{@closeview_field})%
+    end
+    set(hh,'UserData',ViewData)
+else
+    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
+    if ~isempty(corrfig)
+        delete(corrfig)
+    end
+    hview_field=findobj(allchild(0),'tag','view_field');% look for view_field    
+    if ~isempty(hview_field)
+        delete(hview_field)
+    end
+end
+
+function closeview_field(gcbo,eventdata)
+hview_field=findobj(allchild(0),'tag','view_field');% look for view_field    
+    if ~isempty(hview_field)
+        delete(hview_field)
+    end
 %-------------------------------------------------------------------
 % --- Executes on button press in status.
@@ -4754,9 +4773,12 @@
 % --- Executes on button press in CivAll.
 function CivAll_Callback(hObject, eventdata, handles)
-% hObject    handle to CivAll (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 CivAll
-
-
+if get(handles.CivAll,'Value')
+    if get(handles.PATCH1,'Value')
+        set(handles.thresh_patch1,'Visible','on')
+        set(handles.thresh_text1,'Visible','on')
+    end
+else
+    set(handles.thresh_patch1,'Visible','off')
+    set(handles.thresh_text1,'Visible','off')
+end
+
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 223)
+++ /trunk/src/mouse_motion.m	(revision 224)
@@ -220,8 +220,9 @@
                         isx2=floor((str2double(par.isx)-1)/2);
                         isy2=floor((str2double(par.isy)-1)/2);
+                        shiftx=str2double(par.shiftx);
+                        shifty=str2double(par.shifty);
                         hhh=findobj(haxes,'Tag','PIV_box_marker');
                         hhhh=findobj(haxes,'Tag','PIV_search_marker');
                         if isempty(hhh)
-                            %hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab
                             set(0,'CurrentFigure',currentfig)
                             set(currentfig,'CurrentAxes',haxes)
@@ -230,23 +231,23 @@
                                 'LineStyle','-','Tag','PIV_box_marker');
                             rectangle('Curvature',[0 0],...
-                                'Position',[xround-isx2 yround-isy2 2*isx2 2*isy2],'EdgeColor','m',...
+                                'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
                                 'LineStyle','- -','Tag','PIV_search_marker');
-                            % set(0,'Children',hstack);%put back the initial figure stack after plot creation
                         else
 %                             set(hhh,'Visible','on')
                             set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
-                            set(hhhh,'Position',[xround-isx2 yround-isy2 2*isx2 2*isy2])
-                        end
-                        Asub=Field.A(xround-ibx2:xround+ibx2,yround-iby2:yround+iby2);
-                        Asub=reshape(Asub,[],1);
-                        rangx(1)=-(isx2-ibx2);
-                        rangx(2)=isx2-ibx2;
-                        rangy(1)=isy2-iby2;
-                        rangy(2)=-(isy2-iby2);
+                            set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
+                        end
+                        Asub=Field.A(yround-iby2:yround+iby2,xround-ibx2:xround+ibx2);%first sub-image
+                        Asub=reshape(Asub,[],1);%first sub-image reshaped as matlab vector
+                        rangx(1)=-(isx2-ibx2)+shiftx;
+                        rangx(2)=isx2-ibx2+shiftx
+                        rangy(1)=-(isy2-iby2)-shifty;
+                        rangy(2)=(isy2-iby2)-shifty
+                        correl=zeros(rangy(2)-rangy(1)+1,rangx(2)-rangx(1)+1);
                         for id=rangx(1):rangx(2)
-                            for jd=rangy(2):rangy(1)
-                                Bsub=Field.B(xround-ibx2+id:xround+ibx2+id,yround-iby2+jd:yround+iby2+jd);
+                            for jd=rangy(1):rangy(2)
+                                Bsub=Field.B(yround-iby2+jd:yround+iby2+jd,xround-ibx2+id:xround+ibx2+id);
                                 Bsub=reshape(Bsub,[],1);
-                                correl(jd-rangy(2)+1,id-rangx(1)+1)=corr(double(Asub),double(Bsub));
+                                correl(jd-rangy(1)+1,id-rangx(1)+1)=corr(double(Asub),double(Bsub));
                             end
                         end
@@ -261,19 +262,15 @@
                         if isempty(hcorr)
                             corrfig=findobj(allchild(0),'tag','corrfig');
-                            if isempty(corrfig)
-                                corrfig=figure;
-                                set(corrfig,'tag','corrfig')
-                            end
-                            set(0,'CurrentFigure',corrfig)
-                            AxeData.CurrentCorrImage=imagesc(rangx,rangy,correl,[0 1]);
-                            colorbar
-%                             map_r=ones(42,1)*[1 0 0];
-%                             map_g=ones(11,1)*[0 1 0];
-%                             map_b=ones(11,1)*[0 0 1];
-%                             map=[map_r;map_g;map_b];
-%                             set(corrfig,'colormap',map)
-                            set(haxes,'UserData',AxeData)
+                            if ~isempty(corrfig)
+                                set(0,'CurrentFigure',corrfig(1))
+                                AxeData.CurrentCorrImage=imagesc(rangx,-rangy,correl,[0 1]);
+                                colorbar
+                                set(haxes,'UserData',AxeData)
+                                set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
+                            end
                         else
                             set(AxeData.CurrentCorrImage,'CData',correl)
+                            set(AxeData.CurrentCorrImage,'XData',rangx)
+                            set(AxeData.CurrentCorrImage,'YData',-rangy)
                         end        
                     end
