Home > m > gui > ltpdv > callbacks > ltpdv_build_params_panel.m

ltpdv_build_params_panel

PURPOSE ^

SYNOPSIS ^

function ltpdv_build_params_panel(ph, ii, varargin)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ltpdv_build_params_panel(ph, ii, varargin)
0002 
0003   FONTSIZE = 12;
0004   
0005   pmarg = 0.025;
0006 
0007   keyl = pmarg;
0008   keyh = 0.055;
0009   keyw = 0.3;
0010   keyb = 1-pmarg-keyh;
0011 
0012   vall = pmarg*2 + keyw;
0013   valw = 0.5;
0014 
0015   al   = vall + valw + pmarg;
0016   aw   = 0.05;
0017 
0018   delete(get(ph, 'Children'))
0019 
0020   if numel(varargin) > 0
0021     activated = varargin{1};
0022     if strcmpi(activated, 'on')
0023       chkVal = 1;
0024     else
0025       chkVal = 0;
0026     end
0027   else
0028     activated = 'off';
0029     chkVal = 0;
0030   end
0031   
0032   pancomps = {};
0033 
0034   if isa(ii, 'minfo')
0035     % we give a pop-up menu of sets
0036     eh = uicontrol(ph,'Style','popupmenu',...
0037       'String',ii.sets,...
0038       'units', 'normalized', ...
0039       'BackgroundColor', 'w', ...
0040       'Fontsize', FONTSIZE, ...
0041       'Enable', 'on', ...
0042       'Position',[vall keyb valw keyh]);
0043 
0044     set(eh, 'Callback', {@ltpdv_preproc_sets_callback, ii});
0045   else
0046     pl = ii;
0047     
0048     if numel(pl.params) == 0
0049         sth = uicontrol(ph,'Style','text',...
0050           'String', 'contains no parameters',...
0051           'Units', 'normalized', ...
0052           'BackgroundColor', 'w', ...
0053           'Fontsize', FONTSIZE, ...
0054           'Position',[keyl keyb 2*keyw keyh]);
0055     end
0056     % check for any unsupported parameters
0057     unsupported = false;
0058     for j=1:numel(pl.params)
0059       val = pl.params(j).val;
0060       if isa(val, 'timespan')
0061         unsupported = true;
0062       end
0063     end
0064     if unsupported
0065         sth = uicontrol(ph,'Style','text',...
0066           'String', ['contains unsupported parameter of type: ' class(val)],...
0067           'Units', 'normalized', ...
0068           'BackgroundColor', 'w', ...
0069           'Fontsize', FONTSIZE, ...
0070           'Position',[keyl keyb 2*keyw keyh]);
0071       
0072     else
0073       % Build parameters
0074       for j=1:numel(pl.params)
0075 
0076         % Get key and val
0077         key = pl.params(j).key;
0078         val = pl.params(j).val;
0079 
0080         switch class(val)
0081           case 'char'
0082             valstr = val;
0083           case 'double'
0084             valstr = mat2str(val);
0085           case 'specwin'
0086             valstr = specwin.getTypes;
0087           otherwise
0088             valstr = char(val);
0089         end
0090 
0091         % key text
0092         sth = uicontrol(ph,'Style','text',...
0093           'String', key,...
0094           'Units', 'normalized', ...
0095           'BackgroundColor', 'w', ...
0096           'Fontsize', FONTSIZE, ...
0097           'Position',[keyl keyb keyw keyh]);
0098 
0099         % val edit
0100         if ischar(valstr) || isa(valstr, 'time') || isa(valstr, 'sym')
0101           if isa(valstr, 'time') || isa(valstr, 'sym')
0102             valstr = char(valstr);
0103           end
0104           eh = uicontrol(ph,'Style','edit',...
0105             'String', valstr,...
0106             'units', 'normalized', ...
0107             'BackgroundColor', 'w', ...
0108             'Fontsize', FONTSIZE, ...
0109             'Enable', activated, ...
0110             'Position',[vall keyb valw keyh]);
0111         elseif iscell(valstr)
0112           eh = uicontrol(ph,'Style','popupmenu',...
0113             'String',valstr,...
0114             'units', 'normalized', ...
0115             'BackgroundColor', 'w', ...
0116             'Fontsize', FONTSIZE, ...
0117             'Enable', activated, ...
0118             'Position',[vall keyb valw keyh]);
0119         else
0120           valstr
0121           error('### Unknown type for value string.');
0122         end
0123         setappdata(eh, 'valClass', class(val));
0124         % Activate
0125         ah = uicontrol(ph,'Style','checkbox',...
0126           'String','',...
0127           'units', 'normalized', ...
0128           'BackgroundColor', get(ph, 'BackgroundColor'), ...
0129           'Fontsize', FONTSIZE, ...
0130           'Value', chkVal, 'Position', [al keyb aw keyh], ...
0131           'Callback', {@ltpdv_preproc_param_act, ph});
0132 
0133         pancomps = [pancomps; {sth, eh, ah}];
0134 
0135         % Do next line
0136         keyb = keyb - pmarg - keyh;
0137 
0138       end
0139     end
0140   end
0141 
0142   setappdata(ph, 'pancomps', pancomps);
0143 
0144 
0145 end

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003