Index: unk/src/delete_object.m
===================================================================
--- /trunk/src/delete_object.m	(revision 621)
+++ 	(revision )
@@ -1,84 +1,0 @@
-%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
-%------------------------------------------------------------------------
-% function delete_object(hObject)
-%
-% INPUT:
-% hObject: object index (if integer) or handle of the graphic object. If
-%          hObject is a subobject, the parent object is detected and deleted. 
-
-function delete_object(hObject)
-
-huvmat=findobj('tag','uvmat');%handles of the uvmat interface
-UvData=get(huvmat,'UserData');
-hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface
-list_str=get(hlist_object,'String');%objet list
-if isequal(floor(hObject),hObject) %case of an index
-    if  ~isempty(UvData) && isfield(UvData, 'Object') && length(UvData.Object)>=hObject 
-        if isfield(UvData.Object{hObject},'DisplayHandle') && isfield(UvData.Object{hObject}.DisplayHandle,'uvmat')
-            hdisplay=UvData.Object{hObject}.DisplayHandle.uvmat;
-            for iview=1:length(hdisplay)
-                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
-                    ObjectData=get(hdisplay(iview),'UserData');
-                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
-                        delete(ObjectData.SubObject);
-                    end
-                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
-                        delete(ObjectData.DeformPoint);
-                    end
-                    delete(hdisplay(iview))
-                end
-                ishandle(hdisplay(iview))
-            end
-            for iobj=hObject+1:length(UvData.Object)
-                hdisplay=UvData.Object{iobj}.DisplayHandle.uvmat;
-                for iview=1:length(hdisplay)
-                    if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
-                        PlotData=get(hdisplay(iview),'UserData');
-                        PlotData.IndexObj=iobj-1;
-                        set(hdisplay(iview),'UserData',PlotData);
-                    end
-                end
-            end
-        end
-        UvData.Object(hObject)=[];  
-        if ~isempty(list_str)
-            list_str(hObject)=[];
-        end
-    end
-elseif ishandle(hObject)%object handle
-    userdata=get(hObject,'UserData');
-    if ishandle(userdata)%the selected line depends on a parent line
-        hdisplay=userdata;% the parent object becomes the current one
-    else
-        hdisplay=hObject;% the selected object becomes the current one
-    end
-    PlotData=get(hdisplay,'UserData');
-    if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
-            delete(PlotData.SubObject);
-    end
-    if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
-           delete(PlotData.DeformPoint);
-    end
-    delete(hdisplay);
-    if isfield(PlotData,'IndexObj')
-        IndexObj=PlotData.IndexObj;
-        if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
-            if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
-               UvData.Object(IndexObj)=[];
-            end
-            list_str(IndexObj)=[];
-        end
-    end
-end
-set(huvmat,'UserData',UvData);
-set(hlist_object,'String',list_str)
-set(hlist_object,'Value',length(list_str))
-hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface
-old_index=get(hlist_object_1,'Value');
-set(hlist_object_1,'String',list_str)
-if hObject<=old_index
-    set(hlist_object_1,'Value',old_index-1)
-end
-% hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liï¿œst in the uvmat interface
-% set(hlist_object,'String',[list_str;{'...'}])
-% set(hlist_object,'Value',length(list_str)+1)
Index: /trunk/src/keyboard_callback.m
===================================================================
--- /trunk/src/keyboard_callback.m	(revision 621)
+++ /trunk/src/keyboard_callback.m	(revision 622)
@@ -3,5 +3,9 @@
 function keyboard_callback(hObject,eventdata,handleshaxes)
 cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
+if ~isempty(eventdata) && isnumeric(eventdata)
+    xx=eventdata; % keyboard_callback called by mouse_down
+else
 xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
+end
 switch xx
     case {29,28,30,31}    %arrows for displacement
Index: /trunk/src/mouse_down.m
===================================================================
--- /trunk/src/mouse_down.m	(revision 621)
+++ /trunk/src/mouse_down.m	(revision 622)
@@ -23,21 +23,30 @@
 
 function xy=mouse_down(hObject,eventdata)
-AxeData=[];%default
-FigData=get(hObject,'UserData');
+
+%% look for parameters set by the current figure (handle=input parameter hObject)
+AxeData=[];%default data stored on the current axes
+FigData=get(hObject,'UserData'); %default data stored on the current object
 if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
-    hcurrentfig=get(get(FigData,'parent'),'parent');
+    hcurrentfig=get(get(FigData,'parent'),'parent');%handle of the current GUI: zoom plot
 else
-    hcurrentfig=hObject;%usual plot
-end
+    hcurrentfig=hObject; % handle of the current GUI: usual plot
+end
+hhcurrentfig=guidata(hcurrentfig);% tags of the children of the current GUI
+CheckZoom=0;
+if isfield(hhcurrentfig,'CheckZoom') && get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
+    CheckZoom=1;
+end
+test_piv=isfield(FigData,'CivHandle');
 set(hcurrentfig,'Units','pixels')
-GUI_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels)
-set(hcurrentfig,'Units','normalized')
-hhcurrentfig=guidata(hcurrentfig);
-if isfield(hhcurrentfig,'CheckZoom')
-    test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
-else
-    test_zoom=0;
-end
-test_piv=isfield(FigData,'CivHandle');
+GUI_pos=get(hcurrentfig,'Position');%position of the GUI series on the screen (in pixels), used to position message boxes
+set(hcurrentfig,'Units','normalized')% back to current unit for fig position
+
+%% determine the currently selected items
+hcurrentobject=gco;% current object handle (selected by the mouse)
+fig_tag=get(hcurrentfig,'Tag');
+obj_tag=get(gco,'Tag');%tag of the currently selected object
+xy=[];%default
+xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
+haxes=[];
 
 %% look for parameters set by the GUI uvmat
@@ -45,21 +54,16 @@
 test_edit=0;
 test_create=0;
-huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
+huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of  mouse action
 if ~isempty(huvmat)
     hhuvmat=guidata(huvmat);%handles of elements in uvmat
     UvData=get(huvmat,'UserData');
     test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
-    test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority
-    test_edit_vect=get(hhuvmat.edit_vect,'Value');%test for vector editing,  priority 4
-    %     test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation,  priority 5
-    %     if test_create
-    test_create=0;
+    test_edit=get(hhuvmat.edit_object,'Value')&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority
     hset_object=findobj(allchild(0),'tag','set_object');
-
     if ~isempty(hset_object)
         hPLOT=findobj(hset_object,'tag','PLOT');
         test_create=strcmp(get(hPLOT,'enable'),'on') &&~test_edit;% create new object if set_object is in mode enable and uvmat not in mode 'edit_object'
     end
