Home > fcn > DIVA_GUI_callbacks > gui_file_menu_cbk.m

gui_file_menu_cbk

PURPOSE ^

SYNOPSIS ^

function gui_file_menu_cbk(src,eventdata,options)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function gui_file_menu_cbk(src,eventdata,options)
0002   switch(get(src,'tag')),
0003     %--------------------Exit Model--------------------------%
0004    case 'exit',
0005     status=questdlg('Do you wish to exit the GUI and model?', ...
0006                     'Exit?', ...
0007                     'GUI','GUI and Model','No','No');
0008     switch status,
0009      case 'GUI',
0010       save_stat=questdlg('Save GUI state?','Save?','Yes','No','Yes');
0011       if(strcmp('Yes',save_stat))
0012         DIVA('GUI','save');
0013       end
0014       DIVA('removemodule','GUI');
0015      case 'GUI and Model',
0016       save_stat=questdlg('Save DIVA state?','Save?','Yes','No','Yes');
0017       if(strcmp('Yes',save_stat))
0018         DIVA('save');
0019       end;
0020       DIVA('exit');
0021      otherwise
0022       msgbox('Exit Cancelled');
0023     end
0024 
0025     %----------------------- Create a new session-----------------%
0026    case 'new',
0027     sessionname=inputdlg('Session Name: ', 'New Session...',1);
0028     while(~isempty(sessionname) & ...
0029           exist(fullfile('sessions',char(sessionname)),'dir')==7)
0030       sessionname=inputdlg('Session Name Taken, try again', ...
0031                            'New Session...',1);
0032     end
0033     if(~isempty(sessionname))
0034       %    close(gcf);
0035       DIVA('init',sessionname{1});
0036     end
0037 
0038     %---------------------------Load a saved session------------------%
0039    case 'load',
0040     loadhandle=dialog('name','Load Session...','units','norm',...
0041                       'position',[.45 .45 .15 .15]);
0042     sessiondirs=dir('Sessiondata');
0043     j=1;
0044     for i=3:length(sessiondirs)
0045       if(sessiondirs(i).isdir)
0046         sessions{j}=sessiondirs(i).name(9:end);
0047         j=j+1;
0048       end
0049     end
0050     session=sessions{1};
0051     loadmenu=uicontrol('Style','popupmenu','parent',loadhandle,...
0052                        'Tag','session_load_menu',...
0053                        'String',sessions,'units','norm',...
0054                        'position',[0.1 0.7 0.8 0.2]);
0055     loadbutton=uicontrol('Style','pushbutton','parent',loadhandle,...
0056                          'Tag','session_load_button',...
0057                          'String','Load','units','norm',...
0058                          'position',[0.1 0.1 0.4 0.2],...
0059                          'Callback',{@loadmenu_cbk,loadmenu,sessions});
0060     cancelbutton=uicontrol('Style','pushbutton','parent',loadhandle,...
0061                            'Tag','session_cancel_button',...
0062                            'String','Cancel','units','norm',...
0063                            'position',[0.5 0.1 0.4 0.2],...
0064                            'Callback','close(gcf)');
0065 
0066     %------------------------------Save a session------------------------%
0067    case 'save',
0068     status=questdlg('Save Model State?','Save...','Yes','No','Yes');
0069     if(strcmp(status,'Yes'))
0070       DIVA('save');
0071     else
0072       msgbox('Save Cancelled');
0073     end
0074 
0075     % -----------------------Capture a screenshot----------------------%
0076    case 'screenshot',
0077     if(nargin>=3)
0078       if(ishandle(options))
0079         print(options,'-djpeg90','screenshot.jpg');
0080       end
0081     end
0082 
0083     %---------------------------Save last production as WAV------------%
0084    case 'sound',
0085     [y,fs]=getSynthSound();
0086     [fname,pname]=uiputfile('*.wav','Save as');
0087     if(~isempty(fname))
0088       wavwrite(y,fs,[pname,filesep,fname]);
0089     end
0090 
0091     %-----------------Save last production as A/V MOV------------------%
0092    case 'movie',
0093     [y,fs,motor]=getSynthSound();
0094     
0095     h=figure('position',[50 50 640 480],'menubar','none','doublebuffer','on');
0096     wh=waitbar(0,sprintf('%d%% complete',0),'position',[50 700 300 70]);
0097     figure(h);
0098     [fname,pname]=uiputfile('*.mov','Save as');
0099     if(~isempty(fname))
0100       MakeQTMovie('start',[pname,filesep,fname]);
0101       MakeQTMovie('size',[640 480]);
0102       MakeQTMovie('quality',0.8);
0103       for n=1:5:length(motor),
0104         figure(h);
0105         DIVA('VocalTract','plot',motor(1:end-3,n)); axis equal; axis off;
0106         MakeQTMovie('addaxes');
0107         waitbar(n/length(motor),wh,sprintf('%d%% complete',round(100*n/length(motor))));
0108       end
0109       MakeQTMovie('frameRate',200);
0110       MakeQTMovie('addsound',y,fs);
0111       MakeQTMovie('finish');
0112     end
0113     close(h);
0114     close(wh);
0115   end

Generated on Tue 27-Mar-2007 12:06:24 by m2html © 2003