Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 77)
+++ /trunk/src/geometry_calib.m	(revision 78)
@@ -216,5 +216,11 @@
 set(handles.ListCoord,'String',Tabchar)
 MenuPlot_Callback(handles.geometry_calib, [], handles)
-
+if isempty(Coord)
+    set(handles.edit_append,'Value',1)
+    set(handles.edit_append,'BackgroundColor',[1 1 0])
+else
+    set(handles.edit_append,'Value',0)
+    set(handles.edit_append,'BackgroundColor',[0.7 0.7 0.7])
+end
 % 
 %------------------------------------------------------------------------
@@ -441,12 +447,18 @@
 path_uvmat=which('uvmat');% check the path detected for source file uvmat
 path_UVMAT=fileparts(path_uvmat); %path to UVMAT
-
+huvmat=findobj(allchild(0),'Tag','uvmat');
+hhuvmat=guidata(huvmat);
 x_1=Coord(:,4:5)';
 X_1=Coord(:,1:3)';
 n_ima=1;
 % check_cond=0;
-nx=1024;ny=1024;
+
+
+nx=str2num(get(hhuvmat.npx,'String'));
+ny=str2num(get(hhuvmat.npy,'String'));
+
+
 % est_kc=[1;0;0;0;0];
-est_dist=[1;0;0;0;0];
+est_dist=[0;0;0;0;0];
 run(fullfile(path_UVMAT,'TOOLBOX_calib','go_calib_optim'));
 
@@ -652,4 +664,7 @@
 Coord_cell=get(handles.ListCoord,'String');
 val=get(handles.ListCoord,'Value');
+if numel(val)>1
+    return %no action if several lines have been selected
+end
 coord_str=Coord_cell{val};
 k=findstr('|',coord_str);
@@ -706,16 +721,19 @@
 %------------------------------------------------------------------------
 choice=get(handles.edit_append,'Value');
-if choice==1
-       Coord=get(handles.ListCoord,'String'); 
-       val=length(Coord);
-       if val>=1 & isequal(Coord{val},'')
-            val=val-1; %do not take into account blank
-       end
-       Coord{val+1}='';
-       set(handles.ListCoord,'String',Coord)
-       set(handles.ListCoord,'Value',val+1)
-end
-
-
+% if choice==1
+%        Coord=get(handles.ListCoord,'String'); 
+%        val=length(Coord);
+%        if val>=1 & isequal(Coord{val},'')
+%             val=val-1; %do not take into account blank
+%        end
+%        Coord{val+1}='';
+%        set(handles.ListCoord,'String',Coord)
+%        set(handles.ListCoord,'Value',val+1)
+% end
+if choice
+    set(handles.edit_append,'BackgroundColor',[1 1 0])
+else
+    set(handles.edit_append,'BackgroundColor',[0.7 0.7 0.7]) 
+end
     
 function NEW_Callback(hObject, eventdata, handles)
@@ -763,10 +781,11 @@
     Coord_cell=get(handles.ListCoord,'String');
     val=get(handles.ListCoord,'Value');
-    if val<numel(Coord_cell) % the last element '...' has not been selected
+     if max(val)<numel(Coord_cell) % the last element '...' has not been selected
         Coord_cell(val)=[];%remove the selected line
+        set(handles.ListCoord,'Value',min(val)) 
         set(handles.ListCoord,'String',Coord_cell)         
         ListCoord_Callback(hObject, eventdata, handles) 
         MenuPlot_Callback(hObject,eventdata,handles)
-    end
+     end
 end
 
Index: /trunk/src/mouse_down.m
===================================================================
--- /trunk/src/mouse_down.m	(revision 77)
+++ /trunk/src/mouse_down.m	(revision 78)
@@ -63,27 +63,31 @@
         %if the mouse is over an axis, look at the data
         if isequal(htype,'axes')
+            y_lim=get(hchild(ichild),'YLim');
+            x_lim=get(hchild(ichild),'XLim');
             haxes=hchild(ichild);
             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-            AxeData=get(haxes,'UserData');% data attached to the axis