-    
+    test_edit_vect=get(hhuvmat.edit_vect,'Value') && ~test_create && ~(isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint')) ;%test for vector editing,  priority 4
     test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
     if test_cal% test for calibration popints,  priority 6
@@ -75,122 +79,132 @@
 end
 
-%% determine the currently selected items
-hcurrentobject=gco;% current object handle (selected by the mouse)
-%hcurrentfig=hObject;% current figure handle
-fig_tag=get(hcurrentfig,'Tag');
-tag_obj=get(gco,'Tag');%tag of the currently selected object
-xy=[];%default
-xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
+%% loop on all the objects in the current figure (selected by the last mouse click)
 hchildren=get(hObject,'Children');%handles of all objects in the current figure
-haxes=[];
-
-%% loop on all the objects in the current figure (selected by the last mouse click) 
-output_str='';
-state_visible=get(hchildren,'Visible');
-check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise
-hchildren=hchildren(find(check_visible)); %kkep only the visible children
-for ichild=1:length(hchildren)
-    hchild=hchildren(ichild); %handle of the current obj
-    obj_pos=get(hchild,'Position');%position of the object
-    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
-        htype=get(hchild,'Type');%type of object child of the current figure
-        switch htype
-            %if the mouse is over an axis, look at the data
-            case 'axes'
-                y_lim=get(hchild,'YLim');
-                x_lim=get(hchild,'XLim');
-                haxes=hchild;
-                xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-%                 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(hchild,'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 test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create
-                        ivec=[];
-                        FigData=get(hcurrentfig,'UserData');
-                        tagaxes=get(hchild,'tag');
-                        if isfield(FigData,tagaxes)
-                            Field=FigData.(tagaxes);
-                            [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
-                            for icell=1:numel(CellVarIndex)%look for all physical fields
-                                if NbDim(icell)==2 % select 2D field
-                                    if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
-                                        eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
-                                        eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';'])
-                                        flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
-                                            (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f
-                                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
-                                    end
-                                end
+check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
+hchildren=hchildren(check_visible); %kkep only the visible children
+PosChildren=get(hchildren,'Position');% set of object positions
+if iscell(PosChildren)% only one child
+    PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions
+    hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector
+    PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions
+end
+if size(PosChildren,2)~=4
+    return
+end
+xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix
+check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
+ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
+hchild=hchildren(ind_object);% corresponding object handle
+if isempty(hchild)
+%     if test_edit||test_create
+%         hPlotAxes=findobj(hcurrentfig,'Tag','PlotAxes');
+%         if ~isempty( hPlotAxes)
+%             PosPlotAxes=get(hPlotAxes,'Position');
+%             PosDiff(1)=xy_fig(1)-PosPlotAxes(1)-PosPlotAxes(3);% distance to the right axes edge
+%             PosDiff(2)=PosPlotAxes(1)-xy_fig(1);% distance to the left axes edge
+%             PosDiff(3)=xy_fig(2)-PosPlotAxes(1)-PosPlotAxes(3);% distance to the top axes edge
+%             PosDiff(4)=PosPlotAxes(2)-xy_fig(2);% distance to the low axes edge
+%             [tild,ind_sel]=max(PosDiff);
+%             list_arrow=[29 28 30 31];
+%             arrow_option=list_arrow(ind_sel);
+%             keyboard_callback(hcurrentfig,arrow_option)
+%             return
+%         end
+%     end
+else
+    htype=get(hchild,'Type');%type of object child of the current figure
+    switch htype
+        %if the mouse is over an axis, look at the data
+        case 'axes'
+            haxes=hchild;
+            xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            AxeData=get(hchild,'UserData');% data attached to the axis
+%             if isfield(AxeData,'ObjectCoord') && size(AxeData.ProjObjectCoord,2)==3
+%                 xy(1,3)=AxeData.ProjObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
+%             else
+%                 xy(1,3)=0; % z coordinate set to 0 by default
+%             end
+            AxeData.CurrentOrigin=xy(1,1:2);% The current point set by the mouse becomes the current origin
+            
+            if test_edit_vect 
+                ivec=[];
+                FigData=get(hcurrentfig,'UserData');
+                tagaxes=get(hchild,'tag');
+                if isfield(FigData,tagaxes)
+                    Field=FigData.(tagaxes);
+                    [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
+                    for icell=1:numel(CellVarIndex)%look for all physical fields
+                        if NbDim(icell)==2 % select 2D field
+                            if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
+                                X=Field.(Field.ListVarName{VarType{icell}.coord_x});
+                                Y=Field.(Field.ListVarName{VarType{icell}.coord_y});
+                                flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                                    (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f
+                                ivec=find(flag_vec,1);% search the (first) selected vector index ivec
                             end
                         end
                     end
-%                 else
-%                     hchild=[];%mouse out of axes
-%                 end
-                break
+                end
+            end
+            %break% leave the loop once an axes has been selected
+            
+            %if the mouse is over a uicontrol, with right mouse button activated, duplicate the display in an editable  zoom window
+        case 'uicontrol'
+            if isequal(get(hObject,'SelectionType'),'alt') %% && ~isequal(get(hchild,'tag'),'frame_object')
+                obj_pos=PosChildren(ind_object,:);
+                msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
+                display_str=get(hchild,'TooltipString');
+                msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
+                return %leave the function once a uicontrol has been selected
+            end
+            
+            %if the mouse is over a uipanel, look at the children of the uipanel
+        case 'uipanel'
+            if isequal(get(hObject,'SelectionType'),'alt')
+                panel_pos=PosChildren(ind_object,:);%position of the panel
+                hhchildren=get(hchild,'Children');%handles of all objects in the selected panel
+                check_visible=strcmp(get(hhchildren,'Visible'),'on');%=1 if visible='on', =0 otherwise
+                hhchildren=hhchildren(check_visible); %keep only the visible children
                 
-            %if the mouse is over a uicontrol, duplicate the display  in an editable  zoom window
-            case 'uicontrol' 
-                if isequal(get(hObject,'SelectionType'),'alt')  && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&...
-                        ~isequal(get(hchild,'tag'),'ListObject') 
-                    if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames
-                        msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
-                        display_str=get(hchild,'TooltipString');
-                        output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
-                        break
+                PosChildren=get(hhchildren,'Position');
+                PosLength=cellfun('length',PosChildren);
+                hhchildren=hhchildren(PosLength==4);% keep only object with position defined by a 4 element vector
+                PosChildren=cell2mat(PosChildren(PosLength==4));% transform cell array to a matrix of positions
+                xy_panel=(xy_fig-panel_pos(1:2))./panel_pos(3:4);% mouse position relative to the panel
+                xy_panel_mat=ones(size(PosChildren,1),1)*xy_panel;% mouse position on the figure transformed to a matrix
+                check_pos=xy_panel_mat >= PosChildren(:,1:2) & xy_panel_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
+                ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
+                if ~isempty(ind_object)
+                    hhchild=hhchildren(ind_object);% corresponding object handle
+                    if strcmp(get(hhchild,'Type'),'uicontrol')
+                        msg_pos=GUI_pos(1:2)+panel_pos(1:2).*GUI_pos(3:4)+PosChildren(ind_object,1:2).*panel_pos(3:4).*GUI_pos(3:4);
+                        display_str=get(hhchild,'TooltipString');
+                        msgbox_uvmat(['uicontrol: ' get(hhchild,'Tag')],display_str,get(hhchild,'String'),msg_pos);
                     end
                 end
-            case 'uipanel'
-                panel_pos=obj_pos;%position of the panel
-                hhchildren=get(hchild,'Children');%handles of all objects in the current GUI
-                %% loop on all the objects in the current figure (selected by the last mouse click)
-                for iichild=1:length(hhchildren)
-                    hchild=hhchildren(iichild);
-                    rel_pos=get(hchild,'Position');%position of the object relative to the uipanel
-                    obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4);
-                    obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4);
-                    if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
-                        htype=get(hchild,'Type');%type of object child of the current figure
-                        %if the mouse is over a uicontrol, look at the data
-                        if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on')
-                            msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
-                            display_str=get(hchild,'TooltipString');
-                            output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
-                            break
-                        end
-                    end
-                end
-        end
-        if ~isempty(output_str)
-            break   %leave the current loop if a uicontrol has been selected
-        end
-    end
-end
-if ~isempty(output_str)               
-    set(hObject,'Units','pixels')
-    if strcmp(get(hchild,'enable'),'on')
-    set(hchild,'String',output_str)% fill the parent uicontrol with the sttring edited in the msgbox
-    end
-end
-    
-%% desable  object creation and vector editing if NbDim different from 2
-if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
-    test_create=0;
-    test_edit_vect=0;    
+            end
+            %   return %leave the function once a uicontrol has been selected
+    end
 end
 
 %% delete the current zoom rectangle
-if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
-    delete(AxeData.CurrentRectZoom)
-    AxeData.CurrentRectZoom=[];
-end    
-
-%% zoom has first priority 
-if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
-     AxeData.Drawing='zoom'; %initiate drawing mode
-     AxeData.CurrentObject=[];%unselect objects
-     set(hchild,'UserData',AxeData);
-     return
-end
+% if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
+%     delete(AxeData.CurrentRectZoom)
+%     AxeData.CurrentRectZoom=[];
+% end
+
+%% zoom has first priority, stop here
+if CheckZoom 
+    return
+end
+
+%% creation of a zoom subfig
+if get(hhcurrentfig.CheckZoomFig,'Value')
+    AxeData.Drawing='zoom'; %initiate drawing mode
+    AxeData.CurrentObject=[];%unselect objects
+    set(hchild,'UserData',AxeData);
+    return
+end
+
 if isempty(huvmat)%further options require the uvmat GUI
     return 
@@ -199,6 +213,5 @@
 %% ruler has second priority 
 if test_ruler
-    AxeData.RulerCoord(1,1)=xy(1,1);
-    AxeData.RulerCoord(1,2)=xy(1,2);
+    AxeData.RulerCoord(1,1:2)=xy(1,1:2);
     AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
     AxeData.Drawing='ruler';
@@ -218,6 +231,12 @@
 end
 
+%% desable  object creation and vector editing if NbDim different from 2
+if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
+    test_create=0;
+    test_edit_vect=0;
+end
+
 %% selection of an existing projection object (third priority)
-if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
+if  test_edit 
     if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
         userdata=get(hcurrentobject,'UserData');
@@ -228,5 +247,5 @@
         end
         ObjectData=get(AxeData.CurrentObject,'UserData');
-        if test_edit && isfield(ObjectData,'IndexObj')
+        if isfield(ObjectData,'IndexObj')
             hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
             set(hother,'Color','b');%reset all the proj objects in 'blue' by default
@@ -263,5 +282,5 @@
                 end
             end
-            if isequal(tag_obj,'DeformPoint')
+            if isequal(obj_tag,'DeformPoint')
                  set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
             end
@@ -280,5 +299,5 @@
                 set(hhuvmat.ListObject_1,'Value',IndexObj);
                 list_str=get(hhuvmat.ListObject_1,'String');
-                UvData.Object{IndexObj}.Name=list_str{IndexObj};
+                UvData.ProjObject{IndexObj}.Name=list_str{IndexObj};
             end
 %             h_set_object=findobj(allchild(0),'Tag','set_object');
@@ -286,10 +305,10 @@
 %                 delete(h_set_object)
 %             end
-            set_object(UvData.Object{IndexObj})
+            set_object(UvData.ProjObject{IndexObj})
             axes(hchild);%set back the current axes haxes
             testdeform=0;
             set(gcbo,'Pointer','circle'); 
             AxeData.Drawing='deform';
-            if isequal(tag_obj,'DeformPoint')       
+            if isequal(obj_tag,'DeformPoint')       
                if isfield(ObjectData,'DeformPoint')
                    set(hcurrentobject,'Selected','on')
@@ -312,13 +331,12 @@
 
 %%  create  projection  object
-if  test_create && ~isempty(xy) %&& ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
-    hset_object=findobj(allchild(0),'tag','set_object');
+if  test_create && ~isempty(xy) 
     % activate this option if the GUI set_object is opened
-    if ~isempty(hset_object)
+    if ~isempty(hset_object) && ~strcmp(get(hcurrentfig,'SelectionType'),'alt')
         sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
         ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
-        IndexObj=length(UvData.Object);
+        IndexObj=length(UvData.ProjObject);
         %initiate a new object (no data .Coord yet recorded)
-        if ~isfield(UvData.Object{IndexObj},'Coord');
+        if ~isfield(UvData.ProjObject{IndexObj},'Coord');
             ObjectData.Coord=[];
             ObjectNameNew=ObjectData.Name;
@@ -326,5 +344,5 @@
                 ObjectNameNew=ObjectData.Type;
             end
-            % add an index to the object name if the proposed name already exists          
+            % add an index to the object name if the proposed name already exists
             vers=0;% index of the name
             ListObject=get(hhuvmat.ListObject,'String');
@@ -348,5 +366,5 @@
                 ListObject={ObjectName};
             else
-            ListObject{end}=ObjectName;
+                ListObject{end}=ObjectName;
             end
             set(hhuvmat.ListObject,'String',ListObject);%complement the object list
@@ -356,13 +374,13 @@
         end
         ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
-        hobject=UvData.Object{IndexObj}.DisplayHandle.(fig_tag);
+                                                         %TODO replace 0 by z coord for 3D       
+        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
         if isempty(hobject)
             hobject=haxes;
         end
-        ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
+        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
         AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
-        UvData.Object{IndexObj}=ObjectData;      
-        UvData.Object{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object      
-        %UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
+        UvData.ProjObject{IndexObj}=ObjectData;
+        UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object
         set(huvmat,'UserData',UvData)
         PlotData=get(AxeData.CurrentObject,'UserData');
@@ -378,5 +396,5 @@
 
 %% create calibration points if the GUI geometry_calib is opened, if the main axes PlotAxes of uvmat has ben selected
-if ~test_zoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes') 
+if  test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes') 
     h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
     hh_geometry_calib=guidata(h_geometry_calib);
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 621)
+++ /trunk/src/mouse_motion.m	(revision 622)
@@ -35,9 +35,10 @@
 end
 hhCurrentFig=guidata(CurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
-test_zoom=get(hhCurrentFig.CheckZoom,'Value');%test for zoom activated on the current figure
+CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode
+CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode
+test_zoom_draw=0;
 test_draw=0;%test for mouse drawing of object, =0 by default
 test_object=0; %test for object editing or creation 
 test_edit_object=0;% edit test for mouse shap: an arrow
-test_zoom_draw=0; % test for zoom drawing 
 test_ruler=0;%test for active ruler 
 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
@@ -64,210 +65,215 @@
 
 AxeData=[];%default
-mouse=[];
 xy=[];%default
-
+xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
 pointershape='arrow';% default pointer is an arrow 
 
-xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
-hchild=get(hObject,'Children');%handles of all objects in the current figure
-
 %% loop on all the objects in the current figure, detect whether the mouse is over a plot  axes
+hchildren=get(hObject,'Children');%handles of all objects in the current figure
+check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
+hchildren=hchildren(check_visible); %kkep only the visible children
+PosChildren=get(hchildren,'Position');% set of object positions
+if iscell(PosChildren)% only one child
+    PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions
+    hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector
+    PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions
+end
+if size(PosChildren,2)~=4
+    return
+end
+xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix
+check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
+ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
+hchild=hchildren(ind_object);% corresponding object handle
 CurrentAxes=[];
-for ichild=1:length(hchild)
-    obj_pos=get(hchild(ichild),'Position');
-    if numel(obj_pos)~=4% for some versions of matlab a uicontextmenu appears
-        continue
-    end%position of the object
-    if xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
-        htype=get(hchild(ichild),'Type');%type of the crrent child
-        %if the mouse is over an axis, look at the data
-        if strcmp(htype,'axes')
-            CurrentAxes=hchild(ichild);
-            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-            AxeData=get(CurrentAxes,'UserData');% data attached to the axis
-            if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
-                test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
-            end
-            test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
-            test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
-            if ~test_edit_object && ~test_zoom_draw && ~test_ruler
-                pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
-            end
-            FigData=get(CurrentFig,'UserData');
-            tagaxes=get(CurrentAxes,'tag');
-            if isfield(FigData,tagaxes)
-                Field=FigData.(tagaxes);
-                if isfield(Field,'ListVarName')
-                    [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
-                    text_displ_1='';
-                    text_displ_2='';
-                    text_displ_3='';
-                    text_displ_4='';
-                    text_displ_5='';
-                    ivec=[];
-                    xName='';
-                    z=[];
-                    for icell=1:numel(CellInfo)%look for all physical fields
-                        if NbDimArray(icell)>=2 % select 2D field
-                            if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data
-                                X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)});
-                                Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
-                                flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
-                                    (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f
-                                ivec=find(flag_vec,1);% search the (first) selected vector index ivec
-                                hhh=findobj(CurrentAxes,'Tag','vector_marker');
-                                if ~isempty(ivec)
-                                    % mark the vectors with a circle in the absence of other operations
-                                    if ~test_object && ~test_edit_object && ~test_ruler
-                                        pointershape='arrow'; %mouse indicates  the detection of a vector
-                                        if isempty(hhh)
-                                            set(0,'CurrentFigure',CurrentFig)
-                                            set(CurrentFig,'CurrentAxes',CurrentAxes)
-                                            rectangle('Curvature',[1 1],...
-                                                'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
-                                                'LineStyle','-','Tag','vector_marker');
-                                        else
-                                            set(hhh,'Visible','on')
-                                            set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh])
-                                        end
-                                    end
-                                    %display the field values
-                                    for ivar=1:numel(CellInfo{icell}.VarIndex)
-                                        VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
-                                        VarVal=Field.(VarName)(ivec);
-                                        var_text=[VarName '=' num2str(VarVal,4) ','];
-                                        if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1))
-                                            text_displ_1=[text_displ_1 var_text];
-                                        elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
-                                                (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
-                                            text_displ_4=[text_displ_4 var_text];
-                                        else
-                                            text_displ_5=[text_displ_5 var_text];
-                                        end
-                                    end
+
+%if the mouse is over an axis, look at the data
+if strcmp(get(hchild,'Type'),'axes')
+    CurrentAxes=hchild;
+    xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+    AxeData=get(CurrentAxes,'UserData');% data attached to the axis
+    if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
+        test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
+    end
+    test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
+    test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
+    %if ~test_edit_object && ~test_zoom_draw && ~test_ruler
+    if ~test_edit_object  && ~test_ruler && ~CheckZoom
+        pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
+    end
+    FigData=get(CurrentFig,'UserData');
+    tagaxes=get(CurrentAxes,'tag');
+    if isfield(FigData,tagaxes)
+        Field=FigData.(tagaxes);
+        if isfield(Field,'ListVarName')
+            [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
+            text_displ_1='';
+            text_displ_2='';
+            text_displ_3='';
+            text_displ_4='';
+            text_displ_5='';
+            ivec=[];
+            xName='';
+            z=[];
+            for icell=1:numel(CellInfo)%look for all physical fields
+                if NbDimArray(icell)>=2 % select 2D field
+                    if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data
+                        X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)});
+                        Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
+                        flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                            (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f
+                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
+                        hhh=findobj(CurrentAxes,'Tag','vector_marker');
+                        if ~isempty(ivec)
+                            % mark the vectors with a circle in the absence of other operations
+                            if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig
+                                pointershape='arrow'; %mouse indicates  the detection of a vector
+                                if isempty(hhh)
+                                    set(0,'CurrentFigure',CurrentFig)
+                                    set(CurrentFig,'CurrentAxes',CurrentAxes)
+                                    rectangle('Curvature',[1 1],...
+                                        'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
+                                        'LineStyle','-','Tag','vector_marker');
                                 else
-                                    if ~isempty(hhh)
-                                        set(hhh,'Visible','off')
-                                    end
+                                    set(hhh,'Visible','on')
+                                    set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh])
                                 end
