1 | %'uigetfile_uvmat': browser, and display of directories, faster than the Matlab fct uigetfile |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % fileinput=uigetfile_uvmat(title,InputName,FilterExt) |
---|
4 | % |
---|
5 | % OUTPUT: |
---|
6 | % fileinput: detected file name, including path |
---|
7 | % |
---|
8 | % INPUT: |
---|
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' |
---|
17 | % 'uigetdir'; browser used to select a directory (like the matlab browser 'uigetdir') |
---|
18 | |
---|
19 | %======================================================================= |
---|
20 | % Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France |
---|
21 | % http://www.legi.grenoble-inp.fr |
---|
22 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
23 | % |
---|
24 | % This file is part of the toolbox UVMAT. |
---|
25 | % |
---|
26 | % UVMAT is free software; you can redistribute it and/or modify |
---|
27 | % it under the terms of the GNU General Public License as published |
---|
28 | % by the Free Software Foundation; either version 2 of the license, |
---|
29 | % or (at your option) any later version. |
---|
30 | % |
---|
31 | % UVMAT is distributed in the hope that it will be useful, |
---|
32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
34 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
35 | %======================================================================= |
---|
36 | |
---|
37 | function fileinput=uigetfile_uvmat(title,InputName,FilterExt) |
---|
38 | if ~exist('FilterExt','var') |
---|
39 | FilterExt='*'; |
---|
40 | end |
---|
41 | fileinput=''; %default file selection |
---|
42 | if strcmp(title,'status_display') |
---|
43 | option='status_display'; |
---|
44 | else |
---|
45 | option='browser'; |
---|
46 | end |
---|
47 | InputDir=pwd;%look in the current work directory if the input file does not exist |
---|
48 | InputFileName='';%default |
---|
49 | if ischar(InputName) |
---|
50 | if exist(InputName,'dir') |
---|
51 | InputDir=InputName; |
---|
52 | InputFileName=''; |
---|
53 | elseif exist(InputName,'file') |
---|
54 | [InputDir,InputFileName,Ext]=fileparts(InputName); |
---|
55 | if isempty(InputFileName)% if InputName is already the root |
---|
56 | InputFileName=InputDir; |
---|
57 | if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems |
---|
58 | % InputDir=[InputDir '\'];% append '\' for a correct action of dir |
---|
59 | InputFileName=[InputFileName '\']; |
---|
60 | end |
---|
61 | end |
---|
62 | if isdir(InputName) |
---|
63 | InputFileName=['+/' InputFileName Ext]; |
---|
64 | end |
---|
65 | end |
---|
66 | end |
---|
67 | if ismember(computer,{'PCWIN','PCWIN64'})%case of Windows systems |
---|
68 | InputDir=[InputDir '\'];% append '\' for a correct action of dir |
---|
69 | end |
---|
70 | hfig=findobj(allchild(0),'tag',option); |
---|
71 | if isempty(hfig) |
---|
72 | set(0,'Unit','points') |
---|
73 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
74 | Width=350;% fig width in points (1/72 inch) |
---|
75 | Height=min(0.8*ScreenSize(4),500); |
---|
76 | Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 |
---|
77 | Bottom=ScreenSize(4)-Height-40; %put fig at top right |
---|
78 | hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',InputDir); |
---|
79 | BackgroundColor=get(hfig,'Color'); |
---|
80 | path_title=uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.97 0.9 0.03],'BackgroundColor',BackgroundColor,'Tag','Path_title',... |
---|
81 | 'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); |
---|
82 | htitlebox=uicontrol('Style','edit','Units','normalized', 'Position', [0.02 0.89 0.96 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,... |
---|
83 | 'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''titlebox'':current path'); |
---|
84 | uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.02 0.77 0.1 0.05],... |
---|
85 | 'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward,'TooltipString','move backward'); |
---|
86 | home_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.14 0.77 0.2 0.05],... |
---|
87 | 'String','Work dir','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir,'TooltipString','reach the current Matlab working directory'); |
---|
88 | uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.36 0.77 0.2 0.05],'Callback',@refresh_GUI,... |
---|
89 | 'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12); |
---|
90 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.75 0.74 0.23 0.05],'tag','sort_option','Callback',@refresh_GUI,'Visible','off',... |
---|
91 | 'String',{'sort name';'sort date'},'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''sort_option'': sort the files by names or dates'); |
---|
92 | uicontrol('Style','listbox','Units','normalized', 'Position',[0.02 0.08 0.96 0.66], 'Callback', @(src,event)list_Callback(option,FilterExt,src,event),'tag','list',... |
---|
93 | 'FontUnits','points','FontSize',12,'TooltipString','''list'':current list of directories, marked by +/, and files'); |
---|
94 | |
---|
95 | OK_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.58 0.005 0.2 0.07],'BackgroundColor',[0 1 0],... |
---|
96 | 'String','OK','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@(src,event)OK_Callback(option,FilterExt,src,event)); |
---|
97 | close_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.78 0.005 0.2 0.07],'Callback',@(src,event)close(option,src,event),... |
---|
98 | 'FontWeight','bold','FontUnits','points','FontSize',12); |
---|
99 | %set(hrefresh,'UserData',StatusData) |
---|
100 | if strcmp(option,'status_display') %put a run advancement display |
---|
101 | set(hfig,'DeleteFcn',@(src,event)close(option,src,event)) |
---|
102 | uicontrol('Style','frame','Units','normalized', 'Position', [0.02 0.85 0.9 0.04]); |
---|
103 | uicontrol('Style','frame','Units','normalized', 'Position',[0.02 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
104 | % uicontrol('Style','text','Units','normalized', 'Position', [0.4 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,... |
---|
105 | % 'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right'); |
---|
106 | delete(home_button) |
---|
107 | set(OK_button,'String','Open') |
---|
108 | set(close_button,'String','Close') |
---|
109 | elseif strcmp(FilterExt,'uigetdir') %pick a directory |
---|
110 | set(path_title,'String',title); %show the input title for path (directory) |
---|
111 | set(OK_button,'String','Select') |
---|
112 | set(close_button,'String','Cancel') |
---|
113 | else %put a title and additional pushbuttons |
---|
114 | uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.74 0.6 0.03],'BackgroundColor',BackgroundColor,... |
---|
115 | 'String',title,'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); |
---|
116 | uicontrol('Style','togglebutton','Units','normalized', 'Position', [0.75 0.78 0.23 0.04],'tag','check_date','Callback',@dates_Callback,... |
---|
117 | 'String','show dates','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''check_date'':press button to display dates'); |
---|
118 | % uicontrol('Style','text','Units','normalized', 'Position', [0.37 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,... |
---|
119 | % 'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right'); |
---|
120 | set(OK_button,'String','Open') |
---|
121 | set(close_button,'String','Cancel') |
---|
122 | end |
---|
123 | drawnow |
---|
124 | end |
---|
125 | refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir |
---|
126 | if ~strcmp(option,'status_display') |
---|
127 | uiwait(hfig) |
---|
128 | if ishandle(hfig) |
---|
129 | htitlebox=findobj(hfig,'Tag','titlebox'); |
---|
130 | fileinput=get(htitlebox,'String');% retrieve the input file selection |
---|
131 | delete(hfig) |
---|
132 | end |
---|
133 | end |
---|
134 | |
---|
135 | %------------------------------------------------------------------------ |
---|
136 | % --- launched by refreshing the display figure |
---|
137 | %------------------------------------------------------------------------ |
---|
138 | function titlebox_Callback(hObject,event) |
---|
139 | refresh_GUI(hObject) |
---|
140 | |
---|
141 | %------------------------------------------------------------------------ |
---|
142 | % --- launched by selecting OK (relevant for FilterExt='uigetdir') |
---|
143 | %------------------------------------------------------------------------ |
---|
144 | function OK_Callback(option,filter_ext,hObject,event) |
---|
145 | set(hObject,'backgroundColor',[1 1 0])% indicate button activation |
---|
146 | hfig=get(hObject,'parent');%handle of the fig |
---|
147 | htitlebox=findobj(hfig,'tag','titlebox'); % display the current dir name |
---|
148 | DirName=get(htitlebox,'String'); |
---|
149 | if isempty(regexp(DirName,'^http://'))% if the input dir is not a web site (begins by http://) |
---|
150 | % FullSelectName=DirName; |
---|
151 | % else |
---|
152 | if ~strcmp(filter_ext,'uigetdir')% a file is expected as output, not a dir |
---|
153 | hlist=findobj(hfig,'Tag','list'); |
---|
154 | list=get(hlist,'String'); |
---|
155 | index=get(hlist,'Value'); |
---|
156 | if ~isempty(regexp(list{index},'^\+/')) |
---|
157 | return % quit if a dir has been opened |
---|
158 | end |
---|
159 | %SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir |
---|
160 | SelectName=list{index}; |
---|
161 | ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond '...' |
---|
162 | if ~isempty(ind_dot) |
---|
163 | SelectName=SelectName(1:ind_dot-1); |
---|
164 | end |
---|
165 | FullSelectName=fullfile(DirName,SelectName); |
---|
166 | % if regexp(DirName,'^http://')% if the input dir is a web site (begins by http://) |
---|
167 | |
---|
168 | if exist(FullSelectName,'file') |
---|
169 | switch option |
---|
170 | case 'browser' |
---|
171 | set(htitlebox,'String',FullSelectName); |
---|
172 | uiresume(hfig) |
---|
173 | case 'status_display' |
---|
174 | FileInfo=get_file_info(FullSelectName); |
---|
175 | if strcmp(FileInfo.FileType,'txt') |
---|
176 | edit(FullSelectName) |
---|
177 | elseif strcmp(FileInfo.FileType,'xml') |
---|
178 | editxml(FullSelectName) |
---|
179 | elseif strcmp(FileInfo.FileType,'figure') |
---|
180 | open(FullSelectName) |
---|
181 | else |
---|
182 | uvmat(FullSelectName); |
---|
183 | end |
---|
184 | end |
---|
185 | end |
---|
186 | end |
---|
187 | end |
---|
188 | set(hObject,'backgroundColor',[0 1 0])% indicate end button activation |
---|
189 | uiresume(get(hObject,'parent')) |
---|
190 | |
---|
191 | %------------------------------------------------------------------------ |
---|
192 | % --- launched by refreshing the display figure |
---|
193 | function refresh_GUI(hObject,InputFileName,FilterExt) |
---|
194 | %------------------------------------------------------------------------ |
---|
195 | if ~exist('InputFileName','var') |
---|
196 | InputFileName=''; |
---|
197 | end |
---|
198 | if ~exist('FilterExt','var') |
---|
199 | FilterExt='*'; |
---|
200 | end |
---|
201 | if strcmp(FilterExt,'uigetdir') |
---|
202 | FilterExt='*'; |
---|
203 | end |
---|
204 | hfig=get(hObject,'parent'); |
---|
205 | hlist=findobj(hfig,'tag','list');% find the list object |
---|
206 | set(hlist,'BackgroundColor',[1 1 0]) |
---|
207 | drawnow |
---|
208 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
209 | DirName=get(htitlebox,'String'); |
---|
210 | hsort_option=findobj(hfig,'tag','sort_option'); |
---|
211 | if strcmp(get(hfig,'Tag'),'status_display') |
---|
212 | hseries=findobj(allchild(0),'tag','series'); |
---|
213 | hstatus=findobj(hseries,'tag','status'); |
---|
214 | StatusData=get(hstatus,'UserData'); |
---|
215 | TimeStart=0; |
---|
216 | if isfield(StatusData,'TimeStart') |
---|
217 | TimeStart=StatusData.TimeStart; |
---|
218 | end |
---|
219 | hlist=findobj(hfig,'tag','list'); |
---|
220 | testrecent=0; |
---|
221 | NbOutputFile=[]; |
---|
222 | if isfield(StatusData,'NbOutputFile') |
---|
223 | NbOutputFile=StatusData.NbOutputFile; |
---|
224 | NbOutputFile_str=num2str(NbOutputFile); |
---|
225 | end |
---|
226 | [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content |
---|
227 | |
---|
228 | %% update the waitbar |
---|
229 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
230 | if ~isempty(NbOutputFile) |
---|
231 | BarPosition=get(hwaitbar,'Position'); |
---|
232 | BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead |
---|
233 | set(hwaitbar,'Position',BarPosition) |
---|
234 | end |
---|
235 | else |
---|
236 | sort_option='name'; |
---|
237 | if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) |
---|
238 | sort_option='date'; |
---|
239 | end |
---|
240 | hcheck_date=findobj(hfig,'tag','check_date'); |
---|
241 | [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option,FilterExt);% list the directory content |
---|
242 | end |
---|
243 | |
---|
244 | set(hlist,'String',ListFiles) |
---|
245 | Value=[]; |
---|
246 | if ~isempty(InputFileName) |
---|
247 | Value=find(strcmp(InputFileName,ListFiles)); |
---|
248 | end |
---|
249 | if isempty(Value) |
---|
250 | Value=1; |
---|
251 | end |
---|
252 | set(hlist,'Value',Value) |
---|
253 | set(hlist,'BackgroundColor',[0.7 0.7 0.7]) |
---|
254 | |
---|
255 | %------------------------------------------------------------------------ |
---|
256 | % --- launched by selecting an item on the file list |
---|
257 | %------------------------------------------------------------------------ |
---|
258 | function dates_Callback(hObject,event) |
---|
259 | |
---|
260 | hfig=get(hObject,'parent'); |
---|
261 | hsort_option=findobj(hfig,'tag','sort_option'); |
---|
262 | if get(hObject,'Value') |
---|
263 | set(hsort_option,'Visible','on') |
---|
264 | set(hsort_option,'Value',2) |
---|
265 | else |
---|
266 | set(hsort_option,'Visible','off') |
---|
267 | end |
---|
268 | refresh_GUI(hObject,[]) |
---|
269 | |
---|
270 | |
---|
271 | %------------------------------------------------------------------------ |
---|
272 | % --- launched by selecting an item on the file list |
---|
273 | function list_Callback(option,filter_ext,hObject,event) |
---|
274 | %------------------------------------------------------------------------ |
---|
275 | hfig=get(hObject,'parent');%handle of the fig |
---|
276 | set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action |
---|
277 | drawnow |
---|
278 | list=get(hObject,'String'); |
---|
279 | index=get(hObject,'Value'); |
---|
280 | |
---|
281 | htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name |
---|
282 | DirName=get(htitlebox,'String'); |
---|
283 | SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir |
---|
284 | ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond '...' |
---|
285 | if ~isempty(ind_dot) |
---|
286 | SelectName=SelectName(1:ind_dot-1); |
---|
287 | end |
---|
288 | if strcmp(SelectName,'..')% the upward dir option has been selected |
---|
289 | FullSelectName=fileparts(DirName); |
---|
290 | else |
---|
291 | FullSelectName=fullfile(DirName,SelectName); |
---|
292 | end |
---|
293 | if exist(FullSelectName,'dir')% a directory has been selected |
---|
294 | set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action |
---|
295 | drawnow |
---|
296 | hbackward=findobj(hfig,'Tag','backward'); |
---|
297 | set(hbackward,'UserData',DirName); %store the current dir for future backward action |
---|
298 | hsort_option=findobj(hfig,'tag','sort_option'); |
---|
299 | sort_option='name';%default |
---|
300 | if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) |
---|
301 | sort_option='date'; |
---|
302 | end |
---|
303 | hcheck_date=findobj(hfig,'tag','check_date'); |
---|
304 | |
---|
305 | ListFiles=list_files(FullSelectName,get(hcheck_date,'Value'),sort_option,filter_ext);% list the directory content |
---|
306 | set(hObject,'Value',1) |
---|
307 | set(hObject,'String',ListFiles) |
---|
308 | set(hObject,'BackgroundColor',[0.7 0.7 0.7]) |
---|
309 | set(htitlebox,'String',FullSelectName)% record the new dir name |
---|
310 | end |
---|
311 | set(hObject,'BackgroundColor',[0.7 0.7 0.7])% paint list in grey to indicate action end |
---|
312 | |
---|
313 | %------------------------------------------------------------------------- |
---|
314 | % list the content of a directory |
---|
315 | function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext) |
---|
316 | %------------------------------------------------------------------------- |
---|
317 | ListStruct=dir(DirName);% get structure of the current directory |
---|
318 | NumFiles=0; %default |
---|
319 | if numel(ListStruct)<1 % case of empty dir |
---|
320 | % if regexp(DirName,'^http://')% if the input dir is a web site (begins by http://) |
---|
321 | % web(DirName) |
---|
322 | % else |
---|
323 | ListFiles={}; |
---|
324 | return |
---|
325 | % end |
---|
326 | end |
---|
327 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
328 | ListFiles=ListCells(1,:);%list of file names |
---|
329 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
330 | ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display |
---|
331 | if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir') |
---|
332 | if strcmp(filter_ext,'image') |
---|
333 | check_keep=cellfun(@isimage,ListFiles) ; |
---|
334 | elseif strcmp(filter_ext(1),'.') |
---|
335 | ind_ext=regexp(ListFiles,[filter_ext '$']);%look for the input file extension |
---|
336 | check_keep=~cellfun('isempty',ind_ext); |
---|
337 | end |
---|
338 | check_keep=check_keep|check_dir; |
---|
339 | ListFiles=ListFiles(check_keep); |
---|
340 | ListCells=ListCells(:,check_keep); |
---|
341 | check_dir=check_dir(check_keep); |
---|
342 | end |
---|
343 | check_emptydate=cellfun('isempty',ListCells(5,:));% = 1 if datenum undefined |
---|
344 | ListCells(5,find(check_emptydate))={0}; %set to 0 the empty dates |
---|
345 | ListDates=cell2mat(ListCells(5,:));%list of numerical dates |
---|
346 | if isnumeric(sort_option) |
---|
347 | check_old=ListDates<sort_option-1;% -1 is put to account for a 1 s delay in the record of starting time |
---|
348 | NumFiles=numel(find(~check_old&~check_dir)); |
---|
349 | end |
---|
350 | if ~isempty(find(~check_dir)) |
---|
351 | ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front |
---|
352 | end |
---|
353 | |
---|
354 | if isnumeric(sort_option)|| strcmp(sort_option,'date') |
---|
355 | [tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list |
---|
356 | else |
---|
357 | [tild,index_sort]=sort(check_dir,2,'descend');% put the dir first in the list |
---|
358 | end |
---|
359 | ListFiles=ListFiles(index_sort);% list of names sorted by alaphabetical order and dir and file |
---|
360 | cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) |
---|
361 | check_keep=cellfun('isempty', cell_remove); |
---|
362 | ListFiles=[{'+/..'} ListFiles(check_keep)]; |
---|
363 | if check_date |
---|
364 | ListDateString=ListCells(2,:);%list of file dates |
---|
365 | if isnumeric(sort_option) |
---|
366 | ListDateString(check_old)={'--OLD--'}; |
---|
367 | end |
---|
368 | ListDateString(check_dir)={''}; |
---|
369 | ListDateString=ListDateString(index_sort);% sort the corresponding dates |
---|
370 | ListDateString=[{''} ListDateString(check_keep)]; |
---|
371 | ListFiles=[ListFiles; ListDateString]; |
---|
372 | ListFiles=cell2tab(ListFiles','...'); |
---|
373 | end |
---|
374 | |
---|
375 | %------------------------------------------------------------------------ |
---|
376 | % --- launched by selecting home |
---|
377 | function home_dir(hObject,event) |
---|
378 | %------------------------------------------------------------------------ |
---|
379 | DirName=pwd; |
---|
380 | hfig=get(hObject,'parent'); |
---|
381 | hlist=findobj(hfig,'tag','list');% find the list object |
---|
382 | set(hlist,'BackgroundColor',[1 1 0]) |
---|
383 | drawnow |
---|
384 | sort_option='name';%default |
---|
385 | hsort_option=findobj(hfig,'tag','sort_option'); |
---|
386 | if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) |
---|
387 | sort_option='date'; |
---|
388 | end |
---|
389 | hcheck_date=findobj(hfig,'tag','check_date'); |
---|
390 | ListFiles=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content |
---|
391 | htitlebox=findobj(hfig,'Tag','titlebox'); |
---|
392 | set(htitlebox,'String',DirName)% record the new dir name |
---|
393 | set(hlist,'Value',1) |
---|
394 | set(hlist,'String',ListFiles) |
---|
395 | set(hlist,'BackgroundColor',[0.7 0.7 0.7]) |
---|
396 | %------------------------------------------------------------------------ |
---|
397 | |
---|
398 | %------------------------------------------------------------------------ |
---|
399 | % --- launched by pressing the backward (<--) button |
---|
400 | function backward(hObject,event) |
---|
401 | %------------------------------------------------------------------------ |
---|
402 | PrevDir=get(hObject,'UserData'); |
---|
403 | if ~isempty(PrevDir) |
---|
404 | hfig=get(hObject,'parent'); |
---|
405 | htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name |
---|
406 | set(htitlebox,'String',PrevDir) |
---|
407 | refresh_GUI(findobj(hfig,'Tag','refresh')) |
---|
408 | end |
---|
409 | |
---|
410 | %------------------------------------------------------------------------- |
---|
411 | % --- launched by deleting the status figure (only used in mode series status') |
---|
412 | %------------------------------------------------------------------------- |
---|
413 | function close(option,hObject, eventdata) |
---|
414 | |
---|
415 | if strcmp(option,'status_display') |
---|
416 | hseries=findobj(allchild(0),'Tag','series'); |
---|
417 | hstatus=findobj(hseries,'Tag','status'); |
---|
418 | set(hstatus,'value',0) %reset the status uicontrol in the GUI series |
---|
419 | set(hstatus,'BackgroundColor',[0 1 0]) |
---|
420 | end |
---|
421 | delete(gcbf) |
---|
422 | |
---|
423 | %------------------------------------------------------------------------- |
---|
424 | % --- check whether a file is has an image name extension |
---|
425 | %------------------------------------------------------------------------- |
---|
426 | function CheckImage=isimage(filename) |
---|
427 | |
---|
428 | [pp,name,ext]=fileparts(filename); |
---|
429 | CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.',''))); |
---|