source: trunk/src/dataview.m @ 102

Last change on this file since 102 was 89, checked in by sommeria, 14 years ago

many bug corrections and cleaning. Activation of the BW option in uvmat. Improvement of the interaction of get_field with uvmat.

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