-                            elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates
-                                yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)};
-                                xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)};
-                                y=Field.(yName);
-                                x=Field.(xName);
-                                VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)};
-                                nxy=size(Field.(VarName));
-                                MaxAY=max(y(1),y(end)); %#ok<COLND>
-                                MinAY=min(y(1),y(end)); %#ok<COLND>
-                                if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY) %#ok<COLND>
-                                    indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1)));%#ok<COLND> % index x of pixel
-                                    indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1)));%#ok<COLND> % index y of pixel
-                                    if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
-                                        text_displ_2=['i='  num2str(indx0) ',j=' num2str(indy0) ','];
-                                        for ivar=1:numel(CellInfo{icell}.VarIndex)
-                                            VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
-                                            VarVal=Field.(VarName)(indy0,indx0,:);
-                                            var_text=[VarName '=' num2str(VarVal) ','];
-                                            text_displ_4=[text_displ_4 var_text];
-                                        end
-                                    end
+                            end
+                            %display the field values
+                            for ivar=1:numel(CellInfo{icell}.VarIndex)
+                                VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
+                                VarVal=Field.(VarName)(ivec);
+                                var_text=[VarName '=' num2str(VarVal,4) ','];
+                                if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1))
+                                    text_displ_1=[text_displ_1 var_text];
+                                elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
+                                        (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
+                                    text_displ_4=[text_displ_4 var_text];
+                                else
+                                    text_displ_5=[text_displ_5 var_text];
+                                end
+                            end
+                        else
+                            if ~isempty(hhh)
+                                set(hhh,'Visible','off')
+                            end
+                        end
+                    elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates
+                        yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)};
+                        xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)};
+                        y=Field.(yName);
+                        x=Field.(xName);
+                        VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)};
+                        nxy=size(Field.(VarName));
+                        MaxAY=max(y(1),y(end));
+                        MinAY=min(y(1),y(end));
+                        if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
+                            indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel
+                            indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel
+                            if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
+                                text_displ_2=['i='  num2str(indx0) ',j=' num2str(indy0) ','];
+                                for ivar=1:numel(CellInfo{icell}.VarIndex)
+                                    VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
+                                    VarVal=Field.(VarName)(indy0,indx0,:);
+                                    var_text=[VarName '=' num2str(VarVal) ','];
+                                    text_displ_4=[text_displ_4 var_text];
                                 end
                             end
                         end
                     end
