Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 443)
+++ /trunk/src/civ.m	(revision 444)
@@ -3958,4 +3958,5 @@
     Data.ListVarName={'ny','nx','A'};
     Data.VarDimName= {'ny','nx',{'ny','nx'}};
+
     Data.A=imread(filecell.ima1.civ1{1}); % read the first image
     if ndims(Data.A)==3 %case of color image
@@ -3966,4 +3967,5 @@
     Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispaly
     par_civ1=read_GUI(handles.Civ1);
+    par_civ1.FileTypeA=get_file_type(filecell.ima1.civ1{1});
     par_civ1.ImageWidth=size(Data.A,2);
     par_civ1.ImageHeight=size(Data.A,1);
Index: /trunk/src/civ_matlab.m
===================================================================
--- /trunk/src/civ_matlab.m	(revision 443)
+++ /trunk/src/civ_matlab.m	(revision 444)
@@ -97,6 +97,5 @@
         end
     else
-        if isfield(par_civ1,'ImageA')%&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated
-            
+        if isfield(par_civ1,'ImageA')&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated           
             [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.FrameIndexA);
             if ~isempty(errormsg)
@@ -106,5 +105,5 @@
             par_civ1.ImageA=Field.A;%= image matrix A in the first input field 
         end
-        if isfield(par_civ1,'ImageB')%&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader'))
+        if isfield(par_civ1,'ImageB')&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader'))
             [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.FrameIndexB);
             if ~isempty(errormsg)
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 443)
+++ /trunk/src/geometry_calib.m	(revision 444)
@@ -234,7 +234,8 @@
 %     testhandle=1;
     RootPath=get(hhuvmat.RootPath,'String');
-    RootFile=get(hhuvmat.RootFile,'String');
-    filebase=fullfile(RootPath,RootFile);
-    outputfile=[filebase '.xml'];%xml file associated with the currently displayed image
+    SubDir=get(hhuvmat.SubDir,'String');
+%     RootFile=get(hhuvmat.RootFile,'String');
+%     filebase=fullfile(RootPath,RootFile);
+    outputfile=[fullfile(RootPath,SubDir) '.xml'];%xml file associated with the currently displayed image
 else
     question={'save the calibration data and point coordinates in'};
Index: /trunk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 443)
+++ /trunk/src/mouse_up.m	(revision 444)
@@ -55,17 +55,10 @@
 %% 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')...
-           && ~isempty(AxeData.CurrentObject) && ishandle(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  
+    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object
     IndexObj=PlotData.IndexObj;
-    ObjectData=UvData.Object{IndexObj};   
-%     ObjectData.enable_plot=1;
-    if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')
-        NbDefPoint=1;  
-    elseif strcmp(ObjectData.Type,'line')|| strcmp(ObjectData.Type,'plane');
-        NbDefPoint=2; 
-    else
-         NbDefPoint=3;
-    end
+    ObjectData=UvData.Object{IndexObj};
+    check_multiple=0;
     % ending translation
     if isequal(AxeData.Drawing,'translate')
@@ -82,6 +75,6 @@
         ObjectData.Coord(ind_move,2)=xy(1,2);
         
-    %creating object   
-    else   
+    %creating object
+    else
         switch ObjectData.Type
             case {'line'}
@@ -91,9 +84,9 @@
                     xy(1,3)=0; % z coordinate set to 0 by default
                 end
-%                 if ~isequal(ObjectData.Coord,xy(1,:))
-                     if ~isequal(ObjectData.Coord(end,1:2),xy(1,1:2))
+                %                 if ~isequal(ObjectData.Coord,xy(1,:))
+                if ~isequal(ObjectData.Coord(end,1:2),xy(1,1:2))
                     ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the second point of the line if different from the first one
-                     end
-%                 end
+                end
+                %                 end
             case {'rectangle','ellipse','volume'}
                 XYData=AxeData.CurrentOrigin;
@@ -112,4 +105,6 @@
                     end
                 end
+            otherwise
+                check_multiple=1;
         end
     end
@@ -123,33 +118,25 @@
         set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4));
     end
-    if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||...
-              strcmp(AxeData.Drawing,'translate') || strcmp(AxeData.Drawing,'deform');%stop drawing
+
+    %stop drawing and plot projected field if the object manipulation is finished
+    if check_multiple==0  || isequal(get(currentfig,'SelectionType'),'alt')
         AxeData.CurrentOrigin=[]; %suppress the current origin
