[569] | 1 | %'browse_data': function for scanning directories in a campaign |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function varargout = series(varargin) |
---|
| 4 | % associated with the GUI browse_data.fig |
---|
| 5 | |
---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % This file is part of the toolbox UVMAT. |
---|
| 10 | % |
---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published by |
---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 14 | % (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | |
---|
| 22 | function varargout = browse_data(varargin) |
---|
| 23 | |
---|
| 24 | % Last Modified by GUIDE v2.5 15-Feb-2013 19:41:48 |
---|
| 25 | |
---|
| 26 | % Begin initialization code - DO NOT EDIT |
---|
| 27 | gui_Singleton = 1; |
---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @browse_data_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @browse_data_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
| 34 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
| 45 | %------------------------------------------------------------------------ |
---|
| 46 | % --- Executes just before browse_data is made visible. |
---|
[571] | 47 | function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign) |
---|
[569] | 48 | %------------------------------------------------------------------------ |
---|
| 49 | % Choose default command line output for browse_data |
---|
| 50 | handles.output = 'Cancel'; |
---|
| 51 | |
---|
| 52 | % Update handles structure |
---|
| 53 | guidata(hObject, handles); |
---|
| 54 | |
---|
| 55 | % Determine the position of the dialog - centered on the screen |
---|
| 56 | FigPos=get(0,'DefaultFigurePosition'); |
---|
| 57 | OldUnits = get(hObject, 'Units'); |
---|
| 58 | set(hObject, 'Units', 'pixels'); |
---|
| 59 | OldPos = get(hObject,'Position'); |
---|
| 60 | FigWidth = OldPos(3); |
---|
| 61 | FigHeight = OldPos(4); |
---|
| 62 | ScreenUnits=get(0,'Units'); |
---|
| 63 | set(0,'Units','pixels'); |
---|
| 64 | ScreenSize=get(0,'ScreenSize'); |
---|
| 65 | set(0,'Units',ScreenUnits); |
---|
| 66 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth); |
---|
| 67 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight); |
---|
| 68 | FigPos(3:4)=[FigWidth FigHeight]; |
---|
| 69 | set(hObject, 'Position', FigPos); |
---|
| 70 | set(hObject, 'Units', OldUnits); |
---|
[571] | 71 | % |
---|
| 72 | % if exist('GeometryCalib','var') |
---|
| 73 | % DataviewData.GeometryCalib=GeometryCalib; |
---|
| 74 | % set(hObject,'UserData',DataviewData) |
---|
| 75 | % end |
---|
[569] | 76 | if exist('Campaign','var') |
---|
| 77 | [CampaignPath,CampaignName]=fileparts(Campaign); |
---|
| 78 | RootXml=fullfile(Campaign,[CampaignName '.xml']); |
---|
| 79 | s=[]; |
---|
| 80 | if exist(RootXml,'file') |
---|
| 81 | [s,Heading]=xml2struct(RootXml);%read the xml file |
---|
| 82 | if isfield(s,'SourceDir') |
---|
| 83 | set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened |
---|
| 84 | set(handles.MirrorDir,'Visible','on');% mirror dir display |
---|
| 85 | set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir |
---|
| 86 | set(handles.CreateMirror,'String','update_mirror') |
---|
| 87 | end |
---|
| 88 | end |
---|
| 89 | if isempty(s) %a source dir has been opened |
---|
| 90 | set(handles.SourceDir,'String',Campaign); |
---|
| 91 | set(handles.MirrorDir,'Visible','off');% no mirror dir display |
---|
| 92 | set(handles.CreateMirror,'String','create_mirror') |
---|
| 93 | end |
---|
[570] | 94 | scan_campaign(handles,Campaign) |
---|
| 95 | % SourceDir_Callback([],[], handles) |
---|
[569] | 96 | set(handles.edit_xml,'Visible','off') |
---|
| 97 | set(handles.HELP,'Visible','off') |
---|
| 98 | set(handles.OK,'Visible','on') |
---|
| 99 | set(handles.Cancel,'Visible','on') |
---|
| 100 | set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal |
---|
| 101 | set(hObject,'Visible','on') |
---|
| 102 | drawnow |
---|
| 103 | % UIWAIT makes GUI wait for user response (see UIRESUME) |
---|
| 104 | uiwait(handles.figure); |
---|
| 105 | end |
---|
| 106 | |
---|
| 107 | %------------------------------------------------------------------------ |
---|
| 108 | % --- Outputs from this function are returned to the command line. |
---|
| 109 | function varargout = browse_data_OutputFcn(hObject, eventdata, handles) |
---|
| 110 | %------------------------------------------------------------------------ |
---|
| 111 | % Get default command line output from handles structure |
---|
| 112 | varargout{1} = handles.output; |
---|
| 113 | delete(handles.figure) |
---|
| 114 | |
---|
| 115 | %------------------------------------------------------------------------ |
---|
| 116 | % --- Executes on button press in CreateMirror. |
---|
| 117 | function CreateMirror_Callback(hObject, eventdata, handles) |
---|
| 118 | %------------------------------------------------------------------------ |
---|
[571] | 119 | SourceDir=get(handles.SourceDir,'String'); |
---|
| 120 | [SourcePath,ProjectName]=fileparts(SourceDir); |
---|
| 121 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 122 | MirrorDir=get(handles.MirrorDir,'String'); |
---|
| 123 | else |
---|
[569] | 124 | MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser |
---|
| 125 | if ~ischar(MirrorRoot) |
---|
| 126 | return |
---|
| 127 | else |
---|
| 128 | MirrorDir=fullfile(MirrorRoot,ProjectName); |
---|
| 129 | end |
---|
| 130 | if ~exist(MirrorDir,'dir') |
---|
| 131 | mkdir(MirrorDir) |
---|
| 132 | end |
---|
| 133 | MirrorDoc.SourceDir=SourceDir; |
---|
| 134 | t=struct2xml(MirrorDoc); |
---|
| 135 | set(t,1,'name','DataTree'); |
---|
| 136 | save(t,fullfile(MirrorDir,[ProjectName '.xml'])) |
---|
| 137 | set(handles.MirrorDir,'String',MirrorDir) |
---|
| 138 | set(handles.MirrorDir,'Visible','on') |
---|
| 139 | end |
---|
| 140 | set(handles.SourceDir,'BackgroundColor',[1 1 0]) |
---|
| 141 | drawnow |
---|
| 142 | ExpName={''}; |
---|
| 143 | if exist(SourceDir,'dir') |
---|
| 144 | hdir=dir(SourceDir); %list files and dirs |
---|
| 145 | idir=0; |
---|
| 146 | for ilist=1:length(hdir) |
---|
| 147 | if hdir(ilist).isdir |
---|
| 148 | dirname=hdir(ilist).name; |
---|
| 149 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 150 | idir=idir+1; |
---|
| 151 | ExpName{idir}=hdir(ilist).name; |
---|
[571] | 152 | |
---|
[569] | 153 | mirror=fullfile(MirrorDir,ExpName{idir}); |
---|
| 154 | if ~exist(mirror,'dir') |
---|
| 155 | mkdir(mirror) |
---|
| 156 | end |
---|
| 157 | end |
---|
| 158 | % look for the list of 'devices' |
---|
| 159 | else |
---|
| 160 | %warning for isolated files |
---|
| 161 | end |
---|
| 162 | end |
---|
| 163 | set(handles.ListExperiments,'String',[{'*'};ExpName']) |
---|
| 164 | set(handles.ListExperiments,'Value',1) |
---|
| 165 | ListExperiments_Callback(hObject, eventdata, handles) |
---|
| 166 | else |
---|
| 167 | msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) |
---|
| 168 | end |
---|
| 169 | set(handles.SourceDir,'BackgroundColor',[1 1 1]) |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | %------------------------------------------------------------------------ |
---|
| 173 | function MirrorDir_Callback(hObject, eventdata, handles) |
---|
| 174 | %------------------------------------------------------------------------ |
---|
| 175 | MirrorDir=get(handles.MirrorDir,'String'); |
---|
| 176 | [tild,MirrorName]=fileparts(MirrorDir); |
---|
| 177 | s=xml2struct(fullfile(MirrorDir,[MirrorName '.xml'])); |
---|
| 178 | set(handles.SourceDir,'String',s.SourceDir) |
---|
| 179 | SourceDir_Callback([],[], handles) |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | %------------------------------------------------------------------------ |
---|
[570] | 183 | function scan_campaign(handles,Campaign) |
---|
[569] | 184 | %------------------------------------------------------------------------ |
---|
[570] | 185 | %set(handles.SourceDir,'BackgroundColor',[1 1 0]) |
---|
[569] | 186 | drawnow |
---|
[570] | 187 | %SourceDir=get(handles.SourceDir,'String'); |
---|
| 188 | %MirrorDir=get(handles.MirrorDir,'String'); |
---|
[569] | 189 | ExpName={''}; |
---|
[570] | 190 | if exist(Campaign,'dir') |
---|
| 191 | hdir=dir(Campaign); %list files and dirs |
---|
[569] | 192 | idir=0; |
---|
| 193 | for ilist=1:length(hdir) |
---|
| 194 | if hdir(ilist).isdir |
---|
| 195 | dirname=hdir(ilist).name; |
---|
| 196 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 197 | idir=idir+1; |
---|
| 198 | ExpName{idir}=hdir(ilist).name; |
---|
| 199 | end |
---|
| 200 | end |
---|
| 201 | end |
---|
| 202 | set(handles.ListExperiments,'String',[{'*'};ExpName']) |
---|
| 203 | set(handles.ListExperiments,'Value',1) |
---|
[570] | 204 | ListExperiments_Callback([],[], handles) |
---|
[569] | 205 | else |
---|
[570] | 206 | msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) |
---|
[569] | 207 | end |
---|
[570] | 208 | %set(handles.SourceDir,'BackgroundColor',[1 1 1]) |
---|
[569] | 209 | |
---|
| 210 | |
---|
| 211 | %------------------------------------------------------------------------ |
---|
| 212 | % --- Executes on selection change in ListExperiments. |
---|
| 213 | function ListExperiments_Callback(hObject, eventdata, handles) |
---|
| 214 | %------------------------------------------------------------------------ |
---|
[571] | 215 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 216 | CampaignPath=get(handles.MirrorDir,'String'); |
---|
| 217 | else |
---|
| 218 | CampaignPath=get(handles.SourceDir,'String'); |
---|
| 219 | end |
---|
| 220 | % MirrorPath=get(handles.MirrorDir,'String'); |
---|
[569] | 221 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 222 | list_val=get(handles.ListExperiments,'Value'); |
---|
| 223 | if isequal(list_val(1),1) |
---|
| 224 | ListExperiments=ListExperiments(2:end); %choose all experiments |
---|
| 225 | testList=1; |
---|
| 226 | set(handles.ListExperiments,'Value',1) |
---|
| 227 | else |
---|
| 228 | ListExperiments=ListExperiments(list_val);%choose selected experiments |
---|
| 229 | testList=0; |
---|
| 230 | end |
---|
[571] | 231 | scan_experiments(handles,ListExperiments,CampaignPath) |
---|
| 232 | |
---|
| 233 | |
---|
| 234 | %------------------------------------------------------------------------ |
---|
| 235 | % --- Executes on selection change in ListExperiments. |
---|
| 236 | function scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath) |
---|
| 237 | %------------------------------------------------------------------------ |
---|
| 238 | ListDevices={}; |
---|
[569] | 239 | for iexp=1:numel(ListExperiments) |
---|
[571] | 240 | hdir=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory |
---|
[569] | 241 | idir=0; |
---|
| 242 | for ilist=1:length(hdir) |
---|
[570] | 243 | if ~isequal(hdir(ilist).name(1),'.') |
---|
[571] | 244 | DataSeries=fullfile(CampaignPath,ListExperiments{iexp},hdir(ilist).name); |
---|
| 245 | if exist('MirrorPath','var') |
---|
[570] | 246 | mirror=fullfile(MirrorPath,ListExperiments{iexp},hdir(ilist).name); |
---|
[571] | 247 | if ~exist(mirror)% create mirror if needed |
---|
[570] | 248 | system(['ln -s ' source ' ' mirror]) |
---|
| 249 | end |
---|
| 250 | end |
---|
| 251 | check_list=strcmp(hdir(ilist).name,ListDevices); |
---|
[571] | 252 | if isempty(find(check_list, 1)) |
---|
[570] | 253 | ListDevices=[ListDevices;hdir(ilist).name]; |
---|
| 254 | end |
---|
[569] | 255 | end |
---|
| 256 | end |
---|
| 257 | end |
---|
| 258 | set(handles.ListDevices,'String',ListDevices) |
---|
| 259 | |
---|
| 260 | %------------------------------------------------------------------------ |
---|
| 261 | % --- Executes on button press in update_headings. |
---|
| 262 | function ListDevices_Callback(hObject, eventdata, handles) |
---|
| 263 | % CurrentPath=get(handles.SourceDir,'String'); |
---|
| 264 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 265 | % list_val=get(handles.ListExperiments,'Value'); |
---|
| 266 | % if isequal(list_val,1) |
---|
| 267 | % ListExperiments=ListExperiments(2:end); |
---|
| 268 | % else |
---|
| 269 | % ListExperiments=ListExperiments(list_val); |
---|
| 270 | % end |
---|
| 271 | % set(handles.ListRecords,'Value',1) |
---|
| 272 | % set(handles.ListXml,'Value',1) |
---|
| 273 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 274 | % list_val=get(handles.ListDevices,'Value'); |
---|
| 275 | % if isequal(list_val,1) |
---|
| 276 | % ListDevices=ListDevices(2:end); |
---|
| 277 | % else |
---|
| 278 | % ListDevices=ListDevices(list_val); |
---|
| 279 | % end |
---|
| 280 | % [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); |
---|
| 281 | % set(handles.ListRecords,'String',[{'*'};ListRecords']) |
---|
| 282 | % set(handles.ListXml,'String',[{'*'};ListXml']) |
---|
| 283 | % |
---|
| 284 | % |
---|
| 285 | % if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 286 | % CurrentPath=get(handles.MirrorDir,'String'); |
---|
| 287 | % else |
---|
| 288 | % CurrentPath=get(handles.SourceDir,'String'); |
---|
| 289 | % end |
---|
| 290 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 291 | % Device=ListDevices(get(handles.ListDevices,'Value')); |
---|
| 292 | % % else |
---|
| 293 | % hdir=dir(fullfile(SourcePath,Device)); %list files and dirs |
---|
| 294 | |
---|
| 295 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 296 | |
---|
| 297 | |
---|
| 298 | |
---|
| 299 | %------------------------------------------------------------------------ |
---|
| 300 | % --- Executes on selection change in ListRecords. |
---|
| 301 | function ListRecords_Callback(hObject, eventdata, handles) |
---|
| 302 | Value=get(handles.ListRecords,'Value'); |
---|
| 303 | if isequal(Value(1),1) |
---|
| 304 | set(handles.ListRecords,'Value',1); |
---|
| 305 | end |
---|
| 306 | |
---|
| 307 | %------------------------------------------------------------------------ |
---|
| 308 | % --- Executes on button press in CampaignDoc. |
---|
| 309 | function CampaignDoc_Callback(hObject, eventdata, handles) |
---|
| 310 | %------------------------------------------------------------------------ |
---|
| 311 | answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file') |
---|
| 312 | if ~isequal(answer{1},'OK') |
---|
| 313 | return |
---|
| 314 | end |
---|
| 315 | set(handles.ListExperiments,'Value',1) |
---|
| 316 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
| 317 | DataviewData=get(handles.figure,'UserData'); |
---|
| 318 | List=DataviewData.List; |
---|
| 319 | Currentpath=get(handles.SourceDir,'String'); |
---|
| 320 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 321 | Campaign=[Campaign DirExt]; |
---|
| 322 | t=xmltree; |
---|
| 323 | t=set(t,1,'name','CampaignDoc'); |
---|
| 324 | t = attributes(t,'add',1,'source','directory'); |
---|
| 325 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 326 | root_uid=1; |
---|
| 327 | if SubCampaignTest |
---|
| 328 | %TO DO open an exoiting xml doc |
---|
| 329 | [t,root_uid]=add(t,1,'element','SubCampaign'); |
---|
| 330 | t =attributes(t,'add',root_uid,'DirName',Campaign); |
---|
| 331 | end |
---|
| 332 | for iexp=1:length(List.Experiment) |
---|
| 333 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 334 | drawnow |
---|
| 335 | test_mod=0; |
---|
| 336 | [t,uid_exp]=add(t,root_uid,'element','Experiment'); |
---|
| 337 | t = attributes(t,'add',uid_exp,'i',num2str(iexp)); |
---|
| 338 | ExpName=List.Experiment{iexp}.name; |
---|
| 339 | t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); |
---|
| 340 | |
---|
| 341 | if isfield(List.Experiment{iexp},'Device') |
---|
| 342 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 343 | [t,uid_device]=add(t,uid_exp,'element','Device'); |
---|
| 344 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 345 | t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); |
---|
| 346 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 347 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 348 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 349 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); |
---|
| 350 | if test |
---|
| 351 | [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] |
---|
| 352 | end |
---|
| 353 | if isequal(Title,'ImaDoc') |
---|
| 354 | [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); |
---|
| 355 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 356 | [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); |
---|
| 357 | end |
---|
| 358 | end |
---|
| 359 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 360 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 361 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 362 | [t,uid_record]=add(t,uid_device,'element','Record'); |
---|
| 363 | t = attributes(t,'add',uid_record,'DirName',RecordName); |
---|
| 364 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 365 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 366 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 367 | [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); |
---|
| 368 | if test |
---|
| 369 | [FileName ' , Heading updated'] |
---|
| 370 | end |
---|
| 371 | [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); |
---|
| 372 | t = attributes(t,'add',uid_xml,'source','file'); |
---|
| 373 | [t]=add(t,uid_xml,'chardata',FileName); |
---|
| 374 | end |
---|
| 375 | end |
---|
| 376 | end |
---|
| 377 | end |
---|
| 378 | end |
---|
| 379 | end |
---|
| 380 | end |
---|
| 381 | set(handles.ListExperiments,'Value',1) |
---|
| 382 | outputdir=get(handles.SourceDir,'String'); |
---|
| 383 | [path,dirname]=fileparts(outputdir); |
---|
| 384 | outputfile=fullfile(outputdir,[dirname '.xml']); |
---|
| 385 | %campaigndoc(t); |
---|
| 386 | save(t,outputfile) |
---|
| 387 | |
---|
| 388 | %------------------------------------------------------------------------ |
---|
| 389 | % --- Executes on button press in CampaignDoc. |
---|
| 390 | function edit_xml_Callback(hObject, eventdata, handles) |
---|
| 391 | %------------------------------------------------------------------------ |
---|
| 392 | CurrentPath=get(handles.SourceDir,'String'); |
---|
| 393 | %[CurrentPath,Name,Ext]=fileparts(CurrentDir); |
---|
| 394 | ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 395 | Value=get(handles.ListExperiments,'Value'); |
---|
| 396 | if ~isequal(Value,1) |
---|
| 397 | ListExperiments=ListExperiments(Value); |
---|
| 398 | end |
---|
| 399 | ListDevices=get(handles.ListDevices,'String'); |
---|
| 400 | Value=get(handles.ListDevices,'Value'); |
---|
| 401 | if ~isequal(Value,1) |
---|
| 402 | ListDevices=ListDevices(Value); |
---|
| 403 | end |
---|
| 404 | ListRecords=get(handles.ListRecords,'String'); |
---|
| 405 | Value=get(handles.ListRecords,'Value'); |
---|
| 406 | if ~isequal(Value,1) |
---|
| 407 | ListRecords=ListRecords(Value); |
---|
| 408 | end |
---|
| 409 | [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 410 | ListXml=get(handles.ListXml,'String'); |
---|
| 411 | Value=get(handles.ListXml,'Value'); |
---|
| 412 | set(handles.ListXml,'Value',Value(1)); |
---|
| 413 | if isequal(Value(1),1) |
---|
| 414 | msgbox_uvmat('ERROR','an xml file needs to be selected') |
---|
| 415 | return |
---|
| 416 | else |
---|
| 417 | XmlName=ListXml{Value(1)}; |
---|
| 418 | end |
---|
| 419 | for iexp=1:length(List.Experiment) |
---|
| 420 | ExpName=List.Experiment{iexp}.name; |
---|
| 421 | if isfield(List.Experiment{iexp},'Device') |
---|
| 422 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 423 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 424 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 425 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 426 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} |
---|
| 427 | if isequal(FileName,XmlName) |
---|
| 428 | editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); |
---|
| 429 | return |
---|
| 430 | end |
---|
| 431 | end |
---|
| 432 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 433 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 434 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 435 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 436 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 437 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 438 | if isequal(FileName,XmlName) |
---|
| 439 | editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); |
---|
| 440 | return |
---|
| 441 | end |
---|
| 442 | end |
---|
| 443 | end |
---|
| 444 | end |
---|
| 445 | end |
---|
| 446 | end |
---|
| 447 | end |
---|
| 448 | end |
---|
| 449 | |
---|
| 450 | |
---|
| 451 | |
---|
| 452 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 453 | % CurrentPath/Campaign: root directory |
---|
| 454 | function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) |
---|
| 455 | |
---|
| 456 | %Shema for Heading: |
---|
| 457 | % Campaign |
---|
| 458 | % (SubCampaign) |
---|
| 459 | % Experiment |
---|
| 460 | % Device |
---|
| 461 | % (Record) |
---|
| 462 | % ImageName |
---|
| 463 | % DateExp |
---|
| 464 | % old: %Project: suppressed ( changed to Campaign) |
---|
| 465 | %Exp: suppressed (changed to experiment) |
---|
| 466 | %ImaNames: changed to ImageName |
---|
| 467 | if exist('Record','var') && ~isempty(Record) |
---|
| 468 | xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); |
---|
| 469 | testrecord=1; |
---|
| 470 | else |
---|
| 471 | xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); |
---|
| 472 | testrecord=0; |
---|
| 473 | end |
---|
| 474 | if ~exist('testSubCampaign','var') |
---|
| 475 | testSubCampaign=0; |
---|
| 476 | end |
---|
| 477 | if testSubCampaign |
---|
| 478 | SubCampaign=Campaign; |
---|
| 479 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 480 | Campaign=[Campaign DirExt]; |
---|
| 481 | end |
---|
| 482 | test_mod=0; %test for the modification of the xml file |
---|
| 483 | t_device=xmltree(xmlfullname); |
---|
| 484 | Title=get(t_device,1,'name'); |
---|
| 485 | uid_child=children(t_device,1); |
---|
| 486 | Heading_old=[]; |
---|
| 487 | uidheading=0; |
---|
| 488 | for ilist=1:length(uid_child) |
---|
| 489 | name=get(t_device,uid_child(ilist),'name'); |
---|
| 490 | if isequal(name,'Heading') |
---|
| 491 | uidheading=uid_child(ilist); |
---|
| 492 | end |
---|
| 493 | end |
---|
| 494 | if uidheading |
---|
| 495 | subt=branch(t_device,uidheading); |
---|
| 496 | Heading_old=convert(subt); |
---|
| 497 | else |
---|
| 498 | return % do not edit xml files without element 'Heading' |
---|
| 499 | end |
---|
| 500 | if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) |
---|
| 501 | test_mod=1; |
---|
| 502 | end |
---|
| 503 | Heading.Campaign=Campaign; |
---|
| 504 | if testSubCampaign |
---|
| 505 | if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) |
---|
| 506 | test_mod=1; |
---|
| 507 | end |
---|
| 508 | Heading.SubCampaign=SubCampaign; |
---|
| 509 | end |
---|
| 510 | if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) |
---|
| 511 | test_mod=1; |
---|
| 512 | end |
---|
| 513 | Heading.Experiment=Experiment; |
---|
| 514 | if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) |
---|
| 515 | test_mod=1; |
---|
| 516 | end |
---|
| 517 | Heading.Device=Device; |
---|
| 518 | if testrecord |
---|
| 519 | if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) |
---|
| 520 | test_mod=1; |
---|
| 521 | end |
---|
| 522 | Heading.Record=Record; |
---|
| 523 | end |
---|
| 524 | if isfield(Heading_old,'ImaNames') |
---|
| 525 | test_mod=1; |
---|
| 526 | if ~isempty(Heading_old.ImaNames) |
---|
| 527 | Heading.ImageName=Heading_old.ImaNames; |
---|
| 528 | end |
---|
| 529 | end |
---|
| 530 | if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) |
---|
| 531 | Heading.ImageName=Heading_old.ImageName; |
---|
| 532 | end |
---|
| 533 | if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) |
---|
| 534 | Heading.DateExp=Heading_old.DateExp; |
---|
| 535 | end |
---|
| 536 | if test_mod && uidheading |
---|
| 537 | uid_child=children(t_device,uidheading); |
---|
| 538 | t_device=delete(t_device,uid_child); |
---|
| 539 | t_device=struct2xml(Heading,t_device,uidheading); |
---|
| 540 | backupfile=xmlfullname; |
---|
| 541 | testexist=2; |
---|
| 542 | while testexist==2 |
---|
| 543 | backupfile=[backupfile '~']; |
---|
| 544 | testexist=exist(backupfile,'file'); |
---|
| 545 | end |
---|
| 546 | [success,message]=copyfile(xmlfullname,backupfile);%make backup |
---|
| 547 | if isequal(success,1) |
---|
| 548 | delete(xmlfullname) |
---|
| 549 | else |
---|
| 550 | return |
---|
| 551 | end |
---|
| 552 | save(t_device,xmlfullname) |
---|
| 553 | end |
---|
| 554 | |
---|
| 555 | %------------------------------------------------------------------------ |
---|
| 556 | % --- Executes on button press in HELP. |
---|
| 557 | function HELP_Callback(hObject, eventdata, handles) |
---|
| 558 | path_to_uvmat=which ('uvmat')% check the path of uvmat |
---|
| 559 | pathelp=fileparts(path_to_uvmat); |
---|
| 560 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 561 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 562 | else |
---|
| 563 | web([helpfile '#dataview']) |
---|
| 564 | end |
---|
| 565 | |
---|
| 566 | |
---|
| 567 | |
---|
| 568 | % --- Executes on selection change in ListXml. |
---|
| 569 | function ListXml_Callback(hObject, eventdata, handles) |
---|
| 570 | Value=get(handles.ListXml,'Value'); |
---|
| 571 | if isequal(Value(1),1) |
---|
| 572 | set(handles.ListXml,'Value',1); |
---|
| 573 | end |
---|
| 574 | |
---|
| 575 | |
---|
| 576 | % --- Executes on button press in clean_civ_cmx. |
---|
| 577 | function clean_civ_cmx_Callback(hObject, eventdata, handles) |
---|
| 578 | message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)'; |
---|
| 579 | answer=msgbox_uvmat('INPUT_Y-N',message); |
---|
| 580 | if ~isequal(answer,'Yes') |
---|
| 581 | return |
---|
| 582 | end |
---|
| 583 | set(handles.ListExperiments,'Value',1) |
---|
| 584 | ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories |
---|
| 585 | DataviewData=get(handles.figure,'UserData') |
---|
| 586 | List=DataviewData.List; |
---|
| 587 | Currentpath=get(handles.SourceDir,'String'); |
---|
| 588 | [Currentpath,Campaign,DirExt]=fileparts(Currentpath); |
---|
| 589 | Campaign=[Campaign DirExt]; |
---|
| 590 | SubCampaignTest=get(handles.SubCampaignTest,'Value'); |
---|
| 591 | nbdelete_tot=0; |
---|
| 592 | for iexp=1:length(List.Experiment) |
---|
| 593 | set(handles.ListExperiments,'Value',iexp+1) |
---|
| 594 | drawnow |
---|
| 595 | test_mod=0; |
---|
| 596 | ExpName=List.Experiment{iexp}.name; |
---|
| 597 | nbdelete=0; |
---|
| 598 | if isfield(List.Experiment{iexp},'Device') |
---|
| 599 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 600 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 601 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 602 | currentdir=fullfile(Currentpath,Campaign,ExpName,DeviceName); |
---|
| 603 | hdir=dir(currentdir); %list files and dirs |
---|
| 604 | idir=0; |
---|
| 605 | for ilist=1:length(hdir) |
---|
| 606 | if hdir(ilist).isdir |
---|
| 607 | dirname=hdir(ilist).name; |
---|
| 608 | if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') |
---|
| 609 | CivDir=fullfile(currentdir,dirname) |
---|
| 610 | hCivDir=dir(CivDir); |
---|
| 611 | for ilist=1:length(hCivDir) |
---|
| 612 | FileName=hCivDir(ilist).name; |
---|
| 613 | [dd,ff,Ext]=fileparts(FileName); |
---|
| 614 | if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors') |
---|
| 615 | delete(fullfile(CivDir,FileName)) |
---|
| 616 | nbdelete=nbdelete+1; |
---|
| 617 | end |
---|
| 618 | end |
---|
| 619 | end |
---|
| 620 | end |
---|
| 621 | end |
---|
| 622 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 623 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 624 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 625 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 626 | 'look at subdirectories' |
---|
| 627 | end |
---|
| 628 | end |
---|
| 629 | end |
---|
| 630 | end |
---|
| 631 | end |
---|
| 632 | display([num2str(nbdelete) ' files deleted']) |
---|
| 633 | nbdelete_tot=nbdelete_tot+nbdelete; |
---|
| 634 | end |
---|
| 635 | msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete_tot) ' files deleted by clean_civ_cmx']) |
---|
| 636 | set(handles.ListExperiments,'Value',1) |
---|
| 637 | |
---|
| 638 | |
---|
| 639 | % --- Executes on button press in OK. |
---|
| 640 | function OK_Callback(hObject, eventdata, handles) |
---|
| 641 | %------------------------------------------------------------------------ |
---|
| 642 | if strcmp(get(handles.MirrorDir,'Visible'),'on') |
---|
| 643 | Campaign=get(handles.MirrorDir,'String'); |
---|
| 644 | else |
---|
| 645 | Campaign=get(handles.SourceDir,'String'); |
---|
| 646 | end |
---|
| 647 | handles.output.Campaign=Campaign; |
---|
| 648 | Experiment=get(handles.ListExperiments,'String'); |
---|
| 649 | IndicesExp=get(handles.ListExperiments,'Value'); |
---|
| 650 | if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected |
---|
| 651 | Experiment=Experiment(IndicesExp);% use the selection of the list of experiments |
---|
| 652 | end |
---|
| 653 | Device=get(handles.ListDevices,'String'); |
---|
| 654 | Value=get(handles.ListDevices,'Value'); |
---|
| 655 | Device=Device(Value); |
---|
| 656 | handles.output.Experiment=Experiment; |
---|
| 657 | handles.output.Device=Device; |
---|
| 658 | guidata(hObject, handles);% Update handles structure |
---|
| 659 | uiresume(handles.figure); |
---|
| 660 | drawnow |
---|
| 661 | return |
---|
| 662 | |
---|
| 663 | |
---|
| 664 | % ListRecords=get(handles.ListRecords,'String'); |
---|
| 665 | % Value=get(handles.ListRecords,'Value'); |
---|
| 666 | % if ~isequal(Value,1) |
---|
| 667 | % ListRecords=ListRecords(Value); |
---|
| 668 | % end |
---|
| 669 | |
---|
| 670 | %[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices); |
---|
| 671 | ListXml=get(handles.ListXml,'String'); |
---|
| 672 | Value=get(handles.ListXml,'Value'); |
---|
| 673 | if isequal(Value,1) |
---|
| 674 | msgbox_uvmat('ERROR','you need to select in the GUI browse_data the xml files to edit') |
---|
| 675 | return |
---|
| 676 | else |
---|
| 677 | ListXml=ListXml(Value); |
---|
| 678 | end |
---|
| 679 | |
---|
| 680 | %update all the selected xml files |
---|
| 681 | DataviewData=get(handles.figure,'UserData'); |
---|
| 682 | % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... |
---|
| 683 | % DataviewData.GeometryCalib.CalibrationType ' calibration data']) |
---|
| 684 | % if ~isequal(answer,'Yes') |
---|
| 685 | % return |
---|
| 686 | % end |
---|
| 687 | %List.Experiment{1}.Device{1} |
---|
| 688 | %List.Experiment{2}.Device{1} |
---|
| 689 | for iexp=1:length(List.Experiment) |
---|
| 690 | ExpName=List.Experiment{iexp}.name; |
---|
| 691 | set(handles.ListExperiments,'Value',IndicesExp(iexp)); |
---|
| 692 | if isfield(List.Experiment{iexp},'Device') |
---|
| 693 | for idevice=1:length(List.Experiment{iexp}.Device) |
---|
| 694 | DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
| 695 | if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') |
---|
| 696 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
| 697 | FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
| 698 | for ilistxml=1:length(ListXml) |
---|
| 699 | if isequal(FileName,ListXml{ilistxml}) |
---|
| 700 | set(handles.ListXml,'Value',Value(ilistxml)) |
---|
| 701 | drawnow |
---|
| 702 | xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); |
---|
| 703 | update_imadoc(DataviewData.GeometryCalib,xmlfullname) |
---|
| 704 | display([xmlfullname ' updated']) |
---|
| 705 | break |
---|
| 706 | end |
---|
| 707 | end |
---|
| 708 | end |
---|
| 709 | elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') |
---|
| 710 | for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
| 711 | RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
| 712 | if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') |
---|
| 713 | for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
| 714 | FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
| 715 | for ilistxml=1:length(ListXml) |
---|
| 716 | if isequal(FileName,ListXml{ilistxml}) |
---|
| 717 | set(handles.ListXml,'Value',Value(ilistxml)) |
---|
| 718 | drawnow |
---|
| 719 | xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); |
---|
| 720 | update_imadoc(DataviewData.GeometryCalib,xmlfullname) |
---|
| 721 | display([xmlfullname ' updated']) |
---|
| 722 | break |
---|
| 723 | end |
---|
| 724 | end |
---|
| 725 | end |
---|
| 726 | end |
---|
| 727 | end |
---|
| 728 | end |
---|
| 729 | end |
---|
| 730 | end |
---|
| 731 | end |
---|
| 732 | set(handles.ListXml,'Value',Value) |
---|
| 733 | % |
---|
| 734 | % |
---|
| 735 | % |
---|
| 736 | % |
---|
| 737 | % |
---|
| 738 | % |
---|
| 739 | % |
---|
| 740 | % CurrentPath=get(handles.SourceDir,'String');%= get(hObject,'String'); |
---|
| 741 | % ListExperiments=get(handles.ListExperiments,'String'); |
---|
| 742 | % Value=get(handles.ListExperiments,'Value'); |
---|
| 743 | % if ~isequal(Value,1) |
---|
| 744 | % ListExperiments=ListExperiments(Value); |
---|
| 745 | % end |
---|
| 746 | % ListDevices=get(handles.ListDevices,'String'); |
---|
| 747 | % Value=get(handles.ListDevices,'Value'); |
---|
| 748 | % if isequal(Value,1) |
---|
| 749 | % msgbox_uvmat('ERROR','manually select in the GUI browse_data the device being calibrated') |
---|
| 750 | % return |
---|
| 751 | % else |
---|
| 752 | % ListDevices=ListDevices(Value); |
---|
| 753 | % end |
---|
| 754 | % ListRecords=get(handles.ListRecords,'String'); |
---|
| 755 | % Value=get(handles.ListRecords,'Value'); |
---|
| 756 | % if ~isequal(Value,1) |
---|
| 757 | % ListRecords=ListRecords(Value); |
---|
| 758 | % end |
---|
| 759 | % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); |
---|
| 760 | % ListXml=get(handles.ListXml,'String'); |
---|
| 761 | % Value=get(handles.ListXml,'Value'); |
---|
| 762 | % if isequal(Value,1) |
---|
| 763 | % msgbox_uvmat('ERROR','you need to select in the GUI browse_data the xml files to edit') |
---|
| 764 | % return |
---|
| 765 | % else |
---|
| 766 | % ListXml=ListXml(Value); |
---|
| 767 | % end |
---|
| 768 | % handles.output.CurrentPath=CurrentPath; |
---|
| 769 | % handles.output.ListExperiments=ListExperiments; |
---|
| 770 | % handles.output.ListDevices=ListDevices; |
---|
| 771 | % handles.output.ListRecords=ListRecords; |
---|
| 772 | % handles.output.ListXml=ListXml; |
---|
| 773 | % handles.output.List=List; |
---|
| 774 | % handles.output ='OK, Calibration replicated'; |
---|
| 775 | % guidata(hObject, handles);% Update handles structure |
---|
| 776 | % uiresume(handles.figure); |
---|
| 777 | |
---|
| 778 | % --- Executes on button press in Cancel. |
---|
| 779 | function Cancel_Callback(hObject, eventdata, handles) |
---|
| 780 | handles.output = get(hObject,'String'); |
---|
| 781 | guidata(hObject, handles); % Update handles structure |
---|
| 782 | % Use UIRESUME instead of delete because the OutputFcn needs |
---|
| 783 | uiresume(handles.figure); |
---|
| 784 | |
---|
| 785 | % --- Executes when user attempts to close figure. |
---|
| 786 | function figure_CloseRequestFcn(hObject, eventdata, handles) |
---|
| 787 | if isequal(get(handles.figure, 'waitstatus'), 'waiting') |
---|
| 788 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 789 | uiresume(handles.figure); |
---|
| 790 | else |
---|
| 791 | % The GUI is no longer waiting, just close it |
---|
| 792 | delete(handles.figure); |
---|
| 793 | end |
---|
| 794 | |
---|
| 795 | % --- Executes on key press over figure1 with no controls selected. |
---|
| 796 | function figure_KeyPressFcn(hObject, eventdata, handles) |
---|
| 797 | % Check for "enter" or "escape" |
---|
| 798 | if isequal(get(hObject,'CurrentKey'),'escape') |
---|
| 799 | % User said no by hitting escape |
---|
| 800 | handles.output = 'Cancel'; |
---|
| 801 | |
---|
| 802 | % Update handles structure |
---|
| 803 | guidata(hObject, handles); |
---|
| 804 | |
---|
| 805 | uiresume(handles.figure); |
---|
| 806 | end |
---|
| 807 | if isequal(get(hObject,'CurrentKey'),'return') |
---|
| 808 | uiresume(handles.figure); |
---|
| 809 | end |
---|