source: trunk/src/fill_GUI.m @ 361

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

fill_GUI debugged: civ can open the xml file of a previous operation (instead of opening the saved GUI figure)

File size: 2.0 KB
Line 
1% -----------------------------------------------------------------------
2% --- read a GUI with handle 'handle' producing a structure 'struct'
3function errormsg=fill_GUI(Param,handles)
4%------------------------------------------------------------------------
5errormsg='';
6fields=fieldnames(Param);
7for ifield=1:numel(fields)
8    if isstruct(Param.(fields{ifield}))
9        if isfield(handles,fields{ifield})
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);
16        end
17    else
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
24            end
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)
51            end
52        end
53    end
54end
55 
Note: See TracBrowser for help on using the repository browser.