% GUI definitions for missing data demo
% Martin Cooke, 1998

fig=createmadfig('md'); 
% MENUS
set(fig,'Position',[0.00 0.5 0.99 0.45]);

% LOAD
loadmenu=uimenu('Parent',fig,'Label','&Load','Accelerator','L');
  loadspeech=uimenu('Parent',loadmenu,'Label','speech','Tag','loadspeech');
  loadnoise=uimenu('Parent',loadmenu,'Label','noise','Tag','loadnoise');
  loaddelete=uimenu('Parent',loadmenu,'Label','deletions','Enable','off');

uimenu('Parent',loaddelete,'Label','random_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','random_chans_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','random_frames_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','weakest_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','random_90%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','random_chans_90%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','random_frames_90%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','weakest_90%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','lowpass_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','lowpass_25%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','bandpass_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','bandpass_25%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','highpass_50%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','highpass_25%','Callback','md doPresetDeletion');
uimenu('Parent',loaddelete,'Label','two_bands','Callback','md doPresetDeletion');


%EDIT OPTIONS
toolMenu=uimenu('Parent',fig,'Label','&Tool', 'Accelerator','T','Enable','off');
nozzleframesmenu=uimenu('Parent', toolMenu,'Label','frames');
for i=[1 2 3 4 5 10 50 100]
  uimenu('Parent',nozzleframesmenu,'Label',num2str(i),...
  'Callback','md NozzleWidthChanged','Tag','NozzleWidth');
end
uimenu('Parent',nozzleframesmenu,'Label','all',...
'Callback','md NozzleWidthChanged','Tag','NozzleWidth');
nozzlechansmenu=uimenu('Parent',toolMenu,'Label','channels');
for i=[1 2 3 4 5 10 20]
  uimenu('Parent',nozzlechansmenu,'Label',num2str(i),...
  'Callback','md NozzleHeightChanged','Tag','NozzleHeight');
end  
uimenu('Parent',nozzlechansmenu,'Label','all',...
'Callback','md NozzleHeightChanged','Tag','NozzleHeight');

maskMenu=uimenu('Parent',fig,'Label','&Mask', 'Accelerator','M','Enable','off');
  uimenu('Parent', maskMenu,'Label','peaks','Callback','md use_peaks');
  uimenu('Parent', maskMenu,'Label','Hirsch','Callback','md use_Hirsch','Tag','Hirsch');
  uimenu('Parent', maskMenu,'Label','snr > 0','Callback','md use_snr','Tag','snr0');
  uimenu('Parent', maskMenu,'Label','snr > 3','Callback','md use_snr3','Tag','snr3');

recogMenu=uimenu('Parent',fig,'Label','&Recognition', 'Accelerator','R','Enable','off');
  uimenu('Parent', recogMenu,'Label','missing data','Callback','md use_md');
  uimenu('Parent', recogMenu,'Label','auditory induction','Callback','md use_ai',...
  'Tag','AImenu');

%VISUALISE
vismenu=uimenu('Parent',fig,'Label','&Visualise', 'Accelerator','V');
  uimenu('Parent',vismenu,'Label','HMMs',...
  'Callback','md visualise_hmm');
  uimenu('Parent',vismenu,'Label','Output Probs',...
  'Callback','md visualise_probs','Enable','off');


fig=createmadmenus(fig);

% default uicontrol details

sp=0.02;
th=3*sp;		% default text height
eh=4.5*sp;  % default edit box height
ph=4*sp;		% default popup height
ch=3*sp;		% default check box height
bh=6*sp;		% default button height
hsh=5*sp;   % default horizontal slider height

% major row & column positions

left=0.1;
top=0.9;
bottom=0.1;
right=0.75;

% column positions
c1l=0.00;    c1w=0.5;
c3l=c1l+c1w; c3w=1.0-c3l;

% test & label axes

ud.testAxes = axes('Parent',fig,...
  'Position',[left bottom+0.07 right-left top-bottom-0.07],...
  'Tag','TestAxes',...
  'DrawMode','fast',...
  'NextPlot','replacechildren',...
  'XTick',[],...
  'Box','on');

