Index: /trunk/src/find_imadoc.m
===================================================================
--- /trunk/src/find_imadoc.m	(revision 737)
+++ /trunk/src/find_imadoc.m	(revision 738)
@@ -22,6 +22,4 @@
     end   
 end
-% SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
-% XmlFileName=[fullfile(RootPath,SubDirBase) '.xml'];%new convention: xml at the level of the image folder
 if ~exist(XmlFileName,'file')
     XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 737)
+++ /trunk/src/geometry_calib.m	(revision 738)
@@ -50,5 +50,5 @@
 % Edit the above text to modify the response to help geometry_calib
 
-% Last Modified by GUIDE v2.5 29-Oct-2013 06:46:10
+% Last Modified by GUIDE v2.5 11-Apr-2014 23:10:57
 
 % Begin initialization code - DO NOT edit
@@ -110,9 +110,10 @@
 set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])%  rank 3
 set(handles.PointLists,'Position',[1 Height-40-6-92-75-117 418 117]) %  rank 4
-set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 203 30])%  rank 5
+set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 180 30])%  rank 5
 set(handles.PLOT,'Position',[3 Height-394 120 30])%  rank 6
 set(handles.Copy,'Position',[151 Height-394 120 30])%  rank 6
 set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])%  rank 6
 set(handles.ClearLine,'Position',[297 Height-364 120 30])%  rank 6
+set(handles.CoordLine,'Position',[177 Height-364 120 30])%  rank 6
 set(handles.phys_title,'Position',[38 Height-426 125 20])%  rank 7
 set(handles.CoordUnit,'Position',[151 Height-426 120 30])%  rank 7
@@ -124,21 +125,22 @@
 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
 if exist('inputfile','var')&& ~isempty(inputfile)
-    struct.XmlInputFile=inputfile;
+%     struct.XmlInputFile=inputfile;
     [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile);
-    if ~strcmp(FileExt,'.xml')
-        inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file
-        if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir
-            inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
-            if ~exist(inputfile,'file')
-                inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention
-                if ~exist(inputfile,'file')
-                    inputfile='';
-                end
-            end
-        end
-    end
+    struct.XmlInputFile=find_imadoc(RootPath,SubDir,RootFile,FileExt);
+%     if ~strcmp(FileExt,'.xml')
+%         inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file
+%         if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir
+%             inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
+%             if ~exist(inputfile,'file')
+%                 inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention
+%                 if ~exist(inputfile,'file')
+%                     inputfile='';
+%                 end
+%             end
+%         end
+%     end
     set(handles.ListCoord,'Data',[])
-    if exist(inputfile,'file')
-        Heading=loadfile(handles,inputfile);% load data from the xml file
+    if exist(struct.XmlInputFile,'file')
+        Heading=loadfile(handles,struct.XmlInputFile);% load data from the xml file
         if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
             struct.Campaign=Heading.Campaign;
@@ -214,25 +216,15 @@
     
     %% display image with new calibration in the currently opened uvmat interface
-    hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
-    if ~isempty(hhh)
-        delete(hhh);
-    end
-    hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
-    if ~isempty(hhh)
-        delete(hhh);
-    end
-    set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
-    set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
+    set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
     UserData=get(handles.geometry_calib,'UserData');
     UserData.XmlInputFile=outputfile;%save the current xml file name
     set(handles.geometry_calib,'UserData',UserData)
-    uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
+    uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     PLOT_Callback(hObject, eventdata, handles)
-    Data=get(handles.ListCoord,'Data');
-    Data(:,6)=zeros(size(Data,1),1);
-    Data(index,6)=-1;% indicate in the list the point with max deviation (possible mistake)
-    set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake)
-    figure(handles.geometry_calib)
-    set(handles.APPLY,'BackgroundColor',[1 0 0])
+    set(handles.CoordLine,'string',num2str(index))
+    Coord=get(handles.ListCoord,'Data');
+    update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration
+    figure(handles.geometry_calib)% put the GUI geometry_calib in front
+    set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color 
 end
 
@@ -338,16 +330,16 @@
 %% store the calibration data, by default in the xml file of the currently displayed image
 UvData=get(hhuvmat.uvmat,'UserData');
