source: trunk/src/fill_GUI.m @ 493

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

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

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