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