Changeset 99


Ignore:
Timestamp:
Jun 8, 2010, 5:43:33 PM (11 years ago)
Author:
sommeria
Message:

plot_field.m, update_obj.m do not change figure names
view_field.m,uvmat.m cleaning code

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r94 r99  
    141141if testnewfig% create a new figure and axes if the plotting axes does not exist
    142142    hfig=figure;
    143     if isfield(Data,'IndexObj') && isfield(Data,'Style') && isfield(Data,'ProjMode')
    144         figname=[num2str(Data.IndexObj) '-' Data.Style];
    145         set(hfig,'Name',figname)
    146     end
     143%     if isfield(Data,'IndexObj') && isfield(Data,'Style') && isfield(Data,'ProjMode')
     144%         figname=[num2str(Data.IndexObj) '-' Data.Style];
     145%         set(hfig,'Name',figname)
     146%     end
    147147%     testhandle=0;
    148148    if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
  • trunk/src/update_obj.m

    r82 r99  
    7676%         [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
    7777    Object_out.plotaxes=plotaxes;
    78     plotfig=get(plotaxes,'parent');
    79     name_str=get(plotfig,'Name');
    80     if ~isequal(name_str,'uvmat')
    81         set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]);
    82     end
     78%     plotfig=get(plotaxes,'parent');
     79%     name_str=get(plotfig,'Name');
     80%     if ~isequal(name_str,'uvmat')
     81%         set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]);
     82%     end
    8383end
    8484
  • trunk/src/uvmat.m

    r98 r99  
    173173function varargout = uvmat(varargin)
    174174
    175 
    176175% Begin initialization code - DO NOT EDIT
    177176gui_Singleton = 1;
     
    43394338end
    43404339hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
    4341 set(hset_object,'name',ObjectName)
     4340%set(hset_object,'name',ObjectName)
    43424341
    43434342% %project the current field on the object and plot it
     
    49564955[pp,data.Name]=fileparts(FileName);
    49574956%PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4958 hset_object=findobj(allchild(0),'Name','set_object');
     4957hset_object=findobj(allchild(0),'tag','set_object');
    49594958if ~isempty(hset_object)
    49604959    delete(hset_object)% delete existing version of set_object
     
    50525051    delete(hh)
    50535052end
    5054 hh=findobj(allchild(0),'name','geometry_calib');
     5053hh=findobj(allchild(0),'tag','geometry_calib');
    50555054if ~isempty(hh)
    50565055    delete(hh)
  • trunk/src/view_field.m

    r87 r99  
    250250set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    251251
    252 %-------------------------------------------------------------------
    253 function STOP_Callback(hObject, eventdata, handles)
    254 %-------------------------------------------------------------------
    255 set(handles.movie_pair,'BusyAction','Cancel')
    256 set(handles.movie_pair,'value',0)
    257 set(handles.RunMovie,'BusyAction','Cancel')
    258 set(handles.MenuExportMovie,'BusyAction','Cancel')
    259 
    260 
    261 %------------------------------------------------------------------
    262 function runpm(hObject,eventdata,handles,increment)
    263 %------------------------------------------------------------------
    264 %check for mùovie pair status
    265 movie_status=get(handles.movie_pair,'Value');
    266 if isequal(movie_status,1)
    267     STOP_Callback(hObject, eventdata, handles)
    268 end
    269 %read the data on the current input rootfile(s)
    270 
    271 [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
    272 NomType=get(handles.FileIndex,'UserData');
    273 
    274 num1=stra2num(get(handles.i1,'String'));
    275 num2=stra2num(get(handles.i2,'String'));
    276 num_a=stra2num(get(handles.j1,'String'));
    277 num_b=stra2num(get(handles.j2,'String'));
    278 
    279 sub_value= get(handles.SubField,'Value');
    280 if sub_value ==1
    281     [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
    282 end   
    283 
    284 comp_input=get(handles.fix_pair,'Value');
    285 if isequal(NomType,'_i1-i2')|isequal(NomType,'_i1-i2_j')
    286     comp_input=1; %impose a fixed pair interval
    287     set(handles.fix_pair,'Value',1)
    288 end
    289 
    290 %case of scanning along the first direction (rootfile numbers)
    291 if get(handles.scan_i,'Value')==1% case of scanning along field numbers   
    292      num1=num1+increment;
    293      num2=num2+increment;
    294     if comp_input==0% find a free pair
    295         [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out]=...
    296            name_generator(filebase,num1,num_a,FileExt,NomType,0,num2,num_b,subdir);
    297         if exist(filename,'file')
    298             num_a=num_j1_out;
    299             num_b=num_j2_out;
    300         end
    301     end
    302     if sub_value>=2
    303         num_i1=num_i1+increment;
    304         num_i2=num_i2+increment;
    305     end   
    306 else % case of scanning along the second direction (burst numbers)
    307     lastfield_cell=get(handles.last_j,'String'); % get the last field number
    308     lastfield=str2num(lastfield_cell{1});
    309     num_a=num_a+increment;
    310     num_b=num_b+increment;
    311     if sub_value >=2
    312       num_j1=num_j1+increment;
    313       num_j2=num_j2+increment;
    314     elseif ~isempty(lastfield) && num_a>lastfield
    315         num_a=1;
    316         num1=num1+1;
    317         num2=num2+1;
    318     end
    319 end
    320 
    321 % display the new open numbers
    322 set(handles.i1,'String',num2stra(num1,NomType,1));
    323 set(handles.i2,'String',num2stra(num2,NomType,1));
    324 set(handles.j1,'String',num2stra(num_a,NomType,2));
    325 set(handles.j2,'String',num2stra(num_b,NomType,2));
    326 [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
    327 set(handles.FileIndex,'String',indices);
    328 if sub_value ==1
    329     NomType_1=get(handles.FileIndex_1,'UserData');
    330      [indices]=...
    331            name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
    332      set(handles.FileIndex_1,'String',indices);
    333 end
    334 
    335 if isequal(movie_status,1)
    336     set(handles.movie_pair,'Value',1)
    337     movie_pair_Callback(hObject, eventdata, handles); %run
    338 else
    339 % refresh plots
    340     run0_Callback(hObject, eventdata, handles); %run
    341 end
    342 
    343 
    344 %-------------------------------------------------------
    345 % --- Executes on button press in movie_pair: create an alternating movie with two view
    346 %-------------------------------------------------------
    347 function movie_pair_Callback(hObject, eventdata, handles)
    348 status=get(handles.movie_pair,'value');
    349 if isequal(status,0)
    350     set(handles.movie_pair,'BusyAction','Cancel')
    351     return
    352 else
    353     set(handles.movie_pair,'BusyAction','queue')
    354 end
    355 %initialisation
    356 set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
    357 drawnow
    358 list_fields=get(handles.Fields,'String');% list menu fields
    359 index_fields=get(handles.Fields,'Value');% selected string index
    360 FieldName=list_fields{index_fields}; % selected field
    361 if isequal(FieldName,'image')
    362     run0_Callback(hObject, eventdata, handles)%display the first image
    363     UvData=get(handles.view_field,'UserData');
    364 else
    365     msgbox_view_field('ERROR','an image or movie must be first introduced as input')
    366     return
    367 end
    368 [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
    369 NomType=get(handles.FileIndex,'UserData');
    370 num_i1=stra2num(get(handles.i1,'String'));
    371 num_j1=stra2num(get(handles.j1,'String'));
    372 num_i2=stra2num(get(handles.i2,'String'));
    373 num_j2=stra2num(get(handles.j2,'String'));
    374 if isempty(num_j2)
    375     if isempty(num_i2)   
    376         msgbox_view_field('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
    377         return
    378     else
    379         num_j2=num_j1;%repeat the index i1 by default
    380     end
    381 end
    382 if isempty(num_i2)
    383     num_i2=num_i1;%repeat the index i1 by default
    384 end
    385 imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
    386 if ~exist(imaname_1,'file')
    387       msgbox_view_field('ERROR',['second input open (-)  ' imaname_1 ' not found']);
    388       return
    389 end
    390 % set(handles.i2,'String',''); % indicates that the second index i2 is not used
    391 % set(handles.j2,'String',''); % indicates that the second index i2 is not used
    392 
    393 %read the second image
    394 Field.AName='image';
    395 Field.AX=UvData.Field.AX;
    396 Field.AY=UvData.Field.AY;
    397 % z index
    398 nbslice=str2double(get(handles.nb_slice,'String'));
    399 if ~isempty(nbslice)
    400     Field.ZIndex=mod(num_i2-1,nbslice)+1;
    401 end
    402 Field.CoordType='px';
    403 %determine the input file type
    404 if isfield(UvData,'MovieObject')
    405     FileType='movie';
    406 elseif isequal(lower(Ext),'.avi')
    407     FileType='avi';
    408 elseif isequal(lower(Ext),'.vol')
    409     FileType='vol';
    410 else
    411    form=imformats(Ext([2:end]));
    412    if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    413        if isequal(NomType,'*');
    414            FileType='multimage';
    415        else
    416            FileType='image';
    417        end
    418    end
    419 end
    420 switch FileType
    421         case 'movie'
    422             Field.A=read(UvData.MovieObject,num_i2);
    423         case 'avi'
    424             mov=aviread(imaname_1,num_i2);
    425             Field.A=frame2im(mov(1));
    426         case 'vol'
    427             Field.A=imread(imaname_1);
    428         case 'multimage'
    429             Field.A=imread(imaname_1,num_i2);
    430         case 'image'
    431             Field.A=imread(imaname_1);
    432 end
    433 
    434 %px to phys or other transform on field
    435 menu_transform=get(handles.transform_fct,'String');
    436 choice_value=get(handles.transform_fct,'Value');
    437 transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
    438 transform_list=get(handles.transform_fct,'UserData');
    439 transform=transform_list{choice_value};
    440 if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
    441     if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
    442         Field=transform(Field,UvData.XmlData);
    443     end
    444 end
    445 
    446  % make movie until movie speed is set to 0 or STOP is activated
    447 hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
    448 set(handles.STOP,'Visible','on')
    449 set(handles.speed,'Visible','on')
    450 set(handles.speed_txt,'Visible','on')
    451 while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
    452     % read and plot the series of images in non erase mode
    453     set(hima,'CData',Field.A);
    454     pause(1.02-get(handles.speed,'Value'));% wait for next image
    455     set(hima,'CData',UvData.Field.A);
    456     pause(1.02-get(handles.speed,'Value'));% wait for next image
    457 end
    458 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    459 
    460 %-------------------------------------------------------
    461 % --- Executes on button press in run0.
    462 %-------------------------------------------------
    463 function run0_Callback(hObject, eventdata, handles)
    464 
    465 %initialisation
    466 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    467 drawnow
    468 abstime=[];
    469 abstime_1=[];
    470 dt=[];
    471 Field={};
    472 UvData=get(handles.view_field,'UserData');
    473 if isfield(UvData,'Txt')
    474     UvData=rmfield(UvData,'Txt');%erase previous error message
    475 end
    476 %set(handles.run0,'BusyAction','queue');
    477 if ishandle(handles.VIEW_FIELD_title) %remove title panel on view_field
    478     delete(handles.VIEW_FIELD_title)
    479 end
    480 
    481 % determine the main input file information for action
    482 TestInputFile=1;%default
    483 if isfield(UvData,'TestInputFile')&& isequal(UvData.TestInputFile,0),
    484     TestInputFile=0;
    485 end
    486 num_i1=[];%default
    487 FileType=[];%default
    488 if TestInputFile
    489     [filename,RootPath,filebase,xx,Ext]=read_file_boxes(handles);
    490     if ~exist(filename,'file')
    491         msgbox_view_field('ERROR',['input file ' filename ' does not exist'])
    492         return
    493     end
    494     num_i1=stra2num(get(handles.i1,'String'));
    495     num_i2=stra2num(get(handles.i2,'String'));
    496     num_j1=stra2num(get(handles.j1,'String'));
    497     num_j2=stra2num(get(handles.j2,'String'));
    498     NomType=get(handles.FileIndex,'UserData');
    499     %update the z position index
    500     nbslice=str2double(get(handles.nb_slice,'String'));
    501     if ~isnan(nbslice)
    502         z_index=mod(num_i1-1,nbslice)+1;
    503         set(handles.z_index,'String',num2str(z_index))
    504         % refresh menu for save_mask if relevant
    505         masknumber=get(handles.masklevel,'String');
    506         if length(masknumber)>=z_index
    507             set(handles.masklevel,'Value',z_index)
    508         end
    509     end
    510     % determine the input file type
    511     if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
    512         FileType='netcdf';
    513     elseif isfield(UvData,'MovieObject')
    514         FileType='movie';
    515         FieldName='image';
    516     elseif isequal(lower(Ext),'.avi')
    517         FileType='avi';
    518         FieldName='image';
    519     elseif isequal(lower(Ext),'.vol')
    520         FileType='vol';
    521         FieldName='image';
    522     else
    523        form=imformats(Ext([2:end]));
    524        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    525            if isequal(NomType,'*');
    526                FileType='multimage';
    527            else
    528                FileType='image';
    529            end
    530            FieldName='image';
    531        end
    532     end
    533 else
    534     filename=[];
    535     FileType='netcdf';
    536     FieldName='get_field...';
    537 end
    538 VelType=[];%default
    539 if isequal(FileType,'netcdf')
    540     list_fields=get(handles.Fields,'String');% list menu fields
    541     index_fields=get(handles.Fields,'Value');% selected string index
    542     FieldName= list_fields{index_fields}; % selected field
    543     if isequal(FieldName,'get_field...')% read the field names on the interface get_field...
    544         VelType=get(handles.Fields,'UserData');
    545         Field{1}=get(handles.Fields,'UserData');
    546     else
    547        VelType=setfield(handles);
    548     end
    549 end
    550 
    551 % choose a second field if Subfield option is 'on'
    552 filename_1=[];
    553 FieldName_1=[];
    554 scal_color=[];
    555 VelType_1=setfield_1(handles);
    556 sub_value=get(handles.SubField,'Value');
    557 FileType_1='none';%default
    558 if sub_value==1
    559     filename_1=read_file_boxes_1(handles);
    560     if ~exist(filename_1,'file')
    561         msgbox_view_field('ERROR',['second file ' filename_1 ' does not exist'])
    562         return
    563     end
    564     NomType_1=get(handles.FileIndex_1,'UserData');
    565     Ext_1=get(handles.FileExt_1,'String');
    566     % determine the input file type
    567     if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
    568         FileType_1='netcdf';
    569     elseif isfield(UvData,'MovieObject_1')
    570         FileType_1='movie';
    571         FieldName_1='image';
    572     elseif isequal(lower(Ext_1),'.avi')
    573         FileType='avi';
    574         FieldName_1='image';
    575     elseif isequal(lower(Ext_1),'.vol')
    576         FileType_1='vol';
    577         FieldName_1='image';
    578     else
    579        form=imformats(Ext([2:end]));
    580        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    581            if isequal(NomType_1,'*');
    582                FileType_1='multimage';
    583            else
    584                FileType_1='image';
    585            end
    586            FieldName_1='image';
    587        end
    588     end
    589     if ~isequal(FieldName_1,'image')
    590         list_fields=get(handles.Fields_1,'String');% list menu fields
    591         index_fields=get(handles.Fields_1,'Value');% selected string index
    592         FieldName_1= list_fields{index_fields}; % selected field
    593         if isequal(VelType_1,'*')% free veltype choice
    594             VelType_1=[];
    595         elseif isequal(VelType_1,'"')% veltype the same as for the first field
    596             if isempty(VelType)
    597                 VelType_1=[];
    598             else
    599                 VelType_1=VelType;
    600             end
    601         end
    602     end
    603 end
    604 
    605 % test for keeping the previous stored data if the input files are unchanged
    606 test_keepdata_1=0;%defautl
    607 test_keepdata=0;
    608 if sub_value>=2
    609     if ~isequal(NomType_1,'*')%in cas of a series of files (not avi movie)
    610         if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
    611             test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
    612                 isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
    613 
    614         end
    615     end
    616 end
    617 
    618 %read the input field(s)
    619 
    620 %read images
    621 if ~isempty(filename) && isequal(FieldName,'image')
    622      switch FileType
    623         case 'movie'
    624             A=read(UvData.MovieObject,num_i1);
    625         case 'avi'
    626             mov=aviread(filename,num_i1);
    627             A=frame2im(mov(1));
    628         case 'vol'
    629             A=imread(filename);
    630         case 'multimage'
    631             A=imread(filename,num_i1);
    632         case 'image'
    633             A=imread(filename);
    634     end
    635     npxy=size(A);
    636     set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
    637     set(handles.npy,'String',num2str(npxy(1)));
    638     Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    639     Rangy=[npxy(1)-0.5 0.5]; %
    640     Field{1}.AName='image';
    641     Field{1}.ListVarName={'AY','AX','A'}; %
    642     if size(A,3)==3;%color
    643         Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
    644     else
    645         Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
    646     end
    647     Field{1}.AY=Rangy;
    648     Field{1}.AX=Rangx;
    649     Field{1}.A=A;
    650     Field{1}.CoordType='px'; %used for mouse_motion
    651     Field{1}.CoordUnit='pixel'; %used for mouse_motion
    652 end
    653 
    654 %read a second image
    655 if ~isfield(UvData,'Txt')&& ~isempty(filename_1) && isequal(FieldName_1,'image')
    656     switch FileType_1
    657         case 'movie'
    658             A=read(UvData.MovieObject_1,num_i1);
    659         case 'avi'
    660             mov=aviread(filename,num_i1);
    661             A=frame2im(mov(1));
    662         case 'vol'
    663             A=imread(filename);
    664         case 'multimage'
    665             A=imread(filename,num_i1);
    666         case 'image'
    667             A=imread(filename);
    668     end
    669     npxy=size(A);
    670     set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
    671     set(handles.npy,'String',num2str(npxy(1)));
    672     Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    673     Rangy=[npxy(1)-0.5 0.5]; %
    674     Field{2}.AName='image';
    675     Field{2}.ListVarName={'AY','AX','A'}; %
    676     if size(A,3)==3;%color
    677         Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
    678     else
    679         Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
    680     end
    681     Field{2}.AY=Rangy;
    682     Field{2}.AX=Rangx;
    683     Field{2}.A=A;
    684     Field{2}.CoordType='px'; %used for mouse_motion
    685     Field{2}.CoordUnit='px'; %used for move_mou
    686 end
    687 
    688 %read ncfile(s)
    689 CivStage_1=0;%default
    690 VelType_out_1=[];
    691 InputField={FieldName};
    692 InputField_1={FieldName_1};
    693 if ~isfield(UvData,'Txt') && ((~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType,'netcdf'))) ;
    694     %read the velocity field(s) from netcdf rootfile(s)
    695     list_code=get(handles.col_vec,'String');% list menu fields
    696     index_code=get(handles.col_vec,'Value');% selected string index
    697     scal_color= list_code{index_code(1)}; % selected field
    698     if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
    699         InputField=[InputField scal_color];
    700     end
    701     if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
    702         InputField_1=[InputField_1 scal_color];
    703     end
    704     if isequal(FileType,'netcdf')  %read the first nc field
    705         if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
    706             VelType=get(handles.Fields,'UserData');
    707             hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
    708             if isempty(hget_field)
    709                 hget_field= get_field(filename);%open the get_field GUI   
    710             end
    711             hhget_field=guidata(hget_field);
    712             set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
    713             set(hhget_field.ACTION,'Value',1)% PLOT option selected
    714             set(hhget_field.list_fig,'Value',2)% plotting axes =view_field selected
    715             [Field{1},errormsg]=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
    716             if ~isempty(errormsg)
    717                 msgbox_view_field('ERROR',['error in view_field/run0_Callback/read_get_field: ' errormsg])
    718                 return
    719             end
    720             CivStage=0;
    721             VelType_out=[];         
    722         else
    723             [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
    724             if isfield(Field{1},'Txt')
    725                 msgbox_view_field('ERROR',Field{1}.Txt)
    726                 return
    727             end
    728             CivStage=Field{1}.CivStage;
    729             UvData.NbDim=Field{1}.nb_dim;
    730         end
    731     end
    732     if ~isempty(filename_1) && isequal(FileType_1,'netcdf') %read the second file
    733         if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
    734             hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
    735              if isempty(hget_field)
    736                  hget_field= get_field(filename_1);%open the get_field GUI
    737                  set(hget_field,'name','get_field_1')
    738 %                 enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
    739              end
    740             hhget_field=guidata(hget_field);%handles of GUI elements in get_field
    741             SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
    742             [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data               
    743             Field{2}.VarAttribute=SubField.VarAttribute;
    744             %update the display on get_field
    745             set(hhget_field.inputfile,'String',filename_1)
    746             set(hhget_field.variables,'Value',1)
    747             Tabchar={''};%default
    748             Tabcell=[];
    749             if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
    750                 for iline=1:length(Field{2}.ListGlobalAttribute)
    751                     Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
    752                     if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
    753                         eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
    754                         if ischar(val);
    755                             Tabcell{iline,2}=val;
    756                         else
    757                             Tabcell{iline,2}=num2str(val);
    758                         end
    759                     end
    760                 end
    761                 if ~isempty(Tabcell)
    762                     Tabchar=cell2tab(Tabcell,'=');
    763                     Tabchar=[{''};Tabchar];
    764                 end
    765             end
    766             set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
    767         else
    768             [Field{2},VelType_out_1]=read_civxdata(filename_1,[],VelType_1);
    769             CivStage_1=Field{2}.CivStage;
    770         end
    771         if ~isequal(FileType,'netcdf')
    772             VelType_out=VelType_out_1;
    773         end
    774     end
    775 end
    776 
    777 %update the display buttons for the first velocity type (first menuline)
    778 veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    779 if ~isequal(FileType,'netcdf')
    780     reset_vel_type(veltype_handles)
    781 elseif isempty(VelType)
    782     set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
    783     if isempty(VelType_out)
    784         reset_vel_type(veltype_handles)
    785     else
    786         handle1=eval(['handles.' VelType_out]);
    787         reset_vel_type(veltype_handles,handle1)
    788     end
    789 end
    790 
    791 %update the display buttons for the second velocity type (second menuline)
    792 veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    793 if ~isequal(FileType_1,'netcdf')
    794     reset_vel_type(veltype_handles_1)
    795 elseif isempty(VelType_1)
    796     set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
    797     if isempty(VelType_out_1)
    798         reset_vel_type(veltype_handles_1)
    799     else
    800         handle1=eval(['handles.' VelType_out_1 '_1']);
    801         reset_vel_type(veltype_handles_1,handle1)
    802     end
    803 end
    804 
    805 %introduce w as background image by default for a new series (only for nbdim=2)
    806 if ~isfield(UvData,'NewSeries')
    807     UvData.NewSeries=1;
    808 end
    809 %put W as background image by default if NbDim=2:
    810 if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
    811     if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
    812         set(handles.SubField,'Value',1);
    813         %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
    814         set(handles.RootPath_1,'String','"')
    815         set(handles.RootFile_1,'String','"')
    816         set(handles.SubDir_1,'String','"');
    817         [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
    818         set(handles.FileIndex_1,'String',indices)
    819         set(handles.FileExt_1,'String','"');
    820         set(handles.Fields_1,'Visible','on');
    821         set(handles.Fields_1,'Visible','on');
    822         set(handles.RootPath_1,'Visible','on')
    823         set(handles.RootFile_1,'Visible','on')
    824         set(handles.SubDir_1,'Visible','on');
    825         set(handles.FileIndex_1,'Visible','on');
    826         set(handles.FileExt_1,'Visible','on');
    827         set(handles.Fields_1,'Visible','on');
    828         Field{1}.AName='w';
    829         testscal=1;
    830     end
    831 end           
    832 
    833 %multislice case
    834 if TestInputFile &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
    835       isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
    836 %     nbfield2=str2num(get(handles.last_j,'String'));
    837        siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
    838        if siz(1)>1
    839            NbSlice=siz(1);
    840            set(handles.slices,'Visible','on')
    841            set(handles.slices,'Value',1)
    842        else
    843            NbSlice=1;
    844        end
    845        set(handles.nb_slice,'String',num2str(NbSlice))
    846        slices_Callback(hObject, eventdata, handles)
    847 %        Coord=UvData.XmlData.GeometryCalib.SliceCoord;
    848 %        ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
    849 %        Field{1}.Z=ZIndex;
    850 end
    851 
    852 %store the current open names, fields and vel types in view_field interface
    853 UvData.filename=filename;
    854 UvData.filename_1=filename_1;
    855 UvData.VelType=VelType;
    856 UvData.VelType_1=VelType_1;
    857 UvData.FieldName=FieldName;
    858 UvData.FieldName_1=FieldName_1;
    859 if ~isempty(scal_color)
    860     UvData.CName=scal_color;
    861 end
    862 
    863 %coordinate transform or user fct
    864 XmlData=[];%default
    865 if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
    866     XmlData=UvData.XmlData;
    867 end
    868 XmlData_1=[];%default
    869 if isfield(UvData,'XmlData_1')
    870    XmlData_1=UvData.XmlData_1;
    871 end
    872 menu_transform=get(handles.transform_fct,'String');
    873 choice_value=get(handles.transform_fct,'Value');
    874 %transform=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
    875 transform_list=get(handles.transform_fct,'UserData');
    876 transform=transform_list{choice_value};%selected function handles
    877 
    878 % z index
    879 if TestInputFile
    880     Field{1}.ZIndex=mod(num_i1-1,nbslice)+1;
    881 end
    882 %px to phys or other transform on field
    883 if  ~isempty(transform)
    884     if length(Field)>=2
    885         Field{2}.ZIndex=mod(num_i1-1,nbslice)+1;
    886         [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
    887         if isempty(Field{2})
    888             Field(2)=[];
    889         end
    890     else
    891         Field{1}=transform(Field{1},XmlData);
    892     end
    893 end
    894 
    895 %calculate scalar
    896 if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
    897     Field{1}=calc_field(InputField,Field{1});
    898 end
    899 if length(Field)==2 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
    900     Field{2}=calc_field(InputField_1,Field{2});
    901 end
    902 
    903 % combine the two input fields (e.g. substract velocity fields)
    904 if numel(Field)==2
    905     if ~(isequal(get(handles.movie_pair,'Value'),1) && isequal(FieldName,'image') && isequal(FieldName_1,'image')) %combine fields if not viewing image pairs
    906         UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
    907     end
    908 else
    909    UvData.Field=Field{1};
    910 end
    911 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
    912 % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
    913 test_x=0;
    914 test_z=0;% test for unstructured z coordinate
    915 UvData.ZMax=0;
    916 UvData.ZMin=0;%default
    917 UvData.Mesh=1; %default
    918 [UvData.Field,errormsg]=check_field_structure(UvData.Field);
    919 if ~isempty(errormsg)
    920     msgbox_view_field('ERROR',['error in view_field/run0_Callback/check_field_structure: ' errormsg])
    921     return
    922 end
    923 [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
    924 [NbDim,imax]=max(NbDim);
    925 if isempty(imax)
    926 %    DimVarIndex=0;   
    927     coord_x=[];
    928 else
    929 %     VarIndex=CellVarIndex{imax};
    930     coord_x=VarType{imax}.coord_x;
    931 end
    932 if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
    933     NbDim=UvData.NbDim;
    934 else 
    935     UvData.NbDim=NbDim;
    936 end
    937 if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinate z
    938     XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
    939     YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
    940     test_x=1;
    941 elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
    942     XName='X';
    943     YName='Y';
    944     test_x=1;
    945 end
    946 if test_x
    947     eval(['UvData.XMax=max(UvData.Field.' XName ');'])
    948     eval(['UvData.XMin=min(UvData.Field.' XName ');'])
    949     eval(['UvData.YMax=max(UvData.Field.' YName ');'])
    950     eval(['UvData.YMin=min(UvData.Field.' YName ');'])
    951     eval(['nbvec=length(UvData.Field.' XName ');'])
    952     if NbDim==3%
    953         if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
    954             ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
    955             eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
    956             eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
    957             test_z=1;   
    958         elseif isfield(UvData,'Z')% usual civ data
    959             UvData.ZMax=max(UvData.Z);
    960             UvData.ZMin=min(UvData.Z);
    961             test_z=1;
    962         end
    963     end
    964     if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
    965         NbDim=2;
    966         test_z=0;
    967     end   
    968     if test_z
    969          UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
    970          UvData.Mesh=(UvData.Mesh)^(1/3);
    971     else
    972         UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
    973     end
    974 end
    975 %case of structured coordinates
    976 if isfield(UvData.Field,'AX') & isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')
    977     UvData.XMax=max(UvData.Field.AX);
    978     UvData.XMin=min(UvData.Field.AX);
    979     UvData.YMax=max(UvData.Field.AY);
    980     UvData.YMin=min(UvData.Field.AY);
    981     np_A=size(UvData.Field.A);
    982     UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
    983 end
    984 if  isempty(coord_x)&~isempty(CellVarIndex)
    985     VarIndex=CellVarIndex{imax}; % list of variable indices
    986     DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    987     if NbDim==3
    988         nbpoints=UvData.Field.DimValue(DimIndex(1));
    989         %Zvar=DimVarIndex(DimIndex(1));
    990          %Zvar=DimVarIndex(1);
    991          Zvar=VarType{imax}.coord_3;
    992         if Zvar~=0 % z is a dimension variable
    993             ZName=UvData.Field.ListVarName{Zvar};
    994             eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
    995             eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
    996         else
    997             testcoord_z=0;
    998             if length(UvData.Field.VarAttribute)>=VarIndex(1)
    999                 if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
    1000                     Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
    1001                     UvData.ZMax=max(Coord_z);
    1002                     UvData.ZMin=min(Coord_z);
    1003                     testcoord_z=1;
    1004                 end
    1005             end
    1006             if ~testcoord_z
    1007                   UvData.ZMin=1;
    1008                   UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
    1009             end
    1010         end
    1011         UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
    1012     elseif NbDim==2
    1013         nbpoints_y=UvData.Field.DimValue(DimIndex(1));       
    1014         Yvar=VarType{imax}.coord_y;
    1015         if Yvar~=0  % x is a dimension variable
    1016             YName=UvData.Field.ListVarName{Yvar};
    1017             eval(['UvData.YMax=max(UvData.Field.' YName ');'])
    1018             eval(['UvData.YMin=min(UvData.Field.' YName ');'])
    1019         else
    1020             testcoord_y=0;
    1021             if ~testcoord_y
    1022                   UvData.YMin=1;
    1023                   UvData.YMax=UvData.Field.DimValue(DimIndex(1));
    1024             end
    1025         end
    1026         DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
    1027         nbpoints_x=UvData.Field.DimValue(DimIndex(2));
    1028         Xvar=VarType{imax}.coord_x;
    1029         if Xvar~=0  % x is a dimension variable
    1030             XName=UvData.Field.ListVarName{Xvar};
    1031             eval(['UvData.XMax=max(UvData.Field.' XName ');'])
    1032             eval(['UvData.XMin=min(UvData.Field.' XName ');'])
    1033         else
    1034             testcoord_x=0;
    1035             if ~testcoord_x
    1036                   UvData.XMin=1;
    1037                   UvData.XMax=UvData.Field.DimValue(DimIndex(2));
    1038             end
    1039         end
    1040         DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
    1041         UvData.Mesh= sqrt(DX*DY);
    1042     end
    1043 end
    1044 
    1045 %create a default projection menuplane
    1046 UvData.Object{1}.Style='plane';%main plotting plane
    1047 UvData.Object{1}.ProjMode='projection';%main plotting plane
    1048 if ~isfield(UvData.Object{1},'plotaxes')
    1049     UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
    1050     set(handles.list_object,'String',{'1-PLANE';'...'});
    1051     set(handles.list_object,'Value',1);
    1052 end
    1053 
    1054 %3D case (menuvolume)
    1055 if NbDim==3
    1056     UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
    1057     UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
    1058     UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
    1059     UvData.Object{1}.Phi=0;
    1060     UvData.Object{1}.Theta=0;
    1061     UvData.Object{1}.Psi=0;
    1062     UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 
    1063     PlotHandles=get_plot_handles(handles);
    1064     ZBounds(1)=UvData.ZMin; %minimum for the Z slider
    1065     ZBounds(2)=UvData.ZMax;%maximum for the Z slider
    1066     set_object(UvData.Object{1},PlotHandles,ZBounds);
    1067     set(handles.list_object,'Value',1);
    1068 %multilevel case (single menuplane in a 3D space)
    1069 elseif isfield(UvData,'Z')
    1070     if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
    1071         XmlData=UvData.XmlData;
    1072         if isfield(XmlData,'PlanePos')
    1073              UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
    1074         end
    1075         if isfield(XmlData,'PlaneAngle')
    1076             siz=size(XmlData.PlaneAngle);
    1077             indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)             
    1078             UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
    1079             UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
    1080             UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
    1081         end
    1082     elseif isfield(UvData,'ZIndex')
    1083         UvData.Object{1}.ZObject=UvData.ZIndex;
    1084     end
    1085 end
    1086 
    1087 %Plot the projections on all existing  projection objects
    1088 keeplim=get(handles.FixedLimits,'Value');
    1089 %reset the min and max of scalar if only the mask is displayed
    1090 if isfield(UvData,'Mask')&~isfield(UvData,'A')
    1091     set(handles.MinA,'String','0')
    1092     set(handles.MaxA,'String','255')
    1093 end
    1094 
    1095 Object=UvData.Object;
    1096 for iobj=1:length(Object)
    1097     if ~isempty(Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
    1098         %Projeter les champs sur l'objet:*
    1099         ObjectData=proj_field(UvData.Field,Object{iobj},iobj);
    1100    
    1101         %use of mask
    1102         if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
    1103             if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
    1104                  flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
    1105                  AX=ObjectData.AX;
    1106                  AY=ObjectData.AY;
    1107                  MaskX=ObjectData.MaskX;
    1108                  MaskY=ObjectData.MaskY;
    1109                  if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
    1110                      nxy=size(flag_mask);
    1111                      sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
    1112                      sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
    1113                      x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
    1114                      y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
    1115                      %project on the positions of the scalar
    1116                      npxy=size(ObjectData.A);
    1117                      dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
    1118                      dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
    1119                      xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
    1120                      yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];     
    1121                      [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
    1122                     flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
    1123                  end
    1124                  AClass=class(ObjectData.A);
    1125                  ObjectData.A=flag_mask.*double(ObjectData.A);
    1126                  ObjectData.A=feval(AClass,ObjectData.A);
    1127                  ind_off=[];
    1128                  if isfield(ObjectData,'ListVarName')
    1129                       for ilist=1:length(ObjectData.ListVarName)
    1130                            if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
    1131                                ind_off=[ind_off ilist];
    1132                            end
    1133                       end
    1134                       ObjectData.ListVarName(ind_off)=[];
    1135                       ObjectData.VarDimIndex(ind_off)=[];
    1136                       ind_off=[];       
    1137                       for ilist=1:length(ObjectData.ListDimName)       
    1138                            if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
    1139                                ind_off=[ind_off ilist];
    1140                            end
    1141                       end
    1142                       ObjectData.ListDimName(ind_off)=[];
    1143                       ObjectData.DimValue(ind_off)=[];
    1144                  end
    1145             end 
    1146         end
    1147         if ~isempty(ObjectData)
    1148             haxes=[];%default
    1149             if isfield(Object{iobj},'plotaxes')
    1150                 haxes=Object{iobj}.plotaxes;%axes used for representing the projection on the object
    1151             end
    1152             PosColorbar=[];%default: no colorbar
    1153             if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
    1154                 PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the view_field interface
    1155             else
    1156                 PosColorbar='*';%default position
    1157             end
    1158             PlotParam=read_plot_param(handles);%read plotting parameters on the view_field interface
    1159             [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
    1160             if isequal(PlotType,'none')
    1161                 hget_field=findobj(allchild(0),'name','get_field');
    1162                 if isempty(hget_field)
    1163                     get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
    1164                 else
    1165                     msgbox_view_field('ERROR','The field defined by get_field cannot be plotted')
    1166                 end
    1167             end 
    1168             UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
    1169         end
    1170        
    1171     end
    1172 end
    1173 
    1174 %display the updated plotting parameters for the base menuplane
    1175 write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
    1176 set(handles.view_field,'UserData',UvData)
    1177 
    1178 %update the mask
    1179 if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
    1180    update_mask(handles,num_i1,num_i2);
    1181 end
    1182 
    1183 %prepare the menus of histograms (for the whole menuvolume in 3D case)
    1184 menu_histo=(UvData.Field.ListVarName)';
    1185 ind_bad=[];
    1186 nb_histo=1;
    1187 for ivar=1:numel(menu_histo)
    1188     if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
    1189         Role=UvData.Field.VarAttribute{ivar}.Role;
    1190         switch Role
    1191             case {'coord_x','coord_y','coord_z','dimvar'}
    1192                 ind_bad=[ind_bad ivar];
    1193             case {'vector_y'}
    1194                 nb_histo=nb_histo+1;
    1195         end
    1196     end
    1197     DimCell=UvData.Field.VarDimName{ivar};
    1198     DimName='';
    1199     if ischar(DimCell)
    1200         DimName=DimCell;
    1201     elseif iscell(DimCell)&& numel(DimCell)==1
    1202         DimName=DimCell{1};
    1203     end
    1204     if strcmp(DimName,menu_histo{ivar})
    1205         ind_bad=[ind_bad ivar];
    1206     end
    1207 end
    1208 menu_histo(ind_bad)=[];
    1209 test_v=0;
    1210 if ~isempty(menu_histo)
    1211     set(handles.histo1_menu,'Value',1)
    1212     set(handles.histo1_menu,'String',menu_histo)
    1213     histo1_menu_Callback(hObject, eventdata, handles)
    1214     if nb_histo > 1
    1215         test_v=1;
    1216         set(handles.histo2_menu,'Visible','on')
    1217         set(handles.histo_v,'Visible','on')
    1218         set(handles.histo2_menu,'String',menu_histo)
    1219         set(handles.histo2_menu,'Value',2)
    1220         histo2_menu_Callback(hObject, eventdata, handles)
    1221     end
    1222 end
    1223 if ~test_v
    1224     set(handles.histo2_menu,'Visible','off')
    1225     set(handles.histo_v,'Visible','off')
    1226     cla(handles.histo_v)
    1227     set(handles.histo2_menu,'Value',1)
    1228 end
    1229 
    1230 %display time
    1231 testimedoc=0;
    1232 if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
    1233     if isempty(num_i2)
    1234         num_i2=num_i1;
    1235     end
    1236     if isempty(num_j1)
    1237         num_j1=1;
    1238     end
    1239     if isempty(num_j2)
    1240         num_j2=num_j1;
    1241     end
    1242     siz=size(UvData.XmlData.Time);
    1243     if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
    1244         abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
    1245         dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
    1246         testimedoc=1;
    1247     end
    1248 end
    1249 if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
    1250     [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
    1251     num_i2=str2num(str2);
    1252     if isempty(num_i2)
    1253         num_i2=num_i1;
    1254     end
    1255     num_j1=str2num(str_a);
    1256     if isempty(num_j1)
    1257         num_j1=1;
    1258     end
    1259     num_j2=str2num(str_b);
    1260     if isempty(num_j2)
    1261         num_j2=num_j1;
    1262     end
    1263     num_i1=str2num(str1);
    1264     siz=size(UvData.XmlData_1.Time);
    1265     if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
    1266         abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files
    1267     end
    1268 end
    1269 set(handles.abs_time,'String',num2str(abstime,4))
    1270 set(handles.abs_time_1,'String',num2str(abstime_1,4))
    1271 if testimedoc && isfield(UvData,'dt')
    1272     dt=UvData.dt;
    1273 end
    1274 if isequal(dt,0)
    1275     set(handles.Dt_txt,'String','')
    1276 else
    1277     if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
    1278         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
    1279     else
    1280         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
    1281     end
    1282 end
    1283 set(handles.run0,'BackgroundColor',[1 0 0])
    1284 
    1285252
    1286253
     
    1390357
    1391358%-------------------------------------------------------------------
    1392 %determines the fields to read from the interface
     359%-------------------------------------------------------------------
     360%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
     361
    1393362%------------------------------------------------------------------
    1394 function [VelType,civ]=setfield(handles)
    1395 
    1396 VelType=[]; %default
    1397 if (get(handles.civ1,'Value') == 1);
    1398         VelType='civ1';
    1399 % interp1   
    1400 elseif (get(handles.interp1,'Value') == 1);
    1401     VelType='interp1';
    1402 % filter1   
    1403 elseif (get(handles.filter1,'Value') == 1);
    1404     VelType='filter1'; 
    1405 % CIV2
    1406 elseif (get(handles.civ2,'Value') == 1);
    1407     VelType='civ2';
    1408 % interp2   
    1409 elseif (get(handles.interp2,'Value') == 1);
    1410     VelType='interp2';
    1411 % filter2   
    1412 elseif (get(handles.filter2,'Value') == 1); 
    1413     VelType='filter2';
    1414 end
    1415 
    1416 if isequal(get(handles.filter2,'Visible'),'on');
    1417     civ=6;
    1418 % interp1   
    1419 elseif isequal(get(handles.interp2,'Visible'),'on');
    1420     civ=5;
    1421 % filter1   
    1422 elseif isequal(get(handles.civ2,'Visible'),'on');
    1423     civ=4; 
    1424 % CIV2
    1425 elseif isequal(get(handles.filter1,'Visible'),'on');
    1426    civ=3;
    1427 % interp2   
    1428 elseif isequal(get(handles.interp1,'Visible'),'on');
    1429     civ=2;
    1430 % filter2   
    1431 elseif isequal(get(handles.civ1,'Visible'),'on'); 
    1432     civ=1;
    1433 else
    1434     civ=0;
    1435 end
    1436 
    1437 %-------------------------------------------------------------------
    1438 %determines the veltype of the second field to read from the iinterface
    1439 %------------------------------------------------------------------
    1440 function VelType=setfield_1(handles)
    1441 
    1442 VelType=[]; %default
    1443 if (get(handles.civ1_1,'Value') == 1);
    1444     VelType='civ1';
    1445 % interp1   
    1446 elseif (get(handles.interp1_1,'Value') == 1);
    1447     VelType='interp1';
    1448 % filter1   
    1449 elseif (get(handles.filter1_1,'Value') == 1);
    1450     VelType='filter1'; 
    1451 % CIV2
    1452 elseif (get(handles.civ2_1,'Value') == 1);
    1453     VelType='civ2';
    1454 % interp2   
    1455 elseif (get(handles.interp2_1,'Value') == 1);
    1456     VelType='interp2';
    1457 % filter2   
    1458 elseif (get(handles.filter2_1,'Value') == 1); 
    1459     VelType='filter2';
    1460 end
    1461 
    1462 
    1463 %---------------------------------------------------
    1464 % --- Executes on button press in SubField
    1465 function SubField_Callback(hObject, eventdata, handles)
    1466 huvmat=get(handles.run0,'parent');
    1467 UvData=get(huvmat,'UserData');
    1468 if get(handles.SubField,'Value')==0% if the subfield button is desactivated   
    1469     set(handles.RootPath_1,'String','')
    1470     set(handles.RootFile_1,'String','')
    1471     set(handles.SubDir_1,'String','');
    1472     set(handles.FileIndex_1,'String','');
    1473     set(handles.FileExt_1,'String','');
    1474     set(handles.RootPath_1,'Visible','off')
    1475     set(handles.RootFile_1,'Visible','off')
    1476     set(handles.SubDir_1,'Visible','off');
    1477     set(handles.FileIndex_1,'Visible','off');
    1478     set(handles.FileExt_1,'Visible','off');
    1479     set(handles.Fields_1,'Value',1);%set to blank state
    1480     set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
    1481             handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
    1482     if isfield(UvData,'XmlData_1')
    1483         UvData=rmfield(UvData,'XmlData_1');
    1484     end
    1485     set(huvmat,'UserData',UvData);
    1486     run0_Callback(hObject, eventdata, handles); %run
    1487 else
    1488     MenuBrowse_1_Callback(hObject, eventdata, handles)
    1489 end
    1490 
    1491 % %----------------------------------------------
    1492 % %read the data displayed for the input rootfile windows (new)
    1493 % %-------------------------------------------------
    1494 function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
    1495 RootPath=get(handles.RootPath,'String');
    1496 FileName=RootPath; %default
    1497 SubDir=get(handles.SubDir,'String');
    1498 if ~isempty(SubDir) && ~isequal(SubDir,'')
    1499     if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
    1500         SubDir(1)=[]; %suppress possible / or \ separator
    1501     end
    1502     FileName=fullfile(RootPath,SubDir);
    1503 end
    1504 RootFile=get(handles.RootFile,'String');
    1505 if ~isempty(RootFile) && ~isequal(RootFile,'')
    1506     if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
    1507         RootFile(1)=[]; %suppress possible / or \ separator
    1508     end
    1509     FileName=fullfile(FileName,RootFile);
    1510 end
    1511 FileBase=fullfile(RootPath,RootFile);
    1512 FileIndices=get(handles.FileIndex,'String');
    1513 FileExt=get(handles.FileExt,'String');
    1514 FileName=[FileName FileIndices FileExt];
    1515 
    1516 %----------------------------------------------
    1517 %read the data displayed for the second input rootfile windows
    1518 %-------------------------------------------------
    1519 function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
    1520 RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
    1521 if isequal(RootPath_1,'"'),RootPath_1=get(handles.RootPath,'String'); end;
    1522 FileName_1=RootPath_1; %default
    1523 SubDir_1=get(handles.SubDir_1,'String');
    1524 if isequal(SubDir_1,'"')
    1525     SubDir_1=get(handles.SubDir,'String');
    1526 end
    1527 if ~isempty(SubDir_1) && ~isequal(SubDir_1,'')
    1528     if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
    1529         SubDir_1(1)=[]; %suppress possible / or \ separator
    1530     end
    1531     FileName_1=fullfile(RootPath_1,SubDir_1);
    1532 end
    1533 RootFile_1=get(handles.RootFile_1,'String');
    1534 if isequal(RootFile_1,'"'),RootFile_1=get(handles.RootFile,'String'); end;
    1535 if ~isempty(RootFile_1) && ~isequal(RootFile_1,'')
    1536     if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
    1537         RootFile_1(1)=[];%suppress possible / or \ separator
    1538     end
    1539     FileName_1=fullfile(FileName_1,RootFile_1);
    1540 end
    1541 FileBase_1=fullfile(RootPath_1,RootFile_1);
    1542 FileIndices_1=get(handles.FileIndex_1,'String');
    1543 FileExt_1=get(handles.FileExt_1,'String');
    1544 if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
    1545 FileName_1=[FileName_1 FileIndices_1 FileExt_1];
    1546 
    1547 %---------------------------------------------------
    1548 % --- Executes on menu selection Fields
    1549 function Fields_Callback(hObject, eventdata, handles)
    1550 %-------------------------------------------------
    1551 huvmat=get(handles.Fields,'parent');
    1552 list_fields=get(handles.Fields,'String');% list menu fields
    1553 index_fields=get(handles.Fields,'Value');% selected string index
    1554 field= list_fields{index_fields(1)}; % selected string
    1555 if isequal(field,'get_field...')
    1556      veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    1557      set_veltype_display(veltype_handles,0) % unvisible civ buttons
    1558      filename=read_file_boxes(handles);
    1559      hget_field=findobj(allchild(0),'name','get_field');
    1560      if ~isempty(hget_field)
    1561          delete(hget_field)
    1562      end
    1563      get_field(filename)
    1564     return %no action
    1565 end
    1566 list_fields=get(handles.Fields_1,'String');% list menu fields
    1567 index_fields=get(handles.Fields_1,'Value');% selected string index
    1568 field_1= list_fields{index_fields(1)}; % selected string
    1569 UvData=get(huvmat,'UserData');
    1570 
    1571 %read the rootfile input display
    1572 FileExt=get(handles.FileExt,'String');
    1573 [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
    1574 NomTypeNew=NomType;%default
    1575 if isequal(field,'image')
    1576     % transform netc type to the corresponding image type
    1577     if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
    1578         UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
    1579         if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
    1580             UvData.SubDir(1)=[];
    1581         end
    1582         set(handles.SubDir,'String','')
    1583         set(handles.FileExt,'String','.png');
    1584         if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
    1585             NomTypeNew='_i_j';
    1586         elseif isequal(NomType,'#_ab')
    1587             NomTypeNew='#a';
    1588         elseif isequal(NomType,'_i1-i2')
    1589             NomTypeNew='_i';
    1590         end 
    1591     end
    1592     veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    1593     set_veltype_display(veltype_handles,0) % unvisible civ buttons
    1594 else
    1595     ext=get(handles.FileExt,'String');
    1596     if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
    1597          MenuBrowse_Callback(hObject, eventdata, handles)
    1598     end
    1599     if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
    1600         set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    1601         set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
    1602         set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
    1603         set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
    1604     elseif isequal(field,'more...');
    1605         set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    1606         set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
    1607         str=calc_field;%get the list of available scalars by the function calc_scal
    1608         [ind_answer] = listdlg('PromptString','Select a file:',...
    1609                 'SelectionMode','single',...
    1610                 'ListString',str);
    1611        % edit the choice in the field and action menu
    1612         scalar=cell2mat(str(ind_answer));
    1613         menu=update_menu(handles.Fields,scalar);
    1614         menu=[{''};menu];
    1615         set(handles.Fields_1,'String',menu);% store the selected scalar type
    1616     end
    1617 end
    1618 indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
    1619 set(handles.FileIndex,'String',indices)
    1620 set(handles.FileIndex,'UserData',NomTypeNew)
    1621 %common to Fields_1_Callback
    1622 if isequal(field,'image')||isequal(field_1,'image')
    1623     set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
    1624     set(handles.npy_title,'Visible','on')
    1625     set(handles.npx,'Visible','on')
    1626     set(handles.npy,'Visible','on')
    1627     set(handles.fix_pair,'Value',0)
    1628 else
    1629     set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
    1630     set(handles.npy_title,'Visible','off')
    1631     set(handles.npx,'Visible','off')
    1632     set(handles.npy,'Visible','off')
    1633     set(handles.fix_pair,'Value',1)
    1634 end
    1635 % if isequal(field,'velocity')|isequal(field_1,'velocity');
    1636 %     state_vect='on';
    1637 % else
    1638 %     state_vect='off';
    1639 % end
    1640 % if ~isequal(field,'velocity')|(~isequal(field_1,'velocity'));
    1641 %     state_scal='on';
    1642 % else
    1643 %     state_scal='off';
    1644 % end
    1645 setfield(handles);% update the field structure ('civ1'....)
    1646 
    1647 if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
    1648     run0_Callback(hObject, eventdata, handles)
    1649 end
    1650 
    1651 %---------------------------------------------------
    1652 % --- Executes on menu selection Fields
    1653 function Fields_1_Callback(hObject, eventdata, handles)
    1654 %-------------------------------------------------
    1655 huvmat=get(handles.Fields_1,'parent');
    1656 list_fields=get(handles.Fields,'String');% list menu fields
    1657 index_fields=get(handles.Fields,'Value');% selected string index
    1658 field= list_fields{index_fields(1)}; % selected string
    1659 list_fields=get(handles.Fields_1,'String');% list menu fields
    1660 index_fields=get(handles.Fields_1,'Value');% selected string index
    1661 field_1= list_fields{index_fields(1)}; % selected string for the second field
    1662 if isequal(field_1,'') %remove second field if 'blank' field is selected
    1663     set(handles.SubField,'Value',0)
    1664     SubField_Callback(hObject, eventdata, handles)
    1665     return
    1666 end
    1667 UvData=get(huvmat,'UserData');
    1668 
    1669 %read the rootfile input display
    1670 FileExt_prev=get(handles.FileExt_1,'String');
    1671 if isempty(FileExt_prev)|isequal(FileExt_prev,'')
    1672     FileExt_1=get(handles.FileExt,'String');
    1673 else
    1674     FileExt_1=FileExt_prev;
    1675 end
    1676 NomType_1=get(handles.FileIndex_1,'UserData');
    1677 if isempty(NomType_1)|isequal(NomType_1,'')
    1678     NomType_1=get(handles.FileIndex,'UserData');
    1679 end
    1680 NomTypeNew=NomType_1;%default
    1681 
    1682 set(handles.SubField,'Value',1)%introduce second field
    1683 if isfield(UvData,'XmlData')
    1684     UvData.XmlData_1=UvData.XmlData;
    1685 end
    1686 set(handles.FileIndex_1,'Visible','on')
    1687 set(handles.FileExt_1,'Visible','on')
    1688 RootPath_1=get(handles.RootPath_1,'String');
    1689 RootFile_1=get(handles.RootFile_1,'String');
    1690 if isempty(RootPath_1)|isequal(RootPath_1,'')
    1691     set(handles.RootPath_1,'String','"')
    1692 end
    1693 if isempty(RootFile_1) | isequal(RootFile_1,'')
    1694     set(handles.RootFile_1,'String','"')
    1695 end
    1696 if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
    1697     RootFile_1(1)=[];
    1698 end
    1699 
    1700 if isequal(field_1,'get_field...')
    1701      veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    1702      set_veltype_display(veltype_handles,0) % unvisible civ buttons
    1703      filename=read_file_boxes_1(handles);
    1704      hget_field=findobj(allchild(0),'name','get_field_1');
    1705      if ~isempty(hget_field)
    1706          delete(hget_field)
    1707      end
    1708      hget_field=get_field(filename);
    1709      set(hget_field,'name','get_field_1')
    1710     return %no action
    1711 end
    1712 if isequal(field_1,'image')
    1713     % transform netc type to the corresponding image type
    1714     set(handles.FileExt_1,'String','.png');
    1715     if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
    1716         UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
    1717         set(handles.SubDir_1,'String','')
    1718 %         set(handles.FileExt_1,'String','.png');       
    1719         if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
    1720             NomTypeNew='_i_j';
    1721         elseif isequal(NomType_1,'#_ab')
    1722             NomTypeNew='#a';
    1723         elseif isequal(NomType_1,'_i1-i2')
    1724             NomTypeNew='_i';
    1725         end 
    1726     end
    1727     veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    1728     set_veltype_display(veltype_handles,0) % unvisible civ buttons
    1729 else
    1730     set(handles.SubDir_1,'Visible','on')
    1731     if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
    1732         veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    1733         set_veltype_display(veltype_handles,6); % make all civ buttons visible
    1734         RootPath_1=get(handles.RootPath_1,'String');
    1735         RootFile_1=get(handles.RootFile_1,'String');
    1736         if isempty(RootPath_1)|isequal(RootPath_1,'')
    1737             set(handles.RootPath_1,'String','"')
    1738         end
    1739         if isempty(RootFile_1) | isequal(RootFile_1,'')
    1740             set(handles.RootFile_1,'String','"')
    1741         end
    1742         if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
    1743             RootFile_1(1)=[];
    1744         end
    1745         filebase_1=fullfile(RootPath_1,RootFile_1);
    1746         SubDir_1=get(handles.SubDir,'String');
    1747         if isempty(SubDir_1)|isequal(SubDir_1,'')
    1748             if isfield(UvData,'SubDir_1')
    1749                 SubDir_1=UvData.SubDir_1;%retrieve previous subdir
    1750             else
    1751                 SubDir_1='?';
    1752             end
    1753         end
    1754         if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2')
    1755             NomTypeNew=NomType_1;
    1756         elseif isequal(NomType_1,'#a')
    1757              [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
    1758              NomTypeNew='#_ab';
    1759         elseif isequal(NomType_1,'_i_j')
    1760              [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
    1761             if idetect==1
    1762                 NomTypeNew='_i1-i2_j';
    1763             else
    1764                 NomTypeNew='_i_j1-j2';
    1765             end
    1766         else %for instance avi files or any ima_num series
    1767             [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
    1768             NomTypeNew='_i1-i2';
    1769         end           
    1770         [Path,Name]=fileparts(filebase_1);
    1771         set(handles.FileExt_1,'String','.nc');
    1772         if ~isempty(SubDir_1) & ~isequal(SubDir_1,'''')& ~isequal(SubDir_1,'"')
    1773             SubDir_1=['/' SubDir_1];
    1774         end
    1775         set(handles.SubDir_1,'String',SubDir_1);
    1776     end
    1777     if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
    1778         set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    1779         set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
    1780         set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
    1781         set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
    1782     elseif isequal(field_1,'more...'); %add new item to the menu
    1783         set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    1784         set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
    1785         str=calc_field;%get the list of available scalars by the function calc_scal
    1786         [ind_answer,v] = listdlg('PromptString','Select a file:',...
    1787                 'SelectionMode','single',...
    1788                 'ListString',str);
    1789        % edit the choice in the field and action menu
    1790         scalar=cell2mat(str(ind_answer));
    1791         menu=update_menu(handles.Fields_1,scalar);
    1792         set(handles.Fields_1,'String',menu);% store the selected scalar type
    1793     end
    1794 end
    1795 str1=get(handles.i1,'String');
    1796 str2=get(handles.i2,'String');
    1797 str_a=get(handles.j1,'String');
    1798 str_b=get(handles.j2,'String');
    1799 indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
    1800 set(handles.FileIndex_1,'String',indices)
    1801 set(handles.FileIndex_1,'UserData',NomTypeNew)
    1802 
    1803 %common to Fields_Callback
    1804 if isequal(field,'image')|isequal(field_1,'image')
    1805     set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
    1806     set(handles.npy_title,'Visible','on')
    1807     set(handles.npx,'Visible','on')
    1808     set(handles.npy,'Visible','on')
    1809     set(handles.fix_pair,'Value',0)
    1810 else
    1811     set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
    1812     set(handles.npy_title,'Visible','off')
    1813     set(handles.npx,'Visible','off')
    1814     set(handles.npy,'Visible','off')
    1815     set(handles.fix_pair,'Value',1)
    1816 end
    1817 if isequal(field,'velocity')|isequal(field_1,'velocity');
    1818     state_vect='on';
    1819 else
    1820     state_vect='off';
    1821 end
    1822 if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
    1823     state_scal='on';
    1824 else
    1825     state_scal='off';
    1826 end
    1827 set(huvmat,'UserData',UvData)
    1828 setfield(handles);% update the field structure ('civ1'....)
    1829 if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
    1830     run0_Callback(hObject, eventdata, handles)
    1831 end
    1832 
    1833 %------------------------------------------------------------------------
    1834 % --- set the visibility of relevant velocity type menus:
    1835 function set_veltype_display(handles,Civ)
    1836 %------------------------------------------------------------------------
    1837 %Civ=0; all states 'off'
    1838 %Civ=6; all states 'on'
    1839 if isequal(Civ,0)
    1840     imax=0;
    1841 %    set(handles(1),'Visible','on')  % unvisible civ buttons
    1842 % else
    1843 %    set(handles(1),'String','civ1')
    1844 % end
    1845 elseif isequal(Civ,1) || isequal(Civ,2)
    1846    imax=1;
    1847 elseif isequal(Civ,3)
    1848     imax=3;
    1849 elseif isequal(Civ,4) || isequal(Civ,5)
    1850     imax=4;
    1851 elseif isequal(Civ,6) %patch2
    1852     imax=6;
    1853 end
    1854 for ibutton=1:imax;
    1855     set(handles(ibutton),'Visible','on')  % unvisible civ buttons
    1856 end
    1857 % for ibutton=max(imax+1,2):6;
    1858 for ibutton=imax+1:6;
    1859     set(handles(ibutton),'Visible','off')  % unvisible civ buttons
    1860     set(handles(ibutton),'Value',0)%unactivate unvisible buttons
    1861 end
    1862 
    1863 %-------------------------------------------------------------------
    1864 % --- Executes on button press in civ1.
    1865 function civ1_Callback(hObject, eventdata, handles)
    1866 %-------------------------------------------------------------------
    1867 if get(handles.civ1,'Value')==1
    1868     reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
    1869 else
    1870     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    1871 end
    1872 run0_Callback(hObject, eventdata, handles)
    1873 
    1874 %-------------------------------------------------------------------
    1875 % --- Executes on button press in interp1.
    1876 function interp1_Callback(hObject, eventdata, handles)
    1877 %-------------------------------------------------------------------
    1878 if get(handles.interp1,'Value')==1
    1879     reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
    1880 else
    1881      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    1882 end
    1883 run0_Callback(hObject, eventdata, handles)
    1884 
    1885 %-------------------------------------------------------------------
    1886 % --- Executes on button press in filter1.
    1887 function filter1_Callback(hObject, eventdata, handles)
    1888 %-------------------------------------------------------------------
    1889 if get(handles.filter1,'Value')==1
    1890     reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
    1891 else
    1892      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    1893 end
    1894 run0_Callback(hObject, eventdata, handles)
    1895 
    1896 %-------------------------------------------------------------------
    1897 % --- Executes on button press in civ2.
    1898 function civ2_Callback(hObject, eventdata, handles)
    1899 %-------------------------------------------------------------------
    1900 if get(handles.civ2,'Value')==1
    1901     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
    1902 else
    1903      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    1904 end
    1905 run0_Callback(hObject, eventdata, handles)
    1906 
    1907 %-----------------------------------------
    1908 % --- Executes on button press in interp2.
    1909 %-------------------------------------------
    1910 function interp2_Callback(hObject, eventdata, handles)
    1911 if get(handles.interp2,'Value')==1
    1912     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
    1913 else
    1914      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    1915 end
    1916 run0_Callback(hObject, eventdata, handles)
    1917 %---------------------------------------------
    1918 % --- Executes on button press in filter2.
    1919 %-------------------------------------------
    1920 function filter2_Callback(hObject, eventdata, handles)
    1921 if get(handles.filter2,'Value')==1
    1922     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
    1923 else
    1924      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    1925 end
    1926 run0_Callback(hObject, eventdata, handles)
    1927 
    1928 %---------------------------------------------
    1929 function civ1_1_Callback(hObject, eventdata, handles)
    1930 %---------------------------------------------
    1931 if get(handles.civ1_1,'Value')==1
    1932     reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
    1933 else
    1934      reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    1935 end
    1936 run0_Callback(hObject, eventdata, handles)
    1937 
    1938 %--------------------------------------------
    1939 function interp1_1_Callback(hObject, eventdata, handles)
    1940 %--------------------------------------------
    1941 if get(handles.interp1_1,'Value')==1
    1942     reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
    1943 else
    1944     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    1945 end
    1946 run0_Callback(hObject, eventdata, handles)
    1947 
    1948 %--------------------------------------------
    1949 function filter1_1_Callback(hObject, eventdata, handles)
    1950 %--------------------------------------------
    1951 if get(handles.filter1_1,'Value')==1
    1952     reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
    1953 else
    1954     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    1955 end
    1956 run0_Callback(hObject, eventdata, handles)
    1957 
    1958 %--------------------------------------------
    1959 function civ2_1_Callback(hObject, eventdata, handles)
    1960 %--------------------------------------------
    1961 if get(handles.civ2_1,'Value')==1
    1962     reset_vel_type([handles.civ1_1 handles.interp1_1  handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
    1963 else
    1964     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    1965 end
    1966 run0_Callback(hObject, eventdata, handles)
    1967 
    1968 %--------------------------------------------
    1969 function interp2_1_Callback(hObject, eventdata, handles)
    1970 %--------------------------------------------
    1971 if get(handles.interp2_1,'Value')==1
    1972     reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
    1973 else
    1974     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    1975 end
    1976 run0_Callback(hObject, eventdata, handles)
    1977 
    1978 %--------------------------------------------
    1979 function filter2_1_Callback(hObject, eventdata, handles)
    1980 %--------------------------------------------
    1981 if get(handles.filter2_1,'Value')==1
    1982     reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
    1983 else
    1984     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    1985 end
    1986 run0_Callback(hObject, eventdata, handles)
    1987 
    1988 %-----------------------------------------------
    1989 % --- reset civ buttons
    1990 function reset_vel_type(handles_civ0,handle1)
    1991 for ibutton=1:length(handles_civ0)
    1992     set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
    1993     set(handles_civ0(ibutton),'Value',0)
    1994 end
    1995 if exist('handle1','var')%handles of selected button
    1996         set(handle1,'BackgroundColor',[1 1 0]) 
    1997 end
    1998 
    1999 
    2000 %-------------------------------------------------------------------
    2001 %-------------------------------------------------------------------
    2002 %  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
    2003 
    2004 %------------------------------------------------------------------
    2005 
    2006363
    2007364
Note: See TracChangeset for help on using the changeset viewer.