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