source: trunk/src/dataview.m @ 12

Last change on this file since 12 was 12, checked in by gostiaux, 14 years ago

The files from uvmat.2.2.beta that differed from the current version have been updated.
Now the /raid/soft/UVMAT/src should be operational

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