[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=[]; |
---|
| 19 | if isfield(handles,fields{ifield}) |
---|
| 20 | hh=handles.(fields{ifield}); |
---|
| 21 | if strcmp(get(hh,'Type'),'uitable') |
---|
| 22 | set(hh,'Data',input) |
---|
| 23 | break |
---|
[360] | 24 | end |
---|
[361] | 25 | elseif isnumeric(input) && isfield(handles,['num_' fields{ifield}]) |
---|
| 26 | hh=handles.(['num_' fields{ifield}]); |
---|
| 27 | end |
---|
| 28 | if ~isempty(hh) |
---|
| 29 | set(hh,'Visible','on') |
---|
| 30 | switch get(hh,'style') |
---|
| 31 | case {'checkbox','pushbutton','radiobutton','togglebutton'} |
---|
| 32 | if isnumeric(input) |
---|
| 33 | set(hh,'Value',input) |
---|
| 34 | end |
---|
| 35 | case 'edit' |
---|
| 36 | if isnumeric(input) |
---|
| 37 | input=num2str(input); |
---|
| 38 | end |
---|
| 39 | set(hh,'String',input) |
---|
| 40 | case{'Listbox','popupmenu'} |
---|
| 41 | if isnumeric(input) |
---|
| 42 | input=num2str(input); |
---|
| 43 | end |
---|
| 44 | menu=get(hh,'String'); |
---|
| 45 | iline=find(strcmp(input,menu)); |
---|
| 46 | if isempty(iline) |
---|
| 47 | iline=numel(menu)+1; |
---|
| 48 | set(hh,'String',[menu;{input}]) |
---|
| 49 | end |
---|
| 50 | set(hh,'Value',iline) |
---|
[360] | 51 | end |
---|
| 52 | end |
---|
| 53 | end |
---|
| 54 | end |
---|
| 55 | |
---|