0001 function [selected_ch_list, cancel] = vb_te_channel_selector_new(all_ch_list, selected_ch_list, caption)
0002
0003
0004
0005
0006
0007 h = openfig('vb_te_channel_selector.fig');
0008 if exist('caption', 'var')
0009 set(h, 'Name', caption);
0010 end
0011 H = guihandles(h);
0012
0013 cancel = false;
0014
0015 data = struct;
0016 data.H = H;
0017 data.cancel_flag = false;
0018 guidata(h, data);
0019
0020
0021 if ~exist('all_ch_list', 'var')
0022 for k=1:400
0023 all_ch_list{k} = num2str(k);
0024 end
0025 end
0026
0027 if ~exist('selected_ch_list', 'var')
0028 i=1;
0029 for k=1:8:400
0030 selected_ch_list{i} = num2str(k);
0031 i = i+1;
0032 end
0033 end
0034
0035
0036 table = cell(0);
0037 title = {'Channel', 'ON/OFF'};
0038 for k=1:length(all_ch_list)
0039 ix = strmatch(all_ch_list{k}, selected_ch_list, 'exact');
0040 flag = false;
0041 if ~isempty(ix)
0042 flag = true;
0043 end
0044 table{k, 1} = all_ch_list{k};
0045 table{k, 2} = flag;
0046 end
0047 if vb_matlab_version('>=', '7.6')
0048 table_h = uitable('v0', h, table, title);
0049 else
0050 table_h = uitable(h, table, title);
0051 end
0052
0053 data.table_h = table_h;
0054 set(table_h, 'Units', 'normalized');
0055
0056 pop_pos = get(H.channel_selecter_popup, 'Position');
0057 ok_pos = get(H.ok_push, 'Position');
0058
0059 MARGIN = 0.05;
0060 set(table_h, 'Position', [pop_pos(1), ok_pos(2)+ok_pos(4)+MARGIN, 0.8, 0.7]);
0061 set(table_h, 'Units', 'normalized');
0062
0063 guidata(h, data);
0064
0065 waitfor(h, 'Visible', 'off');
0066 if ishandle(h)
0067 data = guidata(h);
0068 if data.cancel_flag
0069 selected_ch_list = [];
0070 cancel = true;
0071 else
0072 tableData = cell(get(table_h, 'data'));
0073 flags = [tableData{:, 2}];
0074 ix = find(flags == 1);
0075 if ~isempty(ix)
0076 selected_ch_list = all_ch_list(ix);
0077 else
0078 selected_ch_list = [];
0079 end
0080 end
0081 delete(h);
0082 end