source: trunk/src/read_GUI.m @ 292

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

GUI civ patch2 corrected (SmoothingParam?).
uvmatand view_field updated with panels.
read_plot_param removed (replaced by the mostgeneral read_GUI)

File size: 2.2 KB
Line 
1% --------------------------------------------------------------------
2% --- read a GUI with handle 'handle' producing a structure 'struct'
3function struct=read_GUI(handle)
4struct=[];%default
5hchild=get(handle,'children');
6for ichild=1:numel(hchild)
7    if strcmp(get(hchild(ichild),'Visible'),'on')
8        object_type=get(hchild(ichild),'Type');
9        tag=get(hchild(ichild),'tag');
10        switch object_type
11            case 'uipanel'
12                eval(['struct.' tag '=read_GUI(hchild(ichild));'])
13            case 'uicontrol'
14                object_style=get(hchild(ichild),'Style');
15                check_input=1;%default
16                switch object_style
17                    case 'edit'
18                        separator=regexp(tag,'_');
19                        if isempty(separator)
20                            input=get(hchild(ichild),'Value');
21                        else
22                            switch(tag(1:separator))
23                                case 'num_'
24                                    input=str2double(get(hchild(ichild),'String'));
25                                    tag=tag(separator+1:end);
26                                    %deal with undefined input: retrieve the default value stored as UserData
27                                    if isnan(input)
28                                        input=get(hchild(ichild),'UserData');
29                                        set(hchild(ichild),'String',num2str(input))
30                                    end
31                                case 'txt_'
32                                    input=get(hchild(ichild),'String');
33                                    tag=tag(separator+1:end);
34                                otherwise
35                                    input=get(hchild(ichild),'String');
36                            end
37                        end
38                    case 'checkbox'
39                        input=get(hchild(ichild),'Value');
40                        %                         key=tag(7:end);
41                    otherwise
42                        check_input=0;
43                end
44                if check_input
45                    struct.(tag)=input;
46                  %  eval(['struct.' tag '=input;'])
47                end
48        end
49    end
50end
Note: See TracBrowser for help on using the repository browser.