-NbSlice_j=1;%default
-ZStart=Z_plane;
-ZEnd=Z_plane;
-volume_scan='n';
-if isfield(UvData,'XmlData')
-    if isfield(UvData.XmlData,'TranslationMotor')
-        NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
-        ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
-        ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
-        volume_scan='y';
-    end
-end
+% NbSlice_j=1;%default
+% ZStart=Z_plane;
+% ZEnd=Z_plane;
+% volume_scan='n';
+% if isfield(UvData,'XmlData')
+%     if isfield(UvData.XmlData,'TranslationMotor')
+%         NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
+%         ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
+%         ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
+%         volume_scan='y';
+%     end
+% end
 
 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';...
@@ -362,26 +354,25 @@
 end
 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
-    input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
-    input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
-    answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
-    GeometryCalib.NbSlice=str2double(answer{5});
-    GeometryCalib.VolumeScan=answer{6};
-    if isempty(answer)
-        Z_plane=0; %default
-    else
-        Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
-    end
-    GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
-    GeometryCalib.SliceAngle(:,3)=0;
-    GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
-    GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
-    GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
-    GeometryCalib.RefractionIndex=str2double(answer{4});
-end
-
-
-
-%------------------------------------------------------------------------
-% determine the parameters for a calibration by an affine function (rescaling and offset, no rotation)
+    msgbox_uvmat('CONFIRMATION',{['The current image series is assumed by default in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be modified by MenuSetSlice in the upper bar menu of uvmat'})
+%     input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
+%     input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
+%     answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
+%     GeometryCalib.NbSlice=str2double(answer{5});
+%     GeometryCalib.VolumeScan=answer{6};
+%     if isempty(answer)
+%         Z_plane=0; %default
+%     else
+%         Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
+%     end
+     GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
+%     GeometryCalib.SliceAngle(:,3)=0;
+%     GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
+%     GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
+%     GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
+%     GeometryCalib.RefractionIndex=str2double(answer{4});
+end
+
+%------------------------------------------------------------------------
+% --- determine the parameters for a calibration by an affine function (rescaling and offset, no rotation)
 function GeometryCalib=calib_rescale(Coord,handles)
 %------------------------------------------------------------------------
@@ -401,7 +392,5 @@
 
 %------------------------------------------------------------------------
-% determine the parameters for a calibration by a linear transform matrix (rescale and rotation)
-
-
+% --- determine the parameters for a calibration by a linear transform matrix (rescale and rotation)
 function GeometryCalib=calib_linear(Coord,handles) 
 %------------------------------------------------------------------------
@@ -432,5 +421,5 @@
 
 %------------------------------------------------------------------------
-% determine the tsai parameters for a view normal to the grid plane
+% --- determine the tsai parameters for a view normal to the grid plane
 % NOT USED
 function GeometryCalib=calib_normal(Coord,handles)
@@ -498,5 +487,5 @@
 %------------------------------------------------------------------------
 function GeometryCalib=calib_3D_linear(Coord,handles)
-%------------------------------------------------------------------
+%------------------------------------------------------------------------
 path_uvmat=which('uvmat');% check the path detected for source file uvmat
 path_UVMAT=fileparts(path_uvmat); %path to UVMAT
@@ -708,4 +697,5 @@
 % --- determine the rms of calibration error
 function ErrorRms=error_calib(calib_param,Calib,Coord)
+%------------------------------------------------------------------------
 %calib_param: vector of free calibration parameters (to optimise)
 %Calib: structure of the given calibration parameters
@@ -734,17 +724,9 @@
 ErrorRms=mean(ErrorRms);
 
-% %------------------------------------------------------------------------
-% function XImage_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% update_list(hObject, eventdata,handles)
-% 
-% %------------------------------------------------------------------------
-% function YImage_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% update_list(hObject, eventdata,handles)
 
 %------------------------------------------------------------------------
 % --- Executes on button press in STORE.
 function STORE_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 Coord=get(handles.ListCoord,'Data');
 %Object=read_geometry_calib(Coord_cell);
@@ -761,5 +743,5 @@
     RootPath=get(hhuvmat.RootPath,'String');
     RootFile=get(hhuvmat.RootFile,'String');
-    filebase=fullfile(RootPath,RootFile);
+    filebase=[fullfile(RootPath,RootFile) '~'];
     while exist([filebase '.xml'],'file')
         filebase=[filebase '~'];
@@ -778,5 +760,5 @@
     set(handles.ListCoordFiles,'string',listfile);
 end
-set(handles.ListCoord,'Data',[])
+CLEAR_PTS_Callback(hObject, eventdata, handles)% clear the current list and point plots
 
 % --------------------------------------------------------------------
@@ -786,7 +768,10 @@
 set(handles.ListCoord,'Data',[])
 PLOT_Callback(hObject, eventdata, handles)
-
-%------------------------------------------------------------------------
-% --- Executes on button press in CLEAR.
+update_calib_marker([]);%remove circle marker
+set(handles.APPLY,'backgroundColor',[1 0 0])% set APPLY button to red color: no calibration wanted without points
+set(handles.CheckEnableMouse,'value',1); %activate mouse to pick new points
+
+%------------------------------------------------------------------------
+% --- Executes on button press in CLEAR LIST
 function CLEAR_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
@@ -800,15 +785,14 @@
 choice=get(handles.CheckEnableMouse,'Value');
 if choice
-    set(handles.CheckEnableMouse,'BackgroundColor',[1 1 0])
     huvmat=findobj(allchild(0),'tag','uvmat');
     if ishandle(huvmat)
         hhuvmat=guidata(huvmat);
+        set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler
         if get(hhuvmat.CheckEditObject,'Value')
-        set(hhuvmat.CheckEditObject,'Value',0)
-        uvmat('CheckEditObject_Callback',hhuvmat.CheckEditObject,[],hhuvmat)
+            set(hhuvmat.CheckEditObject,'Value',0)
+            uvmat('CheckEditObject_Callback',hhuvmat.CheckEditObject,[],hhuvmat)
         end
-    end
-else
-    set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) 
+        set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler
+    end
 end
 
