Changeset 596 for trunk/src/get_field.m


Ignore:
Timestamp:
Mar 30, 2013, 11:34:27 AM (11 years ago)
Author:
sommeria
Message:

corrections done in civ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r591 r596  
    10421042delete(handles.get_field)
    10431043
    1044 
    1045 
    1046 % %------------------------------------------------------------------------
    1047 % function mouse_up_gui(ggg,eventdata,handles)
    1048 % %------------------------------------------------------------------------
    1049 % if isequal(get(ggg,'SelectionType'),'alt')
    1050 %     message=''; 
    1051 %     global CurData
    1052 %     inputfield=get(handles.inputfile,'String');
    1053 %     if exist(inputfield,'file')
    1054 %         CurData=nc2struct(inputfield);
    1055 %     else
    1056 %         CurData=get(ggg,'UserData');% get_field opened from a input field, not a file
    1057 %     end
    1058 %   %%%% TODO: put the matalb command window in front
    1059 %     evalin('base','global CurData')%make CurData global in the workspace
    1060 %     evalin('base','CurData') %display CurData in the workspace
    1061 % end
    1062 
    1063 %------------------------------------------------------------------------
    1064 % --- Executes on selection change in ACTION.
    1065 %------------------------------------------------------------------------
    1066 function ACTION_Callback(hObject, eventdata, handles)
    1067 global nb_builtin
    1068 list_ACTION=get(handles.ACTION,'String');% list menu fields
    1069 index_ACTION=get(handles.ACTION,'Value');% selected string index
    1070 ACTION= list_ACTION{index_ACTION}; % selected string
    1071 list_func_handles=get(handles.ACTION,'UserData');% get list of function handles (full address of the function, including name and path)
    1072 ff=functions(list_func_handles{end});
    1073 % add a new function to the menu
    1074 if isequal(ACTION,'more...')
    1075     [FileName, PathName] = uigetfile( ...
    1076        {'*.m', ' (*.m)';
    1077         '*.m',  '.m files '; ...
    1078         '*.*', 'All Files (*.*)'}, ...
    1079         'Pick a file',ff.file);
    1080     if length(FileName)<2
    1081         return
    1082     end
    1083     [pp,ACTION,ext_fct]=fileparts(FileName);
    1084     if ~isequal(ext_fct,'.m')
    1085         msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
    1086         return
    1087     end
    1088 
    1089     % insert the choice in the action menu
    1090    menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed
    1091    index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list
    1092    addpath(PathName)
    1093    list_func_handles{index_ACTION}=str2func(ACTION);% create the function handle corresponding to the newly seleced function
    1094    set(handles.ACTION,'UserData',list_func_handles)
    1095    set(handles.path_action,'enable','inactive')% indicate that the current path is accessible (not 'off')
    1096    %list_path{index_ACTION}=PathName;
    1097    if length(menu_str)>nb_builtin+5;
    1098        nbremove=length(menu_str)-nb_builtin-5;
    1099        menu_str(nb_builtin+1:end-5)=[];
    1100        list_func_handles(nb_builtin+1:end-4)=[];
    1101        index_ACTION=index_ACTION-nbremove;
    1102        set(handles.ACTION,'Value',index_ACTION)
    1103        set(handles.ACTION,'String',menu_str)
    1104    end   
    1105    %record the current menu in personal file profil_perso
    1106    dir_perso=prefdir;
    1107    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    1108    get_field_fct={};
    1109    for ilist=nb_builtin+1:length(menu_str)-1
    1110        ff=functions(list_func_handles{ilist});
    1111        get_field_fct{ilist-nb_builtin}=ff.file;
    1112    end
    1113    if exist(profil_perso,'file')
    1114         save(profil_perso,'get_field_fct','-append')
    1115    else
    1116      txt=ver('MATLAB');
    1117     Release=txt.Release;
    1118        relnumb=str2num(Release(3:4));
    1119         if relnumb >= 14
    1120             save(profil_perso,'get_field_fct','-V6')
    1121         else
    1122             save(profil_perso, 'get_field_fct')
    1123         end
    1124    end
    1125 end
    1126 
    1127 %check the current path to the selected function
    1128 h_fun=list_func_handles{index_ACTION};
    1129 if isa(h_fun,'function_handle')
    1130     func=functions(h_fun);
    1131     set(handles.path_action,'String',fileparts(func.file)); %show the path to the senlected function
    1132     GUI_input=h_fun();%handles.figure1 =handles of the GUI get_field
    1133 else
    1134     set(handles.path_action,'String','')
    1135     msgbox_uvmat('ERROR','unknown path to ACTION function, reload it')
    1136     return
    1137 end
    1138 
    1139 %prepare the GUI options for the selected ACTION
    1140 test_1Dplot=0;
    1141 test_scalar=0;
    1142 test_vector=0;
    1143 if iscell(GUI_input)
    1144     for ilist=1:size(GUI_input,1)
    1145         switch GUI_input{ilist,1}
    1146                            %RootFile always visible
    1147             case 'CheckPlot1D'   
    1148                  test_1Dplot=isequal(GUI_input{ilist,2},'on');
    1149             case 'CheckScalar'
    1150                  test_scalar=isequal(GUI_input{ilist,2},'on');   
    1151             case 'CheckVector'   
    1152                  test_vector=isequal(GUI_input{ilist,2},'on');
    1153         end
    1154     end
    1155 end
    1156 set(handles.CheckPlot1D,'Value',test_1Dplot);
    1157 set(handles.CheckScalar,'Value',test_scalar);
    1158 set(handles.CheckVector,'Value',test_vector);
    1159 CheckPlot1D_Callback(hObject, eventdata, handles)
    1160 CheckScalar_Callback(hObject, eventdata, handles)
    1161 CheckVector_Callback(hObject, eventdata, handles)
    1162 
    1163 
    1164 %-----------------------------------------------------
    1165 % --- browse existing figures
    1166 %-----------------------------------------------------
    1167 function browse_fig(menu_handle)
    1168 hh=findobj(allchild(0),'Type','figure');
    1169 ilist=0;
    1170 list={};
    1171 for ifig=1:length(hh)  %look for all existing figures
    1172     name=get(hh(ifig),'Name');
    1173      if ~strcmp(name,'uvmat')&& ~strcmp(name,'view_field') %case of uvmat GUI
    1174         hchild=get(hh(ifig),'children');% look for axes contained in each figure
    1175         nbaxe=0;
    1176         for ichild=1:length(hchild)           
    1177             Type=get(hchild(ichild),'Type');
    1178             Tag=get(hchild(ichild),'Tag');
    1179             if isequal(Type,'axes')
    1180                 if ~isequal(Tag,'Colorbar')& ~isequal(Tag,'legend')% don't select colorbars for plotting
    1181                      nbaxe=nbaxe+1;%count the existing axis
    1182                 end
    1183             end
    1184         end   
    1185         if nbaxe==1
    1186              ilist=ilist+1;%add a line in the list of axis
    1187             list{ilist,1}=num2str(hh(ifig));
    1188         elseif nbaxe>1
    1189             for iaxe=1:nbaxe
    1190                ilist=ilist+1;%add a line in the list of axis
    1191                list{ilist,1}=[num2str(hh(ifig)) '_' num2str(iaxe)];
    1192             end
    1193         end
    1194      end
    1195 end
    1196 list=['uvmat';list];
    1197 set(menu_handle,'Value',1)
    1198 set(menu_handle,'String',list)
    1199 
    1200 
    1201 %-----------------------------------------------------
    1202 function list_fig_Callback(hObject, eventdata, handles)
    1203 %-----------------------------------------------------
    1204 list_fig=get(handles.list_fig,'String');
    1205 fig_val=get(handles.list_fig,'Value');
    1206 plot_fig=list_fig{fig_val};
    1207 if strcmp(plot_fig,'view_field')
    1208 %     huvmat=findobj(allchild(0),'name','uvmat');
    1209 %     if ~isempty(huvmat)
    1210 %         uistack(huvmat,'top')
    1211 %     end   
    1212 else%if ~isequal(plot_fig,'new fig...') & ~isequal(plot_fig,'uvmat')
    1213     sep=regexp(plot_fig,'_');
    1214     if ~isempty(sep)
    1215         plot_fig=plot_fig([1:sep-1]);
    1216     end
    1217     if ishandle(str2num(plot_fig))
    1218         figure(str2num(plot_fig))% display existing figure
    1219     else
    1220         browse_fig(handles.list_fig); %reset the current list of figures
    1221     end
    1222 end
    12231044
    12241045
Note: See TracChangeset for help on using the changeset viewer.