Changeset 651 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jun 25, 2013, 12:48:10 AM (10 years ago)
Author:
sommeria
Message:

various bugs corrected. Introduction of campaign lists in Open menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r650 r651  
    4949%
    5050%
    51 % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1
     51% 1) Input filenames are determined by MenuBrowse (first field), MenuBrowseCampaign
    5252% (second field), or by the stored file name .FileName_1, or as an input of uvmat.
    5353% 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes
     
    229229 dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user
    230230 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab
    231  if exist(profil_perso,'file')
    232      h=load (profil_perso);
    233      if isfield(h,'MenuFile')% load the menu of previously opened files
     231 if exist(profil_perso,'file')% if the file exists
     232     h=load (profil_perso); % open the personal file
     233     if isfield(h,'MenuFile')% load the saved menu of previously opened files
    234234         for ifile=1:min(length(h.MenuFile),5)
    235235             set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
    236              set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',h.MenuFile{ifile});
     236         end
     237     end
     238     if isfield(h,'MenuCampaign')% load the saved menu of previously opened campaigns
     239         for ifile=1:min(length(h.MenuCampaign),5)
     240             set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile});
    237241         end
    238242     end
     
    434438    oldfile=get(handles.RootPath,'UserData');
    435439end
    436 fileinput=uigetfile_uvmat('select an input file:',oldfile);
     440fileinput=uigetfile_uvmat('pick an input file',oldfile);
    437441
    438442%% display the selected field and related information
     
    442446
    443447% -----------------------------------------------------------------------
     448% --- Open again the file whose name has been recorded in MenuFile_1
     449function MenuFile_Callback(hObject, eventdata, handles)
     450%------------------------------------------------------------------------
     451fileinput=get(hObject,'Label');
     452display_file_name( handles,fileinput)
     453%
     454% % -----------------------------------------------------------------------
     455% % --- Open again the file whose name has been recorded in MenuFile_2
     456% function MenuFile_2_Callback(hObject, eventdata, handles)
     457% %------------------------------------------------------------------------
     458% fileinput=get(handles.MenuFile_2,'Label');
     459% display_file_name(handles,fileinput)
     460%
     461% % -----------------------------------------------------------------------
     462% % --- Open again the file whose name has been recorded in MenuFile_3
     463% function MenuFile_3_Callback(hObject, eventdata, handles)
     464% %------------------------------------------------------------------------
     465% fileinput=get(handles.MenuFile_3,'Label');
     466% display_file_name(handles,fileinput)
     467%
     468% % -----------------------------------------------------------------------
     469% % --- Open again the file whose name has been recorded in MenuFile_4
     470% function MenuFile_4_Callback(hObject, eventdata, handles)
     471% %------------------------------------------------------------------------
     472% fileinput=get(handles.MenuFile_4,'Label');
     473% display_file_name(handles,fileinput)
     474%
     475% % -----------------------------------------------------------------------
     476% % --- Open again the file whose name has been recorded in MenuFile_5
     477% function MenuFile_5_Callback(hObject, eventdata, handles)
     478% %------------------------------------------------------------------------
     479% fileinput=get(handles.MenuFile_5,'Label');
     480% display_file_name(handles,fileinput)
     481
     482
     483% -----------------------------------------------------------------------
    444484% --- Executes on the menu Open/Browse campaign...
    445 % search the file inside a campaign, using the GUI view_data
     485% --- search the file inside a campaign, using the GUI browse_data
     486% -----------------------------------------------------------------------
    446487function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
    447 % -----------------------------------------------------------------------
     488set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     489drawnow
    448490RootPath=get(handles.RootPath,'String');
    449491if isempty(RootPath)
     
    451493end
    452494CampaignPath=fileparts(fileparts(RootPath));
    453 DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
    454 if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     495DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir');
     496%DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
     497if isempty(DirFull)
    455498    return
    456499end
     
    459502    return
    460503end
    461 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1});
     504DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     505ListStruct=dir(DirName); %list files and the dir DataSeries
     506% select the first appropriate file in the dir
     507FileName='';
     508for ilist=1:numel(ListStruct)
     509    if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
     510        FileName=ListStruct(ilist).name;
     511        FileType=get_file_type(fullfile(DirName,FileName));
     512        switch FileType
     513            case {'image','multimage','civx','civdata','netcdf'}
     514                break
     515        end
     516    end
     517end
     518if isempty(FileName)
     519    msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
     520    return
     521end
     522
     523%% update the list of campaigns in the menubar
     524MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
     525    {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
     526check_dir=isempty(find(strcmp(DirFull,MenuCampaign)));
     527if check_dir %insert the new campaign in the list if it is not found
     528    MenuCampaign(end)=[]; %suppress the last item
     529    MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign
     530    for ilist=1:numel(MenuCampaign)
     531        set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
     532    end
     533    % save the list for future opening:
     534    dir_perso=prefdir;
     535    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     536    if exist(profil_perso,'file')
     537        save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat
     538    else
     539        save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat
     540    end
     541end
     542
     543%% display the selected field and related information
     544display_file_name( handles,fullfile(DirName,FileName))
     545
     546set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
     547
     548% -----------------------------------------------------------------------
     549% --- Open again as second field the file whose name has been recorded in MenuFile_1
     550% -----------------------------------------------------------------------
     551function MenuCampaign_Callback(hObject, eventdata, handles)
     552
     553set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     554OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device
     555if ~isfield(OutPut,'Campaign')
     556    return
     557end
     558DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
    462559hdir=dir(DirName); %list files and dirs
    463560for ilist=1:numel(hdir)
     
    471568    end
    472569end
    473 
    474 %% display the selected field and related information
    475 display_file_name( handles,fullfile(DirName,FileName))
    476 
    477 % -----------------------------------------------------------------------
    478 % --- Open again the file whose name has been recorded in MenuFile_1
    479 function MenuFile_1_Callback(hObject, eventdata, handles)
    480 %------------------------------------------------------------------------
    481 fileinput=get(handles.MenuFile_1,'Label');
    482 display_file_name( handles,fileinput)
    483 
    484 % -----------------------------------------------------------------------
    485 % --- Open again the file whose name has been recorded in MenuFile_2
    486 function MenuFile_2_Callback(hObject, eventdata, handles)
    487 %------------------------------------------------------------------------
    488 fileinput=get(handles.MenuFile_2,'Label');
    489 display_file_name(handles,fileinput)
    490 
    491 % -----------------------------------------------------------------------
    492 % --- Open again the file whose name has been recorded in MenuFile_3
    493 function MenuFile_3_Callback(hObject, eventdata, handles)
    494 %------------------------------------------------------------------------
    495 fileinput=get(handles.MenuFile_3,'Label');
    496 display_file_name(handles,fileinput)
    497 
    498 % -----------------------------------------------------------------------
    499 % --- Open again the file whose name has been recorded in MenuFile_4
    500 function MenuFile_4_Callback(hObject, eventdata, handles)
    501 %------------------------------------------------------------------------
    502 fileinput=get(handles.MenuFile_4,'Label');
    503 display_file_name(handles,fileinput)
    504 
    505 % -----------------------------------------------------------------------
    506 % --- Open again the file whose name has been recorded in MenuFile_5
    507 function MenuFile_5_Callback(hObject, eventdata, handles)
    508 %------------------------------------------------------------------------
    509 fileinput=get(handles.MenuFile_5,'Label');
    510 display_file_name(handles,fileinput)
    511 
    512 %------------------------------------------------------------------------
    513 % --- Executes on the menu Open/Browse_1 for the second input field,
    514 %     search the files, recognize their type according to their name and fill the rootfile input windows
    515 function MenuBrowse_1_Callback(hObject, eventdata, handles)
    516 %------------------------------------------------------------------------
    517 RootPath=get(handles.RootPath,'String');
    518 SubDir=get(handles.SubDir,'String');
    519 fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir));
    520 
    521 if ~isempty(fileinput_1)
    522    
    523     % refresh the current displayed field
    524     set(handles.SubField,'Value',1)
    525     display_file_name(handles,fileinput_1,2)
    526    
    527     %update list of recent files in the menubar
    528     MenuFile_1=fileinput_1;
    529     MenuFile_2=get(handles.MenuFile_1,'Label');
    530     MenuFile_3=get(handles.MenuFile_2,'Label');
    531     MenuFile_4=get(handles.MenuFile_3,'Label');
    532     MenuFile_5=get(handles.MenuFile_4,'Label');
    533     set(handles.MenuFile_1,'Label',MenuFile_1)
    534     set(handles.MenuFile_2,'Label',MenuFile_2)
    535     set(handles.MenuFile_3,'Label',MenuFile_3)
    536     set(handles.MenuFile_4,'Label',MenuFile_4)
    537     set(handles.MenuFile_5,'Label',MenuFile_5)
    538     set(handles.MenuFile_1_1,'Label',MenuFile_1)
    539     set(handles.MenuFile_2_1,'Label',MenuFile_2)
    540     set(handles.MenuFile_3_1,'Label',MenuFile_3)
    541     set(handles.MenuFile_4_1,'Label',MenuFile_4)
    542     set(handles.MenuFile_5_1,'Label',MenuFile_5)
    543 end
    544 
    545 % --------------------------------------------------------------------
    546 function MenuBrowseCampaign_1_Callback(hObject, eventdata, handles)
    547 % -----------------------------------------------------------------------
    548 CampaignPath=fileparts(fileparts(get(handles.RootPath,'String')));
    549 DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
    550 if ~ischar(DirFull)|| ~exist(DirFull,'dir')
    551     return
    552 end
    553 OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device
    554 if ~isfield(OutPut,'Campaign')
    555     return
    556 end
    557 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1});
    558 hdir=dir(DirName); %list files and dirs
    559 for ilist=1:numel(hdir)
    560     if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
    561         FileName=hdir(ilist).name;
    562         FileType=get_file_type(fullfile(DirName,FileName));
    563         switch FileType
    564             case {'image','multimage','civx','civdata','netcdf'}
    565             break
    566         end
    567     end
    568 end
    569 
    570 %% display the selected field and related information
    571 set(handles.SubField,'Value',1)
    572 display_file_name( handles,fullfile(DirName,FileName),2)
    573 
    574 % -----------------------------------------------------------------------
    575 % --- Open again as second field the file whose name has been recorded in MenuFile_1
    576 function MenuFile_1_1_Callback(hObject, eventdata, handles)
    577 % -----------------------------------------------------------------------
    578 fileinput_1=get(handles.MenuFile_1_1,'Label');
    579 set(handles.SubField,'Value',1)
    580 display_file_name(handles,fileinput_1,2)
    581 
    582 % -----------------------------------------------------------------------
    583 % --- Open again as second field the file whose name has been recorded in MenuFile_2
    584 function MenuFile_2_1_Callback(hObject, eventdata, handles)
    585 % -----------------------------------------------------------------------
    586 fileinput_1=get(handles.MenuFile_2_1,'Label');
    587 set(handles.SubField,'Value',1)
    588 display_file_name(handles,fileinput_1,2)
    589 
    590 % -----------------------------------------------------------------------
    591 % --- Open again as second field the file whose name has been recorded in MenuFile_3
    592 function MenuFile_3_1_Callback(hObject, eventdata, handles)
    593 % -----------------------------------------------------------------------
    594 fileinput_1=get(handles.MenuFile_3_1,'Label');
    595 set(handles.SubField,'Value',1)
    596 display_file_name(handles,fileinput_1,2)
    597 
    598 % -----------------------------------------------------------------------
    599 % --- Open again as second field the file whose name has been recorded in MenuFile_4
    600 function MenuFile_4_1_Callback(hObject, eventdata, handles)
    601 % -----------------------------------------------------------------------
    602 fileinput_1=get(handles.MenuFile_4_1,'Label');
    603 set(handles.SubField,'Value',1)
    604 display_file_name(handles,fileinput_1,2)
    605 
    606 % -----------------------------------------------------------------------
    607 % --- Open again as second field the file whose name has been recorded in MenuFile_5
    608 function MenuFile_5_1_Callback(hObject, eventdata, handles)
    609 % -----------------------------------------------------------------------
    610 fileinput_1=get(handles.MenuFile_5_1,'Label');
    611 set(handles.SubField,'Value',1)
    612 display_file_name(handles,fileinput_1,2)
     570display_file_name(handles,fullfile(DirName,FileName))
     571set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    613572
    614573%------------------------------------------------------------------------
     
    855814       
    856815        %enable other menus
    857         set(handles.MenuOpen_1,'Enable','on')
    858         set(handles.MenuFile_1_1,'Enable','on')
    859         set(handles.MenuFile_2_1,'Enable','on')
    860         set(handles.MenuFile_3_1,'Enable','on')
    861         set(handles.MenuFile_4_1,'Enable','on')
    862         set(handles.MenuFile_5_1,'Enable','on')
     816        set(handles.MenuOpenCampaign,'Enable','on')
     817%         set(handles.MenuCampaign_1,'Enable','on')
     818%         set(handles.MenuCampaign_2,'Enable','on')
     819%         set(handles.MenuCampaign_3,'Enable','on')
     820%         set(handles.MenuCampaign_4,'Enable','on')
     821%         set(handles.MenuCampaign_5,'Enable','on')
    863822        set(handles.MenuExport,'Enable','on')
    864823        set(handles.MenuExportFigure,'Enable','on')
     
    880839for ifile=1:min(length(MenuFile),5)
    881840    set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile});
    882     set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile});
     841    %set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile});
    883842end
    884843dir_perso=prefdir;
     
    25702529    end
    25712530    UvData.Field.CoordMesh=min(Mesh);
    2572     UvData.Field.XMax=max(CoordMax(ind,end));
    2573     UvData.Field.XMin=min(CoordMin(ind,end));
    2574     UvData.Field.YMax=max(CoordMax(ind,end-1));
    2575     UvData.Field.YMin=max(CoordMin(ind,end-1));
     2531    UvData.Field.XMax=max(CoordMax(:,end));
     2532    UvData.Field.XMin=min(CoordMin(:,end));
     2533    UvData.Field.YMax=max(CoordMax(:,end-1));
     2534    UvData.Field.YMin=min(CoordMin(:,end-1));
    25762535    if NbDim==3
    25772536        UvData.Field.ZMax=max(CoordMax(ind,1));
     
    30733032    if strcmp(transform_fct,'sub_field')
    30743033        set(handles.TransformName,'Value',1)%suppress the sub_field transform
    3075         T
    3076        
    3077        
    3078         ransformName_Callback(hObject, eventdata, handles);
     3034        TransformName_Callback(hObject, eventdata, handles);
    30793035    else
    30803036        run0_Callback(hObject, eventdata, handles)
    30813037    end 
    30823038else
    3083     MenuBrowse_1_Callback(hObject, eventdata, handles)
     3039    %RootPath=get(handles.RootPath,'String');
     3040    %SubDir=get(handles.SubDir,'String');
     3041    fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String'));
     3042    if isempty(fileinput_1)
     3043        set(handles.SubField,'Value',0)
     3044    else
     3045       
     3046        % refresh the current displayed field
     3047        set(handles.SubField,'Value',1)
     3048        display_file_name(handles,fileinput_1,2)
     3049       
     3050        %update list of recent files in the menubar
     3051        MenuFile_1=fileinput_1;
     3052        MenuFile_2=get(handles.MenuFile_1,'Label');
     3053        MenuFile_3=get(handles.MenuFile_2,'Label');
     3054        MenuFile_4=get(handles.MenuFile_3,'Label');
     3055        MenuFile_5=get(handles.MenuFile_4,'Label');
     3056        set(handles.MenuFile_1,'Label',MenuFile_1)
     3057        set(handles.MenuFile_2,'Label',MenuFile_2)
     3058        set(handles.MenuFile_3,'Label',MenuFile_3)
     3059        set(handles.MenuFile_4,'Label',MenuFile_4)
     3060        set(handles.MenuFile_5,'Label',MenuFile_5)
     3061    end
     3062    %     MenuBrowse_1_Callback(hObject, eventdata, handles)
    30843063end
    30853064
     
    32443223        % display the selected field and related information
    32453224        display_file_name(handles,imagename)%display the image
    3246 %     otherwise
     3225     otherwise
    32473226%         ext=get(handles.FileExt,'String');
    32483227%         if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
     
    32543233%             if ~ischar(FileName),return,end %abandon if the browser is cancelled
    32553234%             FullFileName=[PathName FileName];
    3256 %             % display the selected field and related information
    3257 %             display_file_name( handles,FullFileName)
    3258 %             return
    3259 %         end
    3260 end
    3261 % indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
    3262 % set(handles.FileIndex,'String',indices)
    3263 %
    3264 % %common to Fields_1_Callback
    3265 % list_fields_1=get(handles.FieldName_1,'String');% list menu fields
    3266 % field_1='';
    3267 % if ~isempty(list_fields_1)
    3268 %     field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string
    3269 % end
    3270 % if isequal(field,'image')||isequal(field_1,'image')
    3271 %     set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons
    3272 %     set(handles.num_Npx,'Visible','on')
    3273 %     set(handles.num_Npy,'Visible','on')
    3274 % else
    3275 %     set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons
    3276 %     set(handles.num_Npx,'Visible','off')
    3277 %     set(handles.num_Npy,'Visible','off')
    3278 % end
    3279 % if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    3280 %     run0_Callback(hObject, eventdata, handles)
    3281 % end
     3235            % display the selected field and related information
     3236             run0_Callback(hObject, eventdata, handles)
     3237end
    32823238
    32833239%----------------------------------------------------------------
     
    52405196function MenuSeries_Callback(hObject, eventdata, handles)
    52415197%------------------------------------------------------------------------
     5198Param=read_param(handles);
     5199series(Param); %run the series interface
     5200
     5201% --------------------------------------------------------------------
     5202function MenuPIV_Callback(hObject, eventdata, handles)
     5203    Param=read_param(handles);
     5204    Param.ActionName='civ_series';
     5205series(Param)
     5206
     5207%------------------------------------------------------------------------
     5208% -- open the GUI civ.fig for PIV
     5209function MenuCIVx_Callback(hObject, eventdata, handles)
     5210%------------------------------------------------------------------------
     5211 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     5212 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     5213civ(FileName);% interface de civ(not in the uvmat file)
     5214
     5215function Param=read_param(handles)
     5216   
    52425217[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    52435218Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name
     
    52825257Param.Coord_x_str=get(handles.Coord_x,'String');
    52835258Param.Coord_x_val=get(handles.Coord_x,'Value');
    5284 %Param.Coord_y_str=get(handles.Coord_y,'String');
    52855259Param.Coord_y_str=get(handles.Coord_y,'Data');
    5286 %Param.Coord_y_val=get(handles.Coord_y,'Value');
    5287 series(Param); %run the series interface
    5288 
    5289 %------------------------------------------------------------------------
    5290 % -- open the GUI civ.fig for PIV
    5291 function MenuCIVx_Callback(hObject, eventdata, handles)
    5292 %------------------------------------------------------------------------
    5293  [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    5294  FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    5295 civ(FileName);% interface de civ(not in the uvmat file)
    5296 
    5297 
    5298 % --------------------------------------------------------------------
    5299 function MenuPIV_Callback(hObject, eventdata, handles)
    5300 MenuSeries_Callback(hObject, eventdata, handles)
    5301 
    53025260
    53035261% --------------------------------------------------------------------
     
    54355393    end
    54365394end
    5437 
    5438 
Note: See TracChangeset for help on using the changeset viewer.