@@ -841,4 +825,5 @@
 set(handles.ListCoord,'Data',Coord)
 set(handles.APPLY,'BackgroundColor',[1 0 1])
+set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points
 
 %------------------------------------------------------------------------
@@ -858,4 +843,5 @@
 set(handles.ListCoord,'Data',Coord)
 set(handles.APPLY,'BackgroundColor',[1 0 1])
+set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points
 
 % -----------------------------------------------------------------------
@@ -1002,10 +988,5 @@
 PLOT_Callback(hObject, eventdata, handles)
 set(handles.APPLY,'BackgroundColor',[1 0 1])
-
-% figure(10)
-% hold off
-% imagesc(Amod)
-% hold on
-% plot(Tmod(:,1),Tmod(:,2),'+')
+set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points
 
 
@@ -1085,4 +1066,5 @@
 PLOT_Callback(handles.geometry_calib, [], handles)
 set(handles.APPLY,'BackgroundColor',[1 0 1])
+set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid modifications by default
 
 % -----------------------------------------------------------------------
@@ -1104,4 +1086,5 @@
     loadfile(handles,fileinput)
 end
+set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid modifications by default
 
 % -----------------------------------------------------------------------
@@ -1116,5 +1099,5 @@
     listfile=[listfile;{inputfile}];%update the list of coord files
 end
-set(handles.ListCoordFiles,'string',listfile);
+set(handles.ListCoordFiles,'String',listfile);
 
 
@@ -1243,8 +1226,7 @@
 menu=get(h_menu_coord,'String');
 choice=get(h_menu_coord,'Value');
+option='';
 if iscell(menu)
     option=menu{choice};
-else
-    option='px'; %default
 end
 Coord=get(handles.ListCoord,'Data');
@@ -1252,8 +1234,8 @@
     if isequal(option,'phys')
         Coord_plot=Coord(:,1:3);
-    elseif isequal(option,'px')||isequal(option,'')
+    elseif isempty(option);%optionoption,'px')||isequal(option,'')
         Coord_plot=Coord(:,4:5);
     else
