source: trunk/src/dataview.m @ 146

Last change on this file since 146 was 128, checked in by sommeria, 14 years ago

series: give writting access to the group for all subdirectories produced
uvmat.fig: change of vect and scalar frames (to be consistent with view_field)
uvmat: various cleaning
plot_field: various cleaning to improve axes definition and avoid blinking
geometry_calib: improved dispay of point coordiantes, improved link with dataview for REPLICATE.
struct2nc: repair bug , file was not closed.
cell2tab: cleaning
dataview: improve the browser
civ: solve pb of image naming

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