source: trunk/src/fill_GUI.m @ 477

Last change on this file since 477 was 476, checked in by sommeria, 12 years ago

bugs corrected +
* filter parameter multiplied by 1000 in filter_tps*

File size: 2.9 KB
Line 
1%'fill_GUI': fill a GUI with handles 'handles' from input data Param
2% -----------------------------------------------------------------------
3function errormsg=fill_GUI(Param,handles)
4%------------------------------------------------------------------------
5errormsg='';
6fields=fieldnames(Param);%list of fields in Param
7% loop on the elements of the input structure Param
8for ifield=1:numel(fields)
9    if isstruct(Param.(fields{ifield}))% case of sa sub-structure
10        if isfield(handles,fields{ifield})
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);% apply the function to the substructure
17        end
18    else
19        hh=[];
20        input_data=Param.(fields{ifield})
21        check_done=0;
22        if isfield(handles,fields{ifield})
23            hh=handles.(fields{ifield})
24            if strcmp(get(hh,'Type'),'uitable')
25                set(hh,'Visible','on')
26                if ischar(input_data)
27                    input_data={input_data};% transform string to a single cell if needed
28                end
29                set(hh,'Data',input_data)
30                check_done=1;
31            end
32        elseif isnumeric(input_data) && isfield(handles,['num_' fields{ifield}])
33            hh=handles.(['num_' fields{ifield}]);
34        end
35        if ~isempty(hh)&& ~check_done
36            set(hh,'Visible','on')
37%             input_data
38            switch get(hh,'Style')
39                case {'checkbox','radiobutton','togglebutton'}
40                    if isnumeric(input_data)
41                        set(hh,'Value',input_data)
42                    end
43                case 'edit'
44                    if isnumeric(input_data)
45                        input_data=num2str(input_data);
46                    end
47                    set(hh,'String',input_data)
48                case{'listbox','popupmenu'}
49                    if isnumeric(input_data)
50                        input_data=num2str(input_data);
51                    end
52                    menu=get(hh,'String');
53                    if ischar(input_data)
54                        input_data={input_data};
55                    end
56                    values=zeros(size(input_data));
57                    for idata=1:numel(input_data)
58                        iline=find(strcmp(input_data{idata},menu));
59                        if isempty(iline)
60                            values(idata)=1;
61                            menu=[input_data(idata);menu];
62                        else
63                            values(idata)=iline(1);
64                        end
65                    end
66                    set(hh,'String',menu)
67                    set(hh,'Value',values)
68            end
69        end
70    end
71end
72 
Note: See TracBrowser for help on using the repository browser.