-        msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank, px or phys ')
+        msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank or phys ')
     end
 end
@@ -1290,9 +1272,7 @@
 if ~isempty(eventdata.Indices)
     iline=eventdata.Indices(1);% selected line number
-    Data=get(handles.ListCoord,'Data');
-    Data(:,6)=zeros(size(Data,1),1);
-    Data(iline,6)=-1;% mark the selected line
-    set(handles.ListCoord,'Data',Data)
-    update_calib_marker(Data(iline,:))
+    set(handles.CoordLine,'String',num2str(iline))
+     Data=get(handles.ListCoord,'Data');
+     update_calib_marker(Data(iline,:))
 end
 
@@ -1316,23 +1296,20 @@
 %------------------------------------------------------------------------
 function ListCoord_KeyPressFcn(hObject, eventdata, handles)
+iline=str2num(get(handles.CoordLine,'String'));
 xx=double(get(handles.geometry_calib,'CurrentCharacter'));%get the keyboard character
-if ismember(xx,[30 31 127])% arrow upward, downward, or delete
+if ismember(xx,[28 29 30 31])% directional arrow 
     Coord=get(handles.ListCoord,'Data');
-    ind=find(Coord(:,6));%find the marker '+' for line selection
-    Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
     switch xx
         case 30 % arrow upward
-            Coord(ind-1,6)=1;
+            iline=iline-1;
         case 31% arrow downward
-            Coord(ind+1,6)=1;
-        case 127% remove line
-            Coord(ind,:)=[];
-            PLOT_Callback(hObject,eventdata,handles)
-            set(handles.APPLY,'BackgroundColor',[1 0 1])
-        otherwise
-    end
-    set(handles.ListCoord,'Data',Coord);
+            iline=iline+1;
+    end
+    if iline>=1 && iline<=size(Coord,1)
+        set(handles.CoordLine,'String',num2str(iline))
+        update_calib_marker(Coord(iline,1:5))% show the point corresponding to the selected line
+    end
 else
-    set(handles.APPLY,'BackgroundColor',[1 0 1])
+    set(handles.APPLY,'BackgroundColor',[1 0 1])% paint APPLY in magenta to indicate that the table content has be modified
 end
 
@@ -1341,42 +1318,74 @@
 % --- update the plot of calibration points
 %------------------------------------------------------------------------ 
+% draw a circle around the point defined by the input coordinates Coord as given by line in the table Listcoord
 function update_calib_marker(Coord)
-%% update the plot on uvmat
+
+%% read config on uvmat
 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
-hplot=findobj(huvmat,'Tag','PlotAxes');%main plotting axis of uvmat
-hhh=findobj(hplot,'Tag','calib_marker');
-
-h_menu_coord=findobj(huvmat,'Tag','TransformName');
-menu=get(h_menu_coord,'String');
-choice=get(h_menu_coord,'Value');
+hhuvmat=guidata(huvmat);
+hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');
+if numel(Coord)<5
+    if ~isempty(hhh)
+        delete(hhh)%delete the circle marker in case of no valid input
+    end
+    return
+end
+menu=get(hhuvmat.TransformName,'String');
+choice=get(hhuvmat.TransformName,'Value');
+option='';
 if iscell(menu)
     option=menu{choice};
-else
-    option='px'; %default
-end
-if isequal(option,'phys')
+end
+
+%% read appropriate coordinates (px or phys) in the table ListCoord
+if isequal(option,'phys') % use phys coord 
     XCoord=Coord(1);
     YCoord=Coord(2);
-elseif isequal(option,'px')|| isequal(option,'')
+elseif isempty(option)% use coord in pixels
     XCoord=Coord(4);
     YCoord=Coord(5);
 else
-    msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank, px or phys ')
-end
-if isempty(XCoord)||isempty(YCoord)
-     if ~isempty(hhh)
-        delete(hhh)%delete the circle marker
-    end
+    msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank or phys ')
     return
 end
