Ignore:
Timestamp:
Jun 9, 2013, 10:31:58 PM (11 years ago)
Author:
sommeria
Message:

get_field updated, several bugs corrected,open_uvmat suppressd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uigetfile_uvmat.m

    r646 r648  
    11%'uigetfile_uvmat': browser, and display of directories, faster than the Matlab fct uigetfile
    22%------------------------------------------------------------------------
    3 % hfig=uigetfile_uvmat(OutputDir,option)
     3% fileinput=uigetfile_uvmat(title,InputName,FilterExt)
    44%
    55% OUTPUT:
     
    77%
    88% INPUT:
    9 % title: = displayed title, 'status': display advancement of a series calculation
    10 % InputDir: directory to browse at first display
     9% title: = displayed title,
     10%        if title='status_display': display advancement of a series calculation,
     11%        else uigetfile_uvmat used as browser.
     12% InputName: initial file or directory selection for the browser
     13% FilterExt: string to filter the file display:
     14%          '*' (default) all files displayed
     15%          'image': any image or movie
     16%          '.ext': display only files with extension '.ext'
    1117
    1218function fileinput=uigetfile_uvmat(title,InputName,FilterExt)
     
    106112    InputFileName='';
    107113end
     114if ~exist('FilterExt','var')
     115    FilterExt='*';
     116end
    108117hfig=get(hObject,'parent');
    109118hlist=findobj(hfig,'tag','list');% find the list object
     
    222231    set(hObject,'BackgroundColor',[0.7 0.7 0.7])
    223232    set(htitlebox,'String',FullSelectName)% record the new dir name
    224 elseif exist(FullSelectName,'file')%visualise the field if it exists
    225     FileType=get_file_type(FullSelectName);
    226     if strcmp(FileType,'txt')
    227         edit(FullSelectName)
    228     elseif strcmp(FileType,'xml')
    229         editxml(FullSelectName)
    230     elseif strcmp(FileType,'figure')
    231         open(FullSelectName)
    232     else
    233         %uvmat(FullSelectName);
    234         switch option
    235             case 'browser'
    236                 set(htitlebox,'String',FullSelectName);
    237                 uiresume(hfig)
    238             case 'status_display'
     233elseif exist(FullSelectName,'file')%visualise the field if it exists 
     234    switch option
     235        case 'browser'
     236            set(htitlebox,'String',FullSelectName);
     237            uiresume(hfig)
     238        case 'status_display'
     239            FileType=get_file_type(FullSelectName);
     240            if strcmp(FileType,'txt')
     241                edit(FullSelectName)
     242            elseif strcmp(FileType,'xml')
     243                editxml(FullSelectName)
     244            elseif strcmp(FileType,'figure')
     245                open(FullSelectName)
     246            else
    239247                uvmat(FullSelectName);
    240         end
     248            end
    241249    end
    242250end
     
    256264ListFiles=ListCells(1,:);%list of file names
    257265check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    258 
    259266ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
     267if exist('filter_ext','var') && ~strcmp(filter_ext,'*')
     268    if strcmp(filter_ext,'image')
     269        check_keep=cellfun(@isimage,ListFiles) ;
     270    elseif strcmp(filter_ext(1),'.')
     271        ind_ext=regexp(ListFiles,[filter_ext '$']);%look for the input file extension
     272        check_keep=~cellfun('isempty',ind_ext);
     273    end
     274    check_keep=check_keep|check_dir;
     275    ListFiles=ListFiles(check_keep);
     276    ListCells=ListCells(:,check_keep);
     277    check_dir=check_dir(check_keep);
     278end
    260279ListDates=cell2mat(ListCells(5,:));%list of numerical dates
    261280if isnumeric(sort_option)
     
    275294cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
    276295check_keep=cellfun('isempty', cell_remove);
    277 if exist('filter_ext')
    278     switch filter_ext
    279         case 'image'
    280             check_keep=check_keep & (cellfun(@isimage,ListFiles) |check_dir);
    281     end
    282 end
    283296ListFiles=[{'+/..'} ListFiles(check_keep)];
    284297if check_date
     
    348361
    349362[pp,name,ext]=fileparts(filename);
    350 ext
    351363CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.','')));
Note: See TracChangeset for help on using the changeset viewer.