-              % display the current x,y plot coordinates in the absence of detected vector
-                    if isempty(ivec)
-                        if isempty(xName)
-                            xName='x';
-                            yName='y';
+                end
+            end
+            % display the current x,y plot coordinates in the absence of detected vector
+            if isempty(ivec)
+                if isempty(xName)
+                    xName='x';
+                    yName='y';
+                end
+                text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
+            end
+            %display the z coordinate if defined by the projection plane
+            if isfield(Field,'ObjectType') && strcmp(Field.ObjectType,'plane') && isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
+                pos=[xy(1,1) xy(1,2) 0];
+                if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
+                    om=norm(Field.ObjectAngle);%norm of rotation angle in radians
+                    OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
+                    cos_om=cos(pi*om/180);
+                    sin_om=sin(pi*om/180);
+                    pos=[xy(1,1) xy(1,2) 0];
+                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
+                end
+                pos=pos+[Field.ObjectCoord 0];
+                text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
+            end
+            %                     if ~isempty(z)
+            %                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
+            %                     end
+            % case of PIV correlation display
+            if test_piv
+                par=read_GUI(hhciv.Civ1);
+                [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
+                xround=Field.X(ind_pt);
+                yround=Field.Y(ind_pt);
+                %                         par.Grid=[xround size(Field.A,1)-yround+1];
+                par.Grid=[xround yround];
+                % mark the correlation box with a rectangle
+                par.ImageA=Field.A;
+                par.ImageB=Field.B;
+                par.ImageHeight=size(par.ImageA,1);
+                par.ImageWidth=size(par.ImageA,2);
+                Param.Civ1=par;
+                ibx2=floor((par.CorrBoxSize(1)-1)/2);
+                iby2=floor((par.CorrBoxSize(2)-1)/2);
+                isx2=floor((par.SearchBoxSize(1)-1)/2);
+                isy2=floor((par.SearchBoxSize(2)-1)/2);
+                shiftx=par.SearchBoxShift(1);
+                shifty=par.SearchBoxShift(2);
+                hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
+                hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
+                if isempty(hhh)
+                    set(0,'CurrentFigure',CurrentFig)
+                    set(CurrentFig,'CurrentAxes',CurrentAxes)
+                    rectangle('Curvature',[0 0],...
+                        'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
+                        'LineStyle','-','Tag','PIV_box_marker');
+                    rectangle('Curvature',[0 0],...
+                        'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
+                        'LineStyle','- -','Tag','PIV_search_marker');
+                else
+                    set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
+                    set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
+                end
+                [Data,errormsg,result_conv]= civ_matlab(Param);
+                if ~isempty(errormsg)
+                    text_displ_5=errormsg;
+                else
+                    rangx(1)=-(isx2-ibx2)+shiftx;
+                    rangx(2)=isx2-ibx2+shiftx;
+                    rangy(1)=-(isy2-iby2)-shifty;
+                    rangy(2)=(isy2-iby2)-shifty;
+                    hcorr=[];
+                    if isfield(AxeData,'CurrentCorrImage')
+                        hcorr=AxeData.CurrentCorrImage;
+                        if ~ishandle(hcorr)
+                            hcorr=[];
                         end
-                        text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
                     end
-                    %display the z coordinate if defined by the projection plane
-                    if isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
-                        pos=[xy(1,1) xy(1,2) 0];
-                        if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
-                            om=norm(Field.ObjectAngle);%norm of rotation angle in radians
-                            OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
-                            cos_om=cos(pi*om/180);
-                            sin_om=sin(pi*om/180);
-                            pos=[xy(1,1) xy(1,2) 0];
-                            pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
+                    if isempty(hcorr)
+                        corrfig=findobj(allchild(0),'tag','corrfig');
+                        if ~isempty(corrfig)
+                            set(0,'CurrentFigure',corrfig(1))
+                            AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
+                            AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
+                            AxeData.TitleHandle=title(num2str(par.Grid));
+                            colorbar
+                            set(CurrentAxes,'UserData',AxeData)
+                            set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
                         end
-                        pos=pos+Field.ObjectCoord;
-                        text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
-                    end
-%                     if ~isempty(z)
-%                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
-%                     end
-               % case of PIV correlation display
-                    if test_piv
-                        par=read_GUI(hhciv.Civ1);
-                        [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
-                        xround=Field.X(ind_pt);
-                        yround=Field.Y(ind_pt);
-%                         par.Grid=[xround size(Field.A,1)-yround+1];
-                        par.Grid=[xround yround];
-                        % mark the correlation box with a rectangle
-                        par.ImageA=Field.A;
-                        par.ImageB=Field.B;
-                        par.ImageHeight=size(par.ImageA,1);
-                        par.ImageWidth=size(par.ImageA,2);
-                        Param.Civ1=par;
-                        ibx2=floor((par.CorrBoxSize(1)-1)/2);
-                        iby2=floor((par.CorrBoxSize(2)-1)/2);
-                        isx2=floor((par.SearchBoxSize(1)-1)/2);
-                        isy2=floor((par.SearchBoxSize(2)-1)/2);
-                        shiftx=par.SearchBoxShift(1);
-                        shifty=par.SearchBoxShift(2);     
-                        hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
-                        hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
-                        if isempty(hhh)
-                            set(0,'CurrentFigure',CurrentFig)
-                            set(CurrentFig,'CurrentAxes',CurrentAxes)
-                            rectangle('Curvature',[0 0],...
-                                'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
-                                'LineStyle','-','Tag','PIV_box_marker');
-                            rectangle('Curvature',[0 0],...
-                                'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
-                                'LineStyle','- -','Tag','PIV_search_marker');
-                        else
-                            set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
-                            set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
-                        end
-                        [Data,errormsg,result_conv]= civ_matlab(Param);
-                        if ~isempty(errormsg)
-                            text_displ_5=errormsg;
-                        else
-                            rangx(1)=-(isx2-ibx2)+shiftx;
-                            rangx(2)=isx2-ibx2+shiftx;
-                            rangy(1)=-(isy2-iby2)-shifty;
-                            rangy(2)=(isy2-iby2)-shifty;
-                            hcorr=[];
-                            if isfield(AxeData,'CurrentCorrImage')
-                                hcorr=AxeData.CurrentCorrImage;
-                                if ~ishandle(hcorr)
-                                    hcorr=[];
-                                end
-                            end
-                            if isempty(hcorr)
-                                corrfig=findobj(allchild(0),'tag','corrfig');
-                                if ~isempty(corrfig)
-                                    set(0,'CurrentFigure',corrfig(1))         
-                                    AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
-                                    AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
-                                   AxeData.TitleHandle=title(num2str(par.Grid));
-                                    colorbar
-                                    set(CurrentAxes,'UserData',AxeData)
-                                    set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
-                                end
-                            else
-                                set(AxeData.CurrentCorrImage,'CData',result_conv)
-                                set(AxeData.CurrentCorrImage,'XData',rangx)
-                                set(AxeData.CurrentCorrImage,'YData',-rangy)
-                                set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
-                                set(AxeData.TitleHandle,'String',num2str(par.Grid))
-                            end
-                        end
+                    else
+                        set(AxeData.CurrentCorrImage,'CData',result_conv)
+                        set(AxeData.CurrentCorrImage,'XData',rangx)
+                        set(AxeData.CurrentCorrImage,'YData',-rangy)
+                        set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
+                        set(AxeData.TitleHandle,'String',num2str(par.Grid))
                     end
                 end
@@ -288,7 +294,7 @@
 
 %%%%%%%%%%%%%
-%% draw a zoom rectangle if no object creation is selected
+%% draw a zoom rectangle if checkZoomFig has been selected
 if test_zoom_draw 
-   xy_rect=AxeData.CurrentOrigin;
+   xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down
    if ~isempty(xy_rect) 
         rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
@@ -296,14 +302,13 @@
         rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
         rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
-        if rect(3)>0 & rect(4)>0
-            if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)
+        if rect(3)>0 && rect(4)>0
+            if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
                 set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
             else
-                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
+                AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b');
                 set(CurrentAxes,'UserData',AxeData)
             end
         end
    end
-    pointershape='arrow';
 end
 
@@ -316,10 +321,9 @@
         return
     end
-    ObjectData=UvData.Object{PlotData.IndexObj};
-    ProjObject=[];% object (plane) whose projection is represented on the current axes
+    ObjectData=UvData.ProjObject{PlotData.IndexObj};
     if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat
-        ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
+        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
     else
-        ProjObject=UvData.Object{get(hhuvmat.ListObject,'Value')};
+        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')};
     end
     XYData=AxeData.CurrentOrigin;
@@ -329,8 +333,7 @@
             % ObjectData.Coord(end,:)=xy(1,:);
         elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
-            ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
-            ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
-            ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
-            ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
+                ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate     
+                ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width
+                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height 
         elseif isequal(ObjectData.Type,'plane') %case of 'plane'
             DX=(xy(1,1)-ObjectData.Coord(1,1));
@@ -364,5 +367,5 @@
 %% 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 && ~isempty(h_geometry_calib)
+if ~CheckZoom && ~isempty(h_geometry_calib)
     pointershape='crosshair';%default for geometry_calib: ready to create new points
     hh_geometry_calib=guidata(h_geometry_calib);
Index: /trunk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 621)
+++ /trunk/src/mouse_up.m	(revision 622)
@@ -23,11 +23,11 @@
 
 function mouse_up(hObject,eventdata,handles)