-xlim=get(hplot,'XLim');
-ylim=get(hplot,'YLim');
-ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/20;%defines the size of the circle marker
+
+%% adjust the plot limits if needed
+xlim=get(hhuvmat.PlotAxes,'XLim');
+ylim=get(hhuvmat.PlotAxes,'YLim');
+ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker
+check_xlim=0;
+if XCoord>xlim(2)
+    xlim=xlim+XCoord-xlim(2)+ind_range;% translate plot limit
+    check_xlim=1;
+elseif XCoord<xlim(1)
+    xlim=xlim-XCoord+xlim(1)-ind_range;% translate plot limit
+    check_xlim=1;
+end
+if check_xlim
+    set(hhuvmat.PlotAxes,'XLim',xlim);
+    set(hhuvmat.num_MaxX,'String',num2str(xlim(2)));
+    set(hhuvmat.num_MinX,'String',num2str(xlim(1)));
+end
+check_ylim=0;
+if YCoord>ylim(2)
+    ylim=ylim+YCoord-ylim(2)+ind_range;% translate plot limit
+    check_ylim=1;
+elseif YCoord<ylim(1)
+    ylim=ylim-YCoord+ylim(1)-ind_range;% translate plot limit
+    check_ylim=1;
+end
+if check_ylim
+    set(hhuvmat.PlotAxes,'YLim',ylim);
+    set(hhuvmat.num_MaxY,'String',num2str(ylim(2)));
+    set(hhuvmat.num_MinY,'String',num2str(ylim(1)));
+end
+
+%% plot a circle around the selected point
 if isempty(hhh)
     set(0,'CurrentFig',huvmat)
-    set(huvmat,'CurrentAxes',hplot)
+    set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)
     rectangle('Curvature',[1 1],...
-              'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range],'EdgeColor','m',...
-              'LineStyle','-','Tag','calib_marker');
+        'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range],'EdgeColor','m',...
+        'LineStyle','-','Tag','calib_marker');
 else
     set(hhh,'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range])
@@ -1389,15 +1398,17 @@
 
 Coord=get(handles.ListCoord,'Data');
-ind=find(Coord(:,6));%find the marker '-' for line selection
-if isempty(ind)
+iline=str2num(get(handles.CoordLine,'String'));
+if isempty(iline)
     msgbox_uvmat('WARNING','no line suppressed, select a line in the table')
 else
-    answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(ind) '?']);
+    answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(iline) '?']);
     if isequal(answer,'Yes')
-Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
-Coord(ind,:)=[];
-PLOT_Callback(hObject,eventdata,handles)
-set(handles.APPLY,'BackgroundColor',[1 0 1])
-set(handles.ListCoord,'Data',Coord);
-    end
-end
+        Coord(iline,:)=[];
+        set(handles.APPLY,'BackgroundColor',[1 0 1])
+        set(handles.ListCoord,'Data',Coord);
+        set(handles.CoordLine,'String','')
+        PLOT_Callback(hObject,eventdata,handles)
+        update_calib_marker([]);%remove circle marker
+    end
+end
+
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 737)
+++ /trunk/src/mouse_motion.m	(revision 738)
@@ -403,25 +403,26 @@
         if isnumeric(data.Coord)&&~isempty(data.Coord)
             if test_transform
-                            XCoord=(data.Coord(:,1));
-            YCoord=(data.Coord(:,2));
+                XCoord=(data.Coord(:,1));
+                YCoord=(data.Coord(:,2));
             else
-            XCoord=(data.Coord(:,4));
-            YCoord=(data.Coord(:,5));
+                XCoord=(data.Coord(:,4));
+                YCoord=(data.Coord(:,5));
             end
             xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
             if ~isempty(xy)
                 xlim=get(CurrentAxes,'XLim');
-                ind_range_x=abs((xlim(2)-xlim(1))/50);
+%                 ind_range_x=abs((xlim(2)-xlim(1))/50);
                 ylim=get(CurrentAxes,'YLim');
