% LTPDV_GET_PARAMS_FROM_PANEL get a plist from the parameters on a
% parameters panel
% 
% M Hewitson 26-08-08
% 
% $Id: ltpdv_get_params_from_panel.m,v 1.1 2008/09/02 07:51:47 hewitson Exp $
% 
function pl = ltpdv_get_params_from_panel(parampanh)
  
  
  % Get params
  pancomps  = getappdata(parampanh, 'pancomps');

  % loop over params
  pl = plist();
  for j=1:size(pancomps,1)

    % handles
    keyf = pancomps{j,1};
    valf = pancomps{j,2};
    actf = pancomps{j,3};

    % Get activate status
    if get(actf, 'Value')
      % Get key name
      key = get(keyf, 'String');

      % Get param value
      valclass = getappdata(valf, 'valClass');

      switch valclass
        case 'char'
          val = get(valf, 'String');
        case 'double'
          val = get(valf, 'String');
          try
            val = eval(val);
          end
        case 'sym'
          val = get(valf, 'String');
          val = sym(val);
        case 'specwin'
          strs = get(valf, 'String');
          idx  = get(valf, 'Value');
          val  = strs{idx};
          if strcmp(val, 'Kaiser')
            val = specwin(val, 10, 150);
          else
            val = specwin(val, 10);
          end
        case 'time'
          val = get(valf, 'String');
          val = time(val);
        otherwise
          error(['### Unsupported value class: ' valclass]);
      end

      % Add to plist
      pl = append(pl, key, val);
    end
  end
  
end