Changeset 610 for trunk/src/uigetfile_uvmat.m
- Timestamp:
- Apr 14, 2013, 9:37:42 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uigetfile_uvmat.m
r609 r610 12 12 function fileinput=uigetfile_uvmat(title,InputName) 13 13 fileinput=''; %default file selection 14 if strcmp(title,'status ')15 option='status ';14 if strcmp(title,'status_display') 15 option='status_display'; 16 16 else 17 17 option='browser'; 18 18 end 19 if exist(InputName,'file')||exist(InputName,'dir') 19 if exist(InputName,'dir') 20 InputDir=InputName; 21 InputFileName=''; 22 elseif exist(InputName,'file') 20 23 [InputDir,InputFileName,Ext]=fileparts(InputName); 21 InputFileName=[InputFileName Ext]; 24 if isempty(InputFileName)% if InputName is already the root 25 InputFileName=InputDir; 26 if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems 27 InputDir=[InputDir '\'];% append '\' for a correct action of dir 28 InputFileName=[InputFileName '\']; 29 end 30 end 22 31 if isdir(InputName) 23 InputFileName=['+/' InputFileName ];32 InputFileName=['+/' InputFileName Ext]; 24 33 end 25 34 else … … 45 54 'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12); 46 55 %set(hrefresh,'UserData',StatusData) 47 if strcmp(option,'status ') %put a run advancement display56 if strcmp(option,'status_display') %put a run advancement display 48 57 set(hfig,'DeleteFcn',@stop_status) 49 58 uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.81 0.01 0.05],'BackgroundColor',[1 0 0],'tag','waitbar'); … … 59 68 drawnow 60 69 end 61 refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName) 62 if ~strcmp(option,'status ')70 refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName)% refresh the list of content of the current dir 71 if ~strcmp(option,'status_display') 63 72 uiwait(hfig) 64 end 65 fileinput=get(hfig,'UserData');% retrieve the input file selection 66 delete(hfig) 73 fileinput=get(hfig,'UserData');% retrieve the input file selection 74 delete(hfig) 75 end 76 77 78 79 %------------------------------------------------------------------------ 80 % --- launched by refreshing the display figure 81 function refresh_GUI(hObject,InputFileName) 82 %------------------------------------------------------------------------ 83 if ~exist('InputFileName','var') 84 InputFileName=''; 85 end 86 hfig=get(hObject,'parent'); 87 DirName=get(hfig,'UserData'); 88 ListFiles=list_files(DirName);% list the directory content 89 hlist=findobj(hfig,'tag','list');% find the list object 90 set(hlist,'String',ListFiles) 91 Value=[]; 92 if ~isempty(InputFileName) 93 Value=find(strcmp(InputFileName,ListFiles)); 94 end 95 if isempty(Value) 96 Value=1; 97 end 98 set(hlist,'Value',Value) 99 100 if strcmp(get(hfig,'Tag'),'status_display') 101 102 hseries=findobj(allchild(0),'tag','series'); 103 hstatus=findobj(hseries,'tag','status_display'); 104 StatusData=get(hstatus,'UserData'); 105 TimeStart=0; 106 if isfield(StatusData,'TimeStart') 107 TimeStart=StatusData.TimeStart; 108 end 109 110 111 htitlebox=findobj(hfig,'tag','titlebox'); 112 hlist=findobj(hfig,'tag','list'); 113 OutputDir=get(hfig,'UserData'); 114 115 testrecent=0; 116 datnum=zeros(numel(ListDisplay),1); 117 for ilist=1:numel(ListDisplay) 118 ListDisplay{ilist}=ListFiles(ilist).name; 119 if ListFiles(ilist).isdir 120 ListDisplay{ilist}=['/' ListDisplay{ilist}]; 121 elseif isfield(ListFiles(ilist),'datenum') 122 datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions 123 testrecent=1; 124 if datnum(ilist)<TimeStart 125 ListDisplay{ilist}=[ListDisplay{ilist} ' --OLD--']; 126 end 127 end 128 end 129 130 %% Look at date of creation 131 ListDisplay=ListDisplay(datnum~=0); 132 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 133 134 NbOutputFile=[]; 135 if isempty(datnum) 136 if testrecent 137 message='no result created yet'; 138 else 139 message=''; 140 end 141 else 142 [first,indfirst]=min(datnum); 143 [last,indlast]=max(datnum); 144 NbOutputFile_str='?'; 145 if isfield(StatusData,'NbOutputFile') 146 NbOutputFile=StatusData.NbOutputFile; 147 NbOutputFile_str=num2str(NbOutputFile); 148 end 149 message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];... 150 ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]}; 151 end 152 set(htitlebox,'String', [DirName{1};message]) 153 154 %% update the waitbar 155 hwaitbar=findobj(hfig,'tag','waitbar'); 156 if ~isempty(NbOutputFile) 157 BarPosition=get(hwaitbar,'Position'); 158 BarPosition(3)=0.9*numel(datnum)/NbOutputFile; 159 set(hwaitbar,'Position',BarPosition) 160 end 161 end 67 162 68 163 %------------------------------------------------------------------------ … … 118 213 set(hfig,'UserData',FullSelectName); 119 214 uiresume(hfig) 120 case 'status '215 case 'status_display' 121 216 uvmat(FullSelectName); 122 217 end 123 218 set(gcbo,'Value',1) 124 219 end 125 end126 127 %------------------------------------------------------------------------128 % --- launched by selecting home129 function home_dir(hObject,event)130 %------------------------------------------------------------------------131 DirName=pwd;132 ListFiles=list_files(DirName);% list the directory content133 hfig=get(hObject,'parent');134 set(hfig,'UserData',DirName)% record the new dir name135 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name136 set(htitlebox,'String',DirName)137 hlist=findobj(hfig,'tag','list');% find the list object138 set(hlist,'String',ListFiles)139 %------------------------------------------------------------------------140 141 %------------------------------------------------------------------------142 % --- launched by pressing the backward (<--) button143 function backward(hObject,event)144 %------------------------------------------------------------------------145 PrevDir=get(hObject,'UserData');146 if ~isempty(PrevDir)147 hfig=get(hObject,'parent');148 set(hfig,'UserData',PrevDir)149 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name150 set(htitlebox,'String',PrevDir)151 refresh_GUI(findobj(hfig,'Tag','refresh'))152 end153 154 %------------------------------------------------------------------------155 156 %------------------------------------------------------------------------157 % --- launched by refreshing the display figure158 function refresh_GUI(hObject,InputFileName)159 %------------------------------------------------------------------------160 if ~exist('InputFileName','var')161 InputFileName='';162 end163 hfig=get(hObject,'parent');164 DirName=get(hfig,'UserData');165 ListFiles=list_files(DirName);% list the directory content166 hlist=findobj(hfig,'tag','list');% find the list object167 set(hlist,'String',ListFiles)168 Value=[];169 if ~isempty(InputFileName)170 Value=find(strcmp(InputFileName,ListFiles));171 end172 if isempty(Value)173 Value=1;174 end175 set(hlist,'Value',Value)176 return177 178 %TODO adapt to series status179 hseries=findobj(allchild(0),'tag','series');180 hstatus=findobj(hseries,'tag','status');181 StatusData=get(hstatus,'UserData');182 TimeStart=0;183 if isfield(StatusData,'TimeStart')184 TimeStart=StatusData.TimeStart;185 end186 % testrecent=0;187 % datnum=zeros(numel(ListDisplay),1);188 % for ilist=1:numel(ListDisplay)189 % ListDisplay{ilist}=ListFiles(ilist).name;190 % if ListFiles(ilist).isdir191 % ListDisplay{ilist}=['/' ListDisplay{ilist}];192 % elseif isfield(ListFiles(ilist),'datenum')193 % datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions194 % testrecent=1;195 % if datnum(ilist)<TimeStart196 % ListDisplay{ilist}=[ListDisplay{ilist} ' --OLD--'];197 % end198 % end199 % end200 201 202 %% Look at date of creation203 ListDisplay=ListDisplay(datnum~=0);204 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files205 206 NbOutputFile=[];207 if isempty(datnum)208 if testrecent209 message='no result created yet';210 else211 message='';212 end213 else214 [first,indfirst]=min(datnum);215 [last,indlast]=max(datnum);216 NbOutputFile_str='?';217 if isfield(StatusData,'NbOutputFile')218 NbOutputFile=StatusData.NbOutputFile;219 NbOutputFile_str=num2str(NbOutputFile);220 end221 message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];...222 ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]};223 end224 set(htitlebox,'String', [DirName{1};message])225 226 %% update the waitbar227 hwaitbar=findobj(hfig,'tag','waitbar');228 if ~isempty(NbOutputFile)229 BarPosition=get(hwaitbar,'Position');230 BarPosition(3)=0.9*numel(datnum)/NbOutputFile;231 set(hwaitbar,'Position',BarPosition)232 220 end 233 221 … … 236 224 function ListFiles=list_files(DirName) 237 225 %------------------------------------------------------------------------- 238 ListStruct=dir(DirName); 226 ListStruct=dir(DirName);% get structure of the current directory 239 227 if numel(ListStruct)<1 240 228 ListFiles={}; … … 254 242 ListFiles=[{'+/..'} ListFiles(check_keep)]; 255 243 244 %------------------------------------------------------------------------ 245 % --- launched by selecting home 246 function home_dir(hObject,event) 247 %------------------------------------------------------------------------ 248 DirName=pwd; 249 ListFiles=list_files(DirName);% list the directory content 250 hfig=get(hObject,'parent'); 251 set(hfig,'UserData',DirName)% record the new dir name 252 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 253 set(htitlebox,'String',DirName) 254 hlist=findobj(hfig,'tag','list');% find the list object 255 set(hlist,'String',ListFiles) 256 %------------------------------------------------------------------------ 257 258 %------------------------------------------------------------------------ 259 % --- launched by pressing the backward (<--) button 260 function backward(hObject,event) 261 %------------------------------------------------------------------------ 262 PrevDir=get(hObject,'UserData'); 263 if ~isempty(PrevDir) 264 hfig=get(hObject,'parent'); 265 set(hfig,'UserData',PrevDir) 266 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 267 set(htitlebox,'String',PrevDir) 268 refresh_GUI(findobj(hfig,'Tag','refresh')) 269 end 270 256 271 %------------------------------------------------------------------------- 257 272 % launched by deleting the status figure (only used in mode series status') 258 273 function close(option,hObject, eventdata) 259 274 %------------------------------------------------------------------------- 260 if strcmp(option,'status ')275 if strcmp(option,'status_display') 261 276 hseries=findobj(allchild(0),'tag','series'); 262 hstatus=findobj(hfig,'Tag','status ');277 hstatus=findobj(hfig,'Tag','status_display'); 263 278 set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ 264 279 set(hhciv.status,'BackgroundColor',[0 1 0])
Note: See TracChangeset
for help on using the changeset viewer.