% CB_SELECTMODEL callback fires when the user selects a model.
%
% M Hewitson
%
% $Id: cb_selectModel.m,v 1.4 2008/12/09 07:22:36 hewitson Exp $
%
function cb_selectModel(varargin)

  myh = varargin{1};
  mainfig = varargin{end};
  
  % check model type
  h = findobj(mainfig.handle, 'Tag', 'ModelTypeSelect');
  mtypes = get(h, 'String');
  mtype  = mtypes{get(h, 'Value')};
  
  % Get selected model
  val = get(myh, 'Value');
  models = get(myh, 'String');  
  model = models{val};
  
  % draw parameters panel for this model
  switch mtype
    case 'ao'
      pl = feval(['ao_model_' model], 'PLIST');
%       pl = ii.plists(1);
      desc = feval('help', ['ao_model_' model])
    case 'ssm'
      ii = ssm.getInfo('ssm', 'From Built-in Model');
      pl = ii.plists(1);
      pl.remove('built-in');
      desc = feval('help', ['ssm_model_' model])
  end
  
  ppan = findobj(mainfig.handle, 'Tag', 'MODELVIEWERparamspanel');
  modelViewer.buildParamsPanel(ppan, pl);
  
  
  dtxt = findobj(mainfig.handle, 'Tag', 'MODELVIEWERmodeldescription');
  set(dtxt, 'String', desc);
  set(dtxt, 'TooltipString', desc);
  
  
end