-%MouseAction='none'; %default
-test_zoom=0;%default
+
 test_ruler=0;%default
-currentfig=hObject;
-tagfig=get(currentfig,'tag');
+hcurrentfig=hObject;
+fig_tag=get(hcurrentfig,'tag');
 currentaxes=gca; %store the current axes handle
 AxeData=get(currentaxes,'UserData');
+CurrentOrigin=[];
 if isfield(AxeData,'CurrentOrigin')
     CurrentOrigin=AxeData.CurrentOrigin;
@@ -40,5 +40,5 @@
     testsubplot=1;
 else
-    hhcurrentfig=guidata(currentfig);%the current figure is a GUI (uvmat or view_field)
+    hhcurrentfig=guidata(hcurrentfig);%the current figure is a GUI (uvmat or view_field)
     testsubplot=0;
 end
@@ -59,5 +59,5 @@
     PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object
     IndexObj=PlotData.IndexObj;
-    ObjectData=UvData.Object{IndexObj};
+    ObjectData=UvData.ProjObject{IndexObj};
     check_multiple=0;
     % ending translation
@@ -79,20 +79,24 @@
         switch ObjectData.Type
             case {'line'}
-                if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
-                    xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
+                if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click
+                    check_multiple=1;
                 else
-                    xy(1,3)=0; % z coordinate set to 0 by default
-                end
-                %                 if ~isequal(ObjectData.Coord,xy(1,:))
-                if ~isequal(ObjectData.Coord(end,1:2),xy(1,1:2))
-                    ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the second point of the line if different from the first one
-                end
-                %                 end
+                    %ObjectData.Coord=[ObjectData.Coord ;CurrentOrigin];% append the second point of the line (the last pointed position during mouse down)
+                end
             case {'rectangle','ellipse','volume'}
-                XYData=AxeData.CurrentOrigin;
-                ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
-                ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
-                ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
-                ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
+%                  if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click
+%                     check_multiple=1;
+%                  else
+                ObjectData.Coord=(CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate     
+                ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width
+                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height    
+                if isequal(ObjectData.RangeX,0)||isequal(ObjectData.RangeY,0)
+                    check_multiple=1;% pass to next mous up if width of height=0
+                end
+%                 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
+%                 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
+%                 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
+%                 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
+%                  end
             case 'plane' %case of 'plane'
                 DX=(xy(1,1)-ObjectData.Coord(1,1));
@@ -106,5 +110,5 @@
                 end
             otherwise
-                check_multiple=1;
+                check_multiple=1; 
         end
     end
@@ -120,22 +124,17 @@
 
     %stop drawing and plot projected field if the object manipulation is finished
-    if check_multiple==0  || isequal(get(currentfig,'SelectionType'),'alt')
+    if check_multiple==0  || isequal(get(hcurrentfig,'SelectionType'),'alt')
         AxeData.CurrentOrigin=[]; %suppress the current origin
-%         if isequal(ObjectData.Type,'line') && size(ObjectData.Coord,1)>=2
-% %             AxeData.Drawing='off';
-% %             set(currentaxes,'UserData',AxeData);
-%             
-%         end
+        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
+        if ~isempty(hObject)
+         ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
+        AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
+        end
+        %%
         if  ~isempty(ObjectData)
-            %              testmask=0;
-            %              hmask=findobj(huvmat,'Tag','makemask');
-            %              if ~isempty(hmask)
-            %                 testmask=get(hmask,'Value');
-            %              end
-            
             % plot the field projected on the object
             ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
             if ~isempty(ProjData)
-                if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen in view_field
+                if strcmp(fig_tag,'uvmat')% uvmat plot selected, projection plot seen in view_field
                     hview_field=findobj(allchild(0),'tag','view_field');
                     if isempty(hview_field)
@@ -144,9 +143,7 @@
                         hhview_field=guidata(hview_field);
                         [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing  plot in view_field
-                        %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
                         errormsg=fill_GUI(PlotParam,hview_field);
                     end
                     ViewFieldData=get(hview_field,'UserData');
-                    %                     ViewFieldData.PlotAxes=ProjData;
                     haxes=findobj(hview_field,'tag','axes3');
                     if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table)
@@ -164,5 +161,4 @@
                     [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(hhuvmat));%update an existing field plot
                     errormsg=fill_GUI(PlotParam,huvmat);
-                   % write_plot_param(hhuvmat,PlotParam); %update the display of plotting parameters for the current object
                 end
             end
@@ -176,7 +172,7 @@
     else
         test_drawing=1;%allow continuation of drawing object
-        AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
-    end
-    UvData.Object{IndexObj}=ObjectData;
+         AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
+    end
+    UvData.ProjObject{IndexObj}=ObjectData;
     hother=findobj('Tag','deformpoint');%find all the deformpoints
     set(hother,'Color','b');%reset all the deformpoints in 'blue'
@@ -184,6 +180,6 @@
 
 %% creation of a new zoom plot
-if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
-    hparentfig=currentfig;
+if isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed
+    hparentfig=hcurrentfig;
     %open or update a new zoom figure if a rectangle has been drawn
     if ishandle(currentaxes);
@@ -196,10 +192,14 @@
                 hfig2=figure;%create new figure
                 set(hfig2,'name','zoom')
-                set(hfig2,'Units','normalized')
-                set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
+                set(0,'Unit','pixels')
+                set(hfig2,'Unit','pixels')
+                FigPos=get(hfig2,'Position');
+                ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
+                Left=ScreenSize(3)- FigPos(3)-40; %right edge close to the right, with margin=40 
+                Bottom=ScreenSize(4)-FigPos(4)-40; %put fig at top right
+                FigPos(1:2)=[Left Bottom];
+                set(hfig2,'Position',FigPos);
                 map=colormap(currentaxes);
                 colormap(map);%transmit the current colormap to the zoom fig
-                set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
-                set(hfig2,'Unit','normalized')
                 set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
                 set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
@@ -209,10 +209,10 @@
                 set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig
                 AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure
+                hrect_zoom=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');%find and delete the copy of the rect_zoom rectangle
+                delete(hrect_zoom)
                 ChildAxeData=get(AxeData.ZoomAxes,'UserData');
                 if isfield(ChildAxeData,'ParentGUI')
                     ChildAxeData=rmfield(ChildAxeData,'ParentGUI');%no parent GUI, e.g. uvmat,  for the new plot
                 end
-                %figure(hfig2)
-                %set(0,'CurrentFigure',hfig2)% the zoom figure becomes the current figure
                 set(AxeData.ZoomAxes,'Position',[0.1300    0.1100    0.7750    0.8150])% standard axes position on a figure
                 hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes
@@ -247,5 +247,5 @@
     ylim=get(currentaxes,'YLim');
     % if left mouse button has been pressed, zoom in by a factor of 2
-    if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
+    if  isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
         PlotBoxAspectRatio=get(currentaxes,'PlotBoxAspectRatio');
         yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1);
@@ -346,5 +346,5 @@
 
 %% display the data of the current object selected with the mouse right click