-                ind_range_y=abs((ylim(2)-ylim(1))/50);
-                ind_range=sqrt(ind_range_x*ind_range_y);
-                index_point=find((XCoord<xy(1,1)+ind_range) & (XCoord>xy(1,1)-ind_range) & ...%flagx=1 for the vectors with x position selected by the mouse
-                              (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
+                ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker
+%                 ind_range_y=abs((ylim(2)-ylim(1))/50);
+%                 ind_range=sqrt(ind_range_x*ind_range_y);
+                index_point=find((XCoord<xy(1,1)+ind_range/2) & (XCoord>xy(1,1)-ind_range/2) & ...%flagx=1 for the vectors with x position selected by the mouse
+                    (YCoord<xy(1,2)+ind_range/2) & (YCoord>xy(1,2)-ind_range/2),1);%find the first calibration point in the neighborhood of the mouse
                 if ~isempty(index_point)
-                    pointershape='arrow';% default pointer is an arrow 
+                    pointershape='arrow';% default pointer is an arrow
                 end
                 hh=findobj('Tag','calib_points');%look for handle of calibration points
-               if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value') 
-                   %set(hh,'UserData',index_point)
+                if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value')
+                    %set(hh,'UserData',index_point)
                     index_point=get(hh,'UserData');
                     XCoord(index_point)=xy(1,1);
@@ -429,17 +430,18 @@
                     set(hh,'XData',XCoord)
                     set(hh,'YData',YCoord)
-               end
+                end
                 if ~isempty(index_point)
-                    Data=get(h_ListCoord,'Data');
-                    Data(:,6)=zeros(size(Data,1),1);
-                    Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib
-                    set(h_ListCoord,'Data',Data);
+                    set(hh_geometry_calib.CoordLine,'String',num2str(index_point))
+                   % Data=get(h_ListCoord,'Data');
+%                     Data(:,6)=zeros(size(Data,1),1);
+%                     Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib
+%                     set(h_ListCoord,'Data',Data);
                     hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
                     if ~isempty(hhh)
                         set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range])
                     else
-                                    rectangle('Curvature',[1 1],...
-                'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
-                'LineStyle','-','Tag','calib_marker');
+                        rectangle('Curvature',[1 1],...
+                            'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
+                            'LineStyle','-','Tag','calib_marker');
                     end
                 end
Index: /trunk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 737)
+++ /trunk/src/mouse_up.m	(revision 738)
@@ -349,5 +349,5 @@
 %% finalising ruler
 if test_ruler && ~isempty(xy)
-    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
+    %set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
     xy=get(hcurrentaxes,'CurrentPoint');% get the current mouse coordinates
     RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 737)
+++ /trunk/src/proj_field.m	(revision 738)
@@ -920,19 +920,19 @@
 
 %% extrema along each axis
-testXMin=0;
-testXMax=0;
-testYMin=0;
-testYMax=0;
-if isfield(ObjectData,'RangeX')
+testXMin=0;% test if min of X coordinates defined on the projection object, =0 by default
+testXMax=0;% test if max of X coordinates defined on the projection object, =0 by default
+testYMin=0;% test if min of Y coordinates defined on the projection object, =0 by default
+testYMax=0;% test if max of Y coordinates defined on the projection object, =0 by default
+if isfield(ObjectData,'RangeX') % rangeX defined by the projection object
     XMin=min(ObjectData.RangeX);
     XMax=max(ObjectData.RangeX);
-    testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has tow distinct elements)
-    testXMax=1;% range restriction along X
-end
-if isfield(ObjectData,'RangeY')
+    testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has two distinct elements)
+    testXMax=1;% max of X coordinates defined on the projection object
+end
+if isfield(ObjectData,'RangeY') % rangeY defined by the projection object
     YMin=min(ObjectData.RangeY);
     YMax=max(ObjectData.RangeY);
     testYMin=YMax>YMin;%=1 if YMin defined (i.e. RangeY has tow distinct elements)
-    testYMax=1;
+    testYMax=1;% max of Y coordinates defined on the projection object
 end
 width=0;%default width of the projection band
@@ -1371,5 +1371,5 @@
                     end
                 end
-            else       % case with interpolation
+            else       % case with interpolation on a grid
                 if NbDim==2 %2D case
                     if isequal(ProjMode{icell},'interp_tps')
@@ -1383,22 +1383,24 @@
                     Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
                     Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});
