Index: trunk/src/calc_field.m
===================================================================
--- trunk/src/calc_field.m	(revision 155)
+++ trunk/src/calc_field.m	(revision 156)
@@ -223,4 +223,5 @@
     siz=size(ValCell{1});
     ValCell{1}=reshape(ValCell{1},siz(1),1);
+    Role{1}='scalar';
     if isfield(DataIn,'TimeUnit')
         units={[DataIn.TimeUnit '-1']};
Index: trunk/src/create_grid.m
===================================================================
--- trunk/src/create_grid.m	(revision 155)
+++ trunk/src/create_grid.m	(revision 156)
@@ -12,5 +12,5 @@
 function varargout = create_grid(varargin)
 
-% Last Modified by GUIDE v2.5 05-Mar-2010 21:57:44
+% Last Modified by GUIDE v2.5 16-Dec-2010 00:17:20
 
 % Begin initialization code - DO NOT EDIT
@@ -44,4 +44,8 @@
 if exist('name','var') && ischar(name)
     set(hObject,'name',name)
+    if strcmp(name,'detect_grid')
+        set(handles.white,'Visible','on')
+        set(handles.black,'Visible','on')
+    end
 end
 % Update handles structure
@@ -137,4 +141,5 @@
     varargout{1}=[xarray yarray zarray];
     varargout{2}=T;
+    varargout{3}=get(handles.white,'Value')
 end
 
@@ -189,5 +194,26 @@
 
 
-
-
-
+% --- Executes on button press in white.
+function white_Callback(hObject, eventdata, handles)
+val=get(handles.white,'Value');
+if val
+    set(handles.black,'Value',0)
+else
+    set(handles.black,'Value',1)
+end
+% hObject    handle to white (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 white
+
+
+% --- Executes on button press in black.
+function black_Callback(hObject, eventdata, handles)
+val=get(handles.black,'Value');
+if val
+    set(handles.white,'Value',0)
+else
+    set(handles.white,'Value',1)
+end
+
Index: trunk/src/dataview.m
===================================================================
--- trunk/src/dataview.m	(revision 155)
+++ trunk/src/dataview.m	(revision 156)
@@ -102,4 +102,6 @@
    set(handles.Cancel,'Visible','on')
    set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 
+   set(hObject,'Visible','on')
+   drawnow
    RootDirectory_Callback(hObject, eventdata, handles)
    % UIWAIT makes translate_points wait for user response (see UIRESUME)
@@ -144,4 +146,6 @@
 function RootDirectory_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
+set(handles.RootDirectory,'BackgroundColor',[1 1 0])
+drawnow
 CampaignDir=get(handles.RootDirectory,'String');
 ExpName={''};
@@ -167,4 +171,5 @@
     msgbox_uvmat('ERROR',['The input ' CampaignDir ' is not a directory'])
 end
+set(handles.RootDirectory,'BackgroundColor',[1 1 1])
 
 %------------------------------------------------------------------------
Index: trunk/src/delete_object.m
===================================================================
--- trunk/src/delete_object.m	(revision 155)
+++ trunk/src/delete_object.m	(revision 156)
@@ -17,6 +17,6 @@
 if isequal(floor(hObject),hObject) %case of an index
     if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject 
-        if isfield(UvData.Object{hObject},'HandlesDisplay') 
-            hdisplay=UvData.Object{hObject}.HandlesDisplay;
+        if 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)
@@ -34,5 +34,5 @@
         end   
         for iobj=hObject+1:length(UvData.Object)
-            hdisplay=UvData.Object{iobj}.HandlesDisplay;
+            hdisplay=UvData.Object{iobj}.DisplayHandle_uvmat;
             for iview=1:length(hdisplay)
                 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
Index: trunk/src/geometry_calib.m
===================================================================
--- trunk/src/geometry_calib.m	(revision 155)
+++ trunk/src/geometry_calib.m	(revision 156)
@@ -75,4 +75,5 @@
 %------------------------------------------------------------------------
 % Choose default command line output for geometry_calib
+
 handles.output = hObject;
 
@@ -82,13 +83,12 @@
 
 %set the position of the interface
-if exist('pos','var')&& length(pos)>2
-    pos_gui=get(hObject,'Position');
-    pos_gui(1)=pos(1);
-    pos_gui(2)=pos(2);
-    set(hObject,'Position',pos_gui);
+if exist('pos','var')&& length(pos)>=4
+%     %pos_gui=get(hObject,'Position');
+%     pos_gui(1)=pos(1);
+%     pos_gui(2)=pos(2);
+    set(hObject,'Position',pos);
 end
 
 %set menu of calibration options
-%set(handles.calib_type,'String',{'rescale';'linear';'perspective';'normal';'tsai';'bouguet';'extrinsic'})
 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
 inputxml='';
@@ -99,13 +99,14 @@
         inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file
     end
-end
-set(handles.ListCoord,'String',{'......'})
-if exist(inputfile,'file')
-    Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
-end
-if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
-    struct.Campaign=Heading.Campaign;
-end
-set(hObject,'UserData',struct)
+    set(handles.ListCoord,'String',{'......'})
+    if exist(inputfile,'file')
+        Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
+        if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
+            struct.Campaign=Heading.Campaign;
+        end
+    end   
+    set(hObject,'UserData',struct)
+end
+
 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
 
@@ -126,9 +127,9 @@
 if ~isempty(huvmat)
     handles=guidata(huvmat);
-    set(handles.MenuMask,'enable','on')
-    set(handles.MenuGrid,'enable','on')
-    set(handles.MenuObject,'enable','on')
-    set(handles.MenuEdit,'enable','on')
-    set(handles.edit,'enable','on')
+%     set(handles.MenuMask,'enable','on')
+%     set(handles.MenuGrid,'enable','on')
+%     set(handles.MenuObject,'enable','on')
+%     set(handles.MenuEdit,'enable','on')
+%     set(handles.edit,'enable','on')
     hobject=findobj(handles.axes3,'tag','calib_points');
     if ~isempty(hobject)
@@ -1103,5 +1104,5 @@
     grid_input=CalibData.grid;%retrieve the previously used grid
 end
