source: trunk/src/dataview.m @ 152

Last change on this file since 152 was 152, checked in by sommeria, 13 years ago

bug repair for civtest display in mouse_motion and small cleaning of dataview

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