Changeset 635 for trunk/src/uigetfile_uvmat.m
- Timestamp:
- May 19, 2013, 11:37:49 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uigetfile_uvmat.m
r620 r635 67 67 %set(hrefresh,'UserData',StatusData) 68 68 if strcmp(option,'status_display') %put a run advancement display 69 set(hfig,'DeleteFcn',@stop_status) 70 uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.81 0.01 0.05],'BackgroundColor',[1 0 0],'tag','waitbar'); 71 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 69 set(hfig,'DeleteFcn',@(src,event)close(option,src,event)) 70 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.85 0.9 0.04]); 71 uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar'); 72 72 73 else %put a title and additional pushbuttons 73 74 uicontrol('Style','text','Units','normalized', 'Position', [0.15 0.75 0.6 0.03],'BackgroundColor',BackgroundColor,... … … 109 110 DirName=get(htitlebox,'String'); 110 111 hsort_option=findobj(hfig,'tag','sort_option'); 111 sort_option='name'; 112 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) 113 sort_option='date'; 114 end 115 hcheck_date=findobj(hfig,'tag','check_date'); 116 ListFiles=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content 117 118 set(hlist,'String',ListFiles) 119 Value=[]; 120 if ~isempty(InputFileName) 121 Value=find(strcmp(InputFileName,ListFiles)); 122 end 123 if isempty(Value) 124 Value=1; 125 end 126 set(hlist,'Value',Value) 127 set(hlist,'BackgroundColor',[0.7 0.7 0.7]) 128 if strcmp(get(hfig,'Tag'),'status_display') 112 if strcmp(get(hfig,'Tag'),'status_display') 129 113 hseries=findobj(allchild(0),'tag','series'); 130 hstatus=findobj(hseries,'tag','status _display');114 hstatus=findobj(hseries,'tag','status'); 131 115 StatusData=get(hstatus,'UserData'); 132 116 TimeStart=0; 133 117 if isfield(StatusData,'TimeStart') 134 118 TimeStart=StatusData.TimeStart; 135 end 119 end 136 120 hlist=findobj(hfig,'tag','list'); 137 testrecent=0; 138 datnum=zeros(numel(ListDisplay),1); 139 for ilist=1:numel(ListDisplay) 140 ListDisplay{ilist}=ListFiles(ilist).name; 141 if ListFiles(ilist).isdir 142 ListDisplay{ilist}=['/' ListDisplay{ilist}]; 143 elseif isfield(ListFiles(ilist),'datenum') 144 datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions 145 testrecent=1; 146 if datnum(ilist)<TimeStart 147 ListDisplay{ilist}=[ListDisplay{ilist} ' --OLD--']; 148 end 149 end 150 end 151 152 %% Look at date of creation 153 ListDisplay=ListDisplay(datnum~=0); 154 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 155 121 testrecent=0; 156 122 NbOutputFile=[]; 157 if isempty(datnum) 158 if testrecent 159 message='no result created yet'; 160 else 161 message=''; 162 end 163 else 164 [first,indfirst]=min(datnum); 165 [last,indlast]=max(datnum); 166 NbOutputFile_str='?'; 167 if isfield(StatusData,'NbOutputFile') 168 NbOutputFile=StatusData.NbOutputFile; 169 NbOutputFile_str=num2str(NbOutputFile); 170 end 171 message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];... 172 ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]}; 173 end 174 set(htitlebox,'String', [DirName{1};message]) 123 if isfield(StatusData,'NbOutputFile') 124 NbOutputFile=StatusData.NbOutputFile; 125 NbOutputFile_str=num2str(NbOutputFile); 126 end 127 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 175 128 176 129 %% update the waitbar … … 178 131 if ~isempty(NbOutputFile) 179 132 BarPosition=get(hwaitbar,'Position'); 180 BarPosition(3)=0.9* numel(datnum)/NbOutputFile;133 BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead 181 134 set(hwaitbar,'Position',BarPosition) 182 135 end 183 end 184 136 else 137 sort_option='name'; 138 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) 139 sort_option='date'; 140 end 141 hcheck_date=findobj(hfig,'tag','check_date'); 142 [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content 143 end 144 145 set(hlist,'String',ListFiles) 146 Value=[]; 147 if ~isempty(InputFileName) 148 Value=find(strcmp(InputFileName,ListFiles)); 149 end 150 if isempty(Value) 151 Value=1; 152 end 153 set(hlist,'Value',Value) 154 set(hlist,'BackgroundColor',[0.7 0.7 0.7]) 185 155 %------------------------------------------------------------------------ 186 156 % --- launched by selecting an item on the file list … … 272 242 %------------------------------------------------------------------------- 273 243 % list the content of a directory 274 function ListFiles=list_files(DirName,check_date,sort_option)244 function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option) 275 245 %------------------------------------------------------------------------- 276 246 ListStruct=dir(DirName);% get structure of the current directory 247 NumFiles=0; %default 277 248 if numel(ListStruct)<1 % case of empty dir 278 249 ListFiles={}; … … 283 254 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 284 255 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 285 if strcmp(sort_option,'date') 286 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 287 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front 256 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 257 if isnumeric(sort_option) 258 check_old=ListDates<sort_option-1;% -1 is put to account for a 1 s delay in the record of starting time 259 NumFiles=numel(find(~check_old&~check_dir)); 260 end 261 if ~isempty(find(~check_dir)) 262 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front 263 end 264 if isnumeric(sort_option)|| strcmp(sort_option,'date') 288 265 [tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list 289 266 else … … 295 272 ListFiles=[{'+/..'} ListFiles(check_keep)]; 296 273 if check_date 297 ListDateString=ListCells(2,:);%list of file dates 298 ListDateString(check_dir)={''}; 299 ListDateString=ListDateString(index_sort);% sort the corresponding dates 300 ListDateString=[{''} ListDateString(check_keep)]; 301 ListFiles=[ListFiles; ListDateString]; 302 ListFiles=cell2tab(ListFiles','...'); 274 ListDateString=ListCells(2,:);%list of file dates 275 if isnumeric(sort_option) 276 ListDateString(check_old)={'--OLD--'}; 277 end 278 ListDateString(check_dir)={''}; 279 ListDateString=ListDateString(index_sort);% sort the corresponding dates 280 ListDateString=[{''} ListDateString(check_keep)]; 281 ListFiles=[ListFiles; ListDateString]; 282 ListFiles=cell2tab(ListFiles','...'); 303 283 end 304 284 … … 343 323 %------------------------------------------------------------------------- 344 324 if strcmp(option,'status_display') 345 hseries=findobj(allchild(0),' tag','series');346 hstatus=findobj(h fig,'Tag','status_display');347 set(h hciv.status,'value',0) %reset the status uicontrol in the GUI civ348 set(h hciv.status,'BackgroundColor',[0 1 0])325 hseries=findobj(allchild(0),'Tag','series'); 326 hstatus=findobj(hseries,'Tag','status'); 327 set(hstatus,'value',0) %reset the status uicontrol in the GUI series 328 set(hstatus,'BackgroundColor',[0 1 0]) 349 329 end 350 330 delete(gcbf)
Note: See TracChangeset
for help on using the changeset viewer.