ylabel('Frequency');

ud.labelAxes = axes('Parent',fig,...
  'Position',[left bottom right-left 0.05],...
  'Tag','LabelAxes',...
  'DrawMode','fast',...
  'NextPlot','replacechildren',...
  'YTick',[],...
  'XTick',[],...
  'Box','on');

xlabel('time (frames)');


% STATUS INFO

cx=right-0.2;
uicontrol('Parent',fig, 'Position',[cx top 0.2 th], 'Style','text',...
  'Tag','StatusString','String','no data loaded');

% DELETION options column

cy=top-ph;
cx=right+sp;
uicontrol('Parent',fig, 'Position',[cx cy 0.2 ph], ...
  'String', 'erase|restore|add_noise', ...
  'Style','popupmenu', ...
  'Tag','ModePopup',...
  'Enable','off');

cy=cy-bh-sp;
uicontrol('Parent',fig, 'Position',[cx cy 0.2 bh], ...
  'Style','pushbutton','String','restore',...
  'Tag','RestoreButton','Callback','md restoreAll',...
  'Enable','off');

cy=cy-th-sp;
uicontrol('Parent',fig, 'Position',[cx-sp cy 0.3 th], ...
'Style','text','String','Noise level re. mean:',...
'Enable','off');

cy=cy-ph-sp;
uicontrol('Parent',fig, 'Position',[cx+0.05 cy 0.15 ph], ...
  'String', '-12|-6|0|6|12|18|24|30|36|42', ...
  'Style','popupmenu','Callback','md NoiseLevelChanged', ...
  'Tag','NoiseLevelPopup',...
  'Enable','off');
  
cy=cy-eh-2*sp;
uicontrol('Parent',fig, 'Position',[cx-sp cy 0.14 th], ...
  'Style','text','String','SNR(glob)',...
  'Enable','off');

uicontrol('Parent',fig, 'Position',[cx+0.1 cy 0.1 eh], ...
  'Style','edit','Tag','globalSNR',...
  'String','0',...
  'Callback','md globalSNRChanged',...
  'Enable','off');

cy=cy-ch-3*sp;
uicontrol('Parent',fig, 'Position',[cx cy 0.2 hsh], ...
  'Style', 'checkbox',...
  'String', 'recalculate',...
  'Value',1,...
  'Tag','recalcCheck',...
  'Callback','md recalculate',...
  'Enable','off');



%%% AND now for the other windows

% LOCAL PROBABILITIES

lp_fig = figure('Units','normalized',...
        'Position',[0.05 0.25 0.85 0.2],...
        'Menubar','none',...   
  'Name','Output probabilities',...
  'NumberTitle','off',...
  'CloseRequestFcn','md hide_fig',...
  'BackingStore','on',...
  'Visible','off');

lud.frameProbAxes = axes('Parent',lp_fig,...
  'Position',[left bottom+0.05 right-left top-bottom-0.05],...
  'Tag','frameProbAxes',...
  'DrawMode','fast',...
  'NextPlot','replacechildren',...
  'Box','on');

lud.main_fig=fig;
lud.frameim=[];

% menus for local prob figure

lud.menu = uimenu('Parent',lp_fig, 'Label','&HMM', ...
  'Accelerator','H','Tag','HMMmenu');
uimenu('Parent',lp_fig, 'Label','                        ');

set(lp_fig,'UserData',lud);
ud.lp_fig=lp_fig;

% HMM INSPECTOR

hmm_fig = figure('Units','normalized',...
        'Position',[0.05 0.05 0.85 0.15],...
        'Menubar','none',...   
  'Name','HMM inspector',...
  'NumberTitle','off',...
  'CloseRequestFcn','md hide_fig',...
  'BackingStore','on',...
  'Visible','off');

hud.menu = uimenu('Parent',hmm_fig, 'Label','&HMM', ...
  'Accelerator','H','Tag','HMMmenu');
uimenu('Parent',hmm_fig, 'Label','                        ');

  hud.main_fig=fig;
set(hmm_fig,'UserData',hud);
ud.hmm_fig=hmm_fig;

set(fig,'UserData',ud);
figure(fig);


