Changeset 363 for trunk/src/read_GUI.m


Ignore:
Timestamp:
Jan 10, 2012, 9:13:31 AM (12 years ago)
Author:
sommeria
Message:

civ2 introduced in civ_matlab (still bugs)
bugs corrected in civ and fill_GUI, read_GUI
comments in get_field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_GUI.m

    r350 r363  
    1616                check_input=1;%default
    1717                switch object_style
    18                     case {'checkbox','pushbutton','radiobutton','togglebutton'}
     18                    case {'checkbox','radiobutton','togglebutton'}
    1919                        input=get(hchild(ichild),'Value');
    2020                    case 'edit'
    21                         separator=regexp(tag,'_');
     21                        separator=regexp(tag,'^num_');
    2222                        if isempty(separator)
    2323                            input=get(hchild(ichild),'String');
    2424                        else
    25                             switch(tag(1:separator))
    26                                 case 'num_'
    27                                     input=str2double(get(hchild(ichild),'String'));
    28                                     tag=tag(separator+1:end);
    29                                     %deal with undefined input: retrieve the default value stored as UserData
    30                                     if isnan(input)
    31                                         input=get(hchild(ichild),'UserData');
    32                                         set(hchild(ichild),'String',num2str(input))
    33                                     end
    34                                 case 'txt_'
    35                                     input=get(hchild(ichild),'String');
    36                                     tag=tag(separator+1:end);
    37                                 otherwise
    38                                     input=get(hchild(ichild),'String');
     25                            input=str2double(get(hchild(ichild),'String'));
     26                            tag=regexprep(tag,'^num_','');
     27                            %deal with undefined input: retrieve the default value stored as UserData
     28                            if isnan(input)
     29                                input=get(hchild(ichild),'UserData');
     30                                set(hchild(ichild),'String',num2str(input))
    3931                            end
    40                         end
    41 
    42                         %                         key=tag(7:end);
    43                     case{'Listbox','popupmenu'}
     32                        end                       
     33                    case{'listbox','popupmenu'}
    4434                        listinput=get(hchild(ichild),'String');
    4535                        value=get(hchild(ichild),'Value');
    4636                        if ~isempty(listinput)
    47                         input=listinput(value);
     37                            input=listinput{value};
     38                        else
     39                            check_input=0;
    4840                        end
    49                         separator=regexp(tag,'_');
    50                         if strcmp(tag(1:separator),'num_')
     41                        separator=regexp(tag,'^num_');
     42                        if ~isempty(separator)
    5143                            input=str2double(input);% transform to numerical values if the uicontrol tag begins with 'num_'
    52                             tag=tag(separator+1:end);
     44                            tag=regexprep(tag,'^num_','');
    5345                        end
    5446                    otherwise
     
    5749                if check_input
    5850                    struct.(tag)=input;
    59                   %  eval(['struct.' tag '=input;'])
    6051                end
    6152            case 'uitable'
    62                  struct.(tag)=get(hchild(ichild),'Data');
     53                struct.(tag)=get(hchild(ichild),'Data');
    6354        end
    6455    end
Note: See TracChangeset for help on using the changeset viewer.