Changeset 39 for trunk/src/series.m
- Timestamp:
- Mar 9, 2010, 5:46:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r38 r39 6 6 %INPUT 7 7 % param: structure with input parameters (link with the GUI uvmat) 8 % .menu_coord_str: string for the CoordType(menu for coordinate transforms)9 % .menu_coord_val: value for CoordType(menu for coordinate transforms)8 % .menu_coord_str: string for the transform_fct (menu for coordinate transforms) 9 % .menu_coord_val: value for transform_fct (menu for coordinate transforms) 10 10 % .FileName: input file name 11 11 % .FileName_1: second input file name … … 96 96 %file name and browser initialisation 97 97 if isfield(param,'menu_coord_str') 98 set(handles. CoordType,'String',param.menu_coord_str)98 set(handles.transform_fct,'String',param.menu_coord_str) 99 99 end 100 100 if isfield(param,'menu_coord_val') 101 set(handles. CoordType,'Value',param.menu_coord_val);102 else 103 set(handles. CoordType,'Value',1);%default101 set(handles.transform_fct,'Value',param.menu_coord_val); 102 else 103 set(handles.transform_fct,'Value',1);%default 104 104 end 105 105 … … 132 132 NomType_Callback(hObject, eventdata, handles) 133 133 134 %loads the information stored in prefdir to initiate the browser and the list offunctions134 %loads the information stored in prefdir to initiate the list of ACTION functions 135 135 fct_menu={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; 136 136 transform_menu={'';'phys';'px';'phys_polar'}; … … 139 139 [path_series,name,ext]=fileparts(which('series')); 140 140 path_series=fullfile(path_series,'series');%path of the function 'series' 141 path_transform=fullfile(path_series,'transform_field');%path of the f unction 'series'141 path_transform=fullfile(path_series,'transform_field');%path of the field transform functions 142 142 for ilist=1:length(fct_menu) 143 143 fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' 144 144 end 145 for ilist=1:length(transform_menu) 146 transform_path{ilist,1}=path_transform; 147 end 145 146 %TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions 147 menu_str={'';'phys';'px';'phys_polar'}; 148 nb_builtin=numel(menu_str); %number of functions 149 [path_uvmat,name,ext]=fileparts(which('uvmat')); 150 addpath(fullfile(path_uvmat,'transform_field')) 151 fct_handle{1,1}=[]; 152 testexist(1)=1; 153 for ilist=2:length(menu_str) 154 if exist(menu_str{ilist},'file') 155 fct_handle{ilist,1}=str2func(menu_str{ilist}); 156 testexist(ilist)=1; 157 else 158 testexist(ilist)=0; 159 end 160 end 161 rmpath(fullfile(path_uvmat,'transform_field')) 162 148 163 % read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir 149 164 dir_perso=prefdir; … … 159 174 end 160 175 if isfield(h,'transform_fct') && iscell(h.transform_fct) 161 for ilist=1:length(h.transform_fct)176 for ilist=1:length(h.transform_fct); 162 177 [path,file]=fileparts(h.transform_fct{ilist}); 163 transform_path=[transform_path; {path}];%concatene the list of paths 164 transform_menu=[transform_menu;{file}]; 165 end 178 addpath(path) 179 if exist(file,'file') 180 h_func=str2func(file); 181 testexist=[testexist 1]; 182 else 183 h_func=[]; 184 testexist=[testexist 0]; 185 end 186 fct_handle=[fct_handle; {h_func}];%concatene the list of paths 187 rmpath(path) 188 menu_str=[menu_str; {file}]; 189 end 166 190 end 167 191 end … … 169 193 set(handles.ACTION,'String',fct_menu) 170 194 set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION 171 transform_menu=[transform_menu;{'more...'}]; 172 set(handles.CoordType,'String',transform_menu) 173 set(handles.CoordType,'UserData',transform_path)% store the list of path in UserData of ACTION 195 196 menu_str=menu_str(find(testexist)); 197 fct_handle=fct_handle(find(testexist)); 198 menu_str=[menu_str;{'more...'}]; 199 set(handles.transform_fct,'String',menu_str) 200 set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION 174 201 175 202 % display the GUI for the default action 'check_files' … … 544 571 testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on'); 545 572 testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on'); 546 testtransform=isequal(get(handles. CoordType,'Enable'),'on');573 testtransform=isequal(get(handles.transform_fct,'Enable'),'on'); 547 574 testnc=0; 548 575 testnc_1=0; … … 962 989 function view_TRANSFORM(handles,state) 963 990 set(handles.TRANSFORM_frame,'Visible',state) 964 set(handles. CoordType,'Visible',state);991 set(handles.transform_fct,'Visible',state); 965 992 set(handles.TRANSFORM_title,'Visible',state) 966 993 … … 1328 1355 Series.Field=FieldMenu(FieldValue); 1329 1356 end 1330 menu_coord_state=get(handles. CoordType,'Visible');1357 menu_coord_state=get(handles.transform_fct,'Visible'); 1331 1358 Series.CoordType='';%default 1332 1359 if isequal(menu_coord_state,'on') 1333 menu_coord=get(handles. CoordType,'String');1334 menu_index=get(handles. CoordType,'Value');1360 menu_coord=get(handles.transform_fct,'String'); 1361 menu_index=get(handles.transform_fct,'Value'); 1335 1362 Series.CoordType=menu_coord{menu_index}; 1336 1363 end … … 1593 1620 path_series=which('series');%path to series.m 1594 1621 list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION 1595 1622 default_file=fullfile(list_path{end},ACTION); 1596 1623 % add a new function to the menu if the selected item is 'more...' 1597 1624 if isequal(ACTION,'more...') 1598 1625 pathfct=fileparts(path_series); 1599 % browse_name=fullfile(path_series,'series');%go to UVMAT/series by default1600 % if length(list_path)>nb_builtin1601 % browse_name=list_path{end};% initialize browser with the path of the last introduced function1602 % end1603 1626 [FileName, PathName, filterindex] = uigetfile( ... 1604 1627 {'*.m', ' (*.m)'; 1605 1628 '*.m', '.m files '; ... 1606 1629 '*.*', 'All Files (*.*)'}, ... 1607 'Pick a file', list_path{end});1630 'Pick a file',default_file); 1608 1631 if length(FileName)<2 1609 1632 return … … 1685 1708 set(handles.FieldMenu_1,'Enable','off') 1686 1709 set(handles.VelTypeMenu_1,'Enable','off') 1687 set(handles. CoordType,'Enable','off')1710 set(handles.transform_fct,'Enable','off') 1688 1711 %set the displayed GUI item needed for input parameters 1689 1712 %list_input=feval(ACTION);% input list asked by the selected function … … 1789 1812 case 'CoordType' %hidden by default 1790 1813 if isequal(lower(varargout{ilist+1}),'on') 1791 set(handles. CoordType,'Enable','on')1814 set(handles.transform_fct,'Enable','on') 1792 1815 view_TRANSFORM(handles,'on') 1793 1816 end … … 2110 2133 else 2111 2134 siz=size(times); 2112 if siz(1)>=last_i & siz(2)>=last_j2135 if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1 2113 2136 time_first=times(first_i,first_j); 2114 2137 time_last=times(last_i,last_j); … … 2188 2211 2189 2212 2190 2191 2192 2193 2213 % --- Executes on selection change in transform_fct. 2214 function transform_fct_Callback(hObject, eventdata, handles) 2215 2216 global nb_transform 2217 2218 % huvmat=get(handles.transform_fct,'parent'); 2219 menu=get(handles.transform_fct,'String'); 2220 ind_coord=get(handles.transform_fct,'Value'); 2221 coord_option=menu{ind_coord}; 2222 list_transform=get(handles.transform_fct,'UserData') 2223 ff=functions(list_transform{end}); 2224 if isequal(coord_option,'more...'); 2225 coord_fct=''; 2226 prompt = {'Enter the name of the transform function'}; 2227 dlg_title = 'user defined transform'; 2228 num_lines= 1; 2229 [FileName, PathName, filterindex] = uigetfile( ... 2230 {'*.m', ' (*.m)'; 2231 '*.m', '.m files '; ... 2232 '*.*', 'All Files (*.*)'}, ... 2233 'Pick a file', ff.file); 2234 if isequal(PathName(end),'/')||isequal(PathName(end),'\') 2235 PathName(end)=[]; 2236 end 2237 transform_selected =fullfile(PathName,FileName); 2238 if ~exist(transform_selected,'file') 2239 return 2240 end 2241 [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m 2242 if ~isequal(ext_fct,'.m') 2243 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 2244 return 2245 end 2246 menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu 2247 ind_coord=get(handles.transform_fct,'Value'); 2248 addpath(PathName) 2249 list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function 2250 set(handles.transform_fct,'UserData',list_transform) 2251 rmpath(PathName) 2252 % save the new menu in the personal file 'uvmat_perso.mat' 2253 dir_perso=prefdir;%personal Matalb directory 2254 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 2255 if exist(profil_perso,'file') 2256 for ilist=nb_transform+1:numel(list_transform) 2257 ff=functions(list_transform{ilist}) 2258 transform_fct{ilist-nb_transform}=ff.file; 2259 end 2260 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 2261 end 2262 end 2263 2264 %check the current path to the selected function 2265 func=functions(list_transform{ind_coord}); 2266 set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function 2267 2268 2269 2270 function path_transform_Callback(hObject, eventdata, handles) 2271 % hObject handle to path_transform (see GCBO) 2272 % eventdata reserved - to be defined in a future version of MATLAB 2273 % handles structure with handles and user data (see GUIDATA) 2274 2275 % Hints: get(hObject,'String') returns contents of path_transform as text 2276 % str2double(get(hObject,'String')) returns contents of path_transform as a double 2277 2278 2279 % --- Executes during object creation, after setting all properties. 2280 function path_transform_CreateFcn(hObject, eventdata, handles) 2281 % hObject handle to path_transform (see GCBO) 2282 % eventdata reserved - to be defined in a future version of MATLAB 2283 % handles empty - handles not created until after all CreateFcns called 2284 2285 % Hint: edit controls usually have a white background on Windows. 2286 % See ISPC and COMPUTER. 2287 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 2288 set(hObject,'BackgroundColor','white'); 2289 end 2290 2291
Note: See TracChangeset
for help on using the changeset viewer.