Changeset 39 for trunk/src/uvmat.m
- Timestamp:
- Mar 9, 2010, 5:46:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r38 r39 195 195 %------------------------------------------------------------------- 196 196 %WARNING: avoid the second input parameter, leads to erros 197 global dircur dir_opening 197 global dircur dir_opening nb_builtin 198 198 % Choose default command menuline output for uvmat 199 199 handles.output = hObject; … … 221 221 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function 222 222 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) 223 %set(hObject,'ResizeFcn',{@resize_uvmat}) 223 224 %TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions 225 menu_str={'';'phys';'px';'phys_polar'}; 226 nb_builtin=numel(menu_str); %number of functions 227 [path_uvmat,name,ext]=fileparts(which('uvmat')); 228 addpath(fullfile(path_uvmat,'transform_field')) 229 fct_handle{1,1}=[]; 230 testexist(1)=1; 231 for ilist=2:length(menu_str) 232 if exist(menu_str{ilist},'file') 233 fct_handle{ilist,1}=str2func(menu_str{ilist}); 234 testexist(ilist)=1; 235 else 236 testexist(ilist)=0; 237 end 238 % fct_handle{ilist,1}=fullfile(path_uvmat,'transform_field');%path to the transform functions path_transform; 239 end 240 rmpath(fullfile(path_uvmat,'transform_field')) 224 241 225 242 %load the list of previously browsed files in menus Open and Open_1 … … 247 264 set(handles.MenuFile_5,'Label',h.MenuFile_5); 248 265 set(handles.MenuFile_5_1,'Label',h.MenuFile_5); 249 end 266 end 267 if isfield(h,'transform_fct') && iscell(h.transform_fct) 268 for ilist=1:length(h.transform_fct); 269 [path,file]=fileparts(h.transform_fct{ilist}); 270 addpath(path) 271 if exist(file,'file') 272 h_func=str2func(file); 273 testexist=[testexist 1]; 274 else 275 h_func=[]; 276 testexist=[testexist 0]; 277 end 278 fct_handle=[fct_handle; {h_func}];%concatene the list of paths 279 rmpath(path) 280 menu_str=[menu_str; {file}]; 281 end 282 end 250 283 end 284 menu_str=menu_str(find(testexist)); 285 fct_handle=fct_handle(find(testexist)); 286 menu_str=[menu_str;{'more...'}]; 287 set(handles.transform_fct,'String',menu_str) 288 set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION 251 289 252 290 %initiates menu of vector colors … … 259 297 [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m 260 298 261 %check the path of menu_coordtransform262 %set(handles. menu_coord,'String',{'';'phys';'px';'more...'})299 %check the path of transform_fct transform 300 %set(handles.transform_fct,'String',{'';'phys';'px';'more...'}) 263 301 % path_fct{1}=''; 264 302 % path_fct{2}=fileparts(path_to_uvmat); 265 303 % path_fct{3}=fileparts(path_to_uvmat); 266 304 % path_fct{4}=fileparts(path_to_uvmat); 267 % set(handles. menu_coord,'UserData',path_fct)305 % set(handles.transform_fct,'UserData',path_fct) 268 306 269 307 %case of an input argument for uvmat … … 303 341 if ~isempty(Field) 304 342 set(handles.Fields,'Value',1) 305 set(handles.Fields,'String',{'get_field...'}) 306 % set(handles.Fields,'Value',2)% option 'get_field...' 343 set(handles.Fields,'String',{'get_field...'}) 307 344 set(handles.Fields,'UserData',Field) 308 345 testinputfield=1; … … 344 381 end 345 382 end 346 347 %TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions348 menu_str={'';'phys';'px';'phys_polar'};349 nb_builtin=numel(menu_str); %number of functions350 [path_uvmat,name,ext]=fileparts(which('uvmat'));351 addpath(fullfile(path_uvmat,'transform_field'))352 fct_handle{1,1}=[];353 testexist(1)=1;354 for ilist=2:length(menu_str)355 if exist(menu_str{ilist},'file')356 fct_handle{ilist,1}=str2func(menu_str{ilist});357 testexist(ilist)=1;358 else359 testexist(ilist)=0;360 end361 % fct_handle{ilist,1}=fullfile(path_uvmat,'transform_field');%path to the transform functions path_transform;362 end363 rmpath(fullfile(path_uvmat,'transform_field'))364 % read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir365 dir_perso=prefdir;366 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');367 if exist(profil_perso,'file')368 h=load (profil_perso);369 if isfield(h,'transform_fct') && iscell(h.transform_fct)370 for ilist=1:length(h.transform_fct)371 [path,file]=fileparts(h.transform{ilist});372 addpath(path)373 if exist(file,'file')374 h_func=str2func(path);375 testexist=[testexist 1];376 else377 h_func=[];378 testexist=[testexist 0];379 end380 fct_handle=[fct_handle; {h_func}];%concatene the list of paths381 rmpath(path)382 % fct_path=[fct_path; {path}];%concatene the list of paths383 menu_str=[menu_str; {file}];384 end385 end386 end387 menu_str=menu_str(find(testexist));388 fct_handle=fct_handle(find(testexist));389 menu_str=[menu_str;{'more...'}];390 set(handles.menu_coord,'String',menu_str)391 set(handles.menu_coord,'UserData',fct_handle)% store the list of path in UserData of ACTION392 383 393 384 set_vec_col_bar(handles) … … 790 781 set(handles.pxcm,'String','') 791 782 set(handles.pycm,'String','') 792 set(handles. menu_coord,'Value',1); % no transform by default783 set(handles.transform_fct,'Value',1); % no transform by default 793 784 else 794 785 if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |... … … 802 793 set(handles.pycm,'String',num2str(pixcmy)) 803 794 end 804 set(handles. menu_coord,'Value',2); % phys transform by default795 set(handles.transform_fct,'Value',2); % phys transform by default 805 796 if isfield(GeometryCalib,'SliceCoord') 806 797 siz=size(GeometryCalib.SliceCoord); … … 1516 1507 end 1517 1508 %px to phys or other transform on field 1518 menu_transform=get(handles. menu_coord,'String');1519 choice_value=get(handles. menu_coord,'Value');1520 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu ' menu_coord'1521 transform_list=get(handles. menu_coord,'UserData');1509 menu_transform=get(handles.transform_fct,'String'); 1510 choice_value=get(handles.transform_fct,'Value'); 1511 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' 1512 transform_list=get(handles.transform_fct,'UserData'); 1522 1513 transform=transform_list{choice_value}; 1523 1514 if ~isequal(transform_name,'') && ~isequal(transform_name,'px') … … 1750 1741 1751 1742 %px to phys or other transform on field 1752 menu_transform=get(handles. menu_coord,'String');1753 choice_value=get(handles. menu_coord,'Value');1754 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu ' menu_coord'1755 transform_list=get(handles. menu_coord,'UserData');1743 menu_transform=get(handles.transform_fct,'String'); 1744 choice_value=get(handles.transform_fct,'Value'); 1745 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' 1746 transform_list=get(handles.transform_fct,'UserData'); 1756 1747 transform=transform_list{choice_value}; 1757 1748 if ~isequal(transform_name,'') && ~isequal(transform_name,'px') … … 2034 2025 [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data 2035 2026 Field{2}.VarAttribute=SubField.VarAttribute; 2036 % if isequal(get(hhget_field. menu_coord,'Visible'),'on')2037 % list_transform=get(hhget_field. menu_coord,'String');2038 % val_list=get(hhget_field. menu_coord,'Value');2027 % if isequal(get(hhget_field.transform_fct,'Visible'),'on') 2028 % list_transform=get(hhget_field.transform_fct,'String'); 2029 % val_list=get(hhget_field.transform_fct,'Value'); 2039 2030 % transf=list_transform{val_list}; 2040 2031 % if ~isempty(transf) … … 2171 2162 XmlData_1=UvData.XmlData_1; 2172 2163 end 2173 menu_transform=get(handles. menu_coord,'String');2174 choice_value=get(handles. menu_coord,'Value');2175 %transform=menu_transform{choice_value};%name of the transform fct given by the menu ' menu_coord'2176 transform_list=get(handles. menu_coord,'UserData')2177 transform=transform_list{choice_value} %selected function handles2164 menu_transform=get(handles.transform_fct,'String'); 2165 choice_value=get(handles.transform_fct,'Value'); 2166 %transform=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' 2167 transform_list=get(handles.transform_fct,'UserData'); 2168 transform=transform_list{choice_value};%selected function handles 2178 2169 2179 2170 % z index … … 2190 2181 end 2191 2182 else 2192 'TESTrun'2193 2183 Field{1}=transform(Field{1},XmlData); 2194 Field{1}2195 2184 end 2196 2185 end … … 4003 3992 4004 3993 %------------------------------------------------------------- 4005 % --- Executes on selection change in menu_coord.4006 function menu_coord_Callback(hObject, eventdata, handles)3994 % --- Executes on selection change in transform_fct. 3995 function transform_fct_Callback(hObject, eventdata, handles) 4007 3996 %------------------------------------------------------------- 4008 huvmat=get(handles.menu_coord,'parent'); 4009 menu=get(handles.menu_coord,'String'); 4010 ind_coord=get(handles.menu_coord,'Value'); 3997 global nb_builtin 3998 3999 huvmat=get(handles.transform_fct,'parent'); 4000 menu=get(handles.transform_fct,'String'); 4001 ind_coord=get(handles.transform_fct,'Value'); 4011 4002 coord_option=menu{ind_coord}; 4012 list_transform=get(handles. menu_coord,'UserData');4013 4003 list_transform=get(handles.transform_fct,'UserData'); 4004 ff=functions(list_transform{end}) 4014 4005 if isequal(coord_option,'more...'); 4015 4006 coord_fct=''; 4016 dir_perso=prefdir; 4017 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 4018 if exist(profil_perso,'file') 4019 h=load (profil_perso); 4020 if isfield(h,'coord_fct') 4021 coord_fct=h.coord_fct; 4022 end 4023 end 4007 4008 % if exist(profil_perso,'file') 4009 % h=load (profil_perso); 4010 % if isfield(h,'transform_fct') 4011 % transform_fct=h.transform_fct; 4012 % end 4013 % end 4024 4014 prompt = {'Enter the name of the transform function'}; 4025 4015 dlg_title = 'user defined transform'; … … 4029 4019 '*.m', '.m files '; ... 4030 4020 '*.*', 'All Files (*.*)'}, ... 4031 'Pick a file', coord_fct);4021 'Pick a file', ff.file); 4032 4022 if isequal(PathName(end),'/')||isequal(PathName(end),'\') 4033 4023 PathName(end)=[]; 4034 4024 end 4035 coord_fct=fullfile(PathName,FileName); 4036 if ~exist(coord_fct,'file') 4037 msgbox_uvmat('ERROR',['image procesing fct ' coord_fct ' not found']) 4038 else 4039 [ppp,transform]=fileparts(FileName);% removes extension .m 4040 menu=update_menu(handles.menu_coord,transform);%add the selected fct to the menu 4041 ind_coord=get(handles.menu_coord,'Value'); 4042 addpath(PathName) 4043 list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function 4044 set(handles.menu_coord,'UserData',list_transform) 4045 rmpath(PathName) 4046 if exist(profil_perso,'file') 4047 save (profil_perso,'coord_fct','-append'); %store the root name for future opening of uvmat 4048 end 4049 end 4025 transform_selected =fullfile(PathName,FileName); 4026 if ~exist(transform_selected,'file') 4027 % msgbox_uvmat('ERROR',['procesing fct ' transform_selected ' not found']) 4028 return 4029 end 4030 [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m 4031 if ~isequal(ext_fct,'.m') 4032 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 4033 return 4034 end 4035 menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu 4036 ind_coord=get(handles.transform_fct,'Value'); 4037 addpath(PathName) 4038 list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function 4039 set(handles.transform_fct,'UserData',list_transform) 4040 rmpath(PathName) 4041 % save the new menu in the personal file 'uvmat_perso.mat' 4042 dir_perso=prefdir;%personal Matalb directory 4043 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 4044 if exist(profil_perso,'file') 4045 for ilist=nb_builtin+1:numel(list_transform) 4046 ff=functions(list_transform{ilist}); 4047 transform_fct{ilist-nb_builtin}=ff.file; 4048 end 4049 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 4050 end 4050 4051 end 4051 4052 4052 4053 %check the current path to the selected function 4053 func=functions(list_transform{ind_coord}) 4054 func=functions(list_transform{ind_coord}); 4054 4055 set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function 4055 4056 %CurrentPath=fileparts(which(coord_option)); … … 4808 4809 param.filter1=get(handles.filter1,'Value'); 4809 4810 param.filter2=get(handles.filter2,'Value'); 4810 param.menu_coord_str=get(handles. menu_coord,'String');4811 param.menu_coord_val=get(handles. menu_coord,'Value');4811 param.menu_coord_str=get(handles.transform_fct,'String'); 4812 param.menu_coord_val=get(handles.transform_fct,'Value'); 4812 4813 4813 4814 series(param); %run the series interface … … 4862 4863 %-------------------------------------------------------------------------- 4863 4864 function enable_transform(handles,state) 4864 set(handles. menu_coord,'Visible',state)4865 set(handles.transform_fct,'Visible',state) 4865 4866 set(handles.TRANSFORM_txt,'Visible',state) 4866 set(handles. menu_coord,'Visible',state)4867 set(handles.transform_fct,'Visible',state) 4867 4868 set(handles.path_transform,'Visible',state) 4868 4869 set(handles.pxcmx_txt,'Visible',state)
Note: See TracChangeset
for help on using the changeset viewer.