-            AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
-            if ~isequal(tag_obj,'proj_object') & ~test_create
-                x_mouse=xy(1,1);%default
-                y_mouse=xy(1,2);%default
-                u_mouse=[];
-                v_mouse=[];
-                w_mouse=[];
-                A_mouse=[];
-                c_text=[];
-                f_text=[];
-                ff_text=[];     
-                ivec=[];   
-                if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
-                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
-                      (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
-                    ivec=find(flag_vec,1);% search the (first) selected vector index ivec
+            if xy(1,1)>x_lim(1) && xy(1,1)<x_lim(2) && xy(1,2)>y_lim(1) && xy(1,2)<y_lim(2)
+                AxeData=get(haxes,'UserData');% data attached to the axis
+                AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
+                if ~isequal(tag_obj,'proj_object') & ~test_create
+                    x_mouse=xy(1,1);%default
+                    y_mouse=xy(1,2);%default
+                    u_mouse=[];
+                    v_mouse=[];
+                    w_mouse=[];
+                    A_mouse=[];
+                    c_text=[];
+                    f_text=[];
+                    ff_text=[];     
+                    ivec=[];   
+                    if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
+                        flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                          (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
+                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
+                    end
                 end
-            end
-%         elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
-%            %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
+            else
+                haxes=[];%mouse out of axes
+            end
         end
     end
@@ -240,10 +244,10 @@
 
 % create calibration points if the GUI geometry_calib is opened, if the main axes axes3 of uvmat has ben selected
-if test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'axes3') 
+if ~testzoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'axes3') 
     h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
     hh_geometry_calib=guidata(h_geometry_calib);
     h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
     h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
-    if isequal(get(h_edit_append,'Value'),1) 
+    if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes)
         coord_value=get(hhuvmat.transform_fct,'Value');% set uvmat to pixel coordinates, run it again if not
         if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
@@ -256,5 +260,9 @@
         Coord=get(h_ListCoord,'String');
         data=read_geometry_calib(Coord);%transform char cell to numbers
-        ind_range=10;%range of research around each existing point
+        xlim=get(haxes,'XLim');
+        ind_range_x=abs((xlim(2)-xlim(1))/50);
+        ylim=get(haxes,'YLim');
+        ind_range_y=abs((ylim(2)-ylim(1))/50);
+        ind_range=sqrt(ind_range_x*ind_range_y);
         test_newpoint=1;
         if size(data.Coord,2)>=5 %if calibration points already exist
@@ -265,8 +273,9 @@
             test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position
         end
+        val=get(h_ListCoord,'Value');
         %create a new calib point if we are not close to an existing one
         if test_newpoint                 
              strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
-             val=get(h_ListCoord,'Value');
+           
              if length(Coord)>=val
                  Coord(val+1:length(Coord)+1)=Coord(val:length(Coord));% push the list forward beyond the current point
@@ -286,5 +295,5 @@
             set(hh,'YData',YCoord)
         end
-        set(hh,'UserData','edit_mode')% flag the points to edit mode
+        set(hh,'UserData',val)% flag the points to edit mode
         hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
         if ~isempty(hhh)
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 77)
+++ /trunk/src/mouse_motion.m	(revision 78)
@@ -24,4 +24,5 @@
 
 function mouse_motion(hObject,eventdata,handles)
+
 if ~exist('handles','var')
     return
@@ -34,4 +35,6 @@
 test_ruler=0;
 huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
+hhuvmat=guidata(huvmat);
+test_zoom=get(hhuvmat.zoom,'Value');
 if ~isempty(huvmat)
     UvData=get(huvmat,'UserData');
@@ -207,7 +210,7 @@
 set(handles.text_display_3,'String',text_displ_3);
 set(handles.text_display_4,'String',text_displ_4);
-if ~test_draw
-    return 
-end
+% if ~test_draw
+%     return 
+% end
 % At this stage  if no drawing  operation is done
 
@@ -289,8 +292,8 @@
 % detect calibration points if the GUI geometry_calib is opened
 h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
