[360] | 1 | % ----------------------------------------------------------------------- |
---|
| 2 | % --- read a GUI with handle 'handle' producing a structure 'struct' |
---|
| 3 | function errormsg=fill_GUI(Param,handles) |
---|
| 4 | %------------------------------------------------------------------------ |
---|
| 5 | errormsg=''; |
---|
| 6 | fields=fieldnames(Param); |
---|
| 7 | for ifield=1:numel(fields) |
---|
| 8 | if isstruct(Param.(fields{ifield})) |
---|
| 9 | if isfield(handles,fields{ifield}) |
---|
[361] | 10 | set(handles.(fields{ifield}),'Visible','on') |
---|
| 11 | children=get(handles.(fields{ifield}),'children'); |
---|
| 12 | for ichild=1:numel(children) |
---|
| 13 | hchild.(get(children(ichild),'tag'))=children(ichild); |
---|
| 14 | end |
---|
| 15 | errormsg=fill_GUI(Param.(fields{ifield}),hchild); |
---|
[360] | 16 | end |
---|
| 17 | else |
---|
[361] | 18 | hh=[]; |
---|
[363] | 19 | input_data=Param.(fields{ifield}); |
---|
[361] | 20 | if isfield(handles,fields{ifield}) |
---|
| 21 | hh=handles.(fields{ifield}); |
---|
| 22 | if strcmp(get(hh,'Type'),'uitable') |
---|
[363] | 23 | set(hh,'Data',input_data) |
---|
[361] | 24 | break |
---|
[360] | 25 | end |
---|
[363] | 26 | elseif isnumeric(input_data) && isfield(handles,['num_' fields{ifield}]) |
---|
[361] | 27 | hh=handles.(['num_' fields{ifield}]); |
---|
| 28 | end |
---|
| 29 | if ~isempty(hh) |
---|
| 30 | set(hh,'Visible','on') |
---|
[363] | 31 | get(hh,'style') |
---|
| 32 | input_data |
---|
[361] | 33 | switch get(hh,'style') |
---|
[363] | 34 | case {'checkbox','radiobutton','togglebutton'} |
---|
| 35 | if isnumeric(input_data) |
---|
| 36 | set(hh,'Value',input_data) |
---|
[361] | 37 | end |
---|
| 38 | case 'edit' |
---|
[363] | 39 | if isnumeric(input_data) |
---|
| 40 | input_data=num2str(input_data); |
---|
[361] | 41 | end |
---|
[363] | 42 | set(hh,'String',input_data) |
---|
[361] | 43 | case{'Listbox','popupmenu'} |
---|
[363] | 44 | if isnumeric(input_data) |
---|
| 45 | input_data=num2str(input_data); |
---|
[361] | 46 | end |
---|
| 47 | menu=get(hh,'String'); |
---|
[363] | 48 | iline=find(strcmp(input_data,menu)); |
---|
[361] | 49 | if isempty(iline) |
---|
| 50 | iline=numel(menu)+1; |
---|
[363] | 51 | set(hh,'String',[menu;{input_data}]) |
---|
[361] | 52 | end |
---|
| 53 | set(hh,'Value',iline) |
---|
[360] | 54 | end |
---|
| 55 | end |
---|
| 56 | end |
---|
| 57 | end |
---|
| 58 | |
---|