% CB_DRAWCONTROLS draws the user controls depending on which signal type is
% selected.
%
% M Hewitson
%
% $Id: cb_drawControls.m,v 1.1 2008/10/19 11:42:40 hewitson Exp $
%

function cb_drawControls(varargin)
  
  % Settings
  hmarg = 0.01;
  vmarg = 0.02;
  commHeight = 0.08;
  
  % Get selected signal type
  sigType = varargin{2};
  % main figure
  mainfig = varargin{1};
  % Panel to draw on
  pan = findobj(mainfig.handle, 'Tag', 'ControlsPanel');
  
  % Delete all children
  delete(get(pan, 'Children'))
  drawnow
  
  % Draw the requested controls
  switch lower(sigType)
    case 'sine wave'
      draw_Sine_Wave(pan,mainfig,commHeight,hmarg,vmarg);
    case 'white noise'
      draw_WhiteNoise(pan,mainfig,commHeight,hmarg,vmarg);
    case 'chirp'
      draw_Chirp(pan,mainfig,commHeight,hmarg,vmarg);
    case 'gaussian pulse'
      draw_GaussPulse(pan,mainfig,commHeight,hmarg,vmarg);
    case 'square wave'
      draw_SquareWave(pan,mainfig,commHeight,hmarg,vmarg);
    case 'sawtooth'
      draw_Sawtooth(pan,mainfig,commHeight,hmarg,vmarg);
    case 'noise generator'
      draw_NoiseGenerator(pan,mainfig,commHeight,hmarg,vmarg);
    case 'polynomial'
      draw_Polynomial(pan,mainfig,commHeight,hmarg,vmarg);
    case 'custom'
      draw_Custom(pan,mainfig,commHeight,hmarg,vmarg);
    otherwise
      warning('!!! No controls for signal type: %s', sigType);
  end
  
end

%--------------------------------------------------------------------------
% Draw controls for a polynomial
% 
function draw_Polynomial(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- Coeffs

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Coeffs',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', '1', ...
    'Position', [l b Ewidth h],...
    'Tag', 'Poly_Coeffs', ...
    'Tooltip', 'Polynomial coefficients');

  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Poly_Length',...
    'Tooltip', 'Length of signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a custom f(t)
% 
function draw_Custom(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- Fcn

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'F(t)',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', 't', ...
    'Position', [l b Ewidth h],...
    'Tag', 'Custom_Fcn', ...
    'Tooltip', 'A valid MATLAB function of the variable ''t''');

  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Custom_Length',...
    'Tooltip', 'Length of signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a noise generation
% 
function draw_NoiseGenerator(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- Gains

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Gain',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', '1', ...
    'Position', [l b Ewidth h],...
    'Tag', 'NoiseGen_Gain', ...
    'Tooltip', 'Overall Gain');

  
  % Poles
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Poles',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '{1,1}',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'NoiseGen_Poles',...
    'Tooltip', 'Pole Frequencies (and Q''s). (help pzmodel)');
    
  % Poles
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Zeros',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '10',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'NoiseGen_Zeros',...
    'Tooltip', 'Zero Frequencies (and Q''s). (help pzmodel)');

  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'NoiseGen_Length',...
    'Tooltip', 'Length of signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a sawtooth
% 
function draw_Sawtooth(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- F

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Frequency [Hz]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', '0', ...
    'Position', [l b Ewidth h],...
    'Tag', 'Sawtooth_F', ...
    'Tooltip', 'Frequency [Hz] (help sawtooth)');

  
  % Width
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Width [0-1]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Sawtooth_Width',...
    'Tooltip', 'Width [0-1] (help sawtooth)');
    
  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Sawtooth_Length',...
    'Tooltip', 'Length of signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a square wave
% 
function draw_SquareWave(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- F

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Frequency [Hz]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', '0', ...
    'Position', [l b Ewidth h],...
    'Tag', 'SquareWave_F', ...
    'Tooltip', 'Frequency [Hz]');

  
  % Duty
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Duty Cycle [%]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SquareWave_Duty',...
    'Tooltip', 'Duty Cycle  [%]');
    
  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SquareWave_Length',...
    'Tooltip', 'Length of signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a gaussian pulse
% 
function draw_GaussPulse(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- F0

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'F0 [Hz]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', '0', ...
    'Position', [l b Ewidth h],...
    'Tag', 'GPulse_F0', ...
    'Tooltip', 'Center Frequency [Hz]');

  
  % BW
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'BW',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'GPulse_BW',...
    'Tooltip', 'Fractional Bandwidth [Hz]');
    
  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'GPulse_Length',...
    'Tooltip', 'Length of signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a chirp signal
% 
function draw_Chirp(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  
  %--- F0

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'F0',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'edit', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', '0', ...
    'Position', [l b Ewidth h],...
    'Tag', 'Chirp_F0', ...
    'Tooltip', 'Instantaneous frequency at t=0');

  
  % F1
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'F1',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Chirp_F1', ...
    'Tooltip', 'Instantaneous freuqency at t=T1');
  
  % T1
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'T1',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Chirp_T1', ...
    'Tooltip', 'Time at which F1 is reached');
  
  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'Chirp_Length',...
    'Tooltip', 'Length of the signal in seconds');
  
  
end

%--------------------------------------------------------------------------
% Draw controls for a white noise signal
% 
function draw_WhiteNoise(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  %--- Type

  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Noise Type',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  clsh = uicontrol(pan, ...
    'Style', 'popupmenu', ...
    'Units', 'normalized',...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'BackgroundColor', 'w', ...
    'String', {'Normal', 'Uniform'}, ...
    'Position', [l b Ewidth h],...
    'Tag', 'WhiteNoise_Type');

  
  % sigma
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Sigma',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'WhiteNoise_Sigma');
  
  % nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Length [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'WhiteNoise_Length');
  
  
end
  
%--------------------------------------------------------------------------
% Draw controls for a sine wave signal
% 
function draw_Sine_Wave(pan,mainfig,commHeight,hmarg,vmarg)
  
  Lwidth = 0.25;
  Ewidth  = 0.65;
  h = commHeight;
  %--- Amplitudes
  % label
  l = hmarg;
  b = 1-2*vmarg-h;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Amplitudes',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SineWave_Amplitudes');
  
  %--- Frequencies
  % label
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Frequencies [Hz]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SineWave_Frequencies');
  
  %--- Phases
  % label
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Phases [deg]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '0',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SineWave_Phases');
  
  %--- Nsecs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Lengths [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '1',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SineWave_Lengths');
  
  %--- Toffs
  l = hmarg;
  b = b - h - 2*vmarg;
  sth = uicontrol(pan, 'Style','text',...
    'String', 'Starts [s]',...
    'Units', 'normalized', ...
    'HorizontalAlignment', 'right',...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Lwidth h]);
  
  % edit box
  l = l + Lwidth + hmarg;
  sth = uicontrol(pan, 'Style','edit',...
    'String', '0',...
    'Units', 'normalized', ...
    'BackgroundColor', 'w', ...
    'Fontsize', mainfig.Gproperties.fontsize, ...
    'Position',[l b Ewidth h], ...
    'Tag', 'SineWave_Starts');
end