-[T,CalibData.grid]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
+[T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
 
 set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use
@@ -1200,6 +1201,9 @@
 % [Amod,Rangx,Rangy]=phys_Ima(A-min(min(A)),GeometryCalib,0);
 
-
-Amod=double(Amod);
+if white_test
+    Amod=double(Amod);%will look for image maxima
+else
+    Amod=-double(Amod);%will look for image minima
+end
 % figure(12) %display corrected image
 % Amax=max(max(Amod));
Index: trunk/src/get_plot_handles.m
===================================================================
--- trunk/src/get_plot_handles.m	(revision 155)
+++ trunk/src/get_plot_handles.m	(revision 156)
@@ -65,5 +65,5 @@
 %PlotHandles.cal=handles.cal;
 %PlotHandles.makemask=handles.makemask;
-PlotHandles.edit=handles.edit;
+PlotHandles.edit_object=handles.edit_object;
 PlotHandles.text_display_1=handles.text_display_1;
 PlotHandles.text_display_2=handles.text_display_2;
Index: trunk/src/imadoc2struct.m
===================================================================
--- trunk/src/imadoc2struct.m	(revision 155)
+++ trunk/src/imadoc2struct.m	(revision 156)
@@ -16,6 +16,7 @@
 
 function [s,errormsg]=imadoc2struct(ImaDoc,option) 
+%% default input and output
 if ~exist('option','var')
-    option='default';
+    option='*';
 end
 errormsg=[];%default
@@ -26,4 +27,5 @@
 tsai=[];%default
 
+%% opening the xml file
 if exist(ImaDoc,'file')~=2, errormsg=[ ImaDoc ' does not exist']; return;end;%input file does not exist
 try
@@ -34,9 +36,9 @@
     return
 end
-
 uid_root=find(t,'/ImaDoc');
 if isempty(uid_root), errormsg=[ImaDoc ' is not an image documentation file ImaDoc']; return; end;%not an ImaDoc .xml file
 
-%Heading
+
+%% Heading
 uid_Heading=find(t,'/ImaDoc/Heading');
 if ~isempty(uid_Heading), 
@@ -55,171 +57,154 @@
 end
 
-%Camera   
-uid_Camera=find(t,'/ImaDoc/Camera');
-if ~isempty(uid_Camera)
-    uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
-    if ~isempty(uid_ImageSize);
-        ImageSize=get(t,children(t,uid_ImageSize),'value');
-        xindex=findstr(ImageSize,'x');
-        if length(xindex)>=2
-             s.Npx=str2double(ImageSize(1:xindex(1)-1));
-             s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));
+%% Camera  and timing
+if strcmp(option,'*') || strcmp(option,'Camera')
+    uid_Camera=find(t,'/ImaDoc/Camera');
+    if ~isempty(uid_Camera)
+        uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
+        if ~isempty(uid_ImageSize);
+            ImageSize=get(t,children(t,uid_ImageSize),'value');
+            xindex=findstr(ImageSize,'x');
+            if length(xindex)>=2
+                s.Npx=str2double(ImageSize(1:xindex(1)-1));
+                s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));
+            end
+        end
+        uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
+        if ~isempty(uid_TimeUnit)
+            s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');
+        end
+        uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
+        if ~isempty(uid_BurstTiming)
+            for k=1:length(uid_BurstTiming)
+                subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
+                % reading Dtk
+                Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);
+                Dtj=get_value(subt,'/BurstTiming/Dtj',[]);
+                Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
+                NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);
+                Dti=get_value(subt,'/BurstTiming/Dti',[]);
+                Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
+                NbDti=get_value(subt,'/BurstTiming/NbDti',1);
+                Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit
+                if ~isempty(Dti)
+                    Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
+                    Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
+                end
+                if ~isempty(Dtj)
+                    Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dti vector NbDti times
+                    Dtj=[0 Dtj];
+                    Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
+                end
+                % reading Dtk
+                Dtk=get_value(subt,'/BurstTiming/Dtk',[]);
+                NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);
+                if isempty(Dtk)
+                    s.Time=[s.Time;Time_val];
+                else
+                    for kblock=1:NbDtk+1
+                        Time_val=Time_val+(kblock-1)*Dtk;
+                        s.Time=[s.Time;Time_val];
+                    end
+                end
+            end
         end
     end
-    uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
-    if ~isempty(uid_TimeUnit)
-        s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');
+end
+
+%%  geometric calibration
+if strcmp(option,'*') || strcmp(option,'GeometryCalib')
+    uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
+    if ~isempty(uid_GeometryCalib)
+        if length(uid_GeometryCalib)>1
+            errormsg=['More than one GeometryCalib in ' filecivxml];
+            return
+        end
+        subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
+        cont=get(subt,1,'contents');
+        if ~isempty(cont)
+            uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');
+            if isequal(length(uid_CalibrationType),1)
+                tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');
+            end
+            uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
+            if isequal(length(uid_CoordUnit),1)
+                tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
+            end
+            uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');
+            focal=[];%default fro old convention (Reg Wilson)
+            if isequal(length(uid_fx_fy),1)
+                tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));
+            else %old convention (Reg Wilson)
+                uid_focal=find(subt,'/GeometryCalib/focal');
+                uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
+                uid_sx=find(subt,'/GeometryCalib/sx');
+                if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)
+                    dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
+                    sx=str2num(get(subt,children(subt,uid_sx),'value'));
+                    focal=str2num(get(subt,children(subt,uid_focal),'value'));
+                    tsai.fx_fy(1)=sx*focal/dpx_dpy(1);
+                    tsai.fx_fy(2)=focal/dpx_dpy(2);
+                end
+            end
+            uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
+            if ~isempty(uid_Cx_Cy)
+                tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
+            end
+            uid_kc=find(subt,'/GeometryCalib/kc');
+            if ~isempty(uid_kc)
+                tsai.kc=str2double(get(subt,children(subt,uid_kc),'value'));
+            else %old convention (Reg Wilson)
+                uid_kappa1=find(subt,'/GeometryCalib/kappa1');
+                if ~isempty(uid_kappa1)&& ~isempty(focal)
+                    kappa1=str2double(get(subt,children(subt,uid_kappa1),'value'));
+                    tsai.kc=-kappa1*focal*focal;
+                end
+            end
+            uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
+            if ~isempty(uid_Tx_Ty_Tz)
+                tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));
+            end
+            uid_R=find(subt,'/GeometryCalib/R');
+            if ~isempty(uid_R)
+                RR=get(subt,children(subt,uid_R),'value');
+                if length(RR)==3
+                    tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
+                end
+            end
+            
+            %look for laser plane definitions
+            uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
+            uid_Pos=find(subt,'/GeometryCalib/SliceCoord');
+            if isempty(uid_Pos)
+                uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention
+            end
+            if ~isempty(uid_Angle)
+                tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
+            end
+            if ~isempty(uid_Pos)
+                for j=1:length(uid_Pos)
+                    tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
+                end
+                uid_DZ=find(subt,'/GeometryCalib/SliceDZ');
+                uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');
+                if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)
+                    DZ=str2double(get(subt,children(subt,uid_DZ),'value'));
+                    NbSlice=get(subt,children(subt,uid_NbSlice),'value');
+                    if isequal(NbSlice,'volume')
+                        tsai.NbSlice='volume';
+                        NbSlice=NbDtj+1;
+                    else
+                        tsai.NbSlice=str2double(NbSlice);
+                    end
+                    tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];
+                end
+            end
+            if strcmp(option,'GeometryCalib')
+                tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);
+            end
+            s.GeometryCalib=tsai;
+        end
     end
