source: trunk/src/browse_data.m @ 686

Last change on this file since 686 was 651, checked in by sommeria, 11 years ago

various bugs corrected. Introduction of campaign lists in Open menu

File size: 23.8 KB
Line 
1%'browse_data': function for scanning directories in a campaign
2%------------------------------------------------------------------------
3% function varargout = series(varargin)
4% associated with the GUI browse_data.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 = browse_data(varargin)
23
24% Last Modified by GUIDE v2.5 07-Mar-2013 18:55:00
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', @browse_data_OpeningFcn, ...
31                   'gui_OutputFcn',  @browse_data_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 browse_data is made visible.
47function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign)
48%------------------------------------------------------------------------
49
50%% Choose default command line output for browse_data
51handles.output = 'Cancel';
52
53%% Update handles structure
54guidata(hObject, handles);
55set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
56
57%% Determine the position of the dialog - centered on the screen
58FigPos=get(0,'DefaultFigurePosition');
59OldUnits = get(hObject, 'Units');
60set(hObject, 'Units', 'pixels');
61OldPos = get(hObject,'Position');
62FigWidth = OldPos(3);
63FigHeight = OldPos(4);
64ScreenUnits=get(0,'Units');
65set(0,'Units','pixels');
66ScreenSize=get(0,'ScreenSize');
67set(0,'Units',ScreenUnits);
68FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
69FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
70FigPos(3:4)=[FigWidth FigHeight];
71set(hObject, 'Position', FigPos);
72set(hObject, 'Units', OldUnits);
73%
74% if exist('GeometryCalib','var')
75%     DataviewData.GeometryCalib=GeometryCalib;
76%     set(hObject,'UserData',DataviewData)
77% end
78if exist('Campaign','var')
79    [CampaignPath,CampaignName]=fileparts(Campaign);
80    RootXml=fullfile(Campaign,[CampaignName '.xml']);
81    s=[];
82    if exist(RootXml,'file')
83        [s,Heading]=xml2struct(RootXml);%read the xml file
84        if isfield(s,'SourceDir')
85            set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened
86            set(handles.MirrorDir,'Visible','on');%  mirror dir display
87            set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir
88            set(handles.CreateMirror,'String','update_mirror')
89        end
90    end
91    if isempty(s) %a source dir has been opened
92        set(handles.SourceDir,'String',Campaign);
93        set(handles.MirrorDir,'Visible','off');% no mirror dir display
94        set(handles.CreateMirror,'String','create_mirror')
95    end
96    scan_campaign(handles,Campaign)
97   set(handles.OK,'Visible','on')
98   set(handles.Cancel,'Visible','on')
99   set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
100   set(hObject,'Visible','on')
101   drawnow
102   % UIWAIT makes GUI wait for user response (see UIRESUME)
103   uiwait(handles.browse_data);
104end
105
106%------------------------------------------------------------------------
107% --- Outputs from this function are returned to the command line.
108function varargout = browse_data_OutputFcn(hObject, eventdata, handles)
109%------------------------------------------------------------------------
110% Get default command line output from handles structure
111varargout{1} = handles.output;
112delete(handles.browse_data)
113
114%------------------------------------------------------------------------
115% --- Executes on button press in CreateMirror.
116function CreateMirror_Callback(hObject, eventdata, handles)
117%------------------------------------------------------------------------
118SourceDir=get(handles.SourceDir,'String');
119[SourcePath,ProjectName]=fileparts(SourceDir);
120if strcmp(get(handles.MirrorDir,'Visible'),'on')
121    MirrorDir=get(handles.MirrorDir,'String');
122else
123    MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir');
124%     MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser
125    if isempty(MirrorRoot)
126        return
127    else
128        MirrorDir=fullfile(MirrorRoot,ProjectName);
129    end
130    if ~exist(MirrorDir,'dir')
131        mkdir(MirrorDir)
132    end
133    MirrorDoc.SourceDir=SourceDir;
134    t=struct2xml(MirrorDoc);
135    set(t,1,'name','DataTree');
136    save(t,fullfile(MirrorDir,[ProjectName '.xml']))
137    set(handles.MirrorDir,'String',MirrorDir)
138    set(handles.MirrorDir,'Visible','on')
139end
140set(handles.SourceDir,'BackgroundColor',[1 1 0])
141drawnow
142ExpName={''};
143if exist(SourceDir,'dir')
144    hdir=dir(SourceDir); %list files and dirs
145    idir=0;
146    for ilist=1:length(hdir)
147        if hdir(ilist).isdir
148            dirname=hdir(ilist).name;
149            if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')
150                idir=idir+1;
151                mirror=fullfile(MirrorDir,hdir(ilist).name);
152                if ~exist(mirror,'dir')
153                   mkdir(mirror)
154                end
155                ExpName{idir}=['+/' hdir(ilist).name];
156            end
157            % look for the list of 'devices'
158        else
159            %warning for isolated files
160        end
161    end
162    set(handles.ListExperiments,'String',[{'*'};ExpName'])
163    set(handles.ListExperiments,'Value',1)
164    ListExperiments_Callback(hObject, eventdata, handles)
165else
166    msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory'])
167end
168set(handles.SourceDir,'BackgroundColor',[1 1 1])
169
170
171% %------------------------------------------------------------------------
172% function MirrorDir_Callback(hObject, eventdata, handles)
173% %------------------------------------------------------------------------   
174% MirrorDir=get(handles.MirrorDir,'String');
175% [tild,MirrorName]=fileparts(MirrorDir);
176% s=xml2struct(fullfile(MirrorDir,[MirrorName '.xml']));
177% set(handles.SourceDir,'String',s.SourceDir)
178% SourceDir_Callback([],[], handles)
179
180
181%------------------------------------------------------------------------
182function scan_campaign(handles,Campaign)
183%------------------------------------------------------------------------
184%set(handles.SourceDir,'BackgroundColor',[1 1 0])
185drawnow
186%SourceDir=get(handles.SourceDir,'String');
187%MirrorDir=get(handles.MirrorDir,'String');
188% ExpName={''};
189if exist(Campaign,'dir')
190    ListStruct=dir(Campaign); %list files and dirs
191    ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
192    ListFiles=ListCells(1,:);%list of dir and file  names
193    check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
194    ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
195    cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
196    check_keep=cellfun('isempty', cell_remove);
197    ListFiles=sort((ListFiles(check_keep))');
198    set(handles.ListExperiments,'String',[{'*'};ListFiles])
199    set(handles.ListExperiments,'Value',1)
200    ListExperiments_Callback([],[], handles)
201else
202    msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])
203end
204%set(handles.SourceDir,'BackgroundColor',[1 1 1])
205
206
207%------------------------------------------------------------------------
208% --- Executes on selection change in ListExperiments.
209%------------------------------------------------------------------------
210 function ListExperiments_Callback(hObject, eventdata, handles)
211
212MirrorPath='';
213CampaignPath=get(handles.SourceDir,'String');
214if strcmp(get(handles.MirrorDir,'Visible'),'on')
215    MirrorPath=get(handles.MirrorDir,'String');
216end
217ListExperiments=get(handles.ListExperiments,'String');
218list_val=get(handles.ListExperiments,'Value');
219if isequal(list_val(1),1)
220    ListExperiments=ListExperiments(2:end); %choose all experiments
221    set(handles.ListExperiments,'Value',1)
222else
223    ListExperiments=ListExperiments(list_val);%choose selected experiments
224end
225scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
226
227
228%------------------------------------------------------------------------
229% --- Executes on selection change in ListExperiments.
230%------------------------------------------------------------------------
231 function scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
232
233ListDevices={};
234for iexp=1:numel(ListExperiments)
235    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
236        ListExperiments{iexp}(1)=[];
237        ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory
238        ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
239        ListFiles=ListCells(1,:);%list of dir and file  names
240        cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
241        check_keep=cellfun('isempty', cell_remove);
242        check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
243        for ilist=1:numel(ListFiles)
244            if check_keep(ilist)
245                DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});
246                if ~isempty(MirrorPath)
247                    mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});
248                    if ~exist(mirror)% create mirror if needed
249                        system(['ln -s ' DataSeries ' ' mirror])
250                    end
251                end
252                if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
253                    if check_dir(ilist)
254                        ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
255                    end
256                    ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
257                end
258            end
259        end
260    end
261end
262set(handles.ListDevices,'String',sort(ListDevices))
263
264%------------------------------------------------------------------------
265% --- Executes on button press in CampaignDoc.
266function CampaignDoc_Callback(hObject, eventdata, handles)
267%------------------------------------------------------------------------   
268answer=msgbox_uvmat('INPUT_Y-N','This function will update the global xml rpresentation of the data set and the Heading of each xml file');
269if ~isequal(answer{1},'OK')
270    return
271end
272set(handles.ListExperiments,'Value',1)
273ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
274DataviewData=get(handles.browse_data,'UserData');
275List=DataviewData.List;
276Currentpath=get(handles.SourceDir,'String');
277[Currentpath,Campaign,DirExt]=fileparts(Currentpath);
278Campaign=[Campaign DirExt];
279t=xmltree;
280t=set(t,1,'name','CampaignDoc');
281t = attributes(t,'add',1,'source','directory');
282SubCampaignTest=get(handles.SubCampaignTest,'Value');
283root_uid=1;
284if SubCampaignTest
285    %TO DO open an exoiting xml doc
286    [t,root_uid]=add(t,1,'element','SubCampaign');
287    t =attributes(t,'add',root_uid,'DirName',Campaign);
288end
289for iexp=1:length(List.Experiment)
290    set(handles.ListExperiments,'Value',iexp+1)
291    drawnow
292    test_mod=0;
293    [t,uid_exp]=add(t,root_uid,'element','Experiment');
294    t = attributes(t,'add',uid_exp,'i',num2str(iexp));
295    ExpName=List.Experiment{iexp}.name;
296    t = attributes(t,'add',uid_exp,'DirName',List.Experiment{iexp}.name);
297   
298    if isfield(List.Experiment{iexp},'Device')
299        for idevice=1:length(List.Experiment{iexp}.Device)
300            [t,uid_device]=add(t,uid_exp,'element','Device');
301            DeviceName=List.Experiment{iexp}.Device{idevice}.name;
302            t = attributes(t,'add',uid_device,'DirName',List.Experiment{iexp}.Device{idevice}.name);       
303            if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
304                for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
305                    FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
306                    [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest);
307                    if test
308                        disp([List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated'])
309                    end
310                    if isequal(Title,'ImaDoc')
311                        [t,uid_xml]=add(t,uid_device,'element','ImaDoc');
312                        t = attributes(t,'add',uid_xml,'source','file');
313                        [t]=add(t,uid_xml,'chardata',List.Experiment{iexp}.Device{idevice}.xmlfile{ixml});                   
314                    end
315                end
316             elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
317                for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
318                    RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
319                    [t,uid_record]=add(t,uid_device,'element','Record');
320                    t = attributes(t,'add',uid_record,'DirName',RecordName);
321                    if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
322                        for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
323                            FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
324                            [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest);
325                            if test
326                                disp([FileName ' , Heading updated'])
327                            end
328                            [t,uid_xml]=add(t,uid_record,'element','ImaDoc');
329                            t = attributes(t,'add',uid_xml,'source','file');
330                            [t]=add(t,uid_xml,'chardata',FileName);
331                        end
332                    end
333                end
334            end
335        end
336    end
337end
338set(handles.ListExperiments,'Value',1)
339outputdir=get(handles.SourceDir,'String');
340[path,dirname]=fileparts(outputdir);
341outputfile=fullfile(outputdir,[dirname '.xml']);
342%campaigndoc(t);
343save(t,outputfile)
344
345%------------------------------------------------------------------------
346% --- Executes on button press in CampaignDoc.
347function edit_xml_Callback(hObject, eventdata, handles)
348%------------------------------------------------------------------------
349CurrentPath=get(handles.SourceDir,'String');
350%[CurrentPath,Name,Ext]=fileparts(CurrentDir);
351ListExperiments=get(handles.ListExperiments,'String');
352Value=get(handles.ListExperiments,'Value');
353if ~isequal(Value,1)
354    ListExperiments=ListExperiments(Value);
355end
356ListDevices=get(handles.ListDevices,'String');
357Value=get(handles.ListDevices,'Value');
358if ~isequal(Value,1)
359    ListDevices=ListDevices(Value);
360end
361ListRecords=get(handles.ListRecords,'String');
362Value=get(handles.ListRecords,'Value');
363if ~isequal(Value,1)
364    ListRecords=ListRecords(Value);
365end
366[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
367ListXml=get(handles.ListXml,'String');
368Value=get(handles.ListXml,'Value');
369set(handles.ListXml,'Value',Value(1));
370if isequal(Value(1),1)
371    msgbox_uvmat('ERROR','an xml file needs to be selected')
372   return
373else
374    XmlName=ListXml{Value(1)};
375end
376for iexp=1:length(List.Experiment)
377    ExpName=List.Experiment{iexp}.name;
378    if isfield(List.Experiment{iexp},'Device')
379        for idevice=1:length(List.Experiment{iexp}.Device)
380            DeviceName=List.Experiment{iexp}.Device{idevice}.name;
381            if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
382                for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
383                    FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
384                    if isequal(FileName,XmlName)
385                        editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));
386                        return
387                    end
388                end
389             elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
390                for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
391                    RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
392                    if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
393                        for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
394                            FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
395                            if isequal(FileName,XmlName)
396                                editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName));
397                                return
398                            end                         
399                        end
400                    end
401                end
402            end
403        end
404    end
405end
406
407
408
409%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410% CurrentPath/Campaign: root directory
411function  [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign)
412
413 %Shema for Heading:
414%  Campaign             
415%  (SubCampaign)
416% Experiment
417%  Device
418%  (Record)
419%  ImageName
420%  DateExp
421%                 old: %Project: suppressed ( changed to Campaign)
422                       %Exp: suppressed (changed to experiment)
423                       %ImaNames: changed to ImageName
424if exist('Record','var') && ~isempty(Record)
425    xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 
426    testrecord=1;
427else
428    xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname);
429    testrecord=0;
430end
431if ~exist('testSubCampaign','var')
432    testSubCampaign=0;
433end
434if testSubCampaign
435   SubCampaign=Campaign;
436   [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
437   Campaign=[Campaign DirExt];
438end
439test_mod=0; %test for the modification of the xml file
440t_device=xmltree(xmlfullname);
441Title=get(t_device,1,'name');
442uid_child=children(t_device,1);
443Heading_old=[];
444uidheading=0;
445for ilist=1:length(uid_child)
446    name=get(t_device,uid_child(ilist),'name');
447    if isequal(name,'Heading')
448        uidheading=uid_child(ilist);
449    end
450end
451if uidheading
452    subt=branch(t_device,uidheading);
453    Heading_old=convert(subt);
454else
455   return % do not edit xml files without element 'Heading'
456end
457if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign))
458    test_mod=1;
459end
460Heading.Campaign=Campaign;
461if testSubCampaign
462    if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign))
463        test_mod=1;
464    end
465    Heading.SubCampaign=SubCampaign;
466end
467if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment))
468    test_mod=1;
469end
470Heading.Experiment=Experiment;
471if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device))
472    test_mod=1;
473end
474Heading.Device=Device;
475if testrecord
476    if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record))
477        test_mod=1;
478    end
479    Heading.Record=Record;
480end
481if isfield(Heading_old,'ImaNames')
482    test_mod=1;
483    if  ~isempty(Heading_old.ImaNames)
484        Heading.ImageName=Heading_old.ImaNames;
485    end
486end
487if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName)
488    Heading.ImageName=Heading_old.ImageName;
489end
490if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp)
491    Heading.DateExp=Heading_old.DateExp;
492end
493if test_mod && uidheading
494     uid_child=children(t_device,uidheading);
495     t_device=delete(t_device,uid_child);
496    t_device=struct2xml(Heading,t_device,uidheading);
497    backupfile=xmlfullname;
498    testexist=2;
499    while testexist==2
500       backupfile=[backupfile '~'];
501       testexist=exist(backupfile,'file');
502    end
503    [success,message]=copyfile(xmlfullname,backupfile);%make backup
504    if isequal(success,1)
505        delete(xmlfullname)
506    else
507        return
508    end
509    save(t_device,xmlfullname)
510end
511
512%------------------------------------------------------------------------
513% --- Executes on button press in OK.
514%------------------------------------------------------------------------
515function OK_Callback(hObject, eventdata, handles)
516
517if strcmp(get(handles.MirrorDir,'Visible'),'on')
518    Campaign=get(handles.MirrorDir,'String');
519else
520    Campaign=get(handles.SourceDir,'String');
521end
522handles.output.Campaign=Campaign;
523Experiment=get(handles.ListExperiments,'String');
524IndicesExp=get(handles.ListExperiments,'Value');
525if ~isequal(IndicesExp,1)% if first element ('*') selected all the experiments are selected
526    Experiment=Experiment(IndicesExp);% use the selection of the list of experiments
527end
528Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
529Device=get(handles.ListDevices,'String');
530Value=get(handles.ListDevices,'Value');
531Device=Device(Value);
532Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir
533handles.output.Experiment=Experiment;
534handles.output.DataSeries=Device;
535guidata(hObject, handles);% Update handles structure
536uiresume(handles.browse_data);
537drawnow
538
539%------------------------------------------------------------------------
540% --- Executes on button press in HELP.
541function HELP_Callback(hObject, eventdata, handles)
542path_to_uvmat=which ('uvmat');% check the path of uvmat
543pathelp=fileparts(path_to_uvmat);
544helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
545if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
546else
547web([helpfile '#dataview'])   
548end
549
550%------------------------------------------------------------------------
551% --- Executes on button press in Cancel.
552%------------------------------------------------------------------------
553function Cancel_Callback(hObject, eventdata, handles)
554   
555handles.output = get(hObject,'String');
556guidata(hObject, handles); % Update handles structure
557% Use UIRESUME instead of delete because the OutputFcn needs
558uiresume(handles.browse_data);
559
560%------------------------------------------------------------------------
561% --- Executes when user attempts to close browse_data.
562%------------------------------------------------------------------------
563function browse_data_CloseRequestFcn(hObject, eventdata, handles)
564   
565if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
566    % The GUI is still in UIWAIT, us UIRESUME
567    uiresume(handles.browse_data);
568else
569    % The GUI is no longer waiting, just close it
570    delete(handles.browse_data);
571end
572
573%------------------------------------------------------------------------
574% --- Executes on key press over figure1 with no controls selected.
575%------------------------------------------------------------------------
576function browse_data_KeyPressFcn(hObject, eventdata, handles)
577   
578% Check for "enter" or "escape"
579if isequal(get(hObject,'CurrentKey'),'escape')
580    % User said no by hitting escape
581    handles.output = 'Cancel';
582   
583    % Update handles structure
584    guidata(hObject, handles);
585   
586    uiresume(handles.browse_data);
587end
588if isequal(get(hObject,'CurrentKey'),'return')
589    uiresume(handles.browse_data);
590end
Note: See TracBrowser for help on using the repository browser.