-       if isequal(ObjectData.Type,'line') && size(ObjectData.Coord,1)>=2
-           AxeData.Drawing='off';
-           set(currentaxes,'UserData',AxeData);
-%             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
-
-            %% 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.ListObject_1,'Value');
-%             IndexObj_2=get(hhuvmat.ListObject,'Value');
-%             UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
-
-            %% plot the field projected on the object 
+%         if isequal(ObjectData.Type,'line') && size(ObjectData.Coord,1)>=2
+% %             AxeData.Drawing='off';
+% %             set(currentaxes,'UserData',AxeData);
+%             
+%         end
+        if  ~isempty(ObjectData)
+            %              testmask=0;
+            %              hmask=findobj(huvmat,'Tag','makemask');
+            %              if ~isempty(hmask)
+            %                 testmask=get(hmask,'Value');
+            %              end
+            
+            % plot the field projected on the object
             ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
             if ~isempty(ProjData)
                 if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen in view_field
-                     hview_field=findobj(allchild(0),'tag','view_field');
+                    hview_field=findobj(allchild(0),'tag','view_field');
                     if isempty(hview_field)
                         hview_field=view_field(ProjData); %open the view_field GUI for plot
@@ -160,5 +147,5 @@
                     end
                     ViewFieldData=get(hview_field,'UserData');
-%                     ViewFieldData.axes3=ProjData;
+                    %                     ViewFieldData.axes3=ProjData;
                     haxes=findobj(hview_field,'tag','axes3');
                     if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table)
@@ -172,16 +159,4 @@
                         set(hview_field,'Position',ViewFieldData.GUISize)
                     end
-                    
-%                     Data=get(hview_field,'UserData');
-%                     if isempty(hview_field)
-%                         hview_field=view_field(ProjData);
-%                     else
-%                        hhview_field=guidata(hview_field);
-%                        [PlotType,PlotParam]=plot_field(ProjData,hhview_field.axes3,read_GUI(hview_field));%update an existing field plot
-%                         write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
-%                     end
-%                     ViewFieldData=get(hview_field,'UserData');
-%                     ViewFieldData.axes3=ProjData;
-%                     set(hview_field,'UserData',ViewFieldData)
                 else
                     UvData.axes3=ProjData;
@@ -189,6 +164,4 @@
                     write_plot_param(hhuvmat,PlotParam); %update the display of plotting parameters for the current object
                 end
-                %[PlotType,PlotParam]=plot_field(ProjData,hh_plotfield.axes3,read_plot_param(hh_plotfield));%update an existing field plot
-
             end
             set(hhuvmat.ViewField,'Value',1);%
@@ -199,13 +172,11 @@
             set(hhuvmat.MenuEdit,'Enable','on');%
         end
-    end    
-       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
+    else
+        test_drawing=1;%allow continuation of drawing object
+        AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
+    end
+    UvData.Object{IndexObj}=ObjectData;
     hother=findobj('Tag','deformpoint');%find all the deformpoints
-    set(hother,'Color','b');%reset all the deformpoints in 'blue' 
-else
-    test_drawing=0;
+    set(hother,'Color','b');%reset all the deformpoints in 'blue'
 end
 
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 443)
+++ /trunk/src/uvmat.m	(revision 444)
@@ -1359,7 +1359,6 @@
             errormsg='no file browsed';
         end
-        [RootDir,tild,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname);
-%         [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
-        Mask.Base=fullfile(RootDir,RootFile);
+        [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname);
+        Mask.Base=fullfile(RootDir,SubDir,RootFile);
         Mask.NbSlice=1;
         set(handles.CheckMask,'UserData',Mask);
@@ -1398,6 +1397,4 @@
 [RootPath,RootFile]=fileparts(MaskData.Base);
 MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1);
-%MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
-% huvmat=get(handles.CheckMask,'parent');
 UvData=get(handles.uvmat,'UserData');
 %update mask image if the mask is new
@@ -4716,14 +4713,15 @@
     %mask name
     RootPath=get(handles.RootPath,'String');
+    SubDir=get(handles.SubDir,'String');
     RootFile=get(handles.RootFile,'String');
     if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
         RootFile(1)=[];
     end
-    filebase=fullfile(RootPath,RootFile);
+   % filebase=fullfile(RootPath,RootFile);
     list=get(handles.masklevel,'String');
     masknumber=num2str(length(list));
     maskindex=get(handles.masklevel,'Value');
-    mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex);
-    %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
+   % mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex);
+    mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex);
     imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
     imflag=flipdim(imflag,1);
@@ -4740,11 +4738,13 @@
         mask_dir=fileparts(answer);
         if ~exist(mask_dir,'dir')
-            msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
-            return
+            [xx,msg1]=mkdir(mask_dir);
+            if ~strcmp(msg1,'')
+                errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation
+                return
+            end
         end
         imwrite(imflag,answer,'BitDepth',8);
     end
     set(handles.ListObject,'Value',1)
-%     set(handles.ListObject,'Max',1)
 end
 