-if isequal(get(currentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
+if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
     hother=findobj('Tag','proj_object');%find all the proj objects
     nbselect=0;
@@ -368,6 +368,6 @@
     end
 %     if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat)
-%         currentfig=get(currentobj,'parent');
-%         figname=get(currentfig,'name');
+%         hcurrentfig=get(currentobj,'parent');
+%         figname=get(hcurrentfig,'name');
 %         eval(['global Data_' figname])
 %         eval(['Data_' figname '=get(currentobj,''UserData'')']);
Index: /trunk/src/plot_object.m
===================================================================
--- /trunk/src/plot_object.m	(revision 621)
+++ /trunk/src/plot_object.m	(revision 622)
@@ -115,11 +115,11 @@
         end
     case {'rectangle','ellipse','volume'}
-        if  isequal(YMax,0)
-            ylim=get(haxes,'YLim');
-            YMax=(ylim(2)-ylim(1))/100;
-        end
-        if isequal(XMax,0)
-            XMax=YMax;%default
-        end
+%         if  isequal(YMax,0)
+%             ylim=get(haxes,'YLim');
+%             YMax=(ylim(2)-ylim(1))/100;
+%         end
+%         if isequal(XMax,0)
+%             XMax=YMax;%default
+%         end
     case 'plane'
         if  isequal(XMax,0)
@@ -274,6 +274,14 @@
                end
                %complement missing points
-               if size(ObjectData.Coord,1)>length(PlotData.SubObject)
-                   for ipt=length(PlotData.SubObject)+1:size(ObjectData.Coord,1)
+                if length(PlotData.SubObject)>nbpoints% fpoints in excess on the graph
+               for ii=nbpoints+1: length(PlotData.SubObject);
+                   if ishandle(PlotData.SubObject(ii))
+                        delete(PlotData.SubObject(ii))
+                   end
+               end
+%                NbDeformPoint=nbpoints;
+           end
+               if nbpoints>length(PlotData.SubObject)
+                   for ipt=length(PlotData.SubObject)+1:nbpoints
                      PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
                   'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
@@ -284,5 +292,14 @@
         end
         if isfield(PlotData,'DeformPoint')
-           for ipt=1:length(PlotData.DeformPoint)
+            NbDeformPoint=length(PlotData.DeformPoint);
+           if NbDeformPoint>nbpoints% fpoints in excess on the graph
+               for ii=nbpoints+1:NbDeformPoint;
+                   if ishandle(PlotData.DeformPoint(ii))
+                        delete(PlotData.DeformPoint(ii))
+                   end
+               end
+               NbDeformPoint=nbpoints;
+           end
+           for ipt=1:NbDeformPoint
                if ishandle(PlotData.DeformPoint(ipt))
                    if nbpoints>=ipt  
@@ -299,5 +316,5 @@
            end
         end
-    elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse')
+    elseif (isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse'))&&XMax>0 && YMax>0
         set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])          
     end
Index: /trunk/src/set_grid.m
===================================================================
--- /trunk/src/set_grid.m	(revision 621)
+++ /trunk/src/set_grid.m	(revision 622)
@@ -170,20 +170,4 @@
     set(handles.TxtWarning,'visible','on')
 end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% --- Executes on button press in delete.
-function delete_Callback(hObject, eventdata, handles)
-
-%SetData=get(gcbf,'UserData');%get the interface data
-%IndexObj=SetData.IndexObj;
-huvmat=findobj('Name','uvmat');%find the current uvmat interface handle
-UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
-if isfield(UvData,'CurrentObjectIndex')
-    IndexObj=UvData.CurrentObjectIndex;
-else
-    IndexObj=[];
-end
-delete_object(IndexObj);
-
 
 % ------------------------------------------------------
Index: /trunk/src/set_object.m
===================================================================
--- /trunk/src/set_object.m	(revision 621)
+++ /trunk/src/set_object.m	(revision 622)
@@ -475,14 +475,14 @@
 set(hhuvmat.ListObject,'String',ListObject);%complement the object list
 set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
