Changeset 856 for trunk/src/browse_data.m
- Timestamp:
- Jan 26, 2015, 12:37:56 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r837 r856 24 24 function varargout = browse_data(varargin) 25 25 26 % Last Modified by GUIDE v2.5 11-Mar-2014 22:09:3726 % Last Modified by GUIDE v2.5 24-Jan-2015 16:55:04 27 27 28 28 % Begin initialization code - DO NOT EDIT … … 47 47 %------------------------------------------------------------------------ 48 48 % --- Executes just before browse_data is made visible. 49 function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign,EnableMirror)49 function browse_data_OpeningFcn(hObject, eventdata, handles, DataSeries,EnableMirror) 50 50 %------------------------------------------------------------------------ 51 51 … … 80 80 set(handles.mirror_txt,'Visible','off') 81 81 end 82 if exist('Campaign','var') 83 [tild,CampaignName]=fileparts(Campaign); 84 RootXml=fullfile(Campaign,[CampaignName '.xml']); 85 s=[]; 86 if exist(RootXml,'file') 87 [s,Heading]=xml2struct(RootXml);%read the xml file 88 if isfield(s,'SourceDir') 89 set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened 90 set(handles.MirrorDir,'Visible','on');% mirror dir display 91 set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir 92 set(handles.CreateMirror,'String','update_mirror') 93 end 94 end 95 if isempty(s) %a source dir has been opened 96 set(handles.SourceDir,'String',Campaign); 97 set(handles.MirrorDir,'Visible','off');% no mirror dir display 98 set(handles.CreateMirror,'String','create_mirror') 99 end 100 errormsg=scan_campaign(handles,Campaign); 101 if ~isempty(errormsg) 102 msgbox_uvmat('ERROR',errormsg) 103 return 104 end 105 set(handles.OK,'Visible','on') 106 set(handles.Cancel,'Visible','on') 107 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 108 set(hObject,'Visible','on') 109 drawnow 110 % UIWAIT makes GUI wait for user response (see UIRESUME) 111 uiwait(handles.browse_data); 112 end 82 83 %% initialize the GUI 84 if ~(exist('DataSeries','var') && exist(DataSeries,'dir')) 85 DataSeries=pwd;% current dir is the starting data series by default 86 end 87 [Experiment,DataSeries,Ext]=fileparts(DataSeries); 88 DataSeries=[DataSeries Ext]; 89 [Campaign,Experiment,Ext]=fileparts(Experiment); 90 Experiment=[Experiment Ext]; 91 [tild,CampaignName]=fileparts(Campaign); 92 RootXml=fullfile(Campaign,[CampaignName '.xml']); 93 s=[]; 94 if exist(RootXml,'file') 95 [s,Heading]=xml2struct(RootXml);%read the xml file 96 if isfield(s,'SourceDir') 97 set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened 98 set(handles.MirrorDir,'Visible','on');% mirror dir display 99 set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir 100 set(handles.CreateMirror,'String','update_mirror') 101 end 102 end 103 if isempty(s) %a source dir has been opened 104 set(handles.SourceDir,'String',Campaign); 105 set(handles.MirrorDir,'Visible','off');% no mirror dir display 106 set(handles.CreateMirror,'String','create_mirror') 107 end 108 errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries); 109 if ~isempty(errormsg) 110 msgbox_uvmat('ERROR',errormsg) 111 return 112 end 113 set(handles.OK,'Visible','on') 114 set(handles.Cancel,'Visible','on') 115 116 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 117 set(hObject,'Visible','on') 118 drawnow 119 % UIWAIT makes GUI wait for user response (see UIRESUME) 120 uiwait(handles.browse_data); 121 113 122 114 123 … … 190 199 set(handles.SourceDir,'BackgroundColor',[1 1 1]) 191 200 192 193 %------------------------------------------------------------------------ 194 function errormsg=scan_campaign(handles,Campaign) 195 %------------------------------------------------------------------------ 196 %set(handles.SourceDir,'BackgroundColor',[1 1 0]) 197 %drawnow 198 %SourceDir=get(handles.SourceDir,'String'); 199 %MirrorDir=get(handles.MirrorDir,'String'); 200 % ExpName={''}; 201 %------------------------------------------------------------------------ 202 % List the experiments in a campaign, filling the menu ListExperiments 203 %------------------------------------------------------------------------ 204 function errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries) 205 %------------------------------------------------------------------------ 201 206 errormsg=''; 202 207 if exist(Campaign,'dir') … … 213 218 check_keep=cellfun('isempty', cell_remove); 214 219 ListFiles=sort((ListFiles(check_keep))'); 220 index=find(strcmp(['+/' Experiment],ListFiles)); 221 if isempty(index), index=0; end 215 222 set(handles.ListExperiments,'String',[{'*'};ListFiles]) 216 set(handles.ListExperiments,'Value', 1)223 set(handles.ListExperiments,'Value',index+1)% initialise the menu selection with the folder defined by the input 217 224 ListExperiments_Callback([],[], handles) 225 ListDevices=get(handles.ListDevices,'String'); 226 index=find(strcmp(['+/' DataSeries],ListDevices)); 227 if isempty(index) 228 index=find(strcmp(['~/' DataSeries],ListDevices)); 229 end 230 if ~isempty(index) 231 set(handles.ListDevices,'Value',index) 232 end 218 233 else 219 234 msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) 220 235 end 221 %set(handles.SourceDir,'BackgroundColor',[1 1 1])222 223 236 224 237 %------------------------------------------------------------------------ … … 668 681 669 682 670 % --- Executes during object deletion, before destroying properties. 671 function browse_data_DeleteFcn(hObject, eventdata, handles) 683 % --- Executes on button press in Browse. 684 function Browse_Callback(hObject, eventdata, handles) 685 ListDevices=get(handles.ListDevices,'String'); 686 Device=ListDevices{get(handles.ListDevices,'Value')}; 687 DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir'); 688 uiresume(handles.browse_data); 689 browse_data(DataSeries)
Note: See TracChangeset
for help on using the changeset viewer.