-    uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
-    if ~isempty(uid_BurstTiming)
-        for k=1:length(uid_BurstTiming)
-            subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
-             % reading Dtk
-            Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);
-            Dtj=get_value(subt,'/BurstTiming/Dtj',[]);
-            Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
-            NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);
-            Dti=get_value(subt,'/BurstTiming/Dti',[]);
-            Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
-            NbDti=get_value(subt,'/BurstTiming/NbDti',1);
-            Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit
-            if ~isempty(Dti) 
-                Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
-                Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
-            end
-            if ~isempty(Dtj)
-                Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dti vector NbDti times
-                Dtj=[0 Dtj];
-                Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
-            end
-            % reading Dtk
-            Dtk=get_value(subt,'/BurstTiming/Dtk',[]);
-            NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);
-            if isempty(Dtk)
-                s.Time=[s.Time;Time_val];
-            else
-                for kblock=1:NbDtk+1
-                    Time_val=Time_val+(kblock-1)*Dtk;
-                    s.Time=[s.Time;Time_val];
-                end
-            end
-        end
-    end
-end
-
-%read calibration
-uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
-if ~isempty(uid_GeometryCalib)
-    if length(uid_GeometryCalib)>1
-        errormsg=['More than one GeometryCalib in ' filecivxml];
-        return
-    end
-    subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
-    cont=get(subt,1,'contents');
-    if ~isempty(cont)
-%         uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx');
-%         uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy');
-%         if ~isempty(uid_pixcmx) && ~isempty(uid_pixcmy)%NON UTILISE 
-%            pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value'));
-%             if isempty(pixcmx),pixcmx=1;end; %default
-%             pixcmy=str2num(get(subt,children(subt,uid_pixcmy),'value'));
-%             if isempty(pixcmy),pixcmy=1;end; %default
-%             tsai.Pxcmx=pixcmx;
-%             tsai.Pxcmy=pixcmy;
-%         end
-        %default values:
-        %tsai.dpx_dpy=1;
-        %tsai.dpy=1;
-        %tsai.sx=1;
-%         tsai.Cx_Cy=[0 0];
-       % tsai.Cy=0;
-%         tsai.Tx_Ty_Tz=[0 0 1];
-%         tsai.Tx=0;
-%         tsai.Ty=0;
-%         tsai.R=[1 0 0; 0 1 0; 0 0 0];
-        uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');
-        if isequal(length(uid_CalibrationType),1)
-            tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');
-        end
-        uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
-        if isequal(length(uid_CoordUnit),1)
-            tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
-        end
-        uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');
-        focal=[];%default fro old convention (Reg Wilson)
-        if isequal(length(uid_fx_fy),1)
-            tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));
-        else %old convention (Reg Wilson)
-            uid_focal=find(subt,'/GeometryCalib/focal');
-            uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
-            uid_sx=find(subt,'/GeometryCalib/sx');
-            if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)
-                dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
-                sx=str2num(get(subt,children(subt,uid_sx),'value'));
-                focal=str2num(get(subt,children(subt,uid_focal),'value'));
-                tsai.fx_fy(1)=sx*focal/dpx_dpy(1);
-                tsai.fx_fy(2)=focal/dpx_dpy(2);
-            end
-        end
-        uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
-        if ~isempty(uid_Cx_Cy)
-            tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
-        end
-        uid_kc=find(subt,'/GeometryCalib/kc');
-        if ~isempty(uid_kc) 
-            tsai.kc=str2num(get(subt,children(subt,uid_kc),'value'));
-        else %old convention (Reg Wilson)
-            uid_kappa1=find(subt,'/GeometryCalib/kappa1');
-            if ~isempty(uid_kappa1)&& ~isempty(focal)
-                kappa1=str2num(get(subt,children(subt,uid_kappa1),'value'));
-                tsai.kc=-kappa1*focal*focal;
-            end
-        end
-        uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
-        if ~isempty(uid_Tx_Ty_Tz) 
-            tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));
-        end
-        uid_R=find(subt,'/GeometryCalib/R');
-        if ~isempty(uid_R)
-            RR=get(subt,children(subt,uid_R),'value');
-            if length(RR)==3
-                tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
-            end
-        end
-        
-        %look for laser plane definitions   
-        uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
-        uid_Pos=find(subt,'/GeometryCalib/SliceCoord');
-        if isempty(uid_Pos)
-            uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention
-        end
-        if ~isempty(uid_Angle) 
-            tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
-        end
-        if ~isempty(uid_Pos)     
-            for j=1:length(uid_Pos)
-                tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
-            end
-            uid_DZ=find(subt,'/GeometryCalib/SliceDZ');
-            uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');
-            if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)
-                DZ=str2double(get(subt,children(subt,uid_DZ),'value'));
-                NbSlice=get(subt,children(subt,uid_NbSlice),'value');
-                if isequal(NbSlice,'volume')
-                    tsai.NbSlice='volume';
-                    NbSlice=NbDtj+1;
-                else
-                    tsai.NbSlice=str2double(NbSlice);
-                end
-                tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];
-            end         
-        end
-        if strcmp(option,'GeometryCalib')
-            tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);%time in TimeUnit
-            size(tsai.PointCoord)
-        end
-        s.GeometryCalib=tsai;
-    end
-end   
+end
 
 %--------------------------------------------------
Index: trunk/src/mouse_down.m
===================================================================
--- trunk/src/mouse_down.m	(revision 155)
+++ trunk/src/mouse_down.m	(revision 156)
@@ -24,5 +24,5 @@
 function xy=mouse_down(hObject,eventdata)
 
-MouseAction='none'; %default
+%MouseAction='none'; %default
 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
 if isempty(huvmat)
@@ -30,26 +30,43 @@
 end
 hhuvmat=guidata(huvmat);%handles of elements in uvmat
-guihandles=guidata(hObject);
 UvData=get(huvmat,'UserData');
-MouseAction='none'; %default
+%MouseAction='none'; %default
 currentfig=hObject;
 hhcurrentfig=guidata(currentfig);
-test_zoom=get(hhcurrentfig.zoom,'Value')
-%test_zoom=get(guihandles.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
-
-test_create=~test_zoom && (isequal(MouseAction,'create_object') || isequal(MouseAction,'create_mask'));
+test_zoom=get(hhcurrentfig.zoom,'Value');%test for zoom action, first priority
+% if isfield(UvData,'MouseAction')
+%     MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
+% end
+
 %test_cal=get(handles.cal,'Value');
-test_cal=strcmp(MouseAction,'calib');
-test_ruler=strcmp(MouseAction,'ruler');
-test_edit=strcmp(MouseAction,'edit_object');
-test_edit_vect=strcmp(MouseAction,'edit_vect');
+% test_cal=strcmp(MouseAction,'calib');
+test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority
+%test_ruler=strcmp(MouseAction,'ruler');
+%test_edit=strcmp(MouseAction,'edit_object');
+test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority
+%test_edit_vect=strcmp(MouseAction,'edit_vect');%test for vector editing,  priority 4
+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
+    hset_object=findobj(allchild(0),'tag','set_object');
+    test_create=~isempty(hset_object)&&~test_edit;
+end
+test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
+if test_cal% test for calibration popints,  priority 6
+    h_calib=findobj(allchild(0),'tag','geometry_calib');
+    if isempty(h_calib)
+        test_cal=0;
+        set(hhuvmat.MenuCalib,'checked','off');% test for calibration off
+    else
+        hh_calib=guidata(h_calib);
+        test_cal=get(hh_calib.edit_append,'Value');
+    end
+end
+%test_create=~test_zoom && strcmp(MouseAction,'create_object')&&~test_edit && ~test_edit_vect ;% || isequal(MouseAction,'create_mask'));
 xdisplay=[];%default
 ydisplay=[];%default
 AxeData=[];%default
 
-%edit an existing point or line if found
+%% edit an existing point or line if found
 hcurrentobject=gco;% current object handle (selected by the mouse)
 hcurrentfig=hObject;% current figure handle