-check_handle=isfield(UvData.Object{IndexObj},'DisplayHandle') && isfield(UvData.Object{IndexObj}.DisplayHandle,'uvmat')...
-    && ~isempty(UvData.Object{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.Object{IndexObj}.DisplayHandle.uvmat);
+check_handle=isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')...
+    && ~isempty(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat);
 if check_handle
-    obj_handle=UvData.Object{IndexObj}.DisplayHandle.uvmat;
-end
-UvData.Object{IndexObj}=ObjectData;%record the current object properties in uvmat
+    obj_handle=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
+end
+UvData.ProjObject{IndexObj}=ObjectData;%record the current object properties in uvmat
 if check_handle
-    UvData.Object{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid
-else
-    UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt
+    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid
+else
+    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt
 end
 %set(hhuvmat.edit_object,'Value',1)% set the current object to edit mode
@@ -543,25 +543,25 @@
 
 %% update the object plot 
-hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
+hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
 % if we are editing the object used for projection in uvmat
 if isequal(IndexObj_1,IndexObj)
     %update the representation of the current object for projection field represented in view_field
-    for iobj=1:numel(UvData.Object)
-        UvData.Object{iobj}.DisplayHandle.uvmat=...
-            plot_object(UvData.Object{iobj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'b');
+    for iobj=1:numel(UvData.ProjObject)
+        UvData.ProjObject{iobj}.DisplayHandle.uvmat=...
+            plot_object(UvData.ProjObject{iobj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{iobj}.DisplayHandle.uvmat,'b');
     end
 else %  we are editing the object used for projection field represented in view_field
     %update the representation of the current object in uvmat
-    UvData.Object{IndexObj}.DisplayHandle.uvmat=...
-             plot_object(UvData.Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{IndexObj}.DisplayHandle.uvmat,'m');
+    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=...
+             plot_object(UvData.ProjObject{IndexObj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'m');
     %indicate the object index in the user data of the object plot (needed for further mouse editing)
-    ObjectInfo=get(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData');
+    ObjectInfo=get(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData');
     ObjectInfo.IndexObj=IndexObj;
-    set(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo)
+    set(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo)
     % update the representation of all objects in view_field
-    for iobj=1:numel(UvData.Object)
-        if isfield(UvData.Object{iobj}.DisplayHandle,'view_field')
-            UvData.Object{iobj}.DisplayHandle.view_field=...
-                plot_object(UvData.Object{iobj},UvData.Object{iobj},UvData.Object{iobj}.DisplayHandle.view_field,'b');
+    for iobj=1:numel(UvData.ProjObject)
+        if isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field')
+            UvData.ProjObject{iobj}.DisplayHandle.view_field=...
+                plot_object(UvData.ProjObject{iobj},UvData.ProjObject{iobj},UvData.ProjObject{iobj}.DisplayHandle.view_field,'b');
         end
     end
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 621)
+++ /trunk/src/uvmat.m	(revision 622)
@@ -34,5 +34,5 @@
 %                       .PosGeometryCalib: size of set_object
 %                       .NbBuiltin: nbre of functions always displayed in TransformName menu
-%          .Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default
+%          .ProjObject: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default
 %          .NewSeries: =0/1 flag telling whether a new field series has been opened
 %          .FileName_1: name of the current second field (used to detect a  constant field during file scanning)
@@ -126,5 +126,5 @@
 %              .Phi, .Theta, .Psi : Euler angles
 %              .X,.Y,.U,.V.... : field data projected on the object
-%              .IndexObj: index in the list of UvData.Object
+%              .IndexObj: index in the list of UvData.ProjObject
            %during plotting
 %               .plotaxes: handles of the current axes used to plot the  result of field projection on the object
@@ -214,5 +214,5 @@
 set(handles.FieldName,'Value',1)
 set(handles.FieldName,'string',{''})
-UvData.Object={[]};
+UvData.ProjObject={[]};
 
 %% TRANSFORM menu: builtin fcts
@@ -1809,4 +1809,5 @@
 function movie_pair_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
+
 %% stop movie action if the movie_pair button is off
 if ~get(handles.movie_pair,'value')
@@ -2065,6 +2066,6 @@
 check_proj_tps=0;
 if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
-    for iobj=1:numel(UvData.Object)
-        if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps')
+    for iobj=1:numel(UvData.ProjObject)
+        if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps')
             check_proj_tps=1;
             break
@@ -2547,9 +2548,9 @@
     end
     % default projection plane
-    if isempty(UvData.Object{1})
-        UvData.Object{1}.Type='plane';%main plotting plane
-        UvData.Object{1}.ProjMode='projection';%main plotting plane
-        UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
-        UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
+    if isempty(UvData.ProjObject{1})
+        UvData.ProjObject{1}.Type='plane';%main plotting plane
+        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
+        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
+        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     end
     %% 3D case (menuvolume)
@@ -2563,13 +2564,13 @@
         end
         if test_set_object% reinitiate the GUI set_object
-            delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
-            UvData.Object{1}.NbDim=NbDim;%test for 3D objects
-            UvData.Object{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
-            UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
-            UvData.Object{1}.Angle=[0 0 0];
-            UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
-            UvData.Object{1}.Name='1-PLANE';
-            UvData.Object{1}.enable_plot=1;
-            set_object(UvData.Object{1},handles,ZBounds);
+            delete_object(1);% delete the current projection object in the list UvData.ProjObject, delete its graphic representations and update the list displayed in handles.ListObject and 2
+            UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects
+            UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
+            UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
+            UvData.ProjObject{1}.Angle=[0 0 0];
+            UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
+            UvData.ProjObject{1}.Name='1-PLANE';
+            UvData.ProjObject{1}.enable_plot=1;
+            set_object(UvData.ProjObject{1},handles,ZBounds);
             set(handles.ListObject,'Value',1);
             set(handles.ListObject,'String',{'1-PLANE'});
@@ -2582,13 +2583,13 @@
             XmlData=UvData.XmlData{1};
             if isfield(XmlData,'PlanePos')
-                UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
+                UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
             end
             if isfield(XmlData,'PlaneAngle')
                 siz=size(XmlData.PlaneAngle);
                 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
-                UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
+                UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
             end
         elseif isfield(UvData,'ZIndex')
-            UvData.Object{1}.ZObject=UvData.ZIndex;
+            UvData.ProjObject{1}.ZObject=UvData.ZIndex;
         end
     end
@@ -2631,13 +2632,13 @@
         set(handles.ListObject,'Value',1)
         set(handles.ListObject,'String',{'plane'})
-        UvData.Object{1}.Type='plane';%main plotting plane
-        UvData.Object{1}.ProjMode='projection';%main plotting plane
-        UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
-        UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
+        UvData.ProjObject{1}.Type='plane';%main plotting plane
+        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
+        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
+        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
         set(handles.ListObject_1,'Value',1)
         set(handles.ListObject_1,'String',{'plane'})
     end
     IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
-    if IndexObj(1)> numel(UvData.Object)
+    if IndexObj(1)> numel(UvData.ProjObject)
         IndexObj(1)=1;%select the first object if the selected one does not exist
         set(handles.ListObject_1,'Value',1)
@@ -2682,8 +2683,8 @@
     for imap=1:numel(IndexObj)
         iobj=IndexObj(imap);
-        if numel(UvData.Object)<iobj
+        if numel(UvData.ProjObject)<iobj
             break
         end
-        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
+        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object
         if ~isempty(errormsg)
             return
@@ -2879,69 +2880,63 @@
 end
 
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- translate coordinate to matrix index
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 function [indx,indy]=pos2ind(x0,rangx0,nxy)
 indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel  
 indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
 
-
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in 'CheckZoom'.
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 function CheckZoom_Callback(hObject, eventdata, handles)
 
-if (get(handles.CheckZoom,'Value') == 1); 
-    set(handles.CheckZoom,'BackgroundColor',[1 1 0])
+if get(handles.CheckZoom,'Value') 
     set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
-    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 
-else
-    set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
-end
-
-%-------------------------------------------------------------------
+    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
+end
+
+%------------------------------------------------------------------------
+% --- Executes on button press in CheckZoomFig.
+%------------------------------------------------------------------------
+function CheckZoomFig_Callback(hObject, eventdata, handles)
+
+if get(handles.CheckZoomFig,'Value')
+    set(handles.CheckZoom,'value',0)
+end
+
+%------------------------------------------------------------------------
 % --- Executes on button press in 'CheckFixLimits'.
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 function CheckFixLimits_Callback(hObject, eventdata, handles)
-test=get(handles.CheckFixLimits,'Value');
-if test
-    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
-else
-    set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
+
+if ~get(handles.CheckFixLimits,'Value')
     update_plot(handles);
 end
 
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on button press in CheckFixAspectRatio.
 function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
+
 if get(handles.CheckFixAspectRatio,'Value')
-%     set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])
     update_plot(handles);
 else
-%     set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7])
     update_plot(handles);
 end
 
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 function num_AspectRatio_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
-% set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow
 update_plot(handles);
-%-------------------------------------------------------------------
-
-%-------------------------------------------------------------------
-
-
-
-%-------------------------------------------------------------------
+
+%------------------------------------------------------------------------
 %----Executes on button press in 'record': records the current flags of manual correction.
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 function record_Callback(hObject, eventdata, handles)
-% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
+
 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
-%FileName=read_file_boxes(handles);
 [erread,message]=fileattrib(FileName);
 if ~isempty(message) && ~isequal(message.UserWrite,1)
@@ -3233,5 +3228,5 @@
 end
 
-%---------------------------------------------------
+%----------------------------------------------------------------
 % --- Executes on menu selection FieldName
 function FieldName_1_Callback(hObject, eventdata, handles)
@@ -3452,8 +3447,8 @@
 
 
-%-----------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- reset civ buttons
 function reset_vel_type(handles_civ0,handle1)
-%-----------------------------------------------------------------------
+%------------------------------------------------------------------------
 for ibutton=1:length(handles_civ0)
     set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
@@ -3546,7 +3541,7 @@
 yi=0.5:npy-0.5;
 [Xi,Yi]=meshgrid(xi,yi);
-if isfield(UvData,'Object')
-    for iobj=1:length(UvData.Object)
-        ObjectData=UvData.Object{iobj};
+if isfield(UvData,'ProjObject')
+    for iobj=1:length(UvData.ProjObject)
+        ObjectData=UvData.ProjObject{iobj};
         if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
             flagobj=1;
@@ -3618,14 +3613,14 @@
 image(imflag);
 
-%-------------------------------------------------------------------
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
+%------------------------------------------------------------------------
 %  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
 
-%------------------------------------------------------------------
-%-------------------------------------------------------------
+%------------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- Executes on selection change in TransformName.
 
 function TransformName_Callback(hObject, eventdata, handles)
-%-------------------------------------------------------------
+%------------------------------------------------------------------------
 UvData=get(handles.uvmat,'UserData');
 menu=get(handles.TransformName,'String');refresh
@@ -3749,7 +3744,4 @@
         delete(hhh)
     end
-%     if isfield(UvData,'Object')
-%         UvData.Object=UvData.Object(1);
-%     end
     set(handles.ListObject,'Value',1)
     set(handles.ListObject,'String',{''})
@@ -3762,5 +3754,5 @@
     set(handles.edit_object,'Value',0)
     edit_object_Callback(hObject, eventdata, handles)
-    UvData.Object={[]};
+    UvData.ProjObject={[]};
 end
 set(handles.uvmat,'UserData',UvData)
@@ -3917,6 +3909,7 @@
 %------------------------------------------------------------------------
 % --- Executes on selection change in CheckDecimate4 (nb_vec/4).
+%------------------------------------------------------------------------
 function CheckDecimate4_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
+
 if isequal(get(handles.CheckDecimate4,'Value'),1)
     set(handles.CheckDecimate16,'Value',0)
@@ -3926,6 +3919,7 @@
 %------------------------------------------------------------------------
 % --- Executes on selection change in CheckDecimate16 (nb_vec/16).
+%------------------------------------------------------------------------
 function CheckDecimate16_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
+
 if isequal(get(handles.CheckDecimate16,'Value'),1)
     set(handles.CheckDecimate4,'Value',0)
@@ -4132,5 +4126,5 @@
 list_str=get(handles.ListObject,'String');
 UvData=get(handles.uvmat,'UserData');
-ObjectData=UvData.Object{get(handles.ListObject_1,'Value')};
+ObjectData=UvData.ProjObject{get(handles.ListObject_1,'Value')};
 
 %% update the projection plot on uvmat
@@ -4139,5 +4133,5 @@
 %replot all the objects within the new projected field
 for IndexObj=1:numel(list_str)
-        hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
+        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
         if isempty(hobject) || ~ishandle(hobject)
             hobject=handles.PlotAxes;
@@ -4148,5 +4142,5 @@
             objectcolor='b';
         end
-        UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat      
+        UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat      
 end
 set(handles.uvmat,'UserData',UvData)
@@ -4177,5 +4171,5 @@
 %% The object  is displayed in set_object if this GUI is already opened
 UvData=get(handles.uvmat,'UserData');
-ObjectData=UvData.Object{IndexObj};
+ObjectData=UvData.ProjObject{IndexObj};
 hset_object=findobj(allchild(0),'tag','set_object');
 if ~isempty(hset_object)
@@ -4219,5 +4213,5 @@
 
 %% update the color of the graphic object representation: the selected object in magenta, others in blue
-update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.Object{IndexObj}.DisplayHandle.uvmat)
+update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.ProjObject{IndexObj}.DisplayHandle.uvmat)
 
 %------------------------------------------------------------------------
@@ -4313,6 +4307,6 @@
     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
+    UvData.ProjObject{IndexObj}.Name=list_object{IndexObj};
+    if numel(UvData.ProjObject)<IndexObj;% error in UvData
         msgbox_uvmat('ERROR','invalid object list')
         return
@@ -4324,5 +4318,5 @@
     end
 %     set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion
-    data=UvData.Object{IndexObj};
+    data=UvData.ProjObject{IndexObj};
     if ~isfield(data,'Type')% default plane
         data.Type='plane';
@@ -4374,5 +4368,5 @@
     IndexObj=get(handles.ListObject,'Value');
     UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
-    if numel(UvData.Object)<IndexObj(end);% error in UvData
+    if numel(UvData.ProjObject)<IndexObj(end);% error in UvData
         msgbox_uvmat('ERROR','invalid object list')
         return
@@ -4384,12 +4378,12 @@
     end
     set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion
-    if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane
-        UvData.Object{IndexObj(1)}.Type='plane';
+    if ~isfield(UvData.ProjObject{IndexObj(1)},'Type')% default plane
+        UvData.ProjObject{IndexObj(1)}.Type='plane';
     end
     list_object=get(handles.ListObject,'String');
-    UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)};
+    UvData.ProjObject{IndexObj(end)}.Name=list_object{IndexObj(end)};
     
     %% show the projection of the selected object on view_field
