Changeset 648 for trunk/src/uigetfile_uvmat.m
- Timestamp:
- Jun 9, 2013, 10:31:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uigetfile_uvmat.m
r646 r648 1 1 %'uigetfile_uvmat': browser, and display of directories, faster than the Matlab fct uigetfile 2 2 %------------------------------------------------------------------------ 3 % hfig=uigetfile_uvmat(OutputDir,option)3 % fileinput=uigetfile_uvmat(title,InputName,FilterExt) 4 4 % 5 5 % OUTPUT: … … 7 7 % 8 8 % 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' 11 17 12 18 function fileinput=uigetfile_uvmat(title,InputName,FilterExt) … … 106 112 InputFileName=''; 107 113 end 114 if ~exist('FilterExt','var') 115 FilterExt='*'; 116 end 108 117 hfig=get(hObject,'parent'); 109 118 hlist=findobj(hfig,'tag','list');% find the list object … … 222 231 set(hObject,'BackgroundColor',[0.7 0.7 0.7]) 223 232 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' 233 elseif 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 239 247 uvmat(FullSelectName); 240 end248 end 241 249 end 242 250 end … … 256 264 ListFiles=ListCells(1,:);%list of file names 257 265 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 258 259 266 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 267 if 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); 278 end 260 279 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 261 280 if isnumeric(sort_option) … … 275 294 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 276 295 check_keep=cellfun('isempty', cell_remove); 277 if exist('filter_ext')278 switch filter_ext279 case 'image'280 check_keep=check_keep & (cellfun(@isimage,ListFiles) |check_dir);281 end282 end283 296 ListFiles=[{'+/..'} ListFiles(check_keep)]; 284 297 if check_date … … 348 361 349 362 [pp,name,ext]=fileparts(filename); 350 ext351 363 CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.','')));
Note: See TracChangeset
for help on using the changeset viewer.