-if ~test_zoom_draw && ~isempty(h_geometry_calib)
+if ~test_zoom && ~isempty(h_geometry_calib)
     pointershape='crosshair';%default for geometry_calib: ready to create new points
     hh_geometry_calib=guidata(h_geometry_calib);
-    if get(hh_geometry_calib.edit_append,'Value')  && ~isempty(xy)
+    if  ~isempty(xy)
         h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
         Coord=get(h_ListCoord,'String');
@@ -301,24 +304,29 @@
             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
             if ~isempty(xy)
-                ind_range=10;
+                xlim=get(haxes,'XLim');
+                ind_range_x=abs((xlim(2)-xlim(1))/50);
+                ylim=get(haxes,'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
                 if ~isempty(index_point)
                     pointershape='arrow';% default pointer is an arrow 
-                    set(h_ListCoord,'Value',index_point)%mrk the point on the GUI geometry_calib 
-                    hh=findobj('Tag','calib_points');%look for handle of calibration points 
-                    if ~isempty(hh) && strcmp(get(hh,'UserData'),'edit_mode')
-                        XCoord(index_point)=xy(1,1);
-                        YCoord(index_point)=xy(1,2);
-                        set(hh,'XData',XCoord)
-                        set(hh,'YData',YCoord)
-                    end
+                end
+                hh=findobj('Tag','calib_points');%look for handle of calibration points
+               if ~isempty(hh) && ~isempty(get(hh,'UserData')) && get(hh_geometry_calib.edit_append,'Value') 
+                    index_point=get(hh,'UserData');
+                    XCoord(index_point)=xy(1,1);
+                    YCoord(index_point)=xy(1,2);
+                    set(hh,'XData',XCoord)
+                    set(hh,'YData',YCoord)
+               end
+                if ~isempty(index_point)
+                    set(h_ListCoord,'Value',index_point)%mrk the point on the GUI geometry_calib
                     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])
-%                         set(hhh,'XData',XCoord(index_point))
-%                         set(hhh,'YData',YCoord(index_point))
-                    end
-                end          
+                    end
+                end
             end
         end
Index: /trunk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 77)
+++ /trunk/src/mouse_up.m	(revision 78)
@@ -262,14 +262,16 @@
 
 % editing calibration point
-if strcmp(MouseAction,'calib') 
-    hh=findobj(currentaxes,'Tag','calib_points')%look for handle of calibration points           
-    if ~isempty(hh)
+if ~zoomstate strcmp(MouseAction,'calib') 
+    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
+    hh_geometry_calib=guidata(h_geometry_calib);
+    edit_test=get(hh_geometry_calib.edit_append,'Value');
+    hh=findobj(currentaxes,'Tag','calib_points');%look for handle of calibration points           
+    if ~isempty(hh) && edit_test
+        index_point=get(hh,'UserData');
         set(hh,'UserData',[])%remove edit mode
-        h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
-        hh_geometry_calib=guidata(h_geometry_calib);
         h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list
         Coord=get(h_ListCoord,'String');
-        val=get(h_ListCoord,'Value');
-        coord_str=Coord{val}; %current line (string)
+%         val=get(h_ListCoord,'Value');
+        coord_str=Coord{index_point}; %current line (string)
         k=findstr('|',coord_str);%find separator indices on the string
         xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 
@@ -279,6 +281,9 @@
             coord_str=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
         end
-        Coord{val}=coord_str;        
+        Coord{index_point}=coord_str;        
         set(h_ListCoord,'String',Coord)
+        data=read_geometry_calib(Coord);%transform char cell to numbers
+        set(hh,'XData',data.Coord(:,4))
+        set(hh,'YData',data.Coord(:,5))
     end
 end
Index: /trunk/src/series/merge_proj.m
===================================================================
--- /trunk/src/series/merge_proj.m	(revision 77)
+++ /trunk/src/series/merge_proj.m	(revision 78)
@@ -259,5 +259,5 @@
                     Field{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile));
                 else
-                    Field{iview}.A=read_image(filename,Series.NomType{iview},num_i1{iview}(ifile)); 
+                    Field{iview}.A=imread(filename); 
                 end % TODO: introduce ListVarName
                 npxy=size(Field{iview}.A);
