source: trunk/src/dataview.m @ 295

Last change on this file since 295 was 156, checked in by sommeria, 10 years ago

many bug repairs and corrections for mouse action
create_grid: option for black marjkers for grid detection

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