@@ -60,5 +77,6 @@
 hchild=get(hcurrentfig,'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) 
+
+%% 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
@@ -74,19 +92,22 @@
                 AxeData=get(haxes,'UserData');% data attached to the axis
                 AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
-                if ~isequal(tag_obj,'proj_object') & ~test_create
-                    x_mouse=xy(1,1);%default
-                    y_mouse=xy(1,2);%default
-                    u_mouse=[];
-                    v_mouse=[];
-                    w_mouse=[];
-                    A_mouse=[];
-                    c_text=[];
-                    f_text=[];
-                    ff_text=[];     
-                    ivec=[];   
-                    if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
-                        flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
-                          (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
-                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
+                if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create
+                    ivec=[];
+                    FigData=get(hcurrentfig,'UserData');
+                    tagaxes=get(haxes,'tag');
+                    if isfield(FigData,tagaxes)
+                        eval(['Field=FigData.' tagaxes ';'])
+                        [CellVarIndex,NbDim,VarType]=find_field_indices(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,'Mesh') && ~isempty(Field.Mesh)&& ~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.Mesh/4) & X>(xy(1,1)-Field.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
+                                        (Y<(xy(1,2)+Field.Mesh/4) & Y>(xy(1,2)-Field.Mesh/4));%f
+                                    ivec=find(flag_vec,1);% search the (first) selected vector index ivec
+                                end
+                            end
+                        end
                     end
                 end
@@ -113,5 +134,5 @@
 end    
 
-% zoom has first priority 
+%% zoom has first priority 
 if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
      AxeData.Drawing='zoom'; %initiate drawing mode
@@ -120,14 +141,13 @@
      return
 end
-if isempty(huvmat)
-    return
-end
-
-%ruler has second priority 
+if isempty(huvmat)%further options require the uvmat GUI
+    return 
+end
+
+%% ruler has second priority 
 if test_ruler
-    UvData.RulerCoord(1,1)=xy(1,1);
-    UvData.RulerCoord(1,2)=xy(1,2);
-    UvData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
-    set(huvmat,'UserData',UvData)
+    AxeData.RulerCoord(1,1)=xy(1,1);
+    AxeData.RulerCoord(1,2)=xy(1,2);
+    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
     AxeData.Drawing='ruler';
     set(haxes,'UserData',AxeData);
@@ -135,5 +155,5 @@
 end
 
-%selection of an existing projection object
+%% selection of an existing projection object (third priority)
 if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
     if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
@@ -222,43 +242,51 @@
     end
 end
-%  create new projection  object
+
+%%  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_1,'String');
-        object_name=get(UvData.sethandles.TITLE,'String')
-        if isempty(object_name)|| strcmp(object_name,'')
-            list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style]; 
-            set(UvData.sethandles.TITLE,'String',list_str{IndexObj})
-        else
-           list_str{IndexObj}=object_name;
-        end
-        set(hhuvmat.list_object_1,'String',list_str)
-        list_str{end+1}='...';
-        set(hhuvmat.list_object_2,'String',list_str)
-        if strcmp(fig_tag,'view_field')%we are in view_field plot
-              set(hhuvmat.list_object_1,'Value',IndexObj)% the projection field will be plotted in uvmat frame
-        else%we are in uvmat plot
-            set(hhuvmat.list_object_2,'Value',IndexObj)
-        end
-        PlotData=get(AxeData.CurrentObject,'UserData');
-        PlotData.IndexObj=IndexObj;
-        set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
-        AxeData.Drawing='create';
+        hset_object=findobj(allchild(0),'tag','set_object');
+        if ~isempty(hset_object)
+            sethandles=guidata(hset_object);
+            ObjectData=read_set_object(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;        
+            list_str=get(hhuvmat.list_object_1,'String');
+            object_name=get(sethandles.TITLE,'String');
+            if isempty(object_name)|| strcmp(object_name,'')
+                list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style]; 
+                set(sethandles.TITLE,'String',list_str{IndexObj})
+            else
+               list_str{IndexObj}=object_name;
+            end
+            set(hhuvmat.list_object_1,'String',list_str)
+            list_str{end+1}='...';
+            set(hhuvmat.list_object_2,'String',list_str)
+            if strcmp(fig_tag,'view_field')%we are in view_field plot
+                  set(hhuvmat.list_object_1,'Value',IndexObj)% the projection field will be plotted in uvmat frame
+                  UvData.Object{IndexObj}.DisplayHandle_uvmat=[];
+                  UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;        
+            else%we are in uvmat plot
+                set(hhuvmat.list_object_2,'Value',IndexObj)
+                UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;
+                UvData.Object{IndexObj}.DisplayHandle_view_field=[]; 
+            end
+            set(huvmat,'UserData',UvData)
+            PlotData=get(AxeData.CurrentObject,'UserData');
+            PlotData.IndexObj=IndexObj;
+            set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
+            AxeData.Drawing='create';
+        end
 end
 
@@ -267,7 +295,7 @@
     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) && ~isempty(haxes)
+        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
         coord_value=get(hhuvmat.transform_fct,'Value');% set uvmat to pixel coordinates, run it again if not
         if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
@@ -303,5 +331,4 @@
              Coord{val}=strline;
              set(h_ListCoord,'String',Coord)
-            % set(h_ListCoord,'Value',val+1)
              data=read_geometry_calib(Coord);%transform char cell to numbers
              XCoord=data.Coord(:,4);
@@ -330,15 +357,22 @@
 
 % edit vectors
-if test_edit_vect & ~isempty(ivec) 
-    if ~(isfield(AxeData,'FF')&& ~isempty(AxeData.FF))
-        AxeData.FF=zeros(size(AxeData.X));
-    end
-    if isequal(AxeData.FF(ivec),0)
-        AxeData.FF(ivec)=100; %mark vector #ivec as false
+if test_edit_vect && ~isempty(ivec) 
+    %create the error flag FF if it does not exist
+    if ~isfield(Field,'FF')
+        Field.ListVarName=[Field.ListVarName 'FF'];
+        Field.VarDimName=[Field.VarDimName Field.VarDimName{VarType{icell}.coord_x}];
+        nbvar=length(Field.ListVarName);
+        Field.VarAttribute{nbvar}.Role='errorflag';
+        Field.FF=zeros(size(Field.X));
+    end
+    if isequal(Field.FF(ivec),0)
+        Field.FF(ivec)=100 %mark vector #ivec as false
     else
-        AxeData.FF(ivec)=0;
-    end
-    PlotParam=read_plot_param(hhuvmat);
-    [PlotType,ScalOut]= plot_field(AxeData,haxes,PlotParam,1);
+        Field.FF(ivec)=0;
+    end
+    PlotParam=read_plot_param(hhcurrentfig);
+    plot_field(Field,haxes,PlotParam);
+    eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData
+    set(hcurrentfig,'UserData',FigData);
 end   
 set(haxes,'UserData',AxeData);
Index: trunk/src/mouse_motion.m
===================================================================
--- trunk/src/mouse_motion.m	(revision 155)
+++ trunk/src/mouse_motion.m	(revision 156)
@@ -33,5 +33,5 @@
 test_draw=0;%test for mouse drawing of object, =0 by default
 test_object=0; %test for object editing or creation 
-test_edit=isfield(handles,'edit') && get(handles.edit,'Value');% edit test for mouse shap: an arrow
+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 
@@ -40,10 +40,8 @@
 if ~isempty(huvmat)
     hhuvmat=guidata(huvmat);
-end
-if ~isempty(huvmat)
-    UvData=get(huvmat,'UserData');
-    test_ruler=isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler');
-end
-hciv=findobj(allchild(0),'tag','civ');%find the uvmat interface handle
+    test_edit_object=get(hhuvmat.edit_object,'Value');
+    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');
+end
+hciv=findobj(allchild(0),'tag','civ');%find the civ interface handle
 if ~isempty(hciv) && strcmp(get(currentfig,'tag'),'view_field')
     hhciv=guidata(hciv);
@@ -85,5 +83,5 @@
             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 && ~test_zoom_draw && ~test_ruler
+            if ~test_edit_object && ~test_zoom_draw && ~test_ruler
                 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
             end
@@ -110,5 +108,5 @@
                                     if ~isempty(ivec)
                                         % mark the vectors with a circle in the absence of other operations
-                                        if ~test_object && ~test_edit && ~test_ruler
+                                        if ~test_object && ~test_edit_object && ~test_ruler
                                             pointershape='arrow'; %mouse indicates  the detection of a vector
                                             if isempty(hhh)
@@ -291,5 +289,4 @@
 %%%%%%%%%%%%%%%%%
 %% create or modify an object
-
 if ~isempty(huvmat) && test_object
     PlotData=get(AxeData.CurrentObject,'UserData');
@@ -347,5 +344,5 @@
     pointershape='crosshair';%default for geometry_calib: ready to create new points
     hh_geometry_calib=guidata(h_geometry_calib);
-    if  ~isempty(xy)
+    if  ~isempty(xy) && isfield(hh_geometry_calib,'ListCoord')
         h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
         Coord=get(h_ListCoord,'String');
@@ -368,5 +365,5 @@
                 hh=findobj('Tag','calib_points');%look for handle of calibration points
                if ~isempty(hh) && ~isempty(get(hh,'UserData')) && get(hh_geometry_calib.edit_append,'Value') 
-                    index_point=get(hh,'UserData');
+                    index_point=get(hh,'UserData')
                     XCoord(index_point)=xy(1,1);
                     YCoord(index_point)=xy(1,2);
@@ -387,11 +384,11 @@
 
 %% draw ruler