-    ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData
+    ProjData= proj_field(UvData.Field,UvData.ProjObject{IndexObj});%project the current field on ObjectData
     hview_field=findobj(allchild(0),'tag','view_field');
     if isempty(hview_field)
@@ -4425,10 +4419,93 @@
 %------------------------------------------------------------------------
 % --- Executes on button press in delete_object.
+%------------------------------------------------------------------------
 function delete_object_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
+
 IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field
 IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot
 if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot
     delete_object(IndexObj)
+end
+
+%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
+%------------------------------------------------------------------------
+% function delete_object(hObject)
+%
+% INPUT:
+% hObject: object index (if integer) or handle of the graphic object. If
+%          hObject is a subobject, the parent object is detected and deleted. 
+
+function delete_object(IndexObj)
+
+huvmat=findobj('tag','uvmat');%handles of the uvmat interface
+UvData=get(huvmat,'UserData');
+hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface
+list_str=get(hlist_object,'String');%objet list
+% if isequal(floor(hObject),hObject) %case of an index
+    if  ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj 
+        if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')
+            hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
+            for iview=1:length(hdisplay)
+                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
+                    ObjectData=get(hdisplay(iview),'UserData');
+                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
+                        delete(ObjectData.SubObject);
+                    end
+                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
+                        delete(ObjectData.DeformPoint);
+                    end
+                    delete(hdisplay(iview))
+                end
+                ishandle(hdisplay(iview))
+            end
+            for iobj=IndexObj+1:length(UvData.ProjObject)
+                hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat;
+                for iview=1:length(hdisplay)
+                    if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
+                        PlotData=get(hdisplay(iview),'UserData');
+                        PlotData.IndexObj=iobj-1;
+                        set(hdisplay(iview),'UserData',PlotData);
+                    end
+                end
+            end
+        end
+        UvData.ProjObject(IndexObj)=[];  
+        if ~isempty(list_str)
+            list_str(IndexObj)=[];
+        end
+    end
+% elseif ishandle(hObject)%object handle
+%     userdata=get(hObject,'UserData');
+%     if ishandle(userdata)%the selected line depends on a parent line
+%         hdisplay=userdata;% the parent object becomes the current one
+%     else
+%         hdisplay=hObject;% the selected object becomes the current one
+%     end
+%     PlotData=get(hdisplay,'UserData');
+%     if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
+%             delete(PlotData.SubObject);
+%     end
+%     if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
+%            delete(PlotData.DeformPoint);
+%     end
+%     delete(hdisplay);
+%     if isfield(PlotData,'IndexObj')
+%         IndexObj=PlotData.IndexObj;
+%         if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
+%             if isfield(UvData,'ProjObject')& length(UvData.ProjObject) > IndexObj
+%                UvData.ProjObject(IndexObj)=[];
+%             end
+%             list_str(IndexObj)=[];
+%         end
+%     end
+% end
+set(huvmat,'UserData',UvData);
+set(hlist_object,'String',list_str)
+set(hlist_object,'Value',length(list_str))
+hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface
+old_index=get(hlist_object_1,'Value');
+set(hlist_object_1,'String',list_str)
+if IndexObj<=old_index
+    set(hlist_object_1,'Value',old_index-1)
 end
 
@@ -4599,5 +4676,4 @@
 aviobj=close(aviobj);
 UvData=rmfield(UvData,'plotaxes');
-%UvData.Object{1}.plotaxes=handles.PlotAxes;
 set(huvmat,'UserData',UvData);
 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
@@ -4688,13 +4764,18 @@
 function create_object(data,handles)
 %------------------------------------------------------------------------
-% desactivate geometric calibration if opened
-hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
+%% desactivate concurrent tools
+hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration 
 if ishandle(hgeometry_calib)
     hhgeometry_calib=guidata(hgeometry_calib);
     set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
-    set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
-end
-set(handles.edit_object,'Value',0); %suppress the object edit mode
-set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])  
+end
+set(handles.edit_object,'Value',0)  %desactivate the object edit mode
+set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig
+set(handles.CheckZoom,'Value',0)    %desactivate the zoom action
+if ishandle(handles.UVMAT_title)
+    delete(handles.UVMAT_title)     %delete the initial display of uvmat if no field has been entered yet
+end
+
+%% append a new line to the list of projection objects
 ListObject=get(handles.ListObject,'String');
 if isempty(ListObject)
@@ -4708,7 +4789,10 @@
 set(handles.ListObject,'Value',IndexObj)
 UvData=get(handles.uvmat,'UserData');
-UvData.Object{IndexObj}=[]; %create a new empty object
-UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
-UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
+UvData.ProjObject{IndexObj}=[]; %create a new empty object
+UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
+UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
+set(handles.uvmat,'UserData',UvData)
+
+%% initiate the new projection object
 data.Name=data.Type;% default name=type
 data.Coord=[0 0]; %default
@@ -4724,4 +4808,8 @@
         data.DX=UvData.Field.CoordMesh;
         data.DY=UvData.Field.CoordMesh;
+        if strcmp(data.Type,'rectangle')||strcmp(data.Type,'ellipse')
+            data.RangeX=UvData.Field.CoordMesh;
+            data.RangeY=UvData.Field.CoordMesh;
+        end
     end
     if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
@@ -4732,14 +4820,9 @@
     end
 end
-if ishandle(handles.UVMAT_title)
-    delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
-end
-hset_object=set_object(data,handles);% call the set_object interface
-hhset_object=guidata(hset_object);
+hset_object=set_object(data,handles);% call the GUI set_object 
 hchild=get(hset_object,'children');
 set(hchild,'enable','on')
-set(handles.uvmat,'UserData',UvData)
-set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse
-CheckZoom_Callback(handles.uvmat, [], handles)
+
+
 set(handles.delete_object,'Visible','on')
 
@@ -4771,7 +4854,7 @@
 
 UvData=get(handles.uvmat,'UserData');
-UvData.Object{IndexObj}=[]; %create a new empty object
-UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
-UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
+UvData.ProjObject{IndexObj}=[]; %create a new empty object
+UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
+UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
 set(handles.uvmat,'UserData',UvData)
 set(handles.ListObject,'Value',IndexObj)
@@ -4842,5 +4925,5 @@
 
 %% read lines currently drawn
-ListObj=UvData.Object;
+ListObj=UvData.ProjObject;
 select=zeros(1,numel(ListObj));
 for iobj=1:numel(ListObj);
@@ -4855,5 +4938,5 @@
 else
     set(handles.ListObject,'Value',val);% show the selected lines on the list
-    ObjectData=UvData.Object(val);
+    ObjectData=UvData.ProjObject(val);
     for iobj=1:length(ObjectData)
 %         if isfield(ObjectData{iobj},'Coord')
@@ -4962,5 +5045,5 @@
 %------------------------------------------------------------------------
 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 
-ListObj=UvData.Object;
+ListObj=UvData.ProjObject;
 select=zeros(1,numel(ListObj));
 for iobj=1:numel(ListObj);
@@ -4981,7 +5064,6 @@
     yi=0.5:npy-0.5;
     [Xi,Yi]=meshgrid(xi,yi);
-%     if isfield(UvData,'Object')
-        for iobj=1:length(UvData.Object)
-            ObjectData=UvData.Object{iobj};
+        for iobj=1:length(UvData.ProjObject)
+            ObjectData=UvData.ProjObject{iobj};
             if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
                 flagobj=1;
@@ -5307,9 +5389,2 @@
 
 
-% --- Executes on button press in CheckZoomFig.
-function CheckZoomFig_Callback(hObject, eventdata, handles)
-% hObject    handle to CheckZoomFig (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 CheckZoomFig
Index: /trunk/src/view_field.m
===================================================================
--- /trunk/src/view_field.m	(revision 621)
+++ /trunk/src/view_field.m	(revision 622)
@@ -363,22 +363,28 @@
 % set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
 
-
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 % --- translate coordinate to matrix index
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
 function [indx,indy]=pos2ind(x0,rangx0,nxy)
 indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel  
 indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
 
-%-------------------------------------------------------------------
-% --- Executes on button press in 'zoom'.
-%-------------------------------------------------------------------
+%------------------------------------------------------------------------
+% --- Executes on button press in 'CheckZoom'.
+%------------------------------------------------------------------------
 function CheckZoom_Callback(hObject, eventdata, handles)
-if (get(handles.CheckZoom,'Value') == 1); 
-    set(handles.CheckZoom,'BackgroundColor',[1 1 0])
+
+if get(handles.CheckZoom,'Value') 
     set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
-    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
-else
-    set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
+    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
+end
+
+%------------------------------------------------------------------------
+% --- Executes on button press in CheckZoomFig.
+%------------------------------------------------------------------------
+function CheckZoomFig_Callback(hObject, eventdata, handles)
+
+if get(handles.CheckZoomFig,'Value')
+    set(handles.CheckZoom,'value',0)
 end
 
@@ -839,2 +845,6 @@
 % % eventdata  reserved - to be defined in a future version of MATLAB
 % % handles    structure with handles and user data (see GUIDATA)
+
+
+
+
