Changeset 507 for trunk/src/datatree_browser.m
- Timestamp:
- Jul 29, 2012, 11:18:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/datatree_browser.m
r503 r507 22 22 function varargout = datatree_browser(varargin) 23 23 24 % Last Modified by GUIDE v2.5 2 6-Jul-2012 08:24:2624 % Last Modified by GUIDE v2.5 29-Jul-2012 08:49:20 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before datatree_browser is made visible. 47 function datatree_browser_OpeningFcn(hObject, eventdata, handles, projectxml)47 function datatree_browser_OpeningFcn(hObject, eventdata, handles, InputName) 48 48 %------------------------------------------------------------------------ 49 49 % Choose default command line output for datatree_browser … … 74 74 set(hObject, 'Units', OldUnits); 75 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 ~isempty(regexp(projectxml,'.project.xml$')) 97 if exist(regexprep(projectxml,'.project.xml$','.link'),'dir') 98 99 set(handles.LinkDir,'String',regexprep(projectxml,'.project.xml$','.link')) 100 XmlContent=xml2struct(projectxml); 101 set(handles.SourceDir,'String',XmlContent.SourceDir) 102 set(handles.UpdateLink,'String','UpdateLink') 103 % datatree_browser(regexprep(fileinput,'.project.xml$','.link')) 104 105 elseif exist(regexprep(projectxml,'.project.xml$',''),'dir') 106 set(handles.SourceDir,'String',regexprep(projectxml,'.project.xml$','')) 76 if exist('InputName','var') 77 if isdir(InputName)% opening by uvmat/MenuSetProject 78 set(handles.SourceDir,'String',InputName)% the input directory is considered as a project 79 set(handles.LinkDir,'Visible','off') 80 set(handles.UpdateLink,'String','create_link') 81 set(handles.MarkupDir,'Visible','on') 82 83 else% opening by uvmat/Open 84 InputDir=regexprep(InputName,'.xml$',''); 85 if exist(InputDir,'dir') 86 s=xml2struct(InputName); 87 if isfield(s,'SourceDir') 88 set(handles.SourceDir,'String',s.SourceDir) 89 set(handles.LinkDir,'String',InputDir) 90 set(handles.LinkDir,'Visible','on') 91 else 92 set(handles.SourceDir,'String',InputDir) 107 93 set(handles.LinkDir,'Visible','off') 108 set(handles.UpdateLink,'String','CreateLink') 94 set(handles.MarkupDir,'String','CreateLink') 95 end 109 96 end 110 set(handles.OK,'Visible','on') 111 set(handles.Cancel,'Visible','on') 112 set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 113 drawnow 114 uiwait(handles.figure); 115 end 116 % if exist('RootDir','var') 117 % set(handles.SourceDir,'String',RootDir); 118 % % set(handles.clean_civ_cmx,'Visible','off') 119 % set(handles.edit_xml,'Visible','off') 120 % set(handles.HELP,'Visible','off') 121 % set(handles.OK,'Visible','on') 122 % set(handles.Cancel,'Visible','on') 123 % set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal 124 % set(hObject,'Visible','on') 125 % drawnow 126 % %RootDirectory_Callback(hObject, eventdata, handles) 127 % % UIWAIT makes translate_points wait for user response (see UIRESUME) 128 % uiwait(handles.figure); 129 % end 97 FillExperiments(handles) 98 set(handles.OK,'Visible','on') 99 drawnow 100 101 end 102 end 103 130 104 131 105 %------------------------------------------------------------------------ … … 135 109 % Get default command line output from handles structure 136 110 varargout{1} = handles.output; 137 %delete(handles.figure) 138 139 %------------------------------------------------------------------------ 140 % --- Executes on button press in UpdateLink. 111 %delete(handles.datatree_browser) 112 113 %------------------------------------------------------------------------ 114 % --- Executes on button press in MarkupDir: create a xml file to mark SourceDir as project source 115 function MarkupDir_Callback(hObject, eventdata, handles) 116 %------------------------------------------------------------------------ 117 SourceDir=get(handles.SourceDir,'String'); 118 t=xmltree; 119 t=set(t,1,'name','Project'); 120 try 121 save(t,[SourceDir '.xml']) 122 catch ME 123 msgbox_uvmat('ERROR',ME.message) 124 end 125 126 %------------------------------------------------------------------------ 127 % --- Executes on button press in UpdateLink: create a link dir or update it if it exists 141 128 function UpdateLink_Callback(hObject, eventdata, handles) 142 129 %------------------------------------------------------------------------ 143 InputString=get(handles.UpdateLink,'String') 144 switch InputString 145 case 'CreateLink' 146 CurrentDir=fileparts(get(handles.SourceDir,'String')); 147 if ~exist(CurrentDir,'dir') 148 CurrentDir=''; 149 end 150 SourceDir=uigetdir(CurrentDir,'pick up the source project directory'); %file browser 151 if isequal(SourceDir,0) 152 return 153 else 154 set(handles.SourceDir,'String',SourceDir) 155 end 156 drawnow 157 [SourcePath,ProjectName]=fileparts(SourceDir); 158 MirrorRoot=uigetdir(CurrentDir,'path to the link directory'); %file browser 159 if isempty(MirrorRoot) 160 return 161 else 162 MirrorDir=fullfile(MirrorRoot,[ProjectName '.link']); 163 end 164 if ~exist(MirrorDir,'dir') 165 mkdir(MirrorDir) 166 end 167 MirrorDoc.SourceDir=SourceDir; 168 t=struct2xml(MirrorDoc); 169 set(t,1,'name','DataTree'); 170 save(t,fullfile(MirrorDir,[ProjectName '.xml'])) 171 set(handles.LinkDir,'String',MirrorDir) 172 173 %update_link(SourceDir,LinkDir) 174 SourceDir_Callback([],[], handles) 175 case 'UpDateLink' 176 % MirrorDir=get(handles.LinkDir,'String'); 177 % menu={'*.xml', ' (*.xml)'; 178 % '*.xml', '.xml files '; ... 179 % '*.*', 'All Files (*.*)'}; 180 % [MirrorXml, PathName] = uigetfile( menu, 'Pick the head xml file in the link directory',MirrorDir); 181 [MirrorXml, PathName]=fileparts(get(handles.LinkDir,'String')); 182 %set(handles.LinkDir,'String',fullfile(PathName,regexprep(MirrorXml,'.xml$','.link'))) 183 LinkDir_Callback(hObject, eventdata, handles) 184 end 185 186 % RootDirectory_Callback(hObject, eventdata, handles) 187 %------------------------------------------------------------------------ 188 % --- Executes on button press in open_SubCampaign. 189 function UpdateMirror_Callback(hObject, eventdata, handles) 190 %------------------------------------------------------------------------ 191 % MirrorDir=get(handles.LinkDir,'String'); 192 % menu={'*.xml', ' (*.xml)'; 193 % '*.xml', '.xml files '; ... 194 % '*.*', 'All Files (*.*)'}; 195 % [MirrorXml, PathName] = uigetfile( menu, 'Pick the head xml file in the link directory',MirrorDir); 196 % set(handles.LinkDir,'String',fullfile(PathName,regexprep(MirrorXml,'.xml$','.link'))) 197 % MirrorDir_Callback(hObject, eventdata, handles) 198 199 200 %------------------------------------------------------------------------ 201 function LinkDir_Callback(hObject, eventdata, handles) 202 %------------------------------------------------------------------------ 203 MirrorDir=get(handles.LinkDir,'String'); 204 [tild,MirrorName]=fileparts(MirrorDir); 205 s=xml2struct(fullfile(MirrorDir,[MirrorName '.xml'])); 206 set(handles.SourceDir,'String',s.SourceDir) 207 SourceDir_Callback([],[], handles) 208 %update_link(s.SourceDir, LinkDir) 209 210 211 % %------------------------------------------------------------------------ 212 % function update_link(SourceDir,LinkDir,handles) 213 % %------------------------------------------------------------------------ 214 % SourceDir_Callback([],[], handles) 215 216 %------------------------------------------------------------------------ 217 function SourceDir_Callback(hObject, eventdata, handles) 218 %------------------------------------------------------------------------ 219 set(handles.SourceDir,'BackgroundColor',[1 1 0]) 220 drawnow 130 [SourcePath,ProjectName]=fileparts(get(handles.SourceDir,'String')); 131 LinkDir=get(handles.LinkDir,'String'); 132 if isempty(LinkDir)||strcmp(get(handles.LinkDir,'Visible'),'off') 133 LinkRoot=uigetdir(LinkDir,'pick up the path to the link directory'); %file browser 134 if isempty(LinkRoot),return,end 135 LinkDir=fullfile(LinkRoot,[ProjectName '.link']); 136 set(handles.LinkDir,'Visible','on') 137 set(handles.LinkDir,'String',LinkDir) 138 end 139 140 if ~exist(LinkDir,'dir') 141 try 142 mkdir(LinkDir) 143 catch ME 144 msgbox_uvmat('ERROR',ME.message) 145 end 146 end 147 LinkDirXml=fullfile(fileparts(LinkDir),[ProjectName '.link.xml']); 148 if ~exist(LinkDirXml,'file') 149 LinkDoc.SourceDir=get(handles.SourceDir,'String'); 150 t=struct2xml(LinkDoc); 151 t=set(t,1,'name','Project'); 152 save(t,LinkDirXml) 153 set(handles.UpdateLink,'String','update_link') 154 end 155 156 FillExperiments(handles) 157 158 %------------------------------------------------------------------------ 159 % --- Fill the column 'Experiments' with the list of detected directries 160 function FillExperiments(handles) 161 %------------------------------------------------------------------------ 221 162 SourceDir=get(handles.SourceDir,'String'); 222 MirrorDir=get(handles.LinkDir,'String'); 223 ExpName={''}; 224 if exist(SourceDir,'dir') 225 hdir=dir(SourceDir); %list files and dirs 226 idir=0; 227 for ilist=1:length(hdir) 228 if hdir(ilist).isdir 229 dirname=hdir(ilist).name; 230 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') 231 idir=idir+1; 232 ExpName{idir}=hdir(ilist).name; 233 link=fullfile(MirrorDir,ExpName{idir}) 163 LinkDir=''; 164 if strcmp(get(handles.LinkDir,'Visible'),'on') 165 LinkDir=get(handles.LinkDir,'String'); 166 end 167 168 hdir=dir(SourceDir); %list files and dirs 169 idir=0; 170 ExpName=cell(length(hdir),1); 171 for ilist=1:length(hdir) 172 if hdir(ilist).isdir 173 dirname=hdir(ilist).name; 174 if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')% do not list directories beginning by '0' 175 idir=idir+1; 176 ExpName{idir}=hdir(ilist).name; 177 if ~isempty(LinkDir) 178 link=fullfile(LinkDir,ExpName{idir}); 234 179 if ~exist(link,'dir') 235 mkdir(link) 236 end 237 end 238 % look for the list of 'devices' 239 else 240 %warning for isolated files 241 end 242 end 243 set(handles.ListExperiments,'String',[{'*'};ExpName']) 244 set(handles.ListExperiments,'Value',1) 245 ListExperiments_Callback(hObject, eventdata, handles) 246 else 247 msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory']) 248 end 249 set(handles.SourceDir,'BackgroundColor',[1 1 1]) 250 251 252 %------------------------------------------------------------------------ 253 % --- Executes on selection change in ListExperiments. 254 function ListExperiments_Callback(hObject, eventdata, handles) 255 %------------------------------------------------------------------------ 256 SourcePath=get(handles.SourceDir,'String'); 257 MirrorPath=get(handles.LinkDir,'String'); 258 ListExperiments=get(handles.ListExperiments,'String'); 259 ListDevices={}; 260 list_val=get(handles.ListExperiments,'Value'); 261 if isequal(list_val(1),1) 262 ListExperiments=ListExperiments(2:end); %choose all experiments 263 testList=1; 264 set(handles.ListExperiments,'Value',1) 265 else 266 ListExperiments=ListExperiments(list_val);%choose selected experiments 267 testList=0; 268 end 269 for iexp=1:numel(ListExperiments) 270 hdir=dir(fullfile(SourcePath,ListExperiments{iexp})); %list files and dirs 271 idir=0; 272 for ilist=1:length(hdir) 273 if ~isequal(hdir(ilist).name(1),'.') 274 source=fullfile(SourcePath,ListExperiments{iexp},hdir(ilist).name); 275 link=fullfile(MirrorPath,ListExperiments{iexp},hdir(ilist).name); 276 if ~exist(link) 277 system(['ln -s ' source ' ' link]) 278 end 279 check_list=strcmp(hdir(ilist).name,ListDevices); 280 if isempty(find(check_list)) 281 ListDevices=[ListDevices;hdir(ilist).name]; 282 end 283 end 284 end 285 end 286 set(handles.ListDevices,'String',ListDevices) 287 % if hdir(ilist).isdir 288 % dirname=hdir(ilist).name; 289 % if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0') 290 % idir=idir+1; 291 % ExpName{idir}=hdir(ilist).name; 292 % link=fullfile(LinkDir,ExpName{idir}); 293 % if ~exist(link,'dir') 294 % mkdir(link) 295 % end 296 % end 297 % % look for the list of 'devices' 298 % else 299 % %warning for isolated files 300 % end 301 % end 302 % set(handles.ListExperiments,'String',[{'*'};ExpName']) 303 % set(handles.ListExperiments,'Value',1) 304 % ListExperiments_Callback(hObject, eventdata, handles) 305 306 307 % set(handles.ListDevices,'Value',1) 308 % set(handles.ListRecords,'Value',1) 309 % set(handles.ListXml,'Value',1) 310 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,{},{}); 311 % set(handles.ListRecords,'String',[{'*'};ListRecords']) 312 % set(handles.ListDevices,'String',[{'*'};ListDevices']) 313 % set(handles.ListXml,'String',[{'*'};ListXml']) 314 % if testList 315 % DataviewData=get(handles.figure,'UserData'); 316 % DataviewData.List=List; 317 % set(handles.figure,'UserData',DataviewData) 318 % end 319 % set(handles.CampaignDoc,'Visible','on') 320 % set(handles.edit_xml,'Visible','on') 321 322 %------------------------------------------------------------------------ 323 % --- Executes on button press in update_headings. 324 function ListDevices_Callback(hObject, eventdata, handles) 325 CurrentPath=get(handles.SourceDir,'String'); 326 ListExperiments=get(handles.ListExperiments,'String'); 327 list_val=get(handles.ListExperiments,'Value'); 328 if isequal(list_val,1) 329 ListExperiments=ListExperiments(2:end); 330 else 331 ListExperiments=ListExperiments(list_val); 332 end 333 set(handles.ListRecords,'Value',1) 334 set(handles.ListXml,'Value',1) 335 ListDevices=get(handles.ListDevices,'String'); 336 list_val=get(handles.ListDevices,'Value'); 337 if isequal(list_val,1) 338 ListDevices=ListDevices(2:end); 339 else 340 ListDevices=ListDevices(list_val); 341 end 342 [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); 343 set(handles.ListRecords,'String',[{'*'};ListRecords']) 344 set(handles.ListXml,'String',[{'*'};ListXml']) 345 346 347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 348 349 350 351 %------------------------------------------------------------------------ 352 % --- Executes on selection change in ListRecords. 353 function ListRecords_Callback(hObject, eventdata, handles) 354 Value=get(handles.ListRecords,'Value'); 355 if isequal(Value(1),1) 356 set(handles.ListRecords,'Value',1); 357 end 358 359 %------------------------------------------------------------------------ 360 % --- Executes on button press in CampaignDoc. 361 function CampaignDoc_Callback(hObject, eventdata, handles) 362 %------------------------------------------------------------------------ 363 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') 364 if ~isequal(answer{1},'OK') 365 return 366 end 367 set(handles.ListExperiments,'Value',1) 368 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 369 DataviewData=get(handles.figure,'UserData'); 370 List=DataviewData.List; 371 Currentpath=get(handles.SourceDir,'String'); 372 [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 373 Campaign=[Campaign DirExt]; 374 t=xmltree; 375 t=set(t,1,'name','CampaignDoc'); 376 t = attributes(t,'add',1,'source','directory'); 377 SubCampaignTest=get(handles.SubCampaignTest,'Value'); 378 root_uid=1; 379 if SubCampaignTest 380 %TO DO open an exoiting xml doc 381 [t,root_uid]=add(t,1,'element','SubCampaign'); 382 t =attributes(t,'add',root_uid,'DirName',Campaign); 383 end 384 for iexp=1:length(List.Experiment) 385 set(handles.ListExperiments,'Value',iexp+1) 386 drawnow 387 test_mod=0; 388 [t,uid_exp]=add(t,root_uid,'element','Experiment'); 389 t = attributes(t,'add',uid_exp,'i',num2str(iexp)); 390 ExpName=List.Experiment{iexp}.name; 391 t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); 392 393 if isfield(List.Experiment{iexp},'Device') 394 for idevice=1:length(List.Experiment{iexp}.Device) 395 [t,uid_device]=add(t,uid_exp,'element','Device'); 396 DeviceName=List.Experiment{iexp}.Device{idevice}.name; 397 t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); 398 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 399 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 400 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 401 [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); 402 if test 403 [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] 404 end 405 if isequal(Title,'ImaDoc') 406 [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); 407 t = attributes(t,'add',uid_xml,'source','file'); 408 [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); 409 end 410 end 411 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 412 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 413 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 414 [t,uid_record]=add(t,uid_device,'element','Record'); 415 t = attributes(t,'add',uid_record,'DirName',RecordName); 416 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 417 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 418 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 419 [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); 420 if test 421 [FileName ' , Heading updated'] 422 end 423 [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); 424 t = attributes(t,'add',uid_xml,'source','file'); 425 [t]=add(t,uid_xml,'chardata',FileName); 426 end 427 end 180 mkdir(link)% create the directory containing links 428 181 end 429 182 end … … 431 184 end 432 185 end 186 set(handles.ListExperiments,'String',[{'*'};ExpName(1:idir)]) 433 187 set(handles.ListExperiments,'Value',1) 434 outputdir=get(handles.SourceDir,'String'); 435 [path,dirname]=fileparts(outputdir); 436 outputfile=fullfile(outputdir,[dirname '.xml']); 437 % campaigndoc(t);438 save(t,outputfile) 439 440 %------------------------------------------------------------------------ 441 % --- Executes on button press in CampaignDoc. 442 function edit_xml_Callback(hObject, eventdata, handles) 443 %------------------------------------------------------------------------ 444 CurrentPath=get(handles.SourceDir,'String');445 %[CurrentPath,Name,Ext]=fileparts(CurrentDir); 188 ListExperiments_Callback([],[], handles) 189 190 191 %------------------------------------------------------------------------ 192 % --- Executes on selection change in ListExperiments. 193 function ListExperiments_Callback(hObject,eventdata,handles) 194 %------------------------------------------------------------------------ 195 SourcePath=get(handles.SourceDir,'String'); 196 MirrorPath=''; 197 if strcmp(get(handles.LinkDir,'Visible'),'on') 198 MirrorPath=get(handles.LinkDir,'String'); 199 end 446 200 ListExperiments=get(handles.ListExperiments,'String'); 447 Value=get(handles.ListExperiments,'Value'); 448 if ~isequal(Value,1) 449 ListExperiments=ListExperiments(Value); 450 end 451 ListDevices=get(handles.ListDevices,'String'); 452 Value=get(handles.ListDevices,'Value'); 453 if ~isequal(Value,1) 454 ListDevices=ListDevices(Value); 455 end 456 ListRecords=get(handles.ListRecords,'String'); 457 Value=get(handles.ListRecords,'Value'); 458 if ~isequal(Value,1) 459 ListRecords=ListRecords(Value); 460 end 461 [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 462 ListXml=get(handles.ListXml,'String'); 463 Value=get(handles.ListXml,'Value'); 464 set(handles.ListXml,'Value',Value(1)); 465 if isequal(Value(1),1) 466 msgbox_uvmat('ERROR','an xml file needs to be selected') 467 return 201 if isequal(get(handles.ListExperiments,'Value'),1) 202 ListExperiments=ListExperiments(2:end); %choose all experiments 468 203 else 469 XmlName=ListXml{Value(1)};470 end 471 for iexp=1:length(List.Experiment) 472 ExpName=List.Experiment{iexp}.name; 473 if isfield(List.Experiment{iexp},'Device')474 for idevice=1:length(List.Experiment{iexp}.Device)475 DeviceName=List.Experiment{iexp}.Device{idevice}.name;476 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')477 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)478 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}479 if isequal(FileName,XmlName)480 editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));481 return482 end204 ListExperiments=ListExperiments(get(handles.ListExperiments,'Value')); 205 end 206 ListDevices={}; 207 208 for iexp=1:numel(ListExperiments) 209 hdir=dir(fullfile(SourcePath,ListExperiments{iexp})); %list files and dirs 210 for ilist=1:length(hdir) 211 Device=hdir(ilist).name; 212 if ~isequal(Device(1),'.') 213 if ~isempty(MirrorPath)% we list the links to the data directories of files 214 link=fullfile(MirrorPath,ListExperiments{iexp},Device); 215 if ~exist(link) 216 source=fullfile(SourcePath,ListExperiments{iexp},Device); 217 system(['ln -s ' source ' ' link])%TODO translate for DOS 483 218 end 484 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 485 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 486 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 487 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 488 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 489 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 490 if isequal(FileName,XmlName) 491 editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); 492 return 493 end 494 end 495 end 496 end 219 Device=['@' Device]; 220 end 221 if hdir(ilist).isdir 222 Device=[Device '/']; 223 end 224 check_list=strcmp(Device,ListDevices); 225 if isempty(find(check_list)) 226 ListDevices=[ListDevices;Device]; 497 227 end 498 228 end 499 229 end 500 230 end 501 502 503 504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 505 % CurrentPath/Campaign: root directory 506 function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) 507 508 %Shema for Heading: 509 % Campaign 510 % (SubCampaign) 511 % Experiment 512 % Device 513 % (Record) 514 % ImageName 515 % DateExp 516 % old: %Project: suppressed ( changed to Campaign) 517 %Exp: suppressed (changed to experiment) 518 %ImaNames: changed to ImageName 519 if exist('Record','var') && ~isempty(Record) 520 xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 521 testrecord=1; 522 else 523 xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); 524 testrecord=0; 525 end 526 if ~exist('testSubCampaign','var') 527 testSubCampaign=0; 528 end 529 if testSubCampaign 530 SubCampaign=Campaign; 531 [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 532 Campaign=[Campaign DirExt]; 533 end 534 test_mod=0; %test for the modification of the xml file 535 t_device=xmltree(xmlfullname); 536 Title=get(t_device,1,'name'); 537 uid_child=children(t_device,1); 538 Heading_old=[]; 539 uidheading=0; 540 for ilist=1:length(uid_child) 541 name=get(t_device,uid_child(ilist),'name'); 542 if isequal(name,'Heading') 543 uidheading=uid_child(ilist); 231 set(handles.ListDevices,'String',ListDevices) 232 233 234 %------------------------------------------------------------------------ 235 % --- Executes on selection in column ListDevices 236 function ListDevices_Callback(hObject, eventdata, handles) 237 %------------------------------------------------------------------------ 238 list_val=get(handles.ListExperiments,'Value'); 239 if numel(list_val)~=1 240 msgbox_uvmat('ERROR','select a single experiment') 241 return 242 end 243 ListExperiments=get(handles.ListExperiments,'String'); 244 Experiment=ListExperiments{list_val}; 245 RootPath=''; 246 if strcmp(get(handles.LinkDir,'Visible'),'on') 247 RootPath=get(handles.LinkDir,'String'); 248 end 249 if isempty(RootPath) 250 RootPath=get(handles.SourceDir,'String'); 251 end 252 ListDevices=get(handles.ListDevices,'String'); 253 Device=ListDevices{get(handles.ListDevices,'Value')}; 254 Device=regexprep(Device,'^@',''); 255 if strcmp(Device(end),'/') 256 DataDir=fullfile(RootPath,Experiment,Device(1:end-1)); 257 DirList=dir(DataDir); 258 for ilist=1:numel(DirList) 259 [tild,tild,FileExt]=fileparts(DirList(ilist).name); 260 FileExt=regexprep(FileExt,'^.',''); 261 if ~isempty(FileExt) && (~isempty(imformats(FileExt))||strcmp(lower(FileExt),'avi')||strcmp(lower(FileExt),'nc')) 262 uvmat(fullfile(DataDir,DirList(ilist).name)) 263 return 264 end 544 265 end 545 266 end 546 if uidheading 547 subt=branch(t_device,uidheading); 548 Heading_old=convert(subt); 549 else 550 return % do not edit xml files without element 'Heading' 551 end 552 if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) 553 test_mod=1; 554 end 555 Heading.Campaign=Campaign; 556 if testSubCampaign 557 if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) 558 test_mod=1; 559 end 560 Heading.SubCampaign=SubCampaign; 561 end 562 if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) 563 test_mod=1; 564 end 565 Heading.Experiment=Experiment; 566 if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) 567 test_mod=1; 568 end 569 Heading.Device=Device; 570 if testrecord 571 if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) 572 test_mod=1; 573 end 574 Heading.Record=Record; 575 end 576 if isfield(Heading_old,'ImaNames') 577 test_mod=1; 578 if ~isempty(Heading_old.ImaNames) 579 Heading.ImageName=Heading_old.ImaNames; 580 end 581 end 582 if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) 583 Heading.ImageName=Heading_old.ImageName; 584 end 585 if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) 586 Heading.DateExp=Heading_old.DateExp; 587 end 588 if test_mod && uidheading 589 uid_child=children(t_device,uidheading); 590 t_device=delete(t_device,uid_child); 591 t_device=struct2xml(Heading,t_device,uidheading); 592 backupfile=xmlfullname; 593 testexist=2; 594 while testexist==2 595 backupfile=[backupfile '~']; 596 testexist=exist(backupfile,'file'); 597 end 598 [success,message]=copyfile(xmlfullname,backupfile);%make backup 599 if isequal(success,1) 600 delete(xmlfullname) 601 else 602 return 603 end 604 save(t_device,xmlfullname) 605 end 267 % 268 % set(handles.ListRecords,'Value',1) 269 % set(handles.ListXml,'Value',1) 270 % ListDevices=get(handles.ListDevices,'String'); 271 % list_val=get(handles.ListDevices,'Value'); 272 % if isequal(list_val,1) 273 % ListDevices=ListDevices(2:end); 274 % else 275 % ListDevices=ListDevices(list_val); 276 % end 277 % [ListDevices,ListRecords,ListXml]=ListDir(CurrentPath,ListExperiments,ListDevices,{}); 278 % set(handles.ListRecords,'String',[{'*'};ListRecords']) 279 % set(handles.ListXml,'String',[{'*'};ListXml']) 280 281 282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 283 284 285 286 % %------------------------------------------------------------------------ 287 % % --- Executes on selection change in ListRecords. 288 % function ListRecords_Callback(hObject, eventdata, handles) 289 % Value=get(handles.ListRecords,'Value'); 290 % if isequal(Value(1),1) 291 % set(handles.ListRecords,'Value',1); 292 % end 293 294 % %------------------------------------------------------------------------ 295 % % --- Executes on button press in CampaignDoc. 296 % function CampaignDoc_Callback(hObject, eventdata, handles) 297 % %------------------------------------------------------------------------ 298 % 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') 299 % if ~isequal(answer{1},'OK') 300 % return 301 % end 302 % set(handles.ListExperiments,'Value',1) 303 % ListExperiments_Callback(handles)%update the overview of the experiment directories 304 % DataviewData=get(handles.datatree_browser,'UserData'); 305 % List=DataviewData.List; 306 % Currentpath=get(handles.SourceDir,'String'); 307 % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 308 % Campaign=[Campaign DirExt]; 309 % t=xmltree; 310 % t=set(t,1,'name','CampaignDoc'); 311 % t = attributes(t,'add',1,'source','directory'); 312 % SubCampaignTest=get(handles.SubCampaignTest,'Value'); 313 % root_uid=1; 314 % if SubCampaignTest 315 % %TO DO open an exoiting xml doc 316 % [t,root_uid]=add(t,1,'element','SubCampaign'); 317 % t =attributes(t,'add',root_uid,'DirName',Campaign); 318 % end 319 % for iexp=1:length(List.Experiment) 320 % set(handles.ListExperiments,'Value',iexp+1) 321 % drawnow 322 % test_mod=0; 323 % [t,uid_exp]=add(t,root_uid,'element','Experiment'); 324 % t = attributes(t,'add',uid_exp,'i',num2str(iexp)); 325 % ExpName=List.Experiment{iexp}.name; 326 % t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name); 327 % 328 % if isfield(List.Experiment{iexp},'Device') 329 % for idevice=1:length(List.Experiment{iexp}.Device) 330 % [t,uid_device]=add(t,uid_exp,'element','Device'); 331 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 332 % t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name); 333 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 334 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 335 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 336 % [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest); 337 % if test 338 % [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'] 339 % end 340 % if isequal(Title,'ImaDoc') 341 % [t,uid_xml]=add(t,uid_device,'element','ImaDoc'); 342 % t = attributes(t,'add',uid_xml,'source','file'); 343 % [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}); 344 % end 345 % end 346 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 347 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 348 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 349 % [t,uid_record]=add(t,uid_device,'element','Record'); 350 % t = attributes(t,'add',uid_record,'DirName',RecordName); 351 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 352 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 353 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 354 % [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest); 355 % if test 356 % [FileName ' , Heading updated'] 357 % end 358 % [t,uid_xml]=add(t,uid_record,'element','ImaDoc'); 359 % t = attributes(t,'add',uid_xml,'source','file'); 360 % [t]=add(t,uid_xml,'chardata',FileName); 361 % end 362 % end 363 % end 364 % end 365 % end 366 % end 367 % end 368 % set(handles.ListExperiments,'Value',1) 369 % outputdir=get(handles.SourceDir,'String'); 370 % [path,dirname]=fileparts(outputdir); 371 % outputfile=fullfile(outputdir,[dirname '.xml']); 372 % %campaigndoc(t); 373 % save(t,outputfile) 374 % 375 % %------------------------------------------------------------------------ 376 % % --- Executes on button press in CampaignDoc. 377 % function edit_xml_Callback(hObject, eventdata, handles) 378 % %------------------------------------------------------------------------ 379 % CurrentPath=get(handles.SourceDir,'String'); 380 % %[CurrentPath,Name,Ext]=fileparts(CurrentDir); 381 % ListExperiments=get(handles.ListExperiments,'String'); 382 % Value=get(handles.ListExperiments,'Value'); 383 % if ~isequal(Value,1) 384 % ListExperiments=ListExperiments(Value); 385 % end 386 % ListDevices=get(handles.ListDevices,'String'); 387 % Value=get(handles.ListDevices,'Value'); 388 % if ~isequal(Value,1) 389 % ListDevices=ListDevices(Value); 390 % end 391 % ListRecords=get(handles.ListRecords,'String'); 392 % Value=get(handles.ListRecords,'Value'); 393 % if ~isequal(Value,1) 394 % ListRecords=ListRecords(Value); 395 % end 396 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 397 % ListXml=get(handles.ListXml,'String'); 398 % Value=get(handles.ListXml,'Value'); 399 % set(handles.ListXml,'Value',Value(1)); 400 % if isequal(Value(1),1) 401 % msgbox_uvmat('ERROR','an xml file needs to be selected') 402 % return 403 % else 404 % XmlName=ListXml{Value(1)}; 405 % end 406 % for iexp=1:length(List.Experiment) 407 % ExpName=List.Experiment{iexp}.name; 408 % if isfield(List.Experiment{iexp},'Device') 409 % for idevice=1:length(List.Experiment{iexp}.Device) 410 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 411 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 412 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 413 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} 414 % if isequal(FileName,XmlName) 415 % editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName)); 416 % return 417 % end 418 % end 419 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 420 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 421 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 422 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 423 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 424 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 425 % if isequal(FileName,XmlName) 426 % editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)); 427 % return 428 % end 429 % end 430 % end 431 % end 432 % end 433 % end 434 % end 435 % end 436 437 438 % 439 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 440 % % CurrentPath/Campaign: root directory 441 % function [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign) 442 % 443 % %Shema for Heading: 444 % % Campaign 445 % % (SubCampaign) 446 % % Experiment 447 % % Device 448 % % (Record) 449 % % ImageName 450 % % DateExp 451 % % old: %Project: suppressed ( changed to Campaign) 452 % %Exp: suppressed (changed to experiment) 453 % %ImaNames: changed to ImageName 454 % if exist('Record','var') && ~isempty(Record) 455 % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 456 % testrecord=1; 457 % else 458 % xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname); 459 % testrecord=0; 460 % end 461 % if ~exist('testSubCampaign','var') 462 % testSubCampaign=0; 463 % end 464 % if testSubCampaign 465 % SubCampaign=Campaign; 466 % [Currentpath,Campaign,DirExt]=fileparts(Currentpath); 467 % Campaign=[Campaign DirExt]; 468 % end 469 % test_mod=0; %test for the modification of the xml file 470 % t_device=xmltree(xmlfullname); 471 % Title=get(t_device,1,'name'); 472 % uid_child=children(t_device,1); 473 % Heading_old=[]; 474 % uidheading=0; 475 % for ilist=1:length(uid_child) 476 % name=get(t_device,uid_child(ilist),'name'); 477 % if isequal(name,'Heading') 478 % uidheading=uid_child(ilist); 479 % end 480 % end 481 % if uidheading 482 % subt=branch(t_device,uidheading); 483 % Heading_old=convert(subt); 484 % else 485 % return % do not edit xml files without element 'Heading' 486 % end 487 % if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign)) 488 % test_mod=1; 489 % end 490 % Heading.Campaign=Campaign; 491 % if testSubCampaign 492 % if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign)) 493 % test_mod=1; 494 % end 495 % Heading.SubCampaign=SubCampaign; 496 % end 497 % if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment)) 498 % test_mod=1; 499 % end 500 % Heading.Experiment=Experiment; 501 % if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device)) 502 % test_mod=1; 503 % end 504 % Heading.Device=Device; 505 % if testrecord 506 % if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record)) 507 % test_mod=1; 508 % end 509 % Heading.Record=Record; 510 % end 511 % if isfield(Heading_old,'ImaNames') 512 % test_mod=1; 513 % if ~isempty(Heading_old.ImaNames) 514 % Heading.ImageName=Heading_old.ImaNames; 515 % end 516 % end 517 % if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName) 518 % Heading.ImageName=Heading_old.ImageName; 519 % end 520 % if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp) 521 % Heading.DateExp=Heading_old.DateExp; 522 % end 523 % if test_mod && uidheading 524 % uid_child=children(t_device,uidheading); 525 % t_device=delete(t_device,uid_child); 526 % t_device=struct2xml(Heading,t_device,uidheading); 527 % backupfile=xmlfullname; 528 % testexist=2; 529 % while testexist==2 530 % backupfile=[backupfile '~']; 531 % testexist=exist(backupfile,'file'); 532 % end 533 % [success,message]=copyfile(xmlfullname,backupfile);%make backup 534 % if isequal(success,1) 535 % delete(xmlfullname) 536 % else 537 % return 538 % end 539 % save(t_device,xmlfullname) 540 % end 606 541 607 542 %------------------------------------------------------------------------ … … 616 551 end 617 552 618 619 620 % --- Executes on selection change in ListXml.621 function ListXml_Callback(hObject, eventdata, handles)622 Value=get(handles.ListXml,'Value');623 if isequal(Value(1),1)624 set(handles.ListXml,'Value',1);625 end553 % 554 % 555 % % --- Executes on selection change in ListXml. 556 % function ListXml_Callback(hObject, eventdata, handles) 557 % Value=get(handles.ListXml,'Value'); 558 % if isequal(Value(1),1) 559 % set(handles.ListXml,'Value',1); 560 % end 626 561 627 562 … … 634 569 end 635 570 set(handles.ListExperiments,'Value',1) 636 List Experiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories637 DataviewData=get(handles. figure,'UserData')571 ListDataDir(hObject, eventdata, handles)%update the overview of the experiment directories 572 DataviewData=get(handles.datatree_browser,'UserData') 638 573 List=DataviewData.List; 639 574 Currentpath=get(handles.SourceDir,'String'); … … 688 623 set(handles.ListExperiments,'Value',1) 689 624 690 691 % --- Executes on button press in OK. 692 function OK_Callback(hObject, eventdata, handles) 693 %------------------------------------------------------------------------ 694 CurrentPath=get(handles.SourceDir,'String'); 695 ListExperiments=get(handles.ListExperiments,'String'); 696 IndicesExp=get(handles.ListExperiments,'Value'); 697 if ~isequal(IndicesExp,1) 698 ListExperiments=ListExperiments(IndicesExp); 699 end 700 ListDevices=get(handles.ListDevices,'String'); 701 Value=get(handles.ListDevices,'Value'); 702 if isequal(Value,1) 703 msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') 704 return 705 else 706 ListDevices=ListDevices(Value); 707 end 708 ListRecords=get(handles.ListRecords,'String'); 709 Value=get(handles.ListRecords,'Value'); 710 if ~isequal(Value,1) 711 ListRecords=ListRecords(Value); 712 end 713 [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 714 ListXml=get(handles.ListXml,'String'); 715 Value=get(handles.ListXml,'Value'); 716 if isequal(Value,1) 717 msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') 718 return 719 else 720 ListXml=ListXml(Value); 721 end 722 723 %update all the selected xml files 724 DataviewData=get(handles.figure,'UserData'); 725 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... 726 % DataviewData.GeometryCalib.CalibrationType ' calibration data']) 727 % if ~isequal(answer,'Yes') 625 % 626 % % --- Executes on button press in OK. 627 % function OK_Callback(hObject, eventdata, handles) 628 % %------------------------------------------------------------------------ 629 % CurrentPath=get(handles.SourceDir,'String'); 630 % ListExperiments=get(handles.ListExperiments,'String'); 631 % IndicesExp=get(handles.ListExperiments,'Value'); 632 % if ~isequal(IndicesExp,1) 633 % ListExperiments=ListExperiments(IndicesExp); 634 % end 635 % ListDevices=get(handles.ListDevices,'String'); 636 % Value=get(handles.ListDevices,'Value'); 637 % if isequal(Value,1) 638 % msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') 728 639 % return 729 % end 730 %List.Experiment{1}.Device{1} 731 %List.Experiment{2}.Device{1} 732 for iexp=1:length(List.Experiment) 733 ExpName=List.Experiment{iexp}.name; 734 set(handles.ListExperiments,'Value',IndicesExp(iexp)); 735 if isfield(List.Experiment{iexp},'Device') 736 for idevice=1:length(List.Experiment{iexp}.Device) 737 DeviceName=List.Experiment{iexp}.Device{idevice}.name; 738 if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 739 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 740 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 741 for ilistxml=1:length(ListXml) 742 if isequal(FileName,ListXml{ilistxml}) 743 set(handles.ListXml,'Value',Value(ilistxml)) 744 drawnow 745 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); 746 update_imadoc(DataviewData.GeometryCalib,xmlfullname) 747 display([xmlfullname ' updated']) 748 break 749 end 750 end 751 end 752 elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 753 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 754 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 755 if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 756 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 757 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 758 for ilistxml=1:length(ListXml) 759 if isequal(FileName,ListXml{ilistxml}) 760 set(handles.ListXml,'Value',Value(ilistxml)) 761 drawnow 762 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); 763 update_imadoc(DataviewData.GeometryCalib,xmlfullname) 764 display([xmlfullname ' updated']) 765 break 766 end 767 end 768 end 769 end 770 end 771 end 772 end 773 end 774 end 775 set(handles.ListXml,'Value',Value) 640 % else 641 % ListDevices=ListDevices(Value); 642 % end 643 % ListRecords=get(handles.ListRecords,'String'); 644 % Value=get(handles.ListRecords,'Value'); 645 % if ~isequal(Value,1) 646 % ListRecords=ListRecords(Value); 647 % end 648 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 649 % ListXml=get(handles.ListXml,'String'); 650 % Value=get(handles.ListXml,'Value'); 651 % if isequal(Value,1) 652 % msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') 653 % return 654 % else 655 % ListXml=ListXml(Value); 656 % end 657 % 658 % %update all the selected xml files 659 % DataviewData=get(handles.datatree_browser,'UserData'); 660 % % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ... 661 % % DataviewData.GeometryCalib.CalibrationType ' calibration data']) 662 % % if ~isequal(answer,'Yes') 663 % % return 664 % % end 665 % %List.Experiment{1}.Device{1} 666 % %List.Experiment{2}.Device{1} 667 % for iexp=1:length(List.Experiment) 668 % ExpName=List.Experiment{iexp}.name; 669 % set(handles.ListExperiments,'Value',IndicesExp(iexp)); 670 % if isfield(List.Experiment{iexp},'Device') 671 % for idevice=1:length(List.Experiment{iexp}.Device) 672 % DeviceName=List.Experiment{iexp}.Device{idevice}.name; 673 % if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile') 674 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) 675 % FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; 676 % for ilistxml=1:length(ListXml) 677 % if isequal(FileName,ListXml{ilistxml}) 678 % set(handles.ListXml,'Value',Value(ilistxml)) 679 % drawnow 680 % xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); 681 % update_imadoc(DataviewData.GeometryCalib,xmlfullname) 682 % display([xmlfullname ' updated']) 683 % break 684 % end 685 % end 686 % end 687 % elseif isfield(List.Experiment{iexp}.Device{idevice},'Record') 688 % for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) 689 % RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; 690 % if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile') 691 % for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) 692 % FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; 693 % for ilistxml=1:length(ListXml) 694 % if isequal(FileName,ListXml{ilistxml}) 695 % set(handles.ListXml,'Value',Value(ilistxml)) 696 % drawnow 697 % xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); 698 % update_imadoc(DataviewData.GeometryCalib,xmlfullname) 699 % display([xmlfullname ' updated']) 700 % break 701 % end 702 % end 703 % end 704 % end 705 % end 706 % end 707 % end 708 % end 709 % end 710 % set(handles.ListXml,'Value',Value) 776 711 % 777 712 % … … 817 752 handles.output ='OK, Calibration replicated'; 818 753 guidata(hObject, handles);% Update handles structure 819 uiresume(handles. figure);820 821 % --- Executes on button press in Cancel.822 function Cancel_Callback(hObject, eventdata, handles)823 handles.output = get(hObject,'String');824 guidata(hObject, handles); % Update handles structure825 % Use UIRESUME instead of delete because the OutputFcn needs826 uiresume(handles.figure);827 828 % --- Executes when user attempts to close figure.829 function figure_CloseRequestFcn(hObject, eventdata, handles)830 % if isequal(get(handles. figure, 'waitstatus'), 'waiting')754 uiresume(handles.datatree_browser); 755 % 756 % % --- Executes on button press in Cancel. 757 % function Cancel_Callback(hObject, eventdata, handles) 758 % handles.output = get(hObject,'String'); 759 % guidata(hObject, handles); % Update handles structure 760 % % Use UIRESUME instead of delete because the OutputFcn needs 761 % uiresume(handles.datatree_browser); 762 763 % --- Executes when user attempts to close datatree_browser. 764 function datatree_browser_CloseRequestFcn(hObject, eventdata, handles) 765 % if isequal(get(handles.datatree_browser, 'waitstatus'), 'waiting') 831 766 % % The GUI is still in UIWAIT, us UIRESUME 832 % uiresume(handles. figure);767 % uiresume(handles.datatree_browser); 833 768 % else 834 769 % % The GUI is no longer waiting, just close it 835 % delete(handles.figure); 836 % end 837 838 % --- Executes on key press over figure1 with no controls selected. 839 function figure_KeyPressFcn(hObject, eventdata, handles) 840 % Check for "enter" or "escape" 841 if isequal(get(hObject,'CurrentKey'),'escape') 842 % User said no by hitting escape 843 handles.output = 'Cancel'; 844 845 % Update handles structure 846 guidata(hObject, handles); 847 848 uiresume(handles.figure); 849 end 850 if isequal(get(hObject,'CurrentKey'),'return') 851 uiresume(handles.figure); 852 end 770 % delete(handles.datatree_browser); 771 % end 772 delete(hObject)
Note: See TracChangeset
for help on using the changeset viewer.