Changeset 402


Ignore:
Timestamp:
Apr 29, 2012, 11:29:24 AM (12 years ago)
Author:
sommeria
Message:

bugs corrected and improved procedure for object projection

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_down.m

    r387 r402  
    253253                set(hhuvmat.ListObject,'Value',IndexObj);
    254254                set(hhuvmat.ListObject,'UserData',IndexObj);
    255 %                 list_str=get(hhuvmat.list_object_2,'String');
    256 %                 UvData.Object{IndexObj(2)}.Name=list_str{IndexObj};
    257255            else
    258256                set(hhuvmat.ListObject,'Value',IndexObj);
     
    291289%%  create new projection  object
    292290if  test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
    293         hset_object=findobj(allchild(0),'tag','set_object');
    294         if ~isempty(hset_object)
    295             %ObjectData=read_set_object(sethandles); %read object features in the GUI set_object
    296             ObjectData=read_GUI(hset_object);
    297             ObjectData.Coord=[]; %reset previous object coordinates
    298             ObjectData.Coord(1,1)=xy(1,1);
    299             ObjectData.Coord(1,2)=xy(1,2);
    300 %             ObjectData.Coord(1,3)=0;
    301             if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
    302                  ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
    303             end
    304             AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
    305             if isfield(UvData,'Object')
    306                 IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
    307             else
    308                 IndexObj=2;
    309             end 
    310             UvData.Object{IndexObj}=ObjectData;       
    311             list_str=get(hhuvmat.ListObject,'String');
    312             IndexObj_old=get(hhuvmat.ListObject,'Value');
    313 %             set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj] );
    314             UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;
    315             object_name=ObjectData.Name;
    316             sethandles=guidata(hset_object);
    317             if isempty(object_name)
    318                 list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Type];
    319                 set(sethandles.Name,'String',list_str{IndexObj})
    320             else
    321                list_str{IndexObj}=object_name;
    322             end
    323             set(hhuvmat.ListObject,'String',list_str)
    324             set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj] );
    325             UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
    326             set(huvmat,'UserData',UvData)
    327             PlotData=get(AxeData.CurrentObject,'UserData');
    328             PlotData.IndexObj=IndexObj;
    329             set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
    330             AxeData.Drawing='create';
    331         end
     291    hset_object=findobj(allchild(0),'tag','set_object');
     292    if ~isempty(hset_object)
     293        sethandles=guidata(hset_object);
     294        ObjectData=read_GUI(hset_object); %read object features in the GUI set_object
     295        ObjectData.Coord=[]; %reset previous object coordinates
     296        ObjectData.Coord(1,1)=xy(1,1);
     297        ObjectData.Coord(1,2)=xy(1,2);
     298        if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
     299            ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
     300        end
     301        AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
     302        if isfield(UvData,'Object')
     303            IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
     304        else
     305            IndexObj=2;
     306        end
     307        UvData.Object{IndexObj}=ObjectData;
     308        ListObject=get(hhuvmat.ListObject,'String');
     309        IndexObj_old=get(hhuvmat.ListObject,'Value');
     310        UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;
     311        ObjectNameNew=ObjectData.Name;
     312        if isempty(ObjectNameNew)
     313             ObjectNameNew=ObjectData.Type;
     314        end
     315        vers=0;% index of the name
     316        detectname=1;
     317        while detectname==1
     318            detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
     319            if detectname% if the object name already exists
     320                indstr=regexp(ObjectNameNew,'\D');
     321                if indstr(end)<length(ObjectNameNew) %object name ends by a number
     322                    vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
     323                    ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
     324                else
     325                    vers=vers+1;
     326                    ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
     327                end
     328            end
     329        end
     330        ObjectName=ObjectNameNew;
     331        set(sethandles.Name,'String',ObjectName)% display the default name in set_object
     332        IndexObj=numel(ListObject)+1;% append an object to the list in uvmat
     333        set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list
     334        set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj])
     335        %             if isempty(object_name)
     336        %                 list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Type];
     337        %                 set(sethandles.Name,'String',list_str{IndexObj})
     338        %             else
     339        %                list_str{IndexObj}=object_name;
     340        %             end
     341        %             set(hhuvmat.ListObject,'String',list_str)
     342        UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
     343        set(huvmat,'UserData',UvData)
     344        PlotData=get(AxeData.CurrentObject,'UserData');
     345        PlotData.IndexObj=IndexObj;
     346        set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
     347        AxeData.Drawing='create';
     348    end
    332349end
    333350
  • trunk/src/plot_field.m

    r397 r402  
    531531for icell=1:length(CellVarIndex) % length(CellVarIndex) =1 or 2 (from the calling function)
    532532    VarType=VarTypeCell{icell};
     533    if ~isempty(VarType.coord_tps)
     534        continue
     535    end
    533536    ivar_X=VarType.coord_x; % defines (unique) index for the variable representing unstructured x coordinate (default =[])
    534537    ivar_Y=VarType.coord_y; % defines (unique)index for the variable representing unstructured y coordinate (default =[])
  • trunk/src/proj_field.m

    r399 r402  
    8282function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
    8383errormsg='';%default
    84 if ~exist('FieldName','var')
    85     FieldName='';
    86 end
     84% if ~exist('FieldName','var')
     85%     FieldName='';
     86% end
    8787%% case of no projection (object is used only as graph display)
    8888if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'))
     
    11951195            case 'filter'
    11961196                if ~isempty(VarType.coord_tps)
    1197                     VarType.coord_tps
     1197                     %Coord_tps=FieldData.ListVarName{VarType.coord_tps};
     1198                     %TODO: possibly translate and rotate coordiantes translate  initial coordinates
    11981199                    coord_x_proj=XMin:DX:XMax;
    11991200                    coord_y_proj=YMin:DY:YMax;
     
    12011202                    np_y=numel(coord_y_proj);
    12021203                    [XI,YI]=meshgrid(coord_x_proj,coord_y_proj');
    1203                     XI=reshape(XI,[],1);
    1204                     YI=reshape(YI,[],1);
     1204                    XI=reshape(XI,[],1)+ObjectData.Coord(1,1);
     1205                    YI=reshape(YI,[],1)+ObjectData.Coord(1,2);
    12051206                    ProjData=calc_field(FieldData.FieldList,FieldData,[XI YI]);
    12061207                    for ilist=3:length(ProjData.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise
  • trunk/src/read_get_field.m

    r231 r402  
    450450end
    451451
    452 
    453 
    454452%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    455453%% get the input field
    456454inputfield=get(handles.inputfile,'String');
    457455if exist(inputfield,'file')% read the input data corresponding to the list of selected varaibles
    458     SubField=nc2struct(inputfield,ListVarName);
     456    SubField=nc2struct(inputfield,ListVarName);%read the list of variables ListVarName from the input file
    459457else  % subfield stored in memory
    460458    SubField.ListGlobalAttribute={};
     
    639637    VarNameU=Field.ListVarName{VarIndexU}; % name of u component variable
    640638    DimCellU=Field.VarDimName{VarIndexU}; % list of dimensions for u component 
    641     eval(['npxy=size(SubField.' VarNameU ');']) % npxy= dimension values for the u component
     639  % eval(['npxy=size(SubField.' VarNameU ');']) % npxy= dimension values for the u component
     640   npxy=size(SubField.(VarNameU)); % npxy= dimension values for the u componen
    642641    SingleCellU={};
    643642    if numel(npxy) < numel(DimCellU)
  • trunk/src/set_object.m

    r397 r402  
    8585set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    8686set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
     87set(hObject,'DeleteFcn',{@closefcn})
    8788enable_plot=0;%default: does not allow plot of object and projection
    8889
    8990% fill the interface as set in the input data:
    9091if exist('data','var')
    91     if isfield(data,'enable_plot')
    92         enable_plot=data.enable_plot;%test to desable button PLOT (display mode)
    93     end
     92%     if isfield(data,'enable_plot')
     93%         enable_plot=data.enable_plot;%test to desable button PLOT (display mode)
     94%     end
    9495    if isfield(data,'Coord') &&size(data.Coord,2)==3
    9596        set(handles.z_slider,'Visible','on')
     
    149150    end
    150151end
    151 if enable_plot
    152    set(handles.PLOT,'enable','on')
    153 else
     152% if enable_plot
     153%    set(handles.PLOT,'enable','on')
     154% else
     155% enable the PLOT (REFRESH) button by default
    154156   set(handles.PLOT,'enable','off')
    155 end
     157% end
    156158huvmat=findobj(allchild(0),'tag','uvmat');
    157159UvData=get(huvmat,'UserData');
     
    171173varargout{1} = handles.output;
    172174varargout{2}=handles;
     175
     176%------------------------------------------------------------------------
     177% executed when closing the GUI set_object
     178function closefcn(gcbo,eventdata)
     179%------------------------------------------------------------------------
     180huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle
     181if ~isempty(huvmat)
     182    hhuvmat=guidata(huvmat);
     183    set(hhuvmat.edit_object,'Value',0)
     184    set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
     185    % deselect the object in ListObject when view_field is closed
     186    if isempty(findobj(allchild(0),'Tag','view_field'))
     187        ObjIndex=get(hhuvmat.ListObject,'Value');
     188        ObjIndex=ObjIndex(1);%keep only the first object selected
     189        set(hhuvmat.ListObject,'Value',ObjIndex)
     190        % draw all object colors in blue (unselected) in uvmat
     191        hother=[findobj(hhuvmat.axes3,'Tag','proj_object');findobj(hhuvmat.axes3,'Tag','DeformPoint')];%find all the proj object and deform point representations
     192        for iobj=1:length(hother)
     193            if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
     194                set(hother(iobj),'EdgeColor','b')
     195                if isequal(get(hother(iobj),'FaceColor'),'m')
     196                    set(hother(iobj),'FaceColor','b')
     197                end
     198            elseif isequal(get(hother(iobj),'Type'),'image')
     199                Acolor=get(hother(iobj),'CData');
     200                Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
     201                set(hother(iobj),'CData',Acolor);
     202            else
     203                set(hother(iobj),'Color','b')
     204            end
     205            set(hother(iobj),'Selected','off')
     206        end
     207    end
     208end
     209hseries=findobj(allchild(0),'Name','series');%find the current series interface handle
     210if ~isempty(hseries)
     211    hhseries=guidata(hseries);
     212    set(hhseries.GetObject,'Value',0)
     213    set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green
     214end
     215
    173216
    174217%------------------------------------------------------------------------
     
    364407%------------------------------------------------------------------------
    365408
    366 %------------------------------------------------------------------------
    367 %------------------------------------------------------------------------
    368 %----------------------------------------------------
    369 % executed when closing: set the parent interface button to value 0
    370 function closefcn(gcbo,eventdata,parent_button)
    371 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    372 if ~isempty(huvmat)
    373     hhuvmat=guidata(huvmat);
    374     set(hhuvmat.edit,'Value',0)
    375     set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
    376 end
    377 hseries=findobj(allchild(0),'Name','series');%find the current series interface handle
    378 if ~isempty(hseries)
    379     hhseries=guidata(hseries);
    380     set(hhseries.GetObject,'Value',0)
    381     set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    382 end
    383409
    384410%------------------------------------------------------------------------
     
    396422%% read the object on the GUI set_object
    397423ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
    398 ObjectName=ObjectData.Name;%name of the current object defined in set_object
    399424if iscell(ObjectData.Coord)%check for empty line
    400425    ObjectData.Coord=[0 0 0];
     
    406431    ObjectData.Coord(checknan,:)=[];%remove the NaN lines
    407432end
     433ObjectName=ObjectData.Name;%name of the current object defined in set_object
    408434if isempty(ObjectName)
    409435    if get(hhuvmat.edit_object,'Value')% edit mode
     
    411437            ObjectName='Plane';
    412438        else
    413         ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
     439            ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
    414440        end
    415441    else %new object
    416         StyleList=get(handles.Type,'String');
    417         StyleVal=get(handles.Type,'Value');
    418         ObjectName=StyleList{StyleVal};
     442        ObjectName=ObjectData.Type;
    419443    end
    420444end
     
    422446    detectname=1;
    423447    ObjectNameNew=ObjectName;
    424     vers=0;
     448    vers=0;% index of the name
    425449    while detectname==1
    426450        detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
  • trunk/src/sub_field.m

    r180 r402  
    7272end
    7373iselect=find(NbDim==2);
     74for icell=iselect
     75    if ~isempty(VarTypeCell{icell}.coord_tps)
     76        NbDim(icell)=0;
     77    end
     78end
     79iselect=find(NbDim==2);
    7480if ~isequal(numel(iselect),1)
    7581    errormsg='invalid  first input to sub_field: it must  contain a single 2D field cell';
    7682    return
     83end
     84iselect_1=find(NbDim_1==2);
     85for icell=iselect_1
     86    if ~isempty(VarTypeCell_1{icell}.coord_tps)
     87        NbDim_1(icell)=0;
     88    end
    7789end
    7890iselect_1=find(NbDim_1==2);
  • trunk/src/uvmat.m

    r399 r402  
    168168%------------------------------------------------------------------------
    169169%------------------------------------------------------------------------
    170 %  I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
     170%  I - MAIN FUNCTION UVMAT
    171171%------------------------------------------------------------------------
    172172%------------------------------------------------------------------------
     
    234234%% refresh projection plane
    235235UvData.Object{1}.ProjMode='projection';%main plotting plane
     236set(handles.ListObject,'Value',1)% default: empty projection object
     237set(handles.ListObject,'String',{''})
    236238set(handles.Fields,'Value',1)
    237239set(handles.Fields,'string',{''})
     
    374376
    375377%------------------------------------------------------------------------
     378% --- executed when closing uvmat: delete or desactivate the associated figures if exist
     379function closefcn(gcbo,eventdata)
     380%------------------------------------------------------------------------
     381hh=findobj(allchild(0),'tag','view_field');
     382if ~isempty(hh)
     383    delete(hh)
     384end
     385hh=findobj(allchild(0),'tag','geometry_calib');
     386if ~isempty(hh)
     387    delete(hh)
     388end
     389hh=findobj(allchild(0),'tag','set_object');
     390if ~isempty(hh)
     391    hhh=findobj(hh,'tag','PLOT');
     392    set(hhh,'enable','off')
     393end
     394
     395%------------------------------------------------------------------------
    376396%------------------------------------------------------------------------
    377397%  II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
     
    458478fileinput=get(handles.MenuFile_5,'Label');
    459479display_file_name(hObject, eventdata, handles,fileinput)
     480
     481%------------------------------------------------------------------------
     482% --- Executes on the menu Open/Browse_1 for the second input field,
     483%     search the files, recognize their type according to their name and fill the rootfile input windows
     484function MenuBrowse_1_Callback(hObject, eventdata, handles)
     485%------------------------------------------------------------------------
     486% huvmat=get(handles.run0,'parent');
     487UvData=get(handles.uvmat,'UserData');
     488
     489RootPath=get(handles.RootPath,'String');
     490[FileName, PathName, filterindex] = uigetfile( ...
     491       {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
     492       '*.xml',  '.xml files '; ...
     493        '*.xls',  '.xls files '; ...
     494        '*.civ',  '.civ files '; ...
     495        '*.jpg','.jpg image files'; ...
     496        '*.png','.png image files'; ...
     497        '*.avi;*.AVI','.avi movie files'; ...
     498        '*.nc','.netcdf files'; ...
     499        '*.cdf','.netcdf files'; ...
     500        '*.cmx','.cmx text files';...
     501        '*.cmx2','.cmx2 text files';...
     502        '*.fig','.fig files (matlab fig)';...
     503        '*.log','.log text files ';...
     504        '*.dat','.dat text files ';...
     505        '*.*',  'All Files (*.*)'}, ...
     506        'Pick a second file for comparison',RootPath);
     507fileinput_1=[PathName FileName];%complete file name
     508sizf=size(fileinput_1);
     509if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
     510
     511% refresh the current displayed field
     512set(handles.SubField,'Value',1)
     513display_file_name(hObject,eventdata,handles,fileinput_1,2)
     514
     515%update list of recent files in the menubar
     516MenuFile_1=fileinput_1;
     517MenuFile_2=get(handles.MenuFile_1,'Label');
     518MenuFile_3=get(handles.MenuFile_2,'Label');
     519MenuFile_4=get(handles.MenuFile_3,'Label');
     520MenuFile_5=get(handles.MenuFile_4,'Label');
     521set(handles.MenuFile_1,'Label',MenuFile_1)
     522set(handles.MenuFile_2,'Label',MenuFile_2)
     523set(handles.MenuFile_3,'Label',MenuFile_3)
     524set(handles.MenuFile_4,'Label',MenuFile_4)
     525set(handles.MenuFile_5,'Label',MenuFile_5)
     526set(handles.MenuFile_1_1,'Label',MenuFile_1)
     527set(handles.MenuFile_2_1,'Label',MenuFile_2)
     528set(handles.MenuFile_3_1,'Label',MenuFile_3)
     529set(handles.MenuFile_4_1,'Label',MenuFile_4)
     530set(handles.MenuFile_5_1,'Label',MenuFile_5)
     531dir_perso=prefdir;
     532profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     533if exist(profil_perso,'file')
     534    save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
     535else
     536    txt=ver('MATLAB');
     537    Release=txt.Release;
     538    relnumb=str2double(Release(3:4));
     539    if relnumb >= 14
     540        save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
     541    else
     542        save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
     543    end
     544end
     545
     546% -----------------------------------------------------------------------
     547% --- Open again as second field the file whose name has been recorded in MenuFile_1
     548function MenuFile_1_1_Callback(hObject, eventdata, handles)
     549% -----------------------------------------------------------------------
     550fileinput_1=get(handles.MenuFile_1_1,'Label');
     551set(handles.SubField,'Value',1)
     552display_file_name(hObject,eventdata,handles,fileinput_1,2)
     553
     554% -----------------------------------------------------------------------
     555% --- Open again as second field the file whose name has been recorded in MenuFile_2
     556function MenuFile_2_1_Callback(hObject, eventdata, handles)
     557% -----------------------------------------------------------------------
     558fileinput_1=get(handles.MenuFile_2_1,'Label');
     559set(handles.SubField,'Value',1)
     560display_file_name(hObject,eventdata,handles,fileinput_1,2)
     561
     562% -----------------------------------------------------------------------
     563% --- Open again as second field the file whose name has been recorded in MenuFile_3
     564function MenuFile_3_1_Callback(hObject, eventdata, handles)
     565% -----------------------------------------------------------------------
     566fileinput_1=get(handles.MenuFile_3_1,'Label');
     567set(handles.SubField,'Value',1)
     568display_file_name(hObject,eventdata,handles,fileinput_1,2)
     569
     570% -----------------------------------------------------------------------
     571% --- Open again as second field the file whose name has been recorded in MenuFile_4
     572function MenuFile_4_1_Callback(hObject, eventdata, handles)
     573% -----------------------------------------------------------------------
     574fileinput_1=get(handles.MenuFile_4_1,'Label');
     575set(handles.SubField,'Value',1)
     576display_file_name(hObject,eventdata,handles,fileinput_1,2)
     577
     578% -----------------------------------------------------------------------
     579% --- Open again as second field the file whose name has been recorded in MenuFile_5
     580function MenuFile_5_1_Callback(hObject, eventdata, handles)
     581% -----------------------------------------------------------------------
     582fileinput_1=get(handles.MenuFile_5_1,'Label');
     583set(handles.SubField,'Value',1)
     584display_file_name(hObject,eventdata,handles,fileinput_1,2)
     585
     586%------------------------------------------------------------------------
     587% --- Called by action in RootPath edit box
     588function RootPath_Callback(hObject,eventdata,handles)
     589%------------------------------------------------------------------------
     590% read the current input file name:
     591[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     592% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     593[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     594% initiate the input file series and refresh the current field view:
     595update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
     596
     597%-----------------------------------------------------------------------
     598% --- Called by action in RootPath_1 edit box
     599function RootPath_1_Callback(hObject,eventdata,handles)
     600% -----------------------------------------------------------------------
     601% update_rootinfo_1(hObject,eventdata,handles)
     602[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     603% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     604[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
     605% initiate the input file series and refresh the current field view:
     606update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2);
     607
     608%------------------------------------------------------------------------
     609% --- Called by action in RootFile edit box
     610function SubDir_Callback(hObject, eventdata, handles)
     611%------------------------------------------------------------------------
     612%refresh the menu of input fields
     613Fields_Callback(hObject, eventdata, handles);
     614% refresh the current field view
     615run0_Callback(hObject, eventdata, handles);
     616
     617%------------------------------------------------------------------------
     618% --- Called by action in RootFile edit box
     619function RootFile_Callback(hObject, eventdata, handles)
     620%------------------------------------------------------------------------
     621RootPath_Callback(hObject,eventdata,handles)
     622
     623%-----------------------------------------------------------------------
     624% --- Called by action in RootFile_1 edit box
     625function RootFile_1_Callback(hObject, eventdata, handles)
     626% -----------------------------------------------------------------------
     627RootPath_1_Callback(hObject,eventdata,handles)
     628
     629%------------------------------------------------------------------------
     630% --- Called by action in FileIndex edit box
     631function FileIndex_Callback(hObject, eventdata, handles)
     632%------------------------------------------------------------------------
     633[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
     634set(handles.i1,'String',num2str(i1));
     635set(handles.i2,'String',num2str(i2));
     636set(handles.j1,'String',num2str(j1));
     637set(handles.j2,'String',num2str(j2));
     638
     639% refresh the current field view
     640run0_Callback(hObject, eventdata, handles)
     641
     642%------------------------------------------------------------------------
     643% --- Called by action in FileIndex_1 edit box
     644function FileIndex_1_Callback(hObject, eventdata, handles)
     645%------------------------------------------------------------------------
     646run0_Callback(hObject, eventdata, handles)
     647
     648%------------------------------------------------------------------------
     649% --- Called by action in NomType edit box
     650function NomType_Callback(hObject, eventdata, handles)
     651%------------------------------------------------------------------------
     652i1=str2num(get(handles.i1,'String'));
     653i2=str2num(get(handles.i2,'String'));
     654j1=str2num(get(handles.j1,'String'));
     655j2=str2num(get(handles.j2,'String'));
     656FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2);
     657set(handles.FileIndex,'String',FileIndex)
     658% refresh the current settings and refresh the field view
     659RootPath_Callback(hObject,eventdata,handles)
     660
     661%------------------------------------------------------------------------
     662% --- Called by action in NomType edit box
     663function NomType_1_Callback(hObject, eventdata, handles)
     664%------------------------------------------------------------------------
     665i1=str2num(get(handles.i1,'String'));
     666i2=str2num(get(handles.i2,'String'));
     667j1=str2num(get(handles.j1,'String'));
     668j2=str2num(get(handles.j2,'String'));
     669FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2);
     670set(handles.FileIndex_1,'String',FileIndex)
     671% refresh the current settings and refresh the field view
     672RootPath_1_Callback(hObject,eventdata,handles)
    460673
    461674%------------------------------------------------------------------------
     
    591804set(handles.uvmat,'Pointer','arrow')
    592805
    593 %------------------------------------------------------------------------
    594 % --- Called by action in RootPath edit box
    595 function RootPath_Callback(hObject,eventdata,handles)
    596 %------------------------------------------------------------------------
    597 % read the current input file name:
    598 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    599 %fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    600 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    601 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    602 % initiate the input file series and refresh the current field view:
    603 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
    604 
    605 %------------------------------------------------------------------------
    606 % --- Called by action in RootFile edit box
    607 function SubDir_Callback(hObject, eventdata, handles)
    608 %------------------------------------------------------------------------
    609 %refresh the menu of input fields
    610 Fields_Callback(hObject, eventdata, handles);
    611 % refresh the current field view
    612 run0_Callback(hObject, eventdata, handles);
    613 
    614 %------------------------------------------------------------------------
    615 % --- Called by action in RootFile edit box
    616 function RootFile_Callback(hObject, eventdata, handles)
    617 %------------------------------------------------------------------------
    618 RootPath_Callback(hObject,eventdata,handles)
    619 
    620 %------------------------------------------------------------------------
    621 % --- Called by action in FileIndex edit box
    622 function FileIndex_Callback(hObject, eventdata, handles)
    623 %------------------------------------------------------------------------
    624 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    625 set(handles.i1,'String',num2str(i1));
    626 set(handles.i2,'String',num2str(i2));
    627 set(handles.j1,'String',num2str(j1));
    628 set(handles.j2,'String',num2str(j2));
    629 
    630 % refresh the current field view
    631 run0_Callback(hObject, eventdata, handles)
    632806
    633807%------------------------------------------------------------------------
     
    9711145end
    9721146
    973 
    974 %------------------------------------------------------------------------
    975 % --- Executes on the menu Open/Browse_1 for the second input field,
    976 %     search the files, recognize their type according to their name and fill the rootfile input windows
    977 function MenuBrowse_1_Callback(hObject, eventdata, handles)
    978 %------------------------------------------------------------------------
    979 % huvmat=get(handles.run0,'parent');
    980 UvData=get(handles.uvmat,'UserData');
    981 
    982 RootPath=get(handles.RootPath,'String');
    983 [FileName, PathName, filterindex] = uigetfile( ...
    984        {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
    985        '*.xml',  '.xml files '; ...
    986         '*.xls',  '.xls files '; ...
    987         '*.civ',  '.civ files '; ...
    988         '*.jpg','.jpg image files'; ...
    989         '*.png','.png image files'; ...
    990         '*.avi;*.AVI','.avi movie files'; ...
    991         '*.nc','.netcdf files'; ...
    992         '*.cdf','.netcdf files'; ...
    993         '*.cmx','.cmx text files';...
    994         '*.cmx2','.cmx2 text files';...
    995         '*.fig','.fig files (matlab fig)';...
    996         '*.log','.log text files ';...
    997         '*.dat','.dat text files ';...
    998         '*.*',  'All Files (*.*)'}, ...
    999         'Pick a second file for comparison',RootPath);
    1000 fileinput_1=[PathName FileName];%complete file name
    1001 sizf=size(fileinput_1);
    1002 if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
    1003 
    1004 % refresh the current displayed field
    1005 set(handles.SubField,'Value',1)
    1006 display_file_name(hObject,eventdata,handles,fileinput_1,2)
    1007 
    1008 %update list of recent files in the menubar
    1009 MenuFile_1=fileinput_1;
    1010 MenuFile_2=get(handles.MenuFile_1,'Label');
    1011 MenuFile_3=get(handles.MenuFile_2,'Label');
    1012 MenuFile_4=get(handles.MenuFile_3,'Label');
    1013 MenuFile_5=get(handles.MenuFile_4,'Label');
    1014 set(handles.MenuFile_1,'Label',MenuFile_1)
    1015 set(handles.MenuFile_2,'Label',MenuFile_2)
    1016 set(handles.MenuFile_3,'Label',MenuFile_3)
    1017 set(handles.MenuFile_4,'Label',MenuFile_4)
    1018 set(handles.MenuFile_5,'Label',MenuFile_5)
    1019 set(handles.MenuFile_1_1,'Label',MenuFile_1)
    1020 set(handles.MenuFile_2_1,'Label',MenuFile_2)
    1021 set(handles.MenuFile_3_1,'Label',MenuFile_3)
    1022 set(handles.MenuFile_4_1,'Label',MenuFile_4)
    1023 set(handles.MenuFile_5_1,'Label',MenuFile_5)
    1024 dir_perso=prefdir;
    1025 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    1026 if exist(profil_perso,'file')
    1027     save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    1028 else
    1029     txt=ver('MATLAB');
    1030     Release=txt.Release;
    1031     relnumb=str2double(Release(3:4));
    1032     if relnumb >= 14
    1033         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    1034     else
    1035         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    1036     end
    1037 end
    1038 
    1039 % -----------------------------------------------------------------------
    1040 % --- Open again as second field the file whose name has been recorded in MenuFile_1
    1041 function MenuFile_1_1_Callback(hObject, eventdata, handles)
    1042 % -----------------------------------------------------------------------
    1043 fileinput_1=get(handles.MenuFile_1_1,'Label');
    1044 set(handles.SubField,'Value',1)
    1045 display_file_name(hObject,eventdata,handles,fileinput_1,2)
    1046 
    1047 % -----------------------------------------------------------------------
    1048 % --- Open again as second field the file whose name has been recorded in MenuFile_2
    1049 function MenuFile_2_1_Callback(hObject, eventdata, handles)
    1050 % -----------------------------------------------------------------------
    1051 fileinput_1=get(handles.MenuFile_2_1,'Label');
    1052 set(handles.SubField,'Value',1)
    1053 display_file_name(hObject,eventdata,handles,fileinput_1,2)
    1054 
    1055 % -----------------------------------------------------------------------
    1056 % --- Open again as second field the file whose name has been recorded in MenuFile_3
    1057 function MenuFile_3_1_Callback(hObject, eventdata, handles)
    1058 % -----------------------------------------------------------------------
    1059 fileinput_1=get(handles.MenuFile_3_1,'Label');
    1060 set(handles.SubField,'Value',1)
    1061 display_file_name(hObject,eventdata,handles,fileinput_1,2)
    1062 
    1063 % -----------------------------------------------------------------------
    1064 % --- Open again as second field the file whose name has been recorded in MenuFile_4
    1065 function MenuFile_4_1_Callback(hObject, eventdata, handles)
    1066 % -----------------------------------------------------------------------
    1067 fileinput_1=get(handles.MenuFile_4_1,'Label');
    1068 set(handles.SubField,'Value',1)
    1069 display_file_name(hObject,eventdata,handles,fileinput_1,2)
    1070 
    1071 % -----------------------------------------------------------------------
    1072 % --- Open again as second field the file whose name has been recorded in MenuFile_5
    1073 function MenuFile_5_1_Callback(hObject, eventdata, handles)
    1074 % -----------------------------------------------------------------------
    1075 fileinput_1=get(handles.MenuFile_5_1,'Label');
    1076 set(handles.SubField,'Value',1)
    1077 display_file_name(hObject,eventdata,handles,fileinput_1,2)
    1078 
    1079 %-----------------------------------------------------------------------
    1080 % --- Called by action in RootPath_1 edit box
    1081 function RootPath_1_Callback(hObject,eventdata,handles)
    1082 % -----------------------------------------------------------------------
    1083 % update_rootinfo_1(hObject,eventdata,handles)
    1084 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
    1085 %fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    1086 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    1087 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    1088 % initiate the input file series and refresh the current field view:
    1089 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2);
    1090 %-----------------------------------------------------------------------
    1091 % --- Called by action in RootFile_1 edit box
    1092 function RootFile_1_Callback(hObject, eventdata, handles)
    1093 % -----------------------------------------------------------------------
    1094 RootPath_1_Callback(hObject,eventdata,handles)
    1095 
    1096 %------------------------------------------------------------------------
    1097 % --- Called by action in FileIndex_1 edit box
    1098 function FileIndex_1_Callback(hObject, eventdata, handles)
    1099 %------------------------------------------------------------------------
    1100 run0_Callback(hObject, eventdata, handles)
    11011147
    11021148%------------------------------------------------------------------------
     
    14071453    end
    14081454end
    1409 
    1410 
    1411 %------------------------------------------------------------------------
    1412 function MenuExportFigure_Callback(hObject, eventdata, handles)
    1413 %------------------------------------------------------------------------
    1414 % huvmat=get(handles.MenuExport,'parent');
    1415 hfig=figure;
    1416 copyobj(handles.axes3,hfig);
    1417 map=colormap(handles.axes3);
    1418 colormap(map);%transmit the current colormap to the zoom fig
    1419 colorbar
    14201455
    14211456%------------------------------------------------------------------------
     
    22222257%% combine the two input fields (e.g. substract velocity fields)
    22232258if numel(Field)==2
    2224    UvData.Field=sub_field(Field{1},Field{2}); 
     2259   [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); 
    22252260else
    22262261   UvData.Field=Field{1};
     2262end
     2263if ~isempty(errormsg)
     2264    errormsg=['error in uvmat/refresh_field/sub_field:' errormsg];
     2265    return
    22272266end
    22282267UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation
     
    24402479for imap=1:numel(IndexObj)
    24412480    iobj=IndexObj(imap);
    2442     [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
    2443 
     2481    if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
     2482        ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
     2483        if UvData.Field.Mesh/ord>=5
     2484            mesh=5*ord;
     2485        elseif UvData.Field.Mesh/ord>=2
     2486            mesh=2*ord;
     2487        else
     2488            mesh=ord;
     2489        end
     2490        coord_x=UvData.Field.XMin:mesh:UvData.Field.XMax;
     2491        coord_y=UvData.Field.YMin:mesh:UvData.Field.YMax;
     2492        [XI,YI]=meshgrid(coord_x,coord_y);
     2493        XI=reshape(XI,[],1);
     2494        YI=reshape(YI,[],1);
     2495        [ObjectData,errormsg]=calc_field({FieldName},UvData.Field,[XI YI]);
     2496    else
     2497        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
     2498    end
    24442499    if ~isempty(errormsg)
    24452500        return
    24462501    end
    24472502    %     if testnewseries && isfield(ObjectData,'CoordUnit')&& isfield(PlotParam{imap},'Coordinates')
    2448 %         PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
    2449 %     end
     2503    %         PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
     2504    %     end
    24502505    if testnewseries && isfield(ObjectData,'CoordUnit')
    24512506        PlotParam{imap}.Coordinates.CheckFixEqual=1;
     
    24942549            ObjectData.DimValue(ind_off)=[];
    24952550        end
    2496     end   
     2551    end
    24972552    if ~isempty(ObjectData)
    24982553        PlotType='none'; %default
     
    29493004    UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read)
    29503005end
     3006UvData.filename_1='';% desactivate the use of a constant second file
    29513007list_fields=get(handles.Fields,'String');% list menu fields
    29523008index_fields=get(handles.Fields,'Value');% selected string index
     
    30773133
    30783134%------------------------------------------------------------------------
     3135% --- Executes on button press in FixVelType.
     3136function FixVelType_Callback(hObject, eventdata, handles)
     3137%------------------------------------------------------------------------
     3138val=get(handles.FixVelType,'Value');
     3139if ~val
     3140    run0_Callback(hObject, eventdata, handles)
     3141end
     3142
     3143%------------------------------------------------------------------------
    30793144% --- Executes on button press in VelType.
    30803145function VelType_Callback(hObject, eventdata, handles)
     
    30843149
    30853150%------------------------------------------------------------------------
    3086 % --- Executes on button press in VelType.
     3151% --- Executes on button press in VelType_1.
    30873152function VelType_1_Callback(hObject, eventdata, handles)
    30883153%------------------------------------------------------------------------
     
    31153180    UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists
    31163181end
     3182UvData.filename_1='';% desactivate the use of a constant second file
    31173183set(handles.uvmat,'UserData',UvData)
    31183184num_i1=stra2num(get(handles.i1,'String'));
     
    38143880write_plot_param(handles,PlotParamOut); %update the auto plot parameters
    38153881
     3882%------------------------------------------------------------------------
     3883%------------------------------------------------------------------------
     3884%   SELECTION AND EDITION OF PROJECTION OBJECTS
     3885%------------------------------------------------------------------------
     3886%------------------------------------------------------------------------
     3887
     3888%------------------------------------------------------------------------
     3889% --- Executes on selection change in ListObject.
     3890function ListObject_Callback(hObject, eventdata, handles)
     3891%------------------------------------------------------------------------
     3892list_str=get(handles.ListObject,'String');
     3893IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection
     3894IndexObj=get(handles.ListObject,'Value');%present object selection
     3895
     3896%% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field
     3897if length(IndexObj)>2
     3898     IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most
     3899end
     3900
     3901%% we select one object
     3902if length(IndexObj)==1%
     3903    if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj)   % we select the first previously selected object->
     3904        IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat
     3905    elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object->
     3906        IndexObj=IndexObj_old(1);% it desactivates this object  and keeps only the first previously selected object (uvmat)
     3907    else %
     3908        IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one
     3909    end
     3910end
     3911 
     3912%% The second object is selected, it is displayed in set_object if this GUI is already opened
     3913UvData=get(handles.uvmat,'UserData');
     3914ObjectData=UvData.Object{IndexObj(end)};
     3915hset_object=findobj(allchild(0),'tag','set_object');
     3916if ~isempty(hset_object)
     3917    delete(hset_object)% delete to refesh the content
     3918    ZBounds=0; % default
     3919    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     3920        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     3921        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     3922    end
     3923    ObjectData.Name=list_str{IndexObj(end)};
     3924    set_object(ObjectData,[],ZBounds);
     3925end
     3926%  desactivate the edit object mode
     3927set(handles.edit_object,'Value',0)
     3928set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
     3929
     3930%% update the object value stored in ListObject
     3931set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list
     3932set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time
     3933%
     3934% UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     3935% if numel(UvData.Object)<max(IndexObj);
     3936%     msgbox_uvmat('ERROR','invalid object list')
     3937%     return
     3938% end
     3939% if numel(IndexObj)>=2
     3940%     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation
     3941%     set(handles.uvmat,'UserData',UvData)
     3942% end
     3943
     3944%% update the main plot (on uvmat) if the first selected object has been changed
     3945if ~isequal(IndexObj(1),IndexObj_old(1))
     3946    ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)}
     3947    plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles);
     3948end
     3949
     3950%% update the second plot (on view_field) if view_field is already openened
     3951axes_view_field=[];%default
     3952if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2)))
     3953    hview_field=findobj(allchild(0),'tag','view_field');
     3954    if ~isempty(hview_field)
     3955        PlotHandles=guidata(hview_field);     
     3956        ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
     3957        axes_view_field=PlotHandles.axes3;
     3958        plot_field(ProjData,axes_view_field,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles);
     3959    end
     3960end
     3961
     3962%% update the color of the graphic object representation: the selected object in magenta, others in blue
     3963update_object_color(handles.axes3,axes_view_field,UvData.Object{IndexObj(end)}.DisplayHandle_uvmat)
     3964
     3965%------------------------------------------------------------------------
     3966%--- update the color representation of objects (indicating the selected ones)
     3967function update_object_color(axes_uvmat,axes_view_field,DisplayHandle)
     3968%------------------------------------------------------------------------
     3969if isempty(axes_view_field)% case with no view_field plot
     3970hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations
     3971else
     3972hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations
     3973findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations
     3974end
     3975for iobj=1:length(hother)
     3976    if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
     3977        set(hother(iobj),'EdgeColor','b')
     3978        if isequal(get(hother(iobj),'FaceColor'),'m')
     3979            set(hother(iobj),'FaceColor','b')
     3980        end
     3981    elseif isequal(get(hother(iobj),'Type'),'image')
     3982        Acolor=get(hother(iobj),'CData');
     3983        Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
     3984        set(hother(iobj),'CData',Acolor);
     3985    else
     3986        set(hother(iobj),'Color','b')
     3987    end
     3988    set(hother(iobj),'Selected','off')
     3989end
     3990if ~isempty(DisplayHandle)
     3991    linetype=get(DisplayHandle,'Type');
     3992    if isequal(linetype,'line')
     3993        set(DisplayHandle,'Color','m'); %set the selected object to magenta color
     3994    elseif isequal(linetype,'rectangle')
     3995        set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color
     3996    elseif isequal(linetype,'patch')
     3997        set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color
     3998    end
     3999    SubObjectData=get(DisplayHandle,'UserData');
     4000    if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
     4001        for iobj=1:length(SubObjectData.SubObject)
     4002            hsub=SubObjectData.SubObject(iobj);
     4003            if isequal(get(hsub,'Type'),'rectangle')
     4004                set(hsub,'EdgeColor','m'); %set the selected object to magenta color
     4005            elseif isequal(get(hsub,'Type'),'image')
     4006                Acolor=get(hsub,'CData');
     4007                Acolor(:,:,1)=Acolor(:,:,3);
     4008                set(hsub,'CData',Acolor);
     4009            else
     4010                set(hsub,'Color','m')
     4011            end
     4012        end
     4013    end
     4014    if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
     4015        set(SubObjectData.DeformPoint,'Color','m')
     4016    end
     4017end
     4018
     4019%------------------------------------------------------------------------
     4020% --- Executes on button press in ViewObject.
     4021function ViewObject_Callback(hObject, eventdata, handles)
     4022%------------------------------------------------------------------------
     4023IndexObj=get(handles.ListObject,'Value');
     4024% IndexObj=IndexObj(end); %keeps only the second value
     4025UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     4026if numel(UvData.Object)<IndexObj(end);% error in UvData
     4027    msgbox_uvmat('ERROR','invalid object list')
     4028    return
     4029end
     4030% ObjectData=UvData.Object{IndexObj(};
     4031ZBounds=0; % default
     4032if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     4033    ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     4034    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     4035end
     4036hset_object=findobj(allchild(0),'tag','set_object');
     4037if ~isempty(hset_object)
     4038    delete(hset_object)% delete existing version of set_object
     4039end
     4040set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion
     4041if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane
     4042    UvData.Object{IndexObj(1)}.Type='plane';
     4043end
     4044list_object=get(handles.ListObject,'String');
     4045UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)};
     4046hset_object=set_object(UvData.Object{IndexObj(end)},[],ZBounds);
     4047hhset_object=guidata(hset_object);
     4048if get(handles.edit_object,'Value')% edit mode
     4049    set(hhset_object.PLOT,'Enable','on')
     4050else
     4051    set(hhset_object.PLOT,'Enable','off')
     4052end
     4053
     4054%% show the second plot (on view_field)
     4055if length(IndexObj)==2
     4056    ProjData= proj_field(UvData.Field,UvData.Object{IndexObj(2)});%project the current field on ObjectData
     4057    hview_field=findobj(allchild(0),'tag','view_field');
     4058    if isempty(hview_field)
     4059        hview_field=view_field;
     4060    end
     4061    PlotHandles=guidata(hview_field);     
     4062    plot_field(ProjData,PlotHandles.axes3,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles);
     4063end
     4064
    38164065%-------------------------------------------------------------------
    38174066% --- Executes on selection change in edit_object.
     
    38384087    set(hhset_object.PLOT,'enable','on');
    38394088else
    3840     UvData.MouseAction='none';
    38414089    set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    38424090    hset_object=findobj(allchild(0),'Tag','set_object');
     
    38484096
    38494097%------------------------------------------------------------------------
    3850 % --- Executes on selection change in ListObject.
    3851 function ListObject_Callback(hObject, eventdata, handles)
    3852 %------------------------------------------------------------------------
    3853 
    3854 list_str=get(handles.ListObject,'String');
    3855 IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection
    3856 IndexObj=get(handles.ListObject,'Value');%present object selection
    3857 
    3858 %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field
    3859 if length(IndexObj)>2
    3860      IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most
    3861 end
    3862 
    3863 %% we select one object
    3864 if length(IndexObj)==1%
    3865     if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj)   % we select the first previously selected object->
    3866         IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat
    3867     elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object->
    3868         IndexObj=IndexObj_old(1);% it desactivates this object  and keeps only the first previously selected object (uvmat)
    3869     else %
    3870         IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one
    3871     end
    3872 end
    3873 set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list
    3874 set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time
    3875 
    3876 %% update the object representation
    3877 set(handles.edit_object,'Value',0) % desactivate the edit object mode
    3878 edit_object_Callback(hObject, eventdata, handles)
    3879 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    3880 if numel(UvData.Object)<max(IndexObj);
    3881     msgbox_uvmat('ERROR','invalid object list')
    3882     return
    3883 end
    3884 if numel(IndexObj)>=2
    3885     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation
    3886     set(handles.uvmat,'UserData',UvData)
    3887 end
    3888 
    3889 %% project on the selected object and update the corresponding plot
    3890 % hview_field=findobj(allchild(0),'tag','view_field');
    3891 % ViewObjectAxes=[];%default
    3892 if ~isequal(IndexObj(1),IndexObj_old(1))
    3893     update_object(handles,IndexObj(1),handles.axes3,list_str{IndexObj(1)})%plot the projection in uvmat
    3894 end
    3895 hview_field=findobj(allchild(0),'tag','view_field');
    3896 if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2)))
    3897     if isempty(hview_field)
    3898         hview_field=view_field;
    3899     end
    3900     PlotHandles=guidata(hview_field);
    3901     update_object(handles,IndexObj(2),PlotHandles.axes3,list_str{IndexObj(2)})%plot the projection in view_field
    3902     update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
    3903 else
    3904     if ~isempty(hview_field)
    3905         delete(hview_field)
    3906     end
    3907     hset_object=findobj(allchild(0),'tag','set_object');
    3908     if ~isempty(hset_object)
    3909         delete(hset_object)
    3910     end
    3911     update_object_color(handles.axes3,handles.axes3,[])
    3912 end
    3913 
    3914 %% update the color of the gfraphic object representation: the selected object in magenta, others in blue
    3915 % update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
    3916 
    3917 %------------------------------------------------------------------------
    3918 function update_object(handles,IndexObj,ViewObjectAxes,ObjectName)
    3919 %------------------------------------------------------------------------
    3920 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    3921 ObjectData=UvData.Object{IndexObj};
    3922 ObjectData.Name=ObjectName;
    3923 if isequal(get(handles.edit_object,'Value'),1)
    3924     ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
    3925 end
    3926 ZBounds=0; % default
    3927 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
    3928     ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
    3929     ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    3930 end
    3931 hset_object=findobj(allchild(0),'tag','set_object');
    3932 if ~isempty(hset_object)
    3933     delete(hset_object)% delete existing version of set_object
    3934 end
    3935     hset_object=set_object(ObjectData,[],ZBounds);
    3936 % end
    3937 edit_test=get(handles.edit_object,'Value');
    3938 if edit_test
    3939     ObjectData.enable_plot=1;
    3940 else
    3941     if isfield(ObjectData,'enable_plot')
    3942         ObjectData=rmfield(ObjectData,'enable_plot');
    3943     end
    3944 end
    3945 
    3946 uistack(ViewObjectAxes,'top')% display the plotting axes at the top
    3947 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    3948 plot_field(ProjData,ViewObjectAxes,read_GUI(get(ViewObjectAxes,'Parent')));%read plotting parameters on the uvmat interfacPlotHandles);
    3949 
    3950 %------------------------------------------------------------------------
    3951 %--- update the representation of objects
    3952 function update_object_color(axes_uvmat,axes_view_field,DisplayHandle)
    3953 %------------------------------------------------------------------------
    3954 hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object')] ;%find all the proj objects
    3955 hother=[hother ;findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];
    3956 for iobj=1:length(hother)
    3957     if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
    3958         set(hother(iobj),'EdgeColor','b')
    3959         if isequal(get(hother(iobj),'FaceColor'),'m')
    3960             set(hother(iobj),'FaceColor','b')
    3961         end
    3962     elseif isequal(get(hother(iobj),'Type'),'image')
    3963         Acolor=get(hother(iobj),'CData');
    3964         Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
    3965         set(hother(iobj),'CData',Acolor);
    3966     else
    3967         set(hother(iobj),'Color','b')
    3968     end
    3969     set(hother(iobj),'Selected','off')
    3970 end
    3971 if ~isempty(DisplayHandle)
    3972 linetype=get(DisplayHandle,'Type');
    3973 if isequal(linetype,'line')
    3974     set(DisplayHandle,'Color','m'); %set the selected object to magenta color
    3975 elseif isequal(linetype,'rectangle')
    3976     set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color
    3977 elseif isequal(linetype,'patch')
    3978     set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color
    3979 end
    3980 SubObjectData=get(DisplayHandle,'UserData');
    3981 if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
    3982     for iobj=1:length(SubObjectData.SubObject)
    3983         hsub=SubObjectData.SubObject(iobj);
    3984         if isequal(get(hsub,'Type'),'rectangle')
    3985             set(hsub,'EdgeColor','m'); %set the selected object to magenta color
    3986         elseif isequal(get(hsub,'Type'),'image')
    3987             Acolor=get(hsub,'CData');
    3988             Acolor(:,:,1)=Acolor(:,:,3);
    3989             set(hsub,'CData',Acolor);
    3990         else
    3991             set(hsub,'Color','m')
    3992         end
    3993     end
    3994 end
    3995 if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
    3996     set(SubObjectData.DeformPoint,'Color','m')
    3997 end
    3998 end
    3999 
    4000 %------------------------------------------------------
     4098% --- Executes on button press in delete_object.
     4099function delete_object_Callback(hObject, eventdata, handles)
     4100%------------------------------------------------------------------------
     4101IndexObj=get(handles.ListObject,'Value');
     4102if IndexObj(end)>1
     4103    delete_object(IndexObj(end))
     4104end
     4105
     4106%------------------------------------------------------------------------
     4107%------------------------------------------------------------------------
     4108%  II - TOOLS FROM THE UPPER MENU BAR
     4109%------------------------------------------------------------------------
     4110%------------------------------------------------------------------------
     4111
     4112%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4113% Export  Menu Callbacks
     4114%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4115%------------------------------------------------------------------------
    40014116% --- Executes on button press in Menu/Export/field in workspace.
    4002 %------------------------------------------------------
    40034117function MenuExportField_Callback(hObject, eventdata, handles)
     4118%------------------------------------------------------------------------
    40044119global Data_uvmat
    40054120Data_uvmat=get(handles.uvmat,'UserData');
     
    40094124commandwindow; %brings the Matlab command window to the front
    40104125
    4011 %------------------------------------------------------
     4126%------------------------------------------------------------------------
    40124127% --- Executes on button press in Menu/Export/extract figure.
    4013 %------------------------------------------------------
    4014 function MenuExport_plot_Callback(hObject, eventdata, handles)
    4015 huvmat=get(handles.MenuExport_plot,'parent');
    4016 UvData=get(huvmat,'UserData');
     4128function MenuExportFigure_Callback(hObject, eventdata, handles)
     4129%------------------------------------------------------------------------
     4130% huvmat=get(handles.MenuExport,'parent');
    40174131hfig=figure;
    4018 newaxes=copyobj(handles.axes3,hfig);
     4132copyobj(handles.axes3,hfig);
    40194133map=colormap(handles.axes3);
    40204134colormap(map);%transmit the current colormap to the zoom fig
    40214135colorbar
    40224136
    4023 
    4024 % --------------------------------------------------------------------
    4025 function Insert_Callback(hObject, eventdata, handles)
    4026 
    4027 
    4028 % --------------------------------------------------------------------
    4029 function MenuHelp_Callback(hObject, eventdata, handles)
    4030 % --------------------------------------------------------------------
    4031 path_to_uvmat=which ('uvmat');% check the path of uvmat
    4032 pathelp=fileparts(path_to_uvmat);
    4033 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
    4034 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    4035 else
    4036     addpath (fullfile(pathelp,'uvmat_doc'))
    4037     web(helpfile);
    4038 end
     4137% %------------------------------------------------------
     4138% % --- Executes on button press in Menu/Export/extract figure.
     4139% %------------------------------------------------------
     4140% function MenuExport_plot_Callback(hObject, eventdata, handles)
     4141% huvmat=get(handles.MenuExport_plot,'parent');
     4142% UvData=get(huvmat,'UserData');
     4143% hfig=figure;
     4144% newaxes=copyobj(handles.axes3,hfig);
     4145% map=colormap(handles.axes3);
     4146% colormap(map);%transmit the current colormap to the zoom fig
     4147% colorbar
     4148
     4149%
     4150% % --------------------------------------------------------------------
     4151% function Insert_Callback(hObject, eventdata, handles)
     4152%
    40394153
    40404154%------------------------------------------------------------------------
     
    41234237msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
    41244238
     4239
     4240%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4241% Projection Objects Menu Callbacks
     4242%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4243
     4244% -----------------------------------------------------------------------
     4245function Menupoints_Callback(hObject, eventdata, handles)
     4246%------------------------------------------------------------------------
     4247data.Type='points';
     4248data.ProjMode='projection';%default
     4249create_object(data,handles)
     4250
     4251% -----------------------------------------------------------------------
     4252function Menuline_Callback(hObject, eventdata, handles)
     4253%------------------------------------------------------------------------
     4254data.Type='line';
     4255data.ProjMode='projection';%default
     4256create_object(data,handles)
     4257
     4258%------------------------------------------------------------------------
     4259function Menupolyline_Callback(hObject, eventdata, handles)
     4260%------------------------------------------------------------------------
     4261data.Type='polyline';
     4262data.ProjMode='projection';%default
     4263create_object(data,handles)
     4264
     4265%------------------------------------------------------------------------
     4266function Menupolygon_Callback(hObject, eventdata, handles)
     4267%------------------------------------------------------------------------
     4268data.Type='polygon';
     4269data.ProjMode='inside';%default
     4270create_object(data,handles)
     4271
     4272%------------------------------------------------------------------------
     4273function Menurectangle_Callback(hObject, eventdata, handles)
     4274%------------------------------------------------------------------------
     4275data.Type='rectangle';
     4276data.ProjMode='inside';%default
     4277create_object(data,handles)
     4278
     4279%------------------------------------------------------------------------
     4280function Menuellipse_Callback(hObject, eventdata, handles)
     4281%------------------------------------------------------------------------
     4282data.Type='ellipse';
     4283data.ProjMode='inside';%default
     4284create_object(data,handles)
     4285
     4286%------------------------------------------------------------------------
     4287function MenuMaskObject_Callback(hObject, eventdata, handles)
     4288%------------------------------------------------------------------------
     4289data.Type='polygon';
     4290data.TypeMenu={'polygon'};
     4291data.ProjMode='mask_inside';%default
     4292data.ProjModeMenu={'mask_inside';'mask_outside'};
     4293create_object(data,handles)
     4294
     4295%------------------------------------------------------------------------
     4296function Menuplane_Callback(hObject, eventdata, handles)
     4297%------------------------------------------------------------------------
     4298data.Type='plane';
     4299data.ProjMode='projection';%default
     4300create_object(data,handles)
     4301
     4302%------------------------------------------------------------------------
     4303function Menuvolume_Callback(hObject, eventdata, handles)
     4304%------------------------------------------------------------------------
     4305data.Type='volume';
     4306data.ProjMode='interp';%default
     4307% set(handles.create,'Visible','on')
     4308% set(handles.create,'Value',1)
     4309% VOLUME_Callback(hObject,eventdata,handles)
     4310create_object(data,handles)
     4311
     4312%------------------------------------------------------------------------
     4313% --- generic function used for the creation of a projection object
     4314function create_object(data,handles)
     4315%------------------------------------------------------------------------
     4316
     4317hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
     4318if ishandle(hgeometry_calib)
     4319    hhgeometry_calib=guidata(hgeometry_calib);
     4320    set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
     4321    set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
     4322end
     4323UvData=get(handles.uvmat,'UserData');
     4324set(handles.edit_object,'Value',0); %suppress the object edit mode
     4325set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
     4326% data.enable_plot=1;
     4327data.Coord=[0 0]; %default
     4328if isfield(UvData,'Field')
     4329    Field=UvData.Field;
     4330    if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
     4331        ord=10^(floor(log10(Field.Mesh)));%order of magnitude
     4332        if Field.Mesh/ord>=5
     4333            mesh=5*ord;
     4334        elseif Field.Mesh/ord>=2
     4335            mesh=2*ord;
     4336        else
     4337            mesh=ord;
     4338        end
     4339        data.RangeX=mesh;
     4340        data.RangeY=mesh;
     4341        data.DX=mesh;
     4342        data.DY=mesh;
     4343    elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
     4344        np=size(Field.A);
     4345        meshx=(Field.AX(end)-Field.AX(1))/np(2);
     4346        meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
     4347        data.RangeY=max(meshx,meshy);
     4348        data.RangeX=max(meshx,meshy);
     4349        data.DX=max(meshx,meshy);
     4350    end
     4351    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     4352         data.Coord=[0 0 0]; %default
     4353    end
     4354    if isfield(Field,'CoordUnit')
     4355        data.CoordUnit=Field.CoordUnit;
     4356    end
     4357end
     4358if ishandle(handles.UVMAT_title)
     4359    delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
     4360end
     4361hset_object=findobj(allchild(0),'tag','set_object');
     4362IndexObj=get(handles.ListObject,'Value')
     4363if ~isempty(hset_object)
     4364    delete(hset_object)% delete existing version of set_object
     4365end
     4366set(handles.ListObject,'Value',IndexObj)
     4367hset_object=set_object(data,handles);% call the set_object interface
     4368hhset_object=guidata(hset_object);
     4369set(hhset_object.PLOT,'enable','on')% activate the refresh button
     4370set(handles.MenuObject,'checked','on')
     4371set(handles.uvmat,'UserData',UvData)
     4372set(handles.CheckZoom,'Value',0)
     4373CheckZoom_Callback(handles.uvmat, [], handles)
     4374set(handles.delete_object,'Visible','on')
     4375
     4376
     4377%------------------------------------------------------------------------
     4378function MenuBrowseObject_Callback(hObject, eventdata, handles)
     4379%------------------------------------------------------------------------
     4380%get the object file
     4381[FileName, PathName, filterindex] = uigetfile( ...
     4382       {'*.xml;*.mat', ' (*.xml,*.mat)';
     4383       '*.xml',  '.xml files '; ...
     4384        '*.mat',  '.mat matlab files '}, ...
     4385        'Pick an xml Object file',get(handles.RootPath,'String'));
     4386fileinput=[PathName FileName];%complete file name
     4387sizf=size(fileinput);
     4388if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
     4389
     4390%read the file
     4391data=xml2struct(fileinput);
     4392data.enable_plot=1;
     4393[tild,data.Name]=fileparts(FileName);
     4394hset_object=findobj(allchild(0),'tag','set_object');
     4395if ~isempty(hset_object)
     4396    delete(hset_object)% delete existing version of set_object
     4397end
     4398set_object(data);% call the set_object interface
     4399set(handles.edit_object,'Value',0); %suppress the object edit mode
     4400set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
     4401set(handles.MenuObject,'checked','on')
     4402set(handles.delete_object,'Visible','on')
     4403
     4404%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4405% MenuEdit Callbacks
     4406%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4407%------------------------------------------------------------------------
     4408function MenuEditObject_Callback(hObject, eventdata, handles)
     4409%------------------------------------------------------------------------
     4410set(handles.edit_object,'Value',1)
     4411edit_Callback(hObject, eventdata, handles)
     4412
     4413% %------------------------------------------------------------------------
     4414% function enable_transform(handles,state)
     4415% %------------------------------------------------------------------------
     4416% set(handles.transform_fct,'Visible',state)
     4417% set(handles.TRANSFORM_txt,'Visible',state)   
     4418% set(handles.transform_fct,'Visible',state) 
     4419% set(handles.path_transform,'Visible',state)
     4420% set(handles.pxcmx_txt,'Visible',state)
     4421% set(handles.pxcmy_txt,'Visible',state)
     4422% set(handles.pxcm,'Visible',state)
     4423% set(handles.pycm,'Visible',state)
     4424
     4425%------------------------------------------------------------------------
     4426function MenuEditVectors_Callback(hObject, eventdata, handles)
     4427%------------------------------------------------------------------------
     4428set(handles.edit_vect,'Visible','on')
     4429set(handles.edit_vect,'Value',1)
     4430edit_vect_Callback(hObject, eventdata, handles)
     4431
     4432%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4433% MenuTools Callbacks
     4434%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    41254435%------------------------------------------------------------------------
    41264436function MenuCalib_Callback(hObject, eventdata, handles)
     
    41414451pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
    41424452pos(2)=pos(2)-0.02;
    4143 %[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
    41444453[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    41454454FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     
    42784587set_grid(FileName,CoordList{val});% call the set_object interface
    42794588
     4589
     4590%------------------------------------------------------------------------
     4591function MenuRuler_Callback(hObject, eventdata, handles)
     4592%------------------------------------------------------------------------
     4593set(handles.CheckZoom,'Value',0)
     4594CheckZoom_Callback(handles.uvmat, [], handles)
     4595set(handles.MenuRuler,'checked','on')
     4596UvData=get(handles.uvmat,'UserData');
     4597UvData.MouseAction='ruler';
     4598set(handles.uvmat,'UserData',UvData);
     4599
     4600%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4601% MenuRun Callbacks
     4602%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     4603
    42804604%------------------------------------------------------------------------
    42814605% open the GUI 'series'
     
    42884612    [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    42894613    FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    4290     %FileName_1=read_file_boxes_1(handles);%
    42914614    if ~isequal(FileName_1,param.FileName)
    42924615        param.FileName_1=FileName_1;
     
    42944617end
    42954618param.NomType=get(handles.NomType,'String');
    4296 % param.NomType=get(handles.FileIndex,'UserData');
    42974619param.NomType_1=get(handles.NomType_1,'String');
    4298 % param.NomType_1=get(handles.FileIndex_1,'UserData');
    42994620param.CheckFixPair=get(handles.CheckFixPair,'Value');
    43004621huvmat=get(handles.MenuSeries,'parent');
     
    43254646
    43264647%------------------------------------------------------------------------
    4327 % -- open the GUI civ.fig for civx (PIV)
     4648% -- open the GUI civ.fig for PIV
    43284649function MenuPIV_Callback(hObject, eventdata, handles)
    43294650%------------------------------------------------------------------------
     
    43324653civ(FileName);% interface de civ(not in the uvmat file)
    43334654
    4334 %------------------------------------------------------------------------
    4335 function MenuTools_Callback(hObject, eventdata, handles)
    4336 %------------------------------------------------------------------------
    4337 
    4338 %------------------------------------------------------------------------
    4339 function MenuEditObject_Callback(hObject, eventdata, handles)
    4340 %------------------------------------------------------------------------
    4341 set(handles.edit_object,'Value',1)
    4342 edit_Callback(hObject, eventdata, handles)
    4343 
    4344 %------------------------------------------------------------------------
    4345 function enable_transform(handles,state)
    4346 %------------------------------------------------------------------------
    4347 set(handles.transform_fct,'Visible',state)
    4348 set(handles.TRANSFORM_txt,'Visible',state)   
    4349 set(handles.transform_fct,'Visible',state) 
    4350 set(handles.path_transform,'Visible',state)
    4351 set(handles.pxcmx_txt,'Visible',state)
    4352 set(handles.pxcmy_txt,'Visible',state)
    4353 set(handles.pxcm,'Visible',state)
    4354 set(handles.pycm,'Visible',state)
    4355 
    4356 %------------------------------------------------------------------------
    4357 function MenuEditVectors_Callback(hObject, eventdata, handles)
    4358 %------------------------------------------------------------------------
    4359 set(handles.edit_vect,'Visible','on')
    4360 set(handles.edit_vect,'Value',1)
    4361 edit_vect_Callback(hObject, eventdata, handles)
    4362 
    4363 % -----------------------------------------------------------------------
    4364 function Menupoints_Callback(hObject, eventdata, handles)
    4365 %------------------------------------------------------------------------
    4366 data.Type='points';
    4367 data.ProjMode='projection';%default
    4368 create_object(data,handles)
    4369 
    4370 % -----------------------------------------------------------------------
    4371 function Menuline_Callback(hObject, eventdata, handles)
    4372 %------------------------------------------------------------------------
    4373 data.Type='line';
    4374 data.ProjMode='projection';%default
    4375 create_object(data,handles)
    4376 
    4377 %------------------------------------------------------------------------
    4378 function Menupolyline_Callback(hObject, eventdata, handles)
    4379 %------------------------------------------------------------------------
    4380 data.Type='polyline';
    4381 data.ProjMode='projection';%default
    4382 create_object(data,handles)
    4383 
    4384 %------------------------------------------------------------------------
    4385 function Menupolygon_Callback(hObject, eventdata, handles)
    4386 %------------------------------------------------------------------------
    4387 data.Type='polygon';
    4388 data.ProjMode='inside';%default
    4389 create_object(data,handles)
    4390 
    4391 %------------------------------------------------------------------------
    4392 function Menurectangle_Callback(hObject, eventdata, handles)
    4393 %------------------------------------------------------------------------
    4394 data.Type='rectangle';
    4395 data.ProjMode='inside';%default
    4396 create_object(data,handles)
    4397 
    4398 %------------------------------------------------------------------------
    4399 function Menuellipse_Callback(hObject, eventdata, handles)
    4400 %------------------------------------------------------------------------
    4401 data.Type='ellipse';
    4402 data.ProjMode='inside';%default
    4403 create_object(data,handles)
    4404 
    4405 %------------------------------------------------------------------------
    4406 function MenuMaskObject_Callback(hObject, eventdata, handles)
    4407 %------------------------------------------------------------------------
    4408 data.Type='polygon';
    4409 data.TypeMenu={'polygon'};
    4410 data.ProjMode='mask_inside';%default
    4411 data.ProjModeMenu={'mask_inside';'mask_outside'};
    4412 create_object(data,handles)
    4413 
    4414 %------------------------------------------------------------------------
    4415 function Menuplane_Callback(hObject, eventdata, handles)
    4416 %------------------------------------------------------------------------
    4417 data.Type='plane';
    4418 data.ProjMode='projection';%default
    4419 
    4420 create_object(data,handles)
    4421 
    4422 %------------------------------------------------------------------------
    4423 function Menuvolume_Callback(hObject, eventdata, handles)
    4424 %------------------------------------------------------------------------
    4425 data.Type='volume';
    4426 data.ProjMode='interp';%default
    4427 % set(handles.create,'Visible','on')
    4428 % set(handles.create,'Value',1)
    4429 % VOLUME_Callback(hObject,eventdata,handles)
    4430 create_object(data,handles)
    4431 
    4432 %------------------------------------------------------------------------
    4433 function MenuBrowseObject_Callback(hObject, eventdata, handles)
    4434 %------------------------------------------------------------------------
    4435 %get the object file
    4436 [FileName, PathName, filterindex] = uigetfile( ...
    4437        {'*.xml;*.mat', ' (*.xml,*.mat)';
    4438        '*.xml',  '.xml files '; ...
    4439         '*.mat',  '.mat matlab files '}, ...
    4440         'Pick an xml Object file',get(handles.RootPath,'String'));
    4441 fileinput=[PathName FileName];%complete file name
    4442 sizf=size(fileinput);
    4443 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
    4444 
    4445 %read the file
    4446 data=xml2struct(fileinput);
    4447 data.enable_plot=1;
    4448 [tild,data.Name]=fileparts(FileName);
    4449 hset_object=findobj(allchild(0),'tag','set_object');
    4450 if ~isempty(hset_object)
    4451     delete(hset_object)% delete existing version of set_object
    4452 end
    4453 set_object(data);% call the set_object interface
    4454 set(handles.edit_object,'Value',0); %suppress the object edit mode
    4455 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    4456 set(handles.MenuObject,'checked','on')
    4457 set(handles.delete_object,'Visible','on')
    4458 
    4459 %------------------------------------------------------------------------
    4460 % --- generic function used for the creation of a projection object
    4461 function create_object(data,handles)
    4462 %------------------------------------------------------------------------
    4463 hset_object=findobj(allchild(0),'tag','set_object');
    4464 if ~isempty(hset_object)
    4465     delete(hset_object)% delete existing version of set_object
    4466 end
    4467 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
    4468 if ishandle(hgeometry_calib)
    4469     hhgeometry_calib=guidata(hgeometry_calib);
    4470     set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
    4471     set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
    4472 end
    4473 UvData=get(handles.uvmat,'UserData');
    4474 set(handles.edit_object,'Value',0); %suppress the object edit mode
    4475 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    4476 data.enable_plot=1;
    4477 data.Coord=[0 0]; %default
    4478 if isfield(UvData,'Field')
    4479     Field=UvData.Field;
    4480     if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
    4481         ord=10^(floor(log10(Field.Mesh)));%order of magnitude
    4482         if Field.Mesh/ord>=5
    4483             mesh=5*ord;
    4484         elseif Field.Mesh/ord>=2
    4485             mesh=2*ord;
    4486         else
    4487             mesh=ord;
    4488         end
    4489         data.RangeX=mesh;
    4490         data.RangeY=mesh;
    4491         data.DX=mesh;
    4492         data.DY=mesh;
    4493     elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
    4494         np=size(Field.A);
    4495         meshx=(Field.AX(end)-Field.AX(1))/np(2);
    4496         meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
    4497         data.RangeY=max(meshx,meshy);
    4498         data.RangeX=max(meshx,meshy);
    4499         data.DX=max(meshx,meshy);
    4500     end
    4501     if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
    4502          data.Coord=[0 0 0]; %default
    4503     end
    4504     if isfield(Field,'CoordUnit')
    4505         data.CoordUnit=Field.CoordUnit;
    4506     end
    4507 end
    4508 if ishandle(handles.UVMAT_title)
    4509     delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
    4510 end
    4511 set_object(data,handles);% call the set_object interface
    4512 set(handles.MenuObject,'checked','on')
    4513 set(handles.uvmat,'UserData',UvData)
    4514 set(handles.CheckZoom,'Value',0)
    4515 CheckZoom_Callback(handles.uvmat, [], handles)
    4516 set(handles.delete_object,'Visible','on')
    4517 
    4518 %------------------------------------------------------------------------
    4519 function MenuRuler_Callback(hObject, eventdata, handles)
    4520 %------------------------------------------------------------------------
    4521 set(handles.CheckZoom,'Value',0)
    4522 CheckZoom_Callback(handles.uvmat, [], handles)
    4523 set(handles.MenuRuler,'checked','on')
    4524 UvData=get(handles.uvmat,'UserData');
    4525 UvData.MouseAction='ruler';
    4526 set(handles.uvmat,'UserData',UvData);
    4527 
    4528 %------------------------------------------------------------------------
    4529 % --- executed when closing: set the parent interface button to value 0
    4530 function closefcn(gcbo,eventdata)
    4531 %------------------------------------------------------------------------
    4532 %delete all the associated figures if exist
    4533 hh=findobj(allchild(0),'tag','view_field');
    4534 if ~isempty(hh)
    4535     delete(hh)
    4536 end
    4537 hh=findobj(allchild(0),'tag','geometry_calib');
    4538 if ~isempty(hh)
    4539     delete(hh)
    4540 end
    4541 hh=findobj(allchild(0),'tag','set_object');
    4542 if ~isempty(hh)
    4543     hhh=findobj(hh,'tag','PLOT');
    4544     set(hhh,'enable','off')
    4545 end
    4546 
    4547 %------------------------------------------------------------------------
    4548 % --- Executes on button press in delete_object.
    4549 function delete_object_Callback(hObject, eventdata, handles)
    4550 %------------------------------------------------------------------------
    4551 IndexObj=get(handles.ListObject,'Value');
    4552 if IndexObj(end)>1
    4553     delete_object(IndexObj(end))
    4554 end
    4555 
    4556 % --- Executes on button press in FixVelType.
    4557 function FixVelType_Callback(hObject, eventdata, handles)
    4558 val=get(handles.FixVelType,'Value');
    4559 if ~val
    4560     run0_Callback(hObject, eventdata, handles)
    4561 end
    4562 
    4563 %------------------------------------------------------------------------
    4564 % --- Executes on button press in ViewObject.
    4565 function ViewObject_Callback(hObject, eventdata, handles)
    4566 %------------------------------------------------------------------------
    4567 IndexObj=get(handles.ListObject,'Value');
    4568 IndexObj=IndexObj(end); %keeps only the secodn value
    4569 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    4570 if numel(UvData.Object)<IndexObj;% error in UvData
    4571     msgbox_uvmat('ERROR','invalid object list')
    4572     return
    4573 end
    4574 ObjectData=UvData.Object{IndexObj};
    4575 ZBounds=0; % default
    4576 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
    4577     ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
    4578     ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    4579 end
    4580 hset_object=findobj(allchild(0),'tag','set_object');
    4581 if ~isempty(hset_object)
    4582     delete(hset_object)% delete existing version of set_object
    4583 end
    4584 if ~isfield(ObjectData,'Type')% default plane
    4585     ObjectData.Type='plane';
    4586 end
    4587 hset_object=set_object(ObjectData,[],ZBounds);
    4588 if get(handles.edit_object,'Value')% edit mode
    4589     hhset_object=guidata(hset_object);
    4590     set(hhset_object.PLOT,'Enable','on')
    4591 end
    4592 
    4593 
    4594 function NomType_Callback(hObject, eventdata, handles)
    4595 
    4596 
    4597 function NomType_1_Callback(hObject, eventdata, handles)
    4598 
     4655% --------------------------------------------------------------------
     4656function MenuHelp_Callback(hObject, eventdata, handles)
     4657% --------------------------------------------------------------------
     4658path_to_uvmat=which ('uvmat');% check the path of uvmat
     4659pathelp=fileparts(path_to_uvmat);
     4660helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
     4661if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
     4662else
     4663    addpath (fullfile(pathelp,'uvmat_doc'))
     4664    web(helpfile);
     4665end
     4666
     4667
     4668
     4669
  • trunk/src/view_field.m

    r387 r402  
    102102write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
    103103
    104 %-------------------------------------------------------------------
     104%------------------------------------------------------------------------
    105105% --- Outputs from this function are returned to the command menuline.
    106106function varargout = view_field_OutputFcn(hObject, eventdata, handles)
     107%------------------------------------------------------------------------
    107108varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
    108109
     110%------------------------------------------------------------------------
     111%--- activated when closing the GUI view_field
     112function closefcn(gcbo,eventdata)
     113%------------------------------------------------------------------------
     114huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle
     115if ~isempty(huvmat)
     116    hhuvmat=guidata(huvmat);
     117    set(hhuvmat.edit_object,'Value',0)
     118    set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
     119    % deselect the object in ListObject when view_field is closed
     120    if isempty(findobj(allchild(0),'Tag','set_object'))
     121        ObjIndex=get(hhuvmat.ListObject,'Value');
     122        ObjIndex=ObjIndex(1);%keep only the first object selected
     123        set(hhuvmat.ListObject,'Value',ObjIndex)
     124        % draw all object colors in blue (unselected) in uvmat
     125        hother=[findobj(hhuvmat.axes3,'Tag','proj_object');findobj(hhuvmat.axes3,'Tag','DeformPoint')];%find all the proj object and deform point representations
     126        for iobj=1:length(hother)
     127            if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
     128                set(hother(iobj),'EdgeColor','b')
     129                if isequal(get(hother(iobj),'FaceColor'),'m')
     130                    set(hother(iobj),'FaceColor','b')
     131                end
     132            elseif isequal(get(hother(iobj),'Type'),'image')
     133                Acolor=get(hother(iobj),'CData');
     134                Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
     135                set(hother(iobj),'CData',Acolor);
     136            else
     137                set(hother(iobj),'Color','b')
     138            end
     139            set(hother(iobj),'Selected','off')
     140        end
     141    end
     142end
    109143
    110144%-------------------------------------------------------------------
     
    733767colorbar
    734768
    735 %------------------------------------------------------------------------
    736 function closefcn(hObject, eventdata, handles)
    737 %------------------------------------------------------------------------
    738 huvmat=findobj(allchild(0),'Name','uvmat');
    739 if ~isempty(huvmat)
    740 hhuvmat=guidata(huvmat);
    741 % list_object_2=get(hhuvmat.list_object_2,'String');
    742 % set(hhuvmat.list_object_2,'Value',1)%select the last value ('...')
    743 end
    744 delete(hObject)
    745 
     769
Note: See TracChangeset for help on using the changeset viewer.