-                    xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin
-                    ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid
-                    xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame
-                    ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3));
-                    if testXMin
-                        xcor_new=max(xcor_new,XMin);
-                    end
-                    if testXMax
-                        xcor_new=min(xcor_new,XMax);
-                    end
-                    if testYMin
-                        ycor_new=max(ycor_new,YMin);
-                    end
-                    if testYMax
-                        ycor_new=min(ycor_new,YMax);
-                    end
-                    coord_x_proj=min(xcor_new):DX:max(xcor_new);
-                    coord_y_proj=min(ycor_new):DY:max(ycor_new);
+                    if ~(testXMin && testYMin)% % if the range of the projected coordinates is not fully defined by the projection object, find the extrema of the projected field
+                        xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin
+                        ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid
+                        xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame
+                        ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3));
+                        if ~testXMin
+                            XMin=min(xcor_new);
+                        end
+                        if ~testXMax
+                            XMax=max(xcor_new);
+                        end
+                        if ~testYMin
+                            YMin=min(ycor_new);
+                        end
+                        if ~testYMax
+                            YMax=max(ycor_new);
+                        end
+                    end
+                    coord_x_proj=XMin:DX:XMax;
+                    coord_y_proj=YMin:DY:YMax;
                     ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates
                     ProjData.(AXName)=[coord_x_proj(1) coord_x_proj(end)]; %record the new (projected ) x coordinates
Index: /trunk/src/set_object.m
===================================================================
--- /trunk/src/set_object.m	(revision 737)
+++ /trunk/src/set_object.m	(revision 738)
@@ -36,5 +36,5 @@
 function varargout = set_object(varargin)
 
-% Last Modified by GUIDE v2.5 11-Feb-2014 20:08:17
+% Last Modified by GUIDE v2.5 13-Apr-2014 19:31:58
 
 % Begin initialization code - DO NOT REFRESH
@@ -594,8 +594,13 @@
 set(handles.num_RangeY_2,'BackgroundColor',[1 1 1])
 
-%------------------------------------------------------------------------
-% --- Executes on button press in MenuCoord.
-function MenuCoord_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
+% --- Executes on button press in ExportCoord.
+function ExportCoord_Callback(hObject, eventdata, handles)
+global Coord
+Coord=get(handles.Coord,'Data');
+evalin('base','global Coord')%make Coord global in the workspace
+display('object coordinates:')
+evalin('base','Coord') %display Coord in the workspace
+commandwindow; %brings the Matlab command window to the front
+
 %----------------------------------------------------
 function num_RangeY_1_Callback(hObject, eventdata, handles)
@@ -785,2 +790,6 @@
     set(handles.Coord,'Data',Coord);
 end
+
+
+
+
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 737)
+++ /trunk/src/uvmat.m	(revision 738)
@@ -3811,7 +3811,6 @@
 
 %% delete drawn objects if the output CooordUnit is different from the previous one
-if ~strcmp(CoordUnit,CoordUnitPrev)
+if  ~strcmp(CoordUnit,CoordUnitPrev)
     set(handles.CheckFixLimits,'Value',0)
-% set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     hother=findobj('Tag','proj_object');%find all the proj objects
     for iobj=1:length(hother)
@@ -4544,8 +4543,7 @@
     UvData.ProjObject(IndexObj)=[];
 end
-    if ~isempty(list_str)
-        list_str(IndexObj)=[];
-    end
-% end
+if numel(list_str)>=IndexObj
+    list_str(IndexObj)=[];
+end
 set(huvmat,'UserData',UvData);
 set(hlist_object,'String',list_str)
@@ -4837,4 +4835,5 @@
 %------------------------------------------------------------------------
 %% desactivate concurrent tools
+set(handles.MenuRuler,'checked','off')%desactivate ruler
 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration 
 if ishandle(hgeometry_calib)
@@ -4945,12 +4944,18 @@
 function MenuCalib_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-
+%% suppress the second field if exists
+if get(handles.SubField,'Value')
+    set(handles.SubField,'Value',0)
+    SubField_Callback(hObject, eventdata, handles)
+end
 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 
 
