Index: trunk/src/keyboard_callback.m
===================================================================
--- trunk/src/keyboard_callback.m	(revision 11)
+++ trunk/src/keyboard_callback.m	(revision 11)
@@ -0,0 +1,51 @@
+%'keyboard_callback:' function activated when a key is pressed on the keyboard
+%-----------------------------------
+function keyboard_callback(hObject,eventdata,handleshaxes)
+xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
+cur_axes=get(gcbf,'CurrentAxes');
+if ~isempty(cur_axes)
+    xlimit=get(cur_axes,'XLim');
+    ylimit=get(cur_axes,'Ylim');
+    dx=(xlimit(2)-xlimit(1))/10;
+    dy=(ylimit(2)-ylimit(1))/10;
+   
+    if isequal(xx,29)%move arrow right
+        xlimit=xlimit+dx;
+    elseif isequal(xx,28)%move arrow left
+        xlimit=xlimit-dx;
+    elseif isequal(xx,30)%move arrow up
+        ylimit=ylimit+dy;
+    elseif isequal(xx,31)%move arrow down
+        ylimit=ylimit-dy;
+    end
+    set(cur_axes,'XLim',xlimit)
+    set(cur_axes,'YLim',ylimit)
+end
+if ismember(xx,[8 127]) %if the delete or suppr key is pressed, delete the current object 
+    currentobject=gco;
+    huvmat=findobj(allchild(0),'Name','uvmat');
+%     UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
+    hlist_object=findobj(huvmat,'Tag','list_object');
+    ObjIndex=get(hlist_object,'Value');
+    if ObjIndex>1
+        delete_object(ObjIndex)
+    end
+    if ishandle(currentobject)
+        tag=get(currentobject,'Tag');%tag of the current selected object
+        if isequal(tag,'proj_object')
+            delete_object(currentobject)
+        end
+    end
+elseif isequal(xx,112)%  key 'p'
+    uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
+elseif isequal(xx,109)%  key 'm'
+    uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
+end
+
+AxeData=get(cur_axes,'UserData');
+if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
+    hparentrect=AxeData.ParentRect;
+    rect([1 2])=[xlimit(1) ylimit(1)];
+    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
+    set(hparentrect,'Position',rect)
+end
Index: trunk/src/mouse_down.m
===================================================================
--- trunk/src/mouse_down.m	(revision 11)
+++ trunk/src/mouse_down.m	(revision 11)
@@ -0,0 +1,343 @@
+%'mouse_down': function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn'
+%-------------------------------------------------------------- 
+% xy=mouse_down(hObject,eventdata) 
+% activated by the command:
+% set(hObject,'WindowButtonDownFcn',{'mouse_down'}), 
+% where hObject is the handle of the figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function xy=mouse_down(hObject,eventdata)
+testzoom=0;%default
+MouseAction='none'; %default
+huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
+if ~isempty(huvmat)
+    hhuvmat=guidata(huvmat);%handles of elements in uvmat
+    UvData=get(huvmat,'UserData');
+    testzoom=get(hhuvmat.zoom,'Value');% get the mouse action from the uvmat GUI: options:
+    if isfield(UvData,'MouseAction')
+        MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
+    end
+end
+test_create=~testzoom && (isequal(MouseAction,'create_object') || isequal(MouseAction,'create_mask'));
+%test_cal=get(handles.cal,'Value');
+test_cal=isequal(MouseAction,'calib');
+handles_coord=findobj(huvmat,'Tag','menu_coord');
+menu_coord=get(handles_coord,'String');
+coord_choice=get(handles_coord,'Value');
+coord_type=menu_coord{coord_choice};
+test_edit=isequal(MouseAction,'edit_object');
+test_edit_vect=isequal(MouseAction,'edit_vect');
+xdisplay=[];%default
+ydisplay=[];%default
+haxes=[];
+AxeData=[];%default
+
+%edit an existing point or line if found
+hcurrentobject=gco;% current object handle (selected by the mouse)
+hcurrentfig=gcbo;% current figure handle
+tag_obj=get(gco,'Tag');
+xy=[];%default
+xy_fig=get(hcurrentfig,'CurrentPoint');% current point of the current figure (gcbo)
+hchild=get(hcurrentfig,'Children');%handles of all objects in the current figure
+% loop on all the objects in the current figure (selected by the last mouse click) 
+for ichild=1:length(hchild)
+    obj_pos=get(hchild(ichild),'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(ichild),'Type');%type of object child of the current figure
+        %if the mouse is over an axis, look at the data
+        if isequal(htype,'axes')
+            haxes=hchild(ichild);
+            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            AxeData=get(haxes,'UserData');% data attached to the axis
+            AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
+            if ~isequal(tag_obj,'proj_object') & ~test_create
+                x_mouse=xy(1,1);%default
+                y_mouse=xy(1,2);%default
+                u_mouse=[];
+                v_mouse=[];
+                w_mouse=[];
+                A_mouse=[];
+                c_text=[];
+                f_text=[];
+                ff_text=[];     
+                ivec=[];   
+                if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
+                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                      (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
+                    ivec=find(flag_vec);% search the selected vector index ivec
+                    if length(ivec)>0
+                        ivec=ivec(1);%choice the first selected vector if several are selected                        
+                    end
+                end
+            end
+        elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
+           %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
+        end
+    end
+end
+test2D=0;
+if isfield(AxeData,'NbDim')
+    if isequal(AxeData.NbDim,2)
+        test2D=1;
+    end
+end
+if ~test2D     %desable  object creation and vector editing if NbDim different from 2
+    test_create=0;
+    test_edit_vect=0;
+end
+%delete the current zoom rectangle
+if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
+    delete(AxeData.CurrentRectZoom)
+    AxeData.CurrentRectZoom=[];
+end    
+
+if testzoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
+     AxeData.Drawing='zoom'; %initiate drawing mode
+     AxeData.CurrentObject=[];%unselect objects
+elseif ~isempty(huvmat)
+    %selection of an existing projection object
+    if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
+        if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
+            userdata=get(hcurrentobject,'UserData');
+            if ishandle(userdata)%the selected line depends on a parent line
+                AxeData.CurrentObject=userdata;% the parent object becomes the current one
+            else
+                AxeData.CurrentObject=hcurrentobject;% the selected object becomes the current one
+            end
+            ObjectData=get(AxeData.CurrentObject,'UserData');
+            if test_edit & 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
+                set(hother,'Selected','off')
+                hother=findobj('Tag','proj_object','Type','rectangle');
+                set(hother,'EdgeColor','b');
+                set(hother,'Selected','off');
+                hother=findobj('Tag','proj_object','Type','image');
+                for iobj=1:length(hother)
+                       Acolor=get(hother(iobj),'CData');
+                       Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
+                       set(hother(iobj),'CData',Acolor);
+                end
+                hother=findobj('Tag','DeformPoint');
+                set(hother,'Color','b');
+                set(hother,'Selected','off')    
+                if isequal(get(AxeData.CurrentObject,'Type'),'line')
+                    set(AxeData.CurrentObject,'Color','m'); %set the selected object to magenta color
+                elseif isequal(get(AxeData.CurrentObject,'Type'),'rectangle')
+                     set(AxeData.CurrentObject,'EdgeColor','m'); %set the selected object to magenta color
+                end
+                if isfield(ObjectData,'SubObject')& ishandle(ObjectData.SubObject)
+                    for iobj=1:length(ObjectData.SubObject)
+                        hsub=ObjectData.SubObject(iobj);
+                        if isequal(get(hsub,'Type'),'rectangle')
+                            set(hsub,'EdgeColor','m'); %set the selected object to magenta color
+                        elseif isequal(get(hsub,'Type'),'image')
+                           Acolor=get(hsub,'CData');
+                           Acolor(:,:,1)=Acolor(:,:,3);
+                           set(hsub,'CData',Acolor);
+                        else
+                            set(hsub,'Color','m')
+                        end
+                    end
+                end
+                if isequal(tag_obj,'DeformPoint')
+                     set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
+                end
+                IndexObj=ObjectData.IndexObj;
+                hlist_object=findobj(huvmat,'Tag','list_object');
+                set(hlist_object,'Value',IndexObj);
+                testdeform=0;
+                set(gcbo,'Pointer','circle'); 
+                AxeData.Drawing='deform';
+                if isequal(tag_obj,'DeformPoint')       
+                   if isfield(ObjectData,'DeformPoint')
+                       set(hcurrentobject,'Selected','on')
+                       for ipt=1:length(ObjectData.DeformPoint)
+                           if isequal(ObjectData.DeformPoint(ipt),hcurrentobject)
+                                AxeData.CurrentIndex=ipt;
+                                testdeform=1;
+                           end
+                       end
+                   end
+                end
+                if testdeform==0
+                    AxeData.Drawing='translate';
+                    set(AxeData.CurrentObject,'Selected','on')
+                    set(gcbo,'Pointer','fleur');
+                end
+            end
+        end
+    end
+    %  create new projection  object
+    if  test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
+            ObjectData=read_set_object(UvData.sethandles); 
+            ObjectData.Coord=[]; %reset previous object coordinates
+            ObjectData.Coord(1,1)=xy(1,1);
+            ObjectData.Coord(1,2)=xy(1,2);
+            ObjectData.Coord(1,3)=0;
+            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
+                 ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
+            end
+            AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
+            if isfield(UvData,'Object')
+                IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
+            else
+                IndexObj=2;
+            end  
+            UvData.Object{IndexObj}=ObjectData;
+            UvData.Object{IndexObj}.HandlesDisplay(1)=AxeData.CurrentObject;
+            set(huvmat,'UserData',UvData)
+            list_str=get(hhuvmat.list_object,'String');
+            list_str{IndexObj}=[num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)];
+            if ~isequal(list_str{end},'...')
+                 list_str{end+1}='...';
+            end
+            set(hhuvmat.list_object,'String',list_str)
+            set(hhuvmat.list_object,'Value',IndexObj)
+            PlotData=get(AxeData.CurrentObject,'UserData');
+            PlotData.IndexObj=IndexObj;
+            set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
+            AxeData.Drawing='create';
+    end
+
+    % create calibration points if the GUI geometry_calib is opened
+    if test_cal & ~isempty(xy)
+        h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
+        hh_geometry_calib=guidata(h_geometry_calib);
+        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
+        h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
+        if isequal(get(h_edit_append,'Value'),1) 
+            if ~isequal(coord_type,'')
+                set(handles_coord,'Value',1)
+                coord_type='';
+                set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
+                set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
+                uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
+            end
+%             if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
+                strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
+%             else %phys cordinates
+%                 strline=[ num2str(xy(1,1),4) '    |    '  num2str(xy(1,2),4) '    |    0      |    '  '    |    ' ];
+%             end
+            Coord=get(h_ListCoord,'String');
+            val=get(h_ListCoord,'Value');
+            if isequal(Coord,{''})
+                val=0;
+            end
+            if length(Coord)>val
+                Coord(val+2:length(Coord)+1)=Coord(val+1:length(Coord));% push the list forward beyond the current point
+            end
+            Coord{val+1}=strline;
+            set(h_ListCoord,'String',Coord)
+            set(h_ListCoord,'Value',val+1)
+            geometry_calib('ListCoord_Callback',hObject,eventdata,hh_geometry_calib)
+            data=read_geometry_calib(Coord);
+            if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
+                XCoord=data.Coord(:,4);
+                YCoord=data.Coord(:,5);
+            else %phys cordinates
+                XCoord=data.Coord(:,1);
+                YCoord=data.Coord(:,2);
+            end
+            hh=findobj('Tag','calib_points')           
+            if isempty(hh)
+                line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
+            else
+                set(hh,'XData',XCoord)
+                set(hh,'YData',YCoord)
+            end
+            hhh=findobj('Tag','calib_marker');
+            if ~isempty(hhh)
+                set(hhh,'XData',xy(1,1))
+                set(hhh,'YData',xy(1,2))
+            else
+                line(xy(1,1),xy(1,2),'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',20);
+            end
+            %uistack(h_geometry_calib,'top')
+        end
+    end
+
+    % edit vectors
+    if test_edit_vect & ~isempty(ivec) 
+    %     FF_100=FF-100*double(uint(abs(FF)/100); %value of FF without units and dizaines
+        if ~isfield(AxeData,'FF')
+            AxeData.FF=zeros(size(AxeData.X));
+        end
+        if isequal(AxeData.FF(ivec),0)
+
+            AxeData.FF(ivec)=100; %mark vector #ivec as false
+
+        else
+            AxeData.FF(ivec)=0;
+        end
+        set(haxes,'UserData',AxeData)
+        update_plot
+    end   
+end
+set(haxes,'UserData',AxeData);
+
+%------------------------------------------------------
+function update_plot
+%--------------------------------------------
+huvmat=gcbf;
+UvData=get(gcbf,'UserData');
+%determine the axes of action of the set_edit interface
+% list_axes=get(handles.MenuAxes,'String');% list menu fields
+% index_axes=get(handles.MenuAxes,'Value');% selected string index
+% current_axes= list_axes{index_axes(1)} % selected string
+% eval(['haxes=UvData.' current_axes '.Axes']);
+% if isempty(haxes)|~ishandle(haxes)| ~isequal(get(haxes,'Type'),'axes')
+     haxes= findobj(huvmat,'Tag','axes3'); %main plotting axes as default
+%      set(handles.MenuAxes,'Value',1)
+% end
+AxeData=get(haxes,'UserData');
+%For vector field representation
+%NEW
+PlotHandles.VecScale=findobj(huvmat,'Tag','VecScale');
+PlotHandles.AutoVec=findobj(huvmat,'Tag','AutoVec');
+PlotHandles.checkyellow=findobj(huvmat,'Tag','checkyellow');
+PlotHandles.checkblack=findobj(huvmat,'Tag','checkblack');
+PlotHandles.col_vec=findobj(huvmat,'Tag','col_vec');
+PlotHandles.colcode1=findobj(huvmat,'Tag','colcode1');
+PlotHandles.colcode2=findobj(huvmat,'Tag','colcode2');
+PlotHandles.vec_col_bar=findobj(huvmat,'Tag','vec_col_bar');
+PlotHandles.slider1=findobj(huvmat,'Tag','slider1');
+PlotHandles.slider2=findobj(huvmat,'Tag','slider2');
+PlotHandles.max_vec=findobj(huvmat,'Tag','max_vec');
+PlotHandles.min_vec=findobj(huvmat,'Tag','min_vec');
+PlotHandles.AutoVecColor=findobj(huvmat,'Tag','AutoVecColor');
+PlotHandles.decimate4=findobj(huvmat,'Tag','decimate4');
+
+%vectors
+Vectors.VecScale=str2num(get(PlotHandles.VecScale,'String'));
+Vectors.AutoVec=get(PlotHandles.AutoVec,'Value');%automatic vector length
+Vectors.checkyellow=get(PlotHandles.checkyellow,'Value');
+Vectors.checkblack=get(PlotHandles.checkblack,'Value');
+Vectors.decimate4=get(PlotHandles.decimate4,'Value');% =1; for reducing the nbre of vectors
+menu_col=get(PlotHandles.col_vec,'String');
+menu_val=get(PlotHandles.col_vec,'Value');
+Vectors.CName=menu_col{menu_val}; %'ima_cor','black','white',...
+Vectors.colcode1=str2num(get(PlotHandles.colcode1,'String'));% first threshold for rgb, first value for'continuous' 
+Vectors.colcode2=str2num(get(PlotHandles.colcode2,'String'));% second threshold for rgb, last value (saturation) for 'continuous' 
+Vectors.option=get(PlotHandles.vec_col_bar,'Value'); % =1 (64 colors), =0 (3 colors)
+Vectors.min=get(PlotHandles.slider1,'Min');
+Vectors.max=get(PlotHandles.slider1,'Max');
+Vectors.auto=get(PlotHandles.AutoVecColor,'Value');% =1; thresholds scaling relative to min and max, =0 fixed thresholds
+PlotParam.Vectors=Vectors;
+
+[PlotType,ScalOut]= plot_field(AxeData,haxes,PlotParam,1);
Index: trunk/src/mouse_motion.m
===================================================================
--- trunk/src/mouse_motion.m	(revision 11)
+++ trunk/src/mouse_motion.m	(revision 11)
@@ -0,0 +1,289 @@
+%'mouse_motion': permanently called by mouse motion over a figure (Callback for 'WindowButtonMotionFcn' of the figure)
+%-----------------------------------------------------------------------
+%
+% function mouse_motion(hObject,eventdata,handles)
+% activated by the command:
+% set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})
+% where hObject is the handle of the figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function mouse_motion(hObject,eventdata,handles)
+if ~exist('handles','var')
+    return
+end
+if ~isfield(handles, 'mouse_coord')
+    return
+end
+if ~ishandle(handles.mouse_coord)
+    return
+end
+proj_coord=get(handles.mouse_coord,'String');
+choice=get(handles.mouse_coord,'Value');
+if ~isempty(proj_coord); proj_coord=proj_coord{choice};else;proj_coord=[];end;
+test_create=0;%default
+test_edit=0;%default
+if isfield(handles,'VOLUME') % mouse_motion not applied to the uvmat figure, no object creation
+    test_create=get(handles.create,'Value');   
+end
+test_edit=isfield(handles,'edit') & get(handles.edit,'Value');% edit test for mouse shap: an arrow
+test_zoom=isfield(handles,'zoom')& get(handles.zoom,'Value');% edit test for mouse shap: an arrow 
+
+%find the current axe 'haxes' and display the current mouse position or uicontrol tag
+text_displ_1='';
+text_displ_2='';
+text_displ_3='';
+text_displ_4='';
+
+haxes=[];
+AxeData=[];%default
+mouse=[];
+
+pointershape='arrow';% default pointer is an arrow 
+
+xy_fig=get(gcbo,'CurrentPoint');% current point of the current figure (gcbo)
+hchild=get(gcbo,'Children');%handles of all objects in the current figure
+currentfig=gcbo;%store gcbo as variable currentfig
+% loop on all the objects in the current figure (selected by the last mouse click) 
+for ichild=1:length(hchild)
+    obj_pos=get(hchild(ichild),'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(ichild),'Type');%type of the crrent child
+        %if the mouse is over an axis, look at the data
+        if isequal(htype,'axes')
+            haxes=hchild(ichild);
+            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            mouse.X=xy(1,1);
+            mouse.Y=xy(1,2);
+            u_mouse=[];
+            v_mouse=[];
+            w_mouse=[];
+            A_mouse=[];
+            c_text=[];
+            f_text=[];
+            ff_text=[];     
+            ivec=[];
+            AxeData=get(haxes,'UserData');% data attached to the axis
+             if ~test_edit && ~test_zoom
+                 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
+%                % pointershape='crosshair';%set pointer with cross shape (default over axis)
+             end
+            if isfield(AxeData,'X') && isfield(AxeData,'Y') && isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
+                if ~isempty(AxeData.Mesh)
+                    flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/3) & AxeData.X>(xy(1,1)-AxeData.Mesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                          (AxeData.Y<(xy(1,2)+AxeData.Mesh/3) & AxeData.Y>(xy(1,2)-AxeData.Mesh/3));%f
+                    ivec=find(flag_vec);% search the selected vector index ivec
+                    if length(ivec)>0 
+                        if ~test_create
+                            pointershape='arrow'; %mouse indicates  the detection of a vector
+                        end
+                        ivec=ivec(1);%choice the first selected vector if several are selected
+                        mouse.X=AxeData.X(ivec);
+                        mouse.Y=AxeData.Y(ivec);
+                        u_mouse=AxeData.U(ivec);%displacement
+                        v_mouse=AxeData.V(ivec);
+                        w_mouse=0; %default
+                        if isfield(AxeData,'W')&length(AxeData.W)>=ivec
+                            w_text=[',  w=' num2str(AxeData.W(ivec),3)];
+                        else
+                            w_text='';
+                        end
+                        if ~isfield(AxeData,'CName')
+                            AxeData.CName='C';%REVOIR
+                        end
+                        c_text=[', ' AxeData.CName '=' num2str(AxeData.C(ivec),3)];
+                        if isfield(AxeData,'F')&length(AxeData.F)>=ivec
+                            f_text=[',  f=' num2str(AxeData.F(ivec),3)];
+                        else
+                            f_text='';
+                        end
+                        if isfield(AxeData,'FF')&length(AxeData.FF)>=ivec
+                            ff_text=[',  ff=' num2str(AxeData.FF(ivec),3)];
+                        else
+                            ff_text='';
+                        end
+                    end
+                end
+            end
+            if isfield(AxeData,'Z')
+                mouse.Z=AxeData.Z; %generaliser au cas avec angle
+            end
+            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
+                mouse.Z=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
+            end
+            testscal= isfield(AxeData,'A')& isfield(AxeData,'AX')& isfield(AxeData,'AY');%test the existence of an image (or scalar represented by an image)
+               if testscal
+                   testscal=~isempty(AxeData.A)&~isempty(AxeData.AX)& ~isempty(AxeData.AY);
+               end
+            if testscal%test the existence of an image (or scalar represented by an image)
+                nxy=size(AxeData.A);
+                MaxAY=max(AxeData.AY(1),AxeData.AY(end));
+                MinAY=min(AxeData.AY(1),AxeData.AY(end));
+                if (xy(1,1)>AxeData.AX(1))&(xy(1,1)<AxeData.AX(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
+                    indx0=1+round((nxy(2)-1)*(xy(1,1)-AxeData.AX(1))/(AxeData.AX(end)-AxeData.AX(1)));% index x of pixel
+                    indy0=1+round((nxy(1)-1)*(xy(1,2)-AxeData.AY(1))/(AxeData.AY(end)-AxeData.AY(1)));% index y of pixel
+                    if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
+                        A_mouse=AxeData.A(indy0,indx0,:);
+                    end
+                end
+            end
+            %coordinate transform if proj_coord differs from menu_coord 
+            if isfield(AxeData,'CoordType')
+                  mouse.CoordType=AxeData.CoordType;
+            end
+            if isfield(AxeData,'CoordUnit')
+                  mouse.CoordUnit=AxeData.CoordUnit;
+            end
+            if isfield(mouse,'CoordType') &~isequal(mouse.CoordType,proj_coord)
+                huvmat=findobj(allchild(0),'Tag','uvmat');%find the uvmat interface handle
+                UvData=get(huvmat,'UserData'); %coord transformed stored in the uvmat interface, updated by file input
+                if isfield(AxeData,'CoordType')
+                    mouse.CoordType=AxeData.CoordType;
+                end
+                if isfield(AxeData,'dt')
+                    mouse.dt=AxeData.dt;
+                end
+%                 if ~isempty(z_mouse)
+%                     mouse.Z=z_mouse;
+%                 end
+                if length(ivec)>0 %& isfield(AxeData,'dt')                    
+                      mouse.U=u_mouse; 
+                      mouse.V=v_mouse;
+                end
+                mouse=feval(proj_coord,mouse,UvData);%apply transform proj_coord to the position
+                if length(ivec)>0%& isfield(AxeData,'dt')
+                     u_mouse=mouse.U;
+                     v_mouse=mouse.V;
+                end
+            end  
+            if isfield(mouse,'CoordType') 
+                if isequal(mouse.CoordType,'px')
+                    mouse.CoordUnit='px';
+                end
+            else
+                mouse.CoordUnit='';%default      
+            end      
+            text_displ_1=['x=' num2str(mouse.X,4) ',y=' num2str(mouse.Y,4)];
+            if isfield(mouse,'Z')&~isempty(mouse.Z)
+                text_displ_1=[text_displ_1 ',z=' num2str(mouse.Z,3)];
+            end
+            if isfield(mouse,'CoordUnit')
+                 text_displ_1=[text_displ_1 ' ' mouse.CoordUnit];
+            end
+            if ~isempty(ivec)
+                text_displ_4=['vec#=' num2str(ivec)];
+            end
+            if ~isempty(u_mouse)
+                text_displ_3=['u=' num2str(u_mouse,3) ',v=' num2str(v_mouse,3) w_text ];
+                if  isfield(mouse,'CoordUnit')
+                    if isequal(mouse.CoordUnit,'px')
+                        text_displ_3=[text_displ_3 '  ' mouse.CoordUnit];
+                    elseif isfield(AxeData,'TimeUnit') 
+                        text_displ_3=[text_displ_3 '  ' mouse.CoordUnit '/' AxeData.TimeUnit];
+                    end
+                end
+                text_displ_4=[text_displ_4 c_text f_text ff_text];
+            end
+           
+            if ~isempty(A_mouse)
+                text_displ_2=['A=' num2str(double(A_mouse)) ',i='  num2str(indx0) ',j=' num2str(indy0)];
+            end
+        elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
+            text_displ_1=get(hchild(ichild),'Tag');
+        end
+    end
+end
+set(handles.text_display_1,'String',text_displ_1);
+set(handles.text_display_2,'String',text_displ_2);
+set(handles.text_display_3,'String',text_displ_3);
+set(handles.text_display_4,'String',text_displ_4);
+
+%%%%%%%%%%%%%%%%%
+%create or modify an object
+if isfield(AxeData,'CurrentObject') & ishandle(AxeData.CurrentObject) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off')
+    PlotData=get(AxeData.CurrentObject,'UserData');
+    huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
+    if ~isempty(huvmat)
+        UvData=get(huvmat,'UserData');
+        if ~isfield(PlotData,'IndexObj')
+             return
+        end
+        ObjectData=UvData.Object{PlotData.IndexObj};
+        XYData=AxeData.CurrentOrigin;
+        if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
+           if isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|isequal(ObjectData.Style,'polygon')|isequal(ObjectData.Style,'points')
+              xy(1,3)=0;
+              ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];
+             % ObjectData.Coord(end,:)=xy(1,:);
+           elseif isequal(ObjectData.Style,'rectangle')|isequal(ObjectData.Style,'ellipse')|isequal(ObjectData.Style,'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
+           elseif isequal(ObjectData.Style,'plane') %case of 'plane'
+                DX=(xy(1,1)-ObjectData.Coord(1,1));
+                DY=(xy(1,2)-ObjectData.Coord(1,2));
+                ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
+                if isfield(ObjectData,'RangeX')
+                    XMax=sqrt(DX*DX+DY*DY);
+                    if XMax>max(ObjectData.RangeX)
+                        ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
+                    end
+                end
+           end
+            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
+            pointershape='crosshair';
+        elseif  isequal(AxeData.Drawing,'translate')
+            DX=xy(1,1)-XYData(1);%translation from initial position
+            DY=xy(1,2)-XYData(2);
+            ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
+            ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
+            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
+            pointershape='fleur';
+        elseif  isequal(AxeData.Drawing,'deform')
+            ind_move=AxeData.CurrentIndex;
+            ObjectData.Coord(ind_move,1)=xy(1,1);
+            ObjectData.Coord(ind_move,2)=xy(1,2);
+            plot_object(ObjectData,[],AxeData.CurrentObject,'m');
+            pointershape='circle';
+        end
+    end
+end    
+%%%%%%%%%%%%%
+%draw a rectangle if no object creation is selected
+if ~isempty(haxes) & isfield(AxeData,'Drawing')& isequal(AxeData.Drawing,'zoom')& isfield(AxeData,'CurrentOrigin')...
+        & isequal(get(gcf,'SelectionType'),'normal')% 
+   xy_rect=AxeData.CurrentOrigin;
+   if ~isempty(xy_rect) 
+        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
+        rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
+        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)
+                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
+            else
+                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
+                set(haxes,'UserData',AxeData)
+            end
+        end
+   end
+end
+if test_zoom
+    pointershape='arrow';
+end
+set(currentfig,'Pointer',pointershape);
Index: trunk/src/mouse_up.m
===================================================================
--- trunk/src/mouse_up.m	(revision 11)
+++ trunk/src/mouse_up.m	(revision 11)
@@ -0,0 +1,321 @@
+%'mouse_up': function  activated when the mouse button is released
+%----------------------------------------------------------------
+% function mouse_up(ggg,eventdata,handles)
+% activated by the command:
+% set(hObject,'WindowButtonUpFcn',{'mouse_up'}), 
+% where hObject is the handle of the figure
+%
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%     This file is part of the toolbox UVMAT.
+% 
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published by
+%     the Free Software Foundation; either version 2 of the License, or
+%     (at your option) any later version.
+% 
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+function mouse_up(ggg,eventdata,handles)
+MouseAction='none'; %default
+zoomstate=0;%default
+if ~exist('handles','var')
+   handles=get(gcbo,'UserData');
+end
+huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
+if ~isempty(huvmat)
+    hhuvmat=guidata(huvmat);
+    UvData=get(huvmat,'UserData');
+    if isfield(UvData,'MouseAction')
+        MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)
+    end
+    zoomstate=get(hhuvmat.zoom,'Value');
+end
+if isequal(MouseAction,'calib') && ~zoomstate
+    return
+end
+currentfig=gcbo;
+AxeData=get(gca,'UserData');
+currentaxes=gca; %store the current axes handle
+test_drawing=0;%default
+
+%finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field
+if ~isempty(huvmat) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off') & isfield(AxeData,'CurrentObject')...
+           & ishandle(AxeData.CurrentObject)
+    xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object  
+    IndexObj=PlotData.IndexObj;
+    ObjectData=UvData.Object{IndexObj};    
+    if isequal(AxeData.Drawing,'translate')
+        XYData=AxeData.CurrentOrigin;
+        DX=xy(1,1)-XYData(1);%translation from initial position
+        DY=xy(1,2)-XYData(2);
+        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
+        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
+    elseif isequal(AxeData.Drawing,'deform')
+        ind_move=AxeData.CurrentIndex;
+        ObjectData.Coord(ind_move,1)=xy(1,1);
+        ObjectData.Coord(ind_move,2)=xy(1,2);
+    else   %creating object
+        if isequal(ObjectData.Style,'line')||isequal(ObjectData.Style,'polyline')||...
+                isequal(ObjectData.Style,'polygon')||isequal(ObjectData.Style,'points')
+            if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
+              xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
+            else
+                 xy(1,3)=0; % z coordinate set to 0 by default
+            end
+            if ~isequal(ObjectData.Coord,xy(1,:))
+                ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];% append the coordiantes marked by the mouse to the eobject
+            end
+        elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')||isequal(ObjectData.Style,'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
+        elseif isequal(ObjectData.Style,'plane') %case of 'plane'
+            DX=(xy(1,1)-ObjectData.Coord(1,1));
+            DY=(xy(1,2)-ObjectData.Coord(1,2));
+            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
+            if isfield(ObjectData,'RangeX')
+                XMax=sqrt(DX*DX+DY*DY);
+                if XMax>max(ObjectData.RangeX)
+                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
+                end
+            end
+        end
+    end
+    %set(AxeData.CurrentObject,'UserData',ObjectData); %update the object properties
+    if isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')
+        NbDefPoint=1;  
+    elseif isequal(ObjectData.Style,'line')|| isequal(ObjectData.Style,'plane');
+        NbDefPoint=2; 
+    else
+         NbDefPoint=3;
+    end
+    
+    %show object coordinates in the GUI set_object
+    h_set_object=findobj(allchild(0),'Name','set_object');
+    h_XObject=findobj(h_set_object,'Tag','XObject');
+    h_YObject=findobj(h_set_object,'Tag','YObject');
+    h_ZObject=findobj(h_set_object,'Tag','ZObject');
+    set(h_XObject,'String',num2str(ObjectData.Coord(:,1),4)); 
+    set(h_YObject,'String',num2str(ObjectData.Coord(:,2),4)); 
+    set(h_ZObject,'String',num2str(ObjectData.Coord(:,3),4));
+    if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||...
+              isequal(AxeData.Drawing,'translate') || isequal(AxeData.Drawing,'deform');%stop drawing
+        AxeData.CurrentOrigin=[]; %suppress the current origin
+       if isequal(ObjectData.Style,'line') && size(ObjectData.Coord,1)<=1
+           AxeData.Drawing='off';
+           set(currentaxes,'UserData',AxeData);
+            return % line needs at leqst two points
+       end
+       if  ~isempty(ObjectData)
+             testmask=0;
+             hmask=findobj(huvmat,'Tag','makemask');
+             if ~isempty(hmask)
+                testmask=get(hmask,'Value');
+             end
+             if testmask
+                 PlotHandles=[];%do not project data on the object during mask creation
+             else
+                 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
+             end
+            AxeData.hset_object=set_object(ObjectData,PlotHandles);% call the set_object interface ,*
+            UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
+            %ObjectData=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
+            if  isfield(UvData.Object{IndexObj},'PlotParam')
+                write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
+            end              
+            set(hhuvmat.create,'Value',0);% set to 'off' the button for object creation
+            set(hhuvmat.create,'BackgroundColor',[0 1 0]);% paint the creation button in green
+            set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
+            set(hhuvmat.edit,'Value',1);%
+            set(hhuvmat.edit,'Enable','on');%
+            set(hhuvmat.MenuEdit,'Enable','on');%
+            set(hhuvmat.MenuEdit,'Enable','on');%
+            set(hhuvmat.MenuObject,'Enable','on');%
+            UvData.MouseAction='edit_object'; % set the edit button to 'on'
+        end
+    else
+       AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the new current origin
+       test_drawing=1;%allow continuation of drawing object
+       UvData.Object{IndexObj}=ObjectData;
+    end
+    hother=findobj('Tag','deformpoint');%find all the deformpoints
+    set(hother,'Color','b');%reset all the deformpoints in 'blue' 
+else
+    test_drawing=0;
+end
+
+%creation of a new zoom plot
+test_replot=0;
+if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
+%         FigData=get(currentfig,'UserData');
+        hparentfig=currentfig;
+        %open or update a new zoom figure if a rectangle has been drawn
+        if ishandle(currentaxes);
+            if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
+                PosRect=get(AxeData.CurrentRectZoom,'Position');
+                if isfield(AxeData,'CurrentVec') & ishandle(AxeData.CurrentVec)
+                    delete(AxeData.CurrentVec)
+                end
+                %update the axes UvData.Plane2 if it exists, else create it
+%                 if isfield (UvData,'Plane2') & ishandle(UvData.Plane2.Fig)%if the second plan plotting axis already exists
+%                     hfig2=UvData.Plane2.Fig;
+%                     if isequal(gcf,hfig2)%if we are already on the secondary figure
+%                         test_replot=1;
+%                     else
+%                         figure(hfig2)%set hfig2 as the current figure
+%                         clf; %erase axes
+%                     end
+%                 else
+                    hfig2=figure;%create new figure
+                    set(hfig2,'name','zoom')
+                    set(hfig2,'Units','normalized')
+                    set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
+%                     UvData.Plane2.Fig=hfig2; 
+                    map=colormap(currentaxes);
+                    colormap(map);%transmit the current colormap to the zoom fig
+                    get(handles.RootFile,'String')
+%                 end
+                set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
+                if test_replot==0
+                    set(hfig2,'Unit','normalized')
+                    set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
+                    set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
+                    set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function
+                    set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles})  
+                    set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom,'zoom'})
+                    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 
+                    figure(hfig2)
+                    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
+                    if ~isempty(hcol)             
+                        hcol_new=colorbar;
+                        YTick=get(hcol,'YTick');
+                        YTicklabel=get(hcol,'Yticklabel');  
+                        colbarlim=get(hcol,'YLim'); 
+                        newcolbarlim=get(hcol_new,'YLim');
+                        scale_bar=(newcolbarlim(2)-newcolbarlim(1))/(colbarlim(2)-colbarlim(1));                
+                        YTick_rescaled=newcolbarlim(1)+scale_bar*(YTick-colbarlim(1));
+                        set(hcol_new,'YTick',YTick_rescaled);
+                        set(hcol_new,'Yticklabel',YTicklabel);
+                    end
+                end
+                if ishandle(AxeData.ZoomAxes)
+                    hnew_rect=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');
+                    if ~isempty(hnew_rect)
+                        delete(hnew_rect);
+                        ChildAxeData=get(AxeData.ZoomAxes,'UserData');
+                        ChildAxeData.CurrentRectZoom=[]; % no rect zoom in the new window
+                        ChildAxeData.Drawing='off';
+                        ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle as a 'parent' associated to the new axes
+                        set(AxeData.ZoomAxes,'UserData',ChildAxeData);%update the AxeData of the new axes
+                       % UvData.TopFig=hfig2;%put the new fig to the top of the stack for uvmat
+        %                 set(huvmat,'UserData',UvData)
+                        set(AxeData.ZoomAxes,'Xlim',[PosRect(1) PosRect(1)+PosRect(3)])
+                        set(AxeData.ZoomAxes,'Ylim',[PosRect(2) PosRect(2)+PosRect(4)])
+                    end
+                end
+            end
+        end
+end
+%zoom in if no new figure is created
+if zoomstate
+     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
+        %zoom(2)% zoom in by a factor of 2
+        alpha=0.5; %zoom factor (zoom in by a factor 2)
+        xlim=get(currentaxes,'XLim');
+        xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;
+        xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;
+        set(currentaxes,'XLim',xlim_new)
+        ylim=get(currentaxes,'YLim'); 
+        ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;
+        ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;
+        set(currentaxes,'YLim',ylim_new)
+        if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
+            hparentrect=AxeData.ParentRect;
+            xlim=get(currentaxes,'XLim');
+            ylim=get(currentaxes,'YLim');
+            rect([1 2])=[xlim(1) ylim(1)];
+            rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)];
+            set(hparentrect,'Position',rect)
+        end
+
+     elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed
+            %zoom(0.5)% zoom out by a factor of 2
+            alpha=2; %zoom factor (zoom out by a factor 2)
+            xlim=get(currentaxes,'XLim');
+            xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;
+            xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;
+            ylim=get(currentaxes,'YLim');
+            ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;
+            ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;
+            set(currentaxes,'XLim',xlim_new)
+            set(currentaxes,'YLim',ylim_new)
+            %test whther zoom out is operating (to inactivate AxedAta
+            if ~isfield(AxeData,'CurrentXLim')| ~isequal(xlim,AxeData.CurrentXLim)
+                AxeData.CurrentXLim=xlim;%
+            end
+            if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
+                hparentrect=AxeData.ParentRect;
+                xlim=get(currentaxes,'XLim');
+                ylim=get(currentaxes,'YLim');
+                rect([1 2])=[xlim(1) ylim(1)];
+                rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)];
+                set(hparentrect,'Position',rect)
+            end
+      end
+end
+
+%display the data of the current object selected with the mouse right click
+if isequal(get(currentfig,'SelectionType'),'alt') && ~zoomstate && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
+    hother=findobj('Tag','proj_object');%find all the proj objects
+    nbselect=0;
+    %test the existence of selected objects:
+    for iproj=1:length(hother);
+        iselect=isequal(get(hother(iproj),'Selected'),'on');%reset all the proj objects in 'blue' by default
+        nbselect=nbselect+iselect;
+    end
+    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
+    set(hother,'Selected','off')
+    hother=findobj('Tag','proj_object','Type','rectangle');
+    set(hother,'EdgeColor','b');
+    set(hother,'Selected','off')
+    hother=findobj('Tag','proj_object','Type','patch');
+    set(hother,'FaceColor','b');   
+    if isequal(get(gco,'Type'),'image')
+        currentobj=get(gco,'parent');%parent axes of the image
+    else 
+        currentobj=gco;%default
+    end
+    if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat)
+        global CurData
+        CurData=get(currentobj,'UserData');
+        %plot_text(CurData)
+        %get_field([],CurData);
+        evalin('base','global CurData')%make CurData global in the workspace
+        objtype=get(currentobj,'Type');
+        display(['UserData of ' objtype ':'])
+        evalin('base','CurData') %display CurData in the workspace
+        commandwindow
+    end
+end
+if test_drawing==0
+        AxeData.Drawing='off';%stop current drawing action
+end
+set(currentaxes,'UserData',AxeData);
+if ~isempty(huvmat)
+    set(huvmat,'UserData',UvData);
+end
+
+    
+
