Changeset 596 for trunk/src/get_field.m
- Timestamp:
- Mar 30, 2013, 11:34:27 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r591 r596 1042 1042 delete(handles.get_field) 1043 1043 1044 1045 1046 % %------------------------------------------------------------------------1047 % function mouse_up_gui(ggg,eventdata,handles)1048 % %------------------------------------------------------------------------1049 % if isequal(get(ggg,'SelectionType'),'alt')1050 % message='';1051 % global CurData1052 % inputfield=get(handles.inputfile,'String');1053 % if exist(inputfield,'file')1054 % CurData=nc2struct(inputfield);1055 % else1056 % CurData=get(ggg,'UserData');% get_field opened from a input field, not a file1057 % end1058 % %%%% TODO: put the matalb command window in front1059 % evalin('base','global CurData')%make CurData global in the workspace1060 % evalin('base','CurData') %display CurData in the workspace1061 % end1062 1063 %------------------------------------------------------------------------1064 % --- Executes on selection change in ACTION.1065 %------------------------------------------------------------------------1066 function ACTION_Callback(hObject, eventdata, handles)1067 global nb_builtin1068 list_ACTION=get(handles.ACTION,'String');% list menu fields1069 index_ACTION=get(handles.ACTION,'Value');% selected string index1070 ACTION= list_ACTION{index_ACTION}; % selected string1071 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 menu1074 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)<21081 return1082 end1083 [pp,ACTION,ext_fct]=fileparts(FileName);1084 if ~isequal(ext_fct,'.m')1085 msgbox_uvmat('ERROR','a Matlab function .m must be introduced');1086 return1087 end1088 1089 % insert the choice in the action menu1090 menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed1091 index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list1092 addpath(PathName)1093 list_func_handles{index_ACTION}=str2func(ACTION);% create the function handle corresponding to the newly seleced function1094 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 end1105 %record the current menu in personal file profil_perso1106 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)-11110 ff=functions(list_func_handles{ilist});1111 get_field_fct{ilist-nb_builtin}=ff.file;1112 end1113 if exist(profil_perso,'file')1114 save(profil_perso,'get_field_fct','-append')1115 else1116 txt=ver('MATLAB');1117 Release=txt.Release;1118 relnumb=str2num(Release(3:4));1119 if relnumb >= 141120 save(profil_perso,'get_field_fct','-V6')1121 else1122 save(profil_perso, 'get_field_fct')1123 end1124 end1125 end1126 1127 %check the current path to the selected function1128 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 function1132 GUI_input=h_fun();%handles.figure1 =handles of the GUI get_field1133 else1134 set(handles.path_action,'String','')1135 msgbox_uvmat('ERROR','unknown path to ACTION function, reload it')1136 return1137 end1138 1139 %prepare the GUI options for the selected ACTION1140 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 visible1147 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 end1154 end1155 end1156 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 figures1166 %-----------------------------------------------------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 figures1172 name=get(hh(ifig),'Name');1173 if ~strcmp(name,'uvmat')&& ~strcmp(name,'view_field') %case of uvmat GUI1174 hchild=get(hh(ifig),'children');% look for axes contained in each figure1175 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 plotting1181 nbaxe=nbaxe+1;%count the existing axis1182 end1183 end1184 end1185 if nbaxe==11186 ilist=ilist+1;%add a line in the list of axis1187 list{ilist,1}=num2str(hh(ifig));1188 elseif nbaxe>11189 for iaxe=1:nbaxe1190 ilist=ilist+1;%add a line in the list of axis1191 list{ilist,1}=[num2str(hh(ifig)) '_' num2str(iaxe)];1192 end1193 end1194 end1195 end1196 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 % end1212 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 end1217 if ishandle(str2num(plot_fig))1218 figure(str2num(plot_fig))% display existing figure1219 else1220 browse_fig(handles.list_fig); %reset the current list of figures1221 end1222 end1223 1044 1224 1045
Note: See TracChangeset
for help on using the changeset viewer.