-%suppress competing options 
+%% suppress competing tools
+set(handles.MenuRuler,'checked','off')%desactivate ruler
 set(handles.CheckZoom,'Value',0)
 set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
-set(handles.ListObject,'Value',1)      
-% initiate display of GUI geometry_calib
+set(handles.ListObject,'Value',1) 
+
+%% initiate display of the GUI geometry_calib
 data=[]; %default
 if isfield(UvData,'CoordType')
@@ -4964,4 +4969,74 @@
 set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
 
+
+% --------------------------------------------------------------------
+% --- set the slice plane ro the set of slice planes when volume scan is used
+function MenuSetSlice_Callback(hObject, eventdata, handles)
+% --------------------------------------------------------------------
+%% suppress the second input field if exists
+if get(handles.SubField,'Value')
+    set(handles.SubField,'Value',0)
+    SubField_Callback(hObject, eventdata, handles)
+end
+
+UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 
+check=0;
+if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'GeometryCalib')&& isfield(UvData.XmlData{1}.GeometryCalib,'SliceCoord')
+    GeometryCalib=UvData.XmlData{1}.GeometryCalib;
+    SliceCoord=GeometryCalib.SliceCoord;
+else
+    msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices')
+    return
+end    
+NbSlice_j=1;%default
+Z=SliceCoord(:,3);
+% index=index(ind_dim);
+%set the Z position of the reference plane used for calibration
+if isequal(max(Z),min(Z))%Z constant
+    Z_plane=Z(1);
+    GeometryCalib.NbSlice=1;
+    GeometryCalib.SliceCoord=[0 0 Z_plane];
+end
+ZStart=SliceCoord(1,3);% first Z coordinate present in the calibration file
+ZEnd=SliceCoord(end,3);% last Z coordinate present in the calibration file
+volume_scan='n';
+if isfield(UvData,'XmlData')
+    if isfield(UvData.XmlData{1},'TranslationMotor')
+        NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
+        ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
+        ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
+        volume_scan='y';
+    end
+end	
+input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
+input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
+answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
+GeometryCalib.NbSlice=str2double(answer{5});
+GeometryCalib.VolumeScan=answer{6};
+if isempty(answer)
+    Z_plane=0; %default
+else
+    Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
+end
+GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
+GeometryCalib.SliceAngle(:,3)=0;
+GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
+GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
+GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
+GeometryCalib.RefractionIndex=str2double(answer{4});
+
+%% store the result in the xml file used for calibration
+[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
+FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%name of the xml file for calibration
+[RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(FileName);
+XmlFile=find_imadoc(RootPath,SubDir,RootFile,FileExt);
+errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
+if ~strcmp(errormsg,'')
+    msgbox_uvmat('ERROR',errormsg);
+end
+
+%% display image with new calibration in the currently opened uvmat interface
+set(handles.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
+InputFileREFRESH_Callback(hObject,eventdata,handles); %file input with xml reading  in uvmat, show the image in phys coordinates
 
 %-----------------------------------------------------------------------
@@ -5234,10 +5309,14 @@
 function MenuRuler_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-set(handles.CheckZoom,'Value',0)
-CheckZoom_Callback(handles.uvmat, [], handles)
-set(handles.MenuRuler,'checked','on')
-UvData=get(handles.uvmat,'UserData');
-UvData.MouseAction='ruler';
-set(handles.uvmat,'UserData',UvData);
+if strcmp(get(handles.MenuRuler,'checked'),'on')
+    set(handles.MenuRuler,'checked','off')%desactivate if activated
+else
+    set(handles.MenuRuler,'checked','on')%activate if selected
+    set(handles.CheckZoom,'Value',0)
+    CheckZoom_Callback(handles.uvmat, [], handles)
+    UvData=get(handles.uvmat,'UserData');
+    UvData.MouseAction='ruler';
+    set(handles.uvmat,'UserData',UvData);
+end
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -5453,6 +5532,7 @@
 end
 
-
+% --------------------------------------------------------------------
 % --- Executes on button press in CheckTable.
+% --------------------------------------------------------------------
 function CheckTable_Callback(hObject, eventdata, handles)
 if get(handles.CheckTable,'Value')