-if test_ruler && isequal(AxeData.Drawing,'ruler')
-           if isfield(UvData,'RulerHandle')
-               pointershape='crosshair';
-                RulerCoord=[UvData.RulerCoord ;xy(1,1:2)];
-                set(UvData.RulerHandle,'XData',RulerCoord(:,1));
-                set(UvData.RulerHandle,'YData',RulerCoord(:,2));
-           end
+if test_ruler && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'ruler')
+    if isfield(AxeData,'RulerHandle')
+        pointershape='crosshair'; %give  the mouse pointer a cross shape
+        RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)]; %coordinates defining the ruler segment
+        set(AxeData.RulerHandle,'XData',RulerCoord(:,1));% updtate the x coordinates for the ruler graphic object
+        set(AxeData.RulerHandle,'YData',RulerCoord(:,2));% updtate the y coordinates for the ruler graphic object
+    end
 end
 
Index: trunk/src/mouse_up.m
===================================================================
--- trunk/src/mouse_up.m	(revision 155)
+++ trunk/src/mouse_up.m	(revision 156)
@@ -23,21 +23,23 @@
 
 function mouse_up(hObject,eventdata,handles)
-MouseAction='none'; %default
+%MouseAction='none'; %default
 test_zoom=0;%default
+test_ruler=0;%default
 currentfig=hObject;
 tagfig=get(currentfig,'tag');
 hhcurrentfig=guidata(currentfig);
 test_zoom=get(hhcurrentfig.zoom,'Value');
-if ~exist('handles','var')
-   handles=get(gcbo,'UserData');
-end
+
+% if ~exist('handles','var')
+%    handles=get(gcbo,'UserData');
+% end
 huvmat=findobj(allchild(0),'tag','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
-%     test_zoom=get(hhuvmat.zoom,'Value');
+%     if isfield(UvData,'MouseAction')
+%         MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)
+%     end
+   test_ruler=~test_zoom && isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority
 end
 currentfig=hObject;
@@ -48,6 +50,6 @@
 
 %% 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)
