| [360] | 1 | % ----------------------------------------------------------------------- |
|---|
| 2 | % --- read a GUI with handle 'handle' producing a structure 'struct' |
|---|
| 3 | function errormsg=fill_GUI(Param,handles) |
|---|
| 4 | %------------------------------------------------------------------------ |
|---|
| [368] | 5 | |
|---|
| [360] | 6 | errormsg=''; |
|---|
| 7 | fields=fieldnames(Param); |
|---|
| 8 | for ifield=1:numel(fields) |
|---|
| 9 | if isstruct(Param.(fields{ifield})) |
|---|
| 10 | if isfield(handles,fields{ifield}) |
|---|
| [361] | 11 | set(handles.(fields{ifield}),'Visible','on') |
|---|
| 12 | children=get(handles.(fields{ifield}),'children'); |
|---|
| 13 | for ichild=1:numel(children) |
|---|
| 14 | hchild.(get(children(ichild),'tag'))=children(ichild); |
|---|
| 15 | end |
|---|
| 16 | errormsg=fill_GUI(Param.(fields{ifield}),hchild); |
|---|
| [360] | 17 | end |
|---|
| 18 | else |
|---|
| [361] | 19 | hh=[]; |
|---|
| [363] | 20 | input_data=Param.(fields{ifield}); |
|---|
| [361] | 21 | if isfield(handles,fields{ifield}) |
|---|
| 22 | hh=handles.(fields{ifield}); |
|---|
| 23 | if strcmp(get(hh,'Type'),'uitable') |
|---|
| [363] | 24 | set(hh,'Data',input_data) |
|---|
| [361] | 25 | break |
|---|
| [360] | 26 | end |
|---|
| [363] | 27 | elseif isnumeric(input_data) && isfield(handles,['num_' fields{ifield}]) |
|---|
| [361] | 28 | hh=handles.(['num_' fields{ifield}]); |
|---|
| 29 | end |
|---|
| 30 | if ~isempty(hh) |
|---|
| 31 | set(hh,'Visible','on') |
|---|
| [368] | 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 | |
|---|