+if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')...
+           && ~isempty(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  
@@ -131,25 +133,44 @@
 %                  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
+           % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
 %              end
-            UvData.Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 
-            if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field
-%             if strcmp(projview,'view_field')
-                hview_field=findobj(allchild(0),'tag','view_field');
-                ViewFieldData=get(hview_field,'UserData');
-                ViewFieldData.axes3=ObjectData;
-                set(hview_field,'UserData',ViewFieldData)
-            else
-                UvData.axes3=ObjectData;
-            end
-            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.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
-            set(hhuvmat.edit,'Value',1);%
-            set(hhuvmat.edit,'Enable','on');%
+
+            %% update the object representation
+            ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
+            ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
+            UvData.Object{IndexObj}=ObjectData;%update the current object properties
+            hhuvmat=guidata(huvmat);
+            IndexObj_1=get(hhuvmat.list_object_1,'Value');
+            IndexObj_2=get(hhuvmat.list_object_2,'Value');
+            UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
+
+            %% plot the field projected on the object and store it on the corresponding figure
+            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 on view_field
+                    %             if strcmp(projview,'view_field')
+                    hview_field=findobj(allchild(0),'tag','view_field');
+                    if isempty(hview_field)
+                        hview_field=view_field;
+                    end
+                    ViewFieldData=get(hview_field,'UserData');
+                    ViewFieldData.axes3=ProjData;
+                    set(hview_field,'UserData',ViewFieldData)
+                    PlotHandles=guidata(hview_field);
+                else
+                    UvData.axes3=ProjData;
+                    PlotHandles=hhuvmat;
+                end
+                [PlotType,PlotParam]=plot_field(ProjData,PlotHandles.axes3,PlotHandles);%update an existing field plot
+                write_plot_param(PlotHandles,PlotParam); %update the display of plotting parameters for the current object
+            end
+            %             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.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
+            set(hhuvmat.edit_object,'Value',1);%
+            set(hhuvmat.edit_object,'Enable','on');%
             set(hhuvmat.MenuEditObject,'Enable','on');%
             set(hhuvmat.MenuEdit,'Enable','on');%
-            UvData.MouseAction='edit_object'; % set the edit button to 'on'
         end
     else
@@ -171,7 +192,7 @@
         %open or update a new zoom figure if a rectangle has been drawn
         if ishandle(currentaxes);
-            if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
+            if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
                 PosRect=get(AxeData.CurrentRectZoom,'Position');
-                if isfield(AxeData,'CurrentVec') & ishandle(AxeData.CurrentVec)
+                if isfield(AxeData,'CurrentVec') && ~isempty(AxeData.CurrentVec) && ishandle(AxeData.CurrentVec)
                     delete(AxeData.CurrentVec)
                 end
@@ -182,5 +203,4 @@
                 map=colormap(currentaxes);
                 colormap(map);%transmit the current colormap to the zoom fig
-                get(handles.RootFile,'String')
                 set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
                 if test_replot==0
@@ -288,41 +308,43 @@
 
 %% editing calibration point
-if ~test_zoom && strcmp(MouseAction,'calib')
-    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
-    hh_geometry_calib=guidata(h_geometry_calib);
-    edit_test=get(hh_geometry_calib.edit_append,'Value');
-    hh=findobj(currentaxes,'Tag','calib_points');%look for handle of calibration points
-    if ~isempty(hh) && edit_test
-        index_point=get(hh,'UserData');
-        set(hh,'UserData',[])%remove edit mode
-        h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list
-        Coord=get(h_ListCoord,'String');
-        data=read_geometry_calib(Coord);
-        %         val=get(h_ListCoord,'Value');
-        xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-        data.Coord(index_point,4)=xy(1,1);
-        data.Coord(index_point,5)=xy(1,2);
-        for ipoint=1:size(data.Coord,1)
-            for jcoord=1:5
-                Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits
-            end
+if ~test_zoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration')
+    h_geometry_calib=findobj(allchild(0),'tag','geometry_calib'); %find the geomterty_calib GUI
+    if ~isempty(h_geometry_calib)
+        hh_geometry_calib=guidata(h_geometry_calib);
+        edit_test=get(hh_geometry_calib.edit_append,'Value');
+        hh=findobj(currentaxes,'tag','calib_points');%look for handle of calibration points
+        if ~isempty(hh) && edit_test
+            index_point=get(hh,'UserData');
+            set(hh,'UserData',[])%remove edit mode
+            h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list
+            Coord=get(h_ListCoord,'String');
+            data=read_geometry_calib(Coord);
+            %         val=get(h_ListCoord,'Value');
+            xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            data.Coord(index_point,4)=xy(1,1);
+            data.Coord(index_point,5)=xy(1,2);
+            for ipoint=1:size(data.Coord,1)
+                for jcoord=1:5
+                    Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits
+                end
+            end
+            Tabchar=cell2tab(Coord_cell,' | ');
+            Tabchar=[Tabchar ;{'......'}];
+            set(h_ListCoord,'String',Tabchar)
+            %         coord_str=Coord{index_point}; %current line (string)
+            %         k=findstr('|',coord_str);%find separator indices on the string
+            %         blanks=blank
+            %         xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
+            %         if numel(k)>=3
+            %             coord_str=[coord_str(1:k(3)-1) ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; %update the pixel information while preserving phys coord
+            %         else
+            %             coord_str=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
+            %         end
+            %         Coord{index_point}=coord_str;
+            %         set(h_ListCoord,'String',Coord)
+            %         data=read_geometry_calib(Coord);%transform char cell to numbers
+            set(hh,'XData',data.Coord(:,4))
+            set(hh,'YData',data.Coord(:,5))
         end
-        Tabchar=cell2tab(Coord_cell,' | ');
-        Tabchar=[Tabchar ;{'......'}];
-        set(h_ListCoord,'String',Tabchar)
-        %         coord_str=Coord{index_point}; %current line (string)
-        %         k=findstr('|',coord_str);%find separator indices on the string
-        %         blanks=blank
-        %         xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
-        %         if numel(k)>=3
-        %             coord_str=[coord_str(1:k(3)-1) ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; %update the pixel information while preserving phys coord
-        %         else
-        %             coord_str=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
-        %         end
-        %         Coord{index_point}=coord_str;
-        %         set(h_ListCoord,'String',Coord)
-        %         data=read_geometry_calib(Coord);%transform char cell to numbers
-        set(hh,'XData',data.Coord(:,4))
-        set(hh,'YData',data.Coord(:,5))
     end
 end
@@ -330,18 +352,16 @@
 
 %% finalising ruler
-if strcmp(MouseAction,'ruler')
-    UvData.MouseAction='none';
-    UvData=rmfield(UvData,'RulerHandle');
-     xy=get(currentaxes,'CurrentPoint');
-    RulerCoord=[UvData.RulerCoord ;xy(1,1:2)];
-    set(huvmat,'UserData',UvData)
-    RulerCoord=diff(RulerCoord,1);
+if test_ruler
+    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat  
+    xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates 
+    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates 
+    RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning
     RulerCoord=RulerCoord(1)+i*RulerCoord(2);
     distance=abs(RulerCoord);
     azimuth=(180/pi)*angle(RulerCoord);
     msgbox_uvmat('RULER','',['length: ' num2str(distance,3) ',  angle(degrees): ' num2str(azimuth,3)])
-    hruler=findobj(currentaxes,'Tag','ruler');
-    delete(hruler)
-    AxeData.Drawing='off';%stop current drawing a
+    delete(AxeData.RulerHandle)%delete the ruler graphic object
+    AxeData=rmfield(AxeData,'RulerHandle');%remove the ruler handle in AxeData
+    AxeData.Drawing='off';%exit the ruler drawing mode
 end
 
Index: trunk/src/msgbox_uvmat.m
===================================================================
--- trunk/src/msgbox_uvmat.m	(revision 155)
+++ trunk/src/msgbox_uvmat.m	(revision 156)
@@ -51,20 +51,25 @@
 icontype='quest';%default question icon (text input asked)
 if exist('title','var')
-      set(hObject, 'Name', title); 
-      if isequal (title,'CONFIRMATION')
-         icontype='';
-         testCancel=0; %no cancel button
-      elseif isequal (title,'ERROR')
-         icontype='error';
-         testCancel=0; %no cancel button
-      elseif isequal (title,'WARNING')
-         icontype='warn';
-         testCancel=0; %no cancel button
-      elseif isequal (title,'INPUT_Y-N')
-         icontype='quest'; 
-         testNo=1; % button No activated
-      else
-          testinputstring=1;
-      end
+    set(hObject, 'Name', title);
+    switch title
+        case {'CONFIRMATION'}
+            icontype='';
+            testCancel=0; %no cancel button
+        case 'ERROR'
+            icontype='error';
+            testCancel=0; %no cancel button
+        case 'WARNING'
+            icontype='warn';
+            testCancel=0; %no cancel button
+        case 'INPUT_Y-N'
+            icontype='quest';
+            testNo=1; % button No activated
+        case {'RULER'}
+            icontype='';
+            testCancel=0; %no cancel button
+            testinputstring=1;
+        otherwise
+            testinputstring=1;
+    end
 end
 if exist('display','var')
Index: trunk/src/plot_field.m
===================================================================
--- trunk/src/plot_field.m	(revision 155)
+++ trunk/src/plot_field.m	(revision 156)
@@ -144,16 +144,9 @@
 if testnewfig% create a new figure and axes if the plotting axes does not exist
     hfig=figure;
-%     if isfield(Data,'IndexObj') && isfield(Data,'Style') && isfield(Data,'ProjMode')
-%         figname=[num2str(Data.IndexObj) '-' Data.Style];
-%         set(hfig,'Name',figname)
-%     end
-%     testhandle=0;
     if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
         set(hfig,'UserData',PlotParam)
-%         testhandle=1;
     end
     set(hfig,'Units','normalized')
     set(hfig,'WindowButtonDownFcn','mouse_down')
-    %set(hfig,'WindowButtonMotionFcn',{'mouse_motion',PlotParam})%set mouse action function
     set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function
     set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function
@@ -204,5 +197,4 @@
         if testzoomaxes && isempty(errormsg)
             [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
-            %AxeData.ZoomAxes=zoomaxes;
             Data.ZoomAxes=zoomaxes;
         end
Index: trunk/src/plot_object.m
===================================================================
--- trunk/src/plot_object.m	(revision 155)
+++ trunk/src/plot_object.m	(revision 156)
@@ -37,4 +37,5 @@
 
 function [hh]=plot_object(ObjectDataIn,ProjObject,hplot,col)
+%% default output
 hh=[];%default output
 if isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
@@ -48,9 +49,9 @@
     return % no object representation yet available
 end
-if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
+if ~isfield(ObjectData,'Style')||isempty(ObjectData.Style)||~ischar(ObjectData.Style)
     msgbox_uvmat('ERROR','undefined ObjectData.Style in plot_object.m')
     return
 end
-if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
+if ~isfield(ObjectData,'Style')||isempty(ObjectData.Style)||~ischar(ObjectData.Style)
     msgbox_uvmat('ERROR','undefined ObjectData.Style in plot_object.m')
     return
@@ -63,18 +64,20 @@
 ZMax=0;
 
-%determine the plotting axes (with handle 'haxes')
+%% determine the plotting axes (with handle 'haxes')
 test_newobj=1;
 if ishandle(hplot)
-    if isequal(get(hplot,'Tag'),'proj_object')  
+    if isequal(get(hplot,'Tag'),'proj_object')% hplot is the handle of an object representation  
         test_newobj=0;
         haxes=get(hplot,'parent');
-    elseif isequal(get(hplot,'Type'),'axes')
-        axes(hplot)
+    elseif isequal(get(hplot,'Type'),'axes')% hplot is the handle of an axis 
+        currentfig=get(hplot,'parent');
+        set(0,'CurrentFigure',currentfig)
         haxes=hplot;
-    elseif isequal(get(hplot,'Type'),'figure')
-        figure(hplot);%set the input figure as the current one
+        set(currentfig,'CurrentAxes',haxes);
+    elseif isequal(get(hplot,'Type'),'figure')% hplot is the handle of a figure 
+        set(0,'CurrentFigure',hplot);%set the input figure as the current one
         haxes=findobj(hplot,'Type','axes');%look for axes in the figure
         haxes=haxes(1);
-        axes(haxes); %set the first found axis as the current one
+        set(hplot,'CurrentAxes',haxes);%set the first found axis as the current one
     else
         figure; %create new figure
@@ -88,5 +91,5 @@
 end
 
-%default input parameters
+%% default input parameters
 if ~isfield(ObjectData,'ProjMode')|isempty(ObjectData.ProjMode)
      ObjectData.ProjMode='projection';%default
@@ -148,5 +151,5 @@
 sizcoord=size(ObjectData.Coord);
 
-%determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
+%% determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
 test_line= isequal(ObjectData.Style,'points')|isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...
     isequal(ObjectData.Style,'polygon')| isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume');
@@ -206,5 +209,5 @@
 end
 
-%shading image
+%% shading image
 if test_patch
     npMx=512;
@@ -267,5 +270,5 @@
 
 PlotData=[];%default
-%MODIFY AN EXISTING OBJECT PLOT
+%% MODIFY AN EXISTING OBJECT PLOT
 if test_newobj==0;
     hh=hplot;
@@ -326,5 +329,5 @@
 end
 
-%create the object
+%% create the object
 if test_newobj
     axes(haxes)
Index: trunk/src/proj_field.m
===================================================================
--- trunk/src/proj_field.m	(revision 155)
+++ trunk/src/proj_field.m	(revision 156)
@@ -1,5 +1,5 @@
 %'proj_field': projects the field on a projection object
 %--------------------------------------------------------------------------
-%  function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
+%  function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
 %
 % OUTPUT:
@@ -80,5 +80,5 @@
 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 
-function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
+function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
 errormsg=[];%default
 if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'))
@@ -138,7 +138,7 @@
         [ProjData,errormsg] = proj_volume(FieldData,ObjectData);
 end
-if exist('IndexObj','var')
-    ProjData.IndexObj=IndexObj;%transfer object index
-end
+% if exist('IndexObj','var')
+%     ProjData.IndexObj=IndexObj;%transfer object index
+% end
 
 %-----------------------------------------------------------------
Index: trunk/src/read_civxdata.m
===================================================================
--- trunk/src/read_civxdata.m	(revision 155)
+++ trunk/src/read_civxdata.m	(revision 156)
@@ -89,5 +89,5 @@
     Field.ListVarName(end-2:end)=[];
     Field.ListVarName{end}='DjUi';
-    Field.VarDimIndex(end-2:end)=[];
+    Field.VarDimName(end-2:end)=[];
     Field.VarAttribute(end-2:end)=[];
 end
Index: trunk/src/series.m
===================================================================
--- trunk/src/series.m	(revision 155)
+++ trunk/src/series.m	(revision 156)
@@ -61,4 +61,5 @@
 guidata(hObject, handles);
 %default initial parameters
+drawnow
 
 %load the list of previously browsed files in menus Open and Open_1
@@ -656,5 +657,5 @@
 if isequal(ext_imadoc,'.xml')
         [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
-        if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName')
+        if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName)
             [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
         end
Index: trunk/src/set_object.m
===================================================================
--- trunk/src/set_object.m	(revision 155)
+++ trunk/src/set_object.m	(revision 156)
@@ -721,4 +721,5 @@
 function PLOT_Callback(hObject, eventdata, handles)
 
+%% reading the object parameters on the GUI uvmat
 huvmat=findobj('tag','uvmat');%find the current uvmat interface handle
 UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat 
@@ -728,40 +729,54 @@
 IndexObj_1=get(hhuvmat.list_object_1,'Value');
 IndexObj_2=get(hhuvmat.list_object_2,'Value');
-ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
 testnew=0;
 PlotHandles=get_plot_handles(hhuvmat);
-projview='';
+projview='view_field';%default
 if strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame
-   ObjectData.HandlesDisplay=hhuvmat.axes3;
+%    ObjectData.HandlesDisplay=hhuvmat.axes3;
+%     Object_set{iobj}.DisplayHandle_view_field
     IndexObj=IndexObj_1;
     projview='uvmat';
+     plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
 elseif IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field
+   
+    IndexObj=IndexObj_2;
+%     projview='view_field';
+else %new object 
+    testnew=1;
+    IndexObj=numel(ListObject)+1;
     hview_field=findobj(allchild(0),'tag','view_field');
     if ~isempty(hview_field)
         PlotHandles=guidata(hview_field);
-        ObjectData.HandlesDisplay=PlotHandles.axes3;%handle of axes3 in view_field
-    end
-    IndexObj=IndexObj_2;
-    projview='view_field';
-else %new object 
-    testnew=1;  
-    IndexObj=numel(ListObject)+1;
-end
+        plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
+%         ObjectData.HandlesDisplay=PlotHandles.axes3;%handle of axes3 in view_field
+    end
+end
+if strcmp(projview,'view_field')
+    hview_field=findobj(allchild(0),'tag','view_field')
+    if isempty(hview_field)
+        hview_field=view_field
+    end
+    PlotHandles=guidata(hview_field);
+    plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
+end   
+ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
+
+%% naming the object
 if length(ObjectName)<1% name of object not defined in set_object
     ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name
-elseif ~get(hhuvmat.edit,'Value')%not in edit mode (new object created)
+elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created)
     detectname=1;
     ObjectNameNew=ObjectName;
     vers=0;
-    while detectname==1 %create a new subdir if the netcdf files already exist
-        detectname=find(strcmp(ObjectNameNew,ListObject),1)%test the existence of the proposed name in the list
-        if detectname% if athe object name already exists
-            indstr=regexp(ObjectNameNew,'\D')
+    while detectname==1 
+        detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
+        if detectname% if the object name already exists
+            indstr=regexp(ObjectNameNew,'\D');
             if indstr(end)<length(ObjectNameNew) %object name ends by a number
                 vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
                 ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
             else
-                vers=vers+1
-                ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]      
+                vers=vers+1;
+                ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];      
             end
         end
@@ -772,10 +787,23 @@
 set(hhuvmat.list_object_1,'String',ListObject)
 set(hhuvmat.list_object_2,'String',[ListObject;{'...'}])
+
+%% update the object plot and projection field
 if testnew
     set(hhuvmat.list_object_2,'Value',IndexObj)
-end
-
-% update the object plot and projection field
-UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
+    ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
+    ObjectData.DisplayHandle_view_field=[];
+else % save the previous object graph handles
+    ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
+    ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
+end
+UvData.Object{IndexObj}=ObjectData;%update the current object properties
+IndexObj
+ObjectData
+UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
+
+%% plot the field projected on the object and store it the corresponding figue
+get(plotaxes,'tag')
+ProjData= proj_field(UvData.Field,ObjectData)%project the current interface field on ObjectData
+[PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot
 if strcmp(projview,'view_field')
     ViewFieldData=get(hview_field,'UserData');
@@ -786,10 +814,10 @@
 end
 
-%set uvmat to object edit mode to allow further object update
+%% update the GUI uvmat
 hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI
 set(hhuvmat.MenuEditObject,'enable','on')
-set(hhuvmat.edit,'Value',1)
-set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
-UvData.MouseAction='edit_object'; % set the edit button to 'on'
+set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update
+set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
+%UvData.MouseAction='edit_object'; % set the edit button to 'on'
 set(huvmat,'UserData',UvData)
 %------------------------------------------------------------------------
Index: trunk/src/update_imadoc.m
===================================================================
--- trunk/src/update_imadoc.m	(revision 155)
+++ trunk/src/update_imadoc.m	(revision 156)
@@ -8,4 +8,5 @@
 %-------------------------------------------------------------
 function errormsg=update_imadoc(GeometryCalib,outputfile)
+tic
 errormsg='';
 testappend=0;
@@ -21,5 +22,5 @@
     [success,message]=copyfile(outputfile,backupfile);%make backup
     if success==0
-        errormsg=message
+        errormsg=message;
     end
     uid=find(t,'ImaDoc');
@@ -56,9 +57,8 @@
         [t,uid_camera]=add(t,1,'element','Camera');
         Camera.TimeUnit='s';
-%         Camera.BurstTiming.FrameFrequency=info.FramesPerSecond;
         Camera.BurstTiming.Time=0;
         Camera.BurstTiming.Dti=1/info.FramesPerSecond;
         Camera.BurstTiming.NbDti=info.NumFrames-1;
-        t=struct2xml(Camera,t,uid_camera)
+        t=struct2xml(Camera,t,uid_camera);
     end
    [t,uid_calib]=add(t,1,'element','GeometryCalib');
@@ -66,2 +66,3 @@
 t=struct2xml(GeometryCalib,t,uid_calib); 
 save(t,outputfile);
+toc
Index: trunk/src/update_obj.m
===================================================================
--- trunk/src/update_obj.m	(revision 155)
+++ trunk/src/update_obj.m	(revision 156)
@@ -1,79 +1,120 @@
 %'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
 %-------------------------------------------------------------------
-%Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
-%
+%Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
+
 %OUTPUT:
-%UvData: data to be stored as 'Userdata' on the uvmat interface
-%IndexObj: object index for a new object added to the list in UvData
-%   the function updates UvData.Object{IndexObj}, and possibly adds a new plot (UvData.Plane or Line) in the list atached to the interface
+% Object_out= cell array of structures containing the properties of the existing objects     .
 %
 %INPUT:
-%UvData: structure stored as 'Userdata' on the uvmat interface, it contains
+%UvData: structure stored as 'Userdata' on the uvmat interface, it contains:
 %    .Object{1},{2}... description of all the projection objects 
-%    .Object{iview}.plotaxes: axes for the plot of the field projected on this object
-%    .Object{iview}.HandlesDisplay(ih): array of handles for plots representing the object #iview in the field #ih
-%IndexObjIn: object index for an existing objects stored in UvData
-%ObjectData: structure containing the input object properties
+%    .Field , the current input field to be projected on the object
+%    .Object{IndexObj}.DisplayHandle_uvmat: handles of the object plot on uvmat, =[] if it does not exist
+%    .Object{IndexObj}.DisplayHandle_view_field: handles of the object plot on view_field, =[] if it does not exist
+%IndexObj: object index of  UvData.Object correspopnding to the updated object
+%ObjectData: structure containing the input object properties to be attributed to the object #IndexObj
 %       .Style: style of the object: 'line', 'rectangle'...
 %PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat or view_field interface 
 %-------------------------------------
 
-function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
+function Object_out=update_obj(UvData,IndexObj_1,IndexObj_2)
 
-%default input and output
-Object_out=ObjectData;%default
-if  isfield(UvData,'Object') 
-    Object_set=UvData.Object;
-else
-    Object_set={};%create the object
-end
+%% default input and output
+% Object_out{IndexObj}=ObjectData;%default
+% if  isfield(UvData,'Object') 
+%     Object_set=UvData.Object;
+% else
+%     Object_set={};%create the object
+% end
+Object_out=UvData.Object;
 
-% object representation in the different projected field plots
-for iview=1:length(Object_set) %loop on projection planes iview
-      if isfield(Object_set{iview},'plotaxes')
-         haxes=Object_set{iview}.plotaxes% axes for the field plot
-         if ishandle(haxes) & isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
-             testupdate=0;
-             HandlesDisplay=[];%default
-             if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
-                 HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
-             end
-             hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes
-             for ih=1:length(HandlesDisplay)
-                 plot_detect=find(hplot_list==HandlesDisplay(ih));
-                 if ~isempty(plot_detect)
-                     Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iview},HandlesDisplay(ih),'m');%update the the object representation
-                     testupdate=1;
-                     break
-                 end
-             end
-             if ~testupdate% draw new object plot
-                hh=plot_object(ObjectData,Object_set{iview},haxes,'m');%draw the object with the new object data
-                if isfield(Object_out,'HandlesDisplay')
-                    Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
-                else
-                    Object_out.HandlesDisplay=hh;
-                end
-                PlotData=get(hh,'UserData');
-                PlotData.IndexObj=IndexObj;
-                set(hh,'UserData',PlotData); %record the object index in the graph
-             end
-         end
-      end
-end
+%% plot the field projected on the object
+% ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
+% if ~isempty(ProjData)   
+%     plotaxes=[];%default
+%     if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
+%         plotaxes=Object_set{IndexObj}.plotaxes;
+%         [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot
+%         plotfig=get(plotaxes,'parent');
+%         ViewData=get(plotfig,'UserData');
+%         eval(
+%     else
+%         hview_field=view_field(ProjData);%create a new field plot with view_field
+%         hhview_field=guidata(hview_field);
+%         plotaxes=hhview_field.axes3;
+%     end
+%     Object_out{IndexObj}.plotaxes=plotaxes;
+% end
 
-% plot the field projected on the object
-ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
-if ~isempty(ProjData)   
-    plotaxes=[];%default
-    if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
-        plotaxes=Object_set{IndexObj}.plotaxes;
-        [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);        
-    else
-        [plotaxes]=view_field(ProjData);
+%%  representation of the different objects in the plots uvmat and view_field
+%hfig=get(plotaxes,'parent');
+%tagfig=get(hfig,'tag');
+% if length(Object_set)<IndexObj
+    %Object_set{IndexObj}=ObjectData;
+% end
+% plot the updated object in uvmat
+%  hobject=[];
+% if isfield(Object_set{IndexObj},'DisplayHandle_uvmat') && ~isempty(Object_set{IndexObj}.DisplayHandle_uvmat) && ishandle(Object_set{IndexObj}.DisplayHandle_uvmat)
+%     hobject=Object_set{IndexObj}.DisplayHandle_uvmat;
+% % else
+% %     hobject=plotaxes;
+% end
+% Object_out{IndexObj}.DisplayHandle_uvmat=plot_object(Object_set{IndexObj},Object_set{1},hobject,'m');%update the object representation
+
+% if strcmp(tagfig,'uvmat')%plot uvmat
+    for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_1
+         hobject=[];
+        if isfield(Object_out{iobj},'DisplayHandle_uvmat') && ~isempty(Object_out{iobj}.DisplayHandle_uvmat) && ishandle(Object_out{iobj}.DisplayHandle_uvmat)
+            hobject=Object_out{iobj}.DisplayHandle_uvmat;
+%         else 
+%             hobject=plotaxes;
+        end
+        Object_out{iobj}.DisplayHandle_uvmat=plot_object(Object_out{iobj},Object_out{IndexObj_1},hobject,'m');%update the object representation
     end
-    Object_out.plotaxes=plotaxes;
-end
+% else%plot view_field
+    for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_2
+        hobject=[];
+        if isfield(Object_out{iobj},'DisplayHandle_view_field') &&  ~isempty(Object_out{iobj}.DisplayHandle_view_field) && ishandle(Object_out{iobj}.DisplayHandle_view_field)
+            hobject=Object_out{iobj}.DisplayHandle_view_field;
+%         else 
+%             hobject=plotaxes;
+        end
+        Object_out{iobj}.DisplayHandle_view_field=plot_object(Object_out{iobj},Object_out{IndexObj_2},hobject,'m');%update the object representation
+    end
+%  end
+
+%     if isfield(Object_set{iobj},'plotaxes')
+%         haxes=Object_set{iobj}.plotaxes;% axes for the field plot
+%         if ishandle(haxes) && isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
+%             testupdate=0;
+%             HandlesDisplay=[];%default
+%             if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
+%                 HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
+%             end
+%             hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes
+%             for ih=1:length(HandlesDisplay)
+%                 plot_detect=find(hplot_list==HandlesDisplay(ih));
+%                 if ~isempty(plot_detect)
+%                     Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iobj},HandlesDisplay(ih),'m');%update the the object representation
+%                     testupdate=1;
+%                     break
+%                 end
+%             end
+%             if ~testupdate% draw new object plot
+%                 hh=plot_object(ObjectData,Object_set{iobj},haxes,'m');%draw the object with the new object data
+%                 if isfield(Object_out,'HandlesDisplay')
+%                     Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
+%                 else
+%                     Object_out.HandlesDisplay=hh;
+%                 end
+%                 PlotData=get(hh,'UserData');
+%                 PlotData.IndexObj=IndexObj;
+%                 set(hh,'UserData',PlotData); %record the object index in the graph
+%             end
+%         end
+%     end
+% end
 
 
 
+
Index: trunk/src/view_field.m
===================================================================
--- trunk/src/view_field.m	(revision 155)
+++ trunk/src/view_field.m	(revision 156)
@@ -75,5 +75,5 @@
     set(hhuvmat.list_object_2,'Visible','on')
     % handles_mouse.create=hhuvmat.create;
-    handles_mouse.edit=hhuvmat.edit;
+    handles_mouse.edit=hhuvmat.edit_object;
     pos_uvmat=get(huvmat,'Position');
     pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
@@ -89,9 +89,11 @@
 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse}) 
 set(hObject,'CloseRequestFcn',{@closefcn})%
+if ~exist('Field','var')
+    return
+end
 
 [PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
 ViewFieldData.axes3=Field;
 set(handles.view_field,'UserData',ViewFieldData);%store the current field
-get(handles.view_field)
 if isfield(PlotParamOut,'Vectors')
     set(handles.VECT_title,'Visible','on')
