Changeset 648 for trunk/src/uvmat.m
- Timestamp:
- Jun 9, 2013, 10:31:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r646 r648 518 518 SubDir=get(handles.SubDir,'String'); 519 519 fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir)); 520 520 521 if ~isempty(fileinput_1) 521 % [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);522 % if ~ischar(FileName),return,end %abandon if the browser is cancelled523 % fileinput_1=[PathName FileName];%complete file name524 522 525 523 % refresh the current displayed field … … 720 718 end 721 719 720 %% detect root name, nomenclature and indices in the input file name: 721 [FilePath,FileName,FileExt]=fileparts(fileinput); 722 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 723 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 724 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); 725 if strcmp(FileType,'txt') 726 edit(fileinput) 727 return 728 elseif strcmp(FileType,'xml') 729 editxml(fileinput) 730 return 731 elseif strcmp(FileType,'figure') 732 open(fileinput) 733 return 734 end 735 722 736 %% set the mouse pointer to 'watch' 723 737 set(handles.uvmat,'Pointer','watch') … … 750 764 set(handles.NomType_1,'Visible','on'); 751 765 end 752 753 %% detect root name, nomenclature and indices in the input file name:754 [FilePath,FileName,FileExt]=fileparts(fileinput);755 % detect the file type, get the movie object if relevant, and look for the corresponding file series:756 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists757 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);758 766 759 767 %% open the file or fill the GUI uvmat according to the detected file type … … 945 953 end 946 954 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 955 if index==1 956 set(handles.TimeName,'video') 957 else 958 set(handles.TimeName_1,'video') 959 end 947 960 ColorType='truecolor'; 948 961 elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image … … 1012 1025 end 1013 1026 end 1014 if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) 1027 if (isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) 1028 if index==1 1029 set(handles.TimeName,'xml') 1030 else 1031 set(handles.TimeName_1,'xml') 1032 end 1033 else 1015 1034 XmlData.Time=Time; %time set by video 1016 1035 end … … 1021 1040 end 1022 1041 1023 %% store last index in handles. lat_i and .last_j1042 %% store last index in handles.MaxIndex_i and .MaxIndex_j 1024 1043 nbfield=max(max(max(i2_series))); 1025 1044 if isempty(nbfield) … … 1033 1052 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 1034 1053 if isequal(size(XmlData.Time,1),1) 1035 %NomType=get(handles.NomType,'String');1036 1054 XmlData.Time=(XmlData.Time)'; 1037 1055 end 1038 1056 end 1039 last_i_cell=get(handles. last_i,'String');1057 last_i_cell=get(handles.MaxIndex_i,'String'); 1040 1058 if isempty(nbfield) 1041 1059 last_i_cell{index}=''; … … 1043 1061 last_i_cell{index}=num2str(nbfield); 1044 1062 end 1045 set(handles. last_i,'String',last_i_cell)1046 last_j_cell=get(handles. last_j,'String');1063 set(handles.MaxIndex_i,'String',last_i_cell) 1064 last_j_cell=get(handles.MaxIndex_j,'String'); 1047 1065 if isempty(nbfield_j) 1048 1066 last_j_cell{index}=''; … … 1050 1068 last_j_cell{index}=num2str(nbfield_j); 1051 1069 end 1052 set(handles. last_j,'String',last_j_cell);1070 set(handles.MaxIndex_j,'String',last_j_cell); 1053 1071 1054 1072 %% store geometric calibration in UvData … … 1093 1111 %% update the data attached to the uvmat interface 1094 1112 if ~isempty(TimeUnit) 1095 set(handles. time_var,'String',['time (' TimeUnit ')'])1113 set(handles.TimeName,'String',['time (' TimeUnit ')']) 1096 1114 end 1097 1115 UvData.TimeUnit=TimeUnit; 1098 1116 UvData.XmlData{index}=XmlData; 1099 1117 UvData.NewSeries=1; 1100 % UvData.MovieObject=MovieObject;1101 1118 1102 1119 %display warning message … … 1179 1196 set(handles.j1,'Visible',state_j) 1180 1197 set(handles.j2,'Visible',state_j) 1181 set(handles. last_j,'Visible',state_j);1198 set(handles.MaxIndex_j,'Visible',state_j); 1182 1199 %set(handles.frame_j,'Visible',state_j); 1183 1200 set(handles.j_text,'Visible',state_j); … … 1377 1394 end 1378 1395 end 1379 if mdetect==0 1380 MaskFullName=uigetfile_uvmat('pick a mask image file:',fullfile(RootPath,SubDir),'image'); 1381 [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); 1382 [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt]); 1383 if ~(isempty(i2_series) && isempty(j2_series)) 1384 MaskNomType='*'; 1385 end 1386 end 1387 Mask.Path=MaskPath; 1388 Mask.File=MaskFile; 1389 Mask.Ext=MaskExt; 1390 Mask.NomType=MaskNomType; 1391 set(handles.CheckMask,'UserData',Mask); 1392 end 1393 errormsg=update_mask(handles); 1396 end 1397 if mdetect==0 1398 MaskFullName=uigetfile_uvmat('pick a mask image file:',fullfile(RootPath,SubDir),'image'); 1399 if isempty(MaskFullName) 1400 set(handles.CheckMask,'Value',0) 1401 end 1402 [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); 1403 [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt]); 1404 if ~(isempty(i2_series) && isempty(j2_series)) 1405 MaskNomType='*'; 1406 end 1407 end 1408 Mask.Path=MaskPath; 1409 Mask.File=MaskFile; 1410 Mask.Ext=MaskExt; 1411 Mask.NomType=MaskNomType; 1412 set(handles.CheckMask,'UserData',Mask); 1413 errormsg=update_mask(handles); 1394 1414 else % desactivate mask display 1395 1415 MaskData=get(handles.CheckMask,'UserData'); … … 2153 2173 ParamIn.FieldName=FieldName; 2154 2174 ParamIn.VelType=VelType; 2155 XNameMenu=get(handles.Coord_x,'String'); 2156 if ~isempty(XNameMenu) 2157 ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); 2158 end 2159 % YNameMenu=get(handles.Coord_y,'String'); 2175 ParamIn.Coord_x=get(handles.Coord_x,'String'); 2160 2176 ParamIn.Coord_y=get(handles.Coord_y,'Data'); 2161 % if ~isempty(YNameMenu)2162 % ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value'));2163 % end2164 2177 end 2165 2178 check_tps = 0; … … 2176 2189 set(handles.num_Npy,'String',num2str(ParamOut.Npy)); 2177 2190 end 2178 if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field 2179 set(handles.i1,'String',num2str(ParamOut.TimeIndex)) 2180 end 2181 if isfield(ParamOut,'TimeValue') 2182 Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field 2183 end 2191 % 2192 % if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field 2193 % set(handles.i1,'String',num2str(ParamOut.TimeIndex)) 2194 % end 2195 % if isfield(ParamOut,'TimeValue') 2196 % Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field 2197 % end 2184 2198 Field{1}.ZIndex=z_index; %used for multiplane 3D calibration 2185 2199 … … 2196 2210 return 2197 2211 end 2198 % Name=FileName_1;2199 2212 switch UvData.FileType{2} 2200 2213 case {'civx','civdata','netcdf'}; … … 2374 2387 %% display time 2375 2388 abstime=[];%default inputs 2376 abstime_1=[];2377 2389 dt=[]; 2378 2390 TimeUnit=''; … … 2390 2402 siz=size(UvData.XmlData{1}.Time); 2391 2403 if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1) 2404 set(handles.TimeName,'xml')% indicate that time is from xml 2392 2405 abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files 2393 2406 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); … … 2423 2436 % look for timing in the input file if not defined in a xml file or movie 2424 2437 if isempty(abstime) 2425 if isfield(Field{1},'Dt') 2426 dt=Field{1}.Dt;%dt read from the netcdf input file 2427 if isfield(Field{1},'TimeUnit') 2428 TimeUnit=Field{1}.TimeUnit; 2429 end 2430 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 2431 dt=Field{2}.Dt;%dt read from the netcdf input file 2432 if isfield(Field{2},'TimeUnit') 2433 TimeUnit=Field{2}.TimeUnit; 2434 end 2435 end 2438 TimeName=get(handles.TimeName,'String'); 2439 if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:')) 2440 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file 2441 end 2442 if isfield(Field{1},'Dt') 2443 dt=Field{1}.Dt;%dt read from the netcdf input file 2444 if isfield(Field{1},'TimeUnit') 2445 TimeUnit=Field{1}.TimeUnit; 2446 end 2447 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 2448 dt=Field{2}.Dt;%dt read from the netcdf input file 2449 if isfield(Field{2},'TimeUnit') 2450 TimeUnit=Field{2}.TimeUnit; 2451 end 2452 end 2436 2453 end 2437 2454 % if ~isequal(numel(abstime),1) … … 2441 2458 % abstime_1=[]; 2442 2459 % end 2443 set(handles.abs_time,'String',num2str(abstime,5)) 2444 set(handles.abs_time_1,'String',num2str(abstime_1,5)) 2460 abstime_1=[]; 2461 TimeName_1=get(handles.TimeName_1,'String'); 2462 if ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) 2463 abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file 2464 end 2465 set(handles.TimeValue_1,'String',num2str(abstime_1,5)) 2445 2466 if isempty(dt)||isequal(dt,0) 2446 2467 set(handles.Dt_txt,'String','') … … 2499 2520 2500 2521 %% analyse input field 2501 %test_x=0;2502 %test_z=0;% test for unstructured z coordinate2503 %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure2504 % if ~isempty(errormsg)2505 % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error2506 % return2507 % end2508 2522 [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure 2509 2523 if ~isempty(errormsg) … … 2517 2531 NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates 2518 2532 end 2519 2520 %UvData.Field=get_bounds(UvData.Field);2521 2533 2522 2534 %% get bounds and mesh (needed to propose default options for projection objects) … … 3036 3048 set(handles.SubDir_1,'Visible','off'); 3037 3049 set(handles.NomType_1,'Visible','off'); 3038 set(handles. abs_time_1,'Visible','off')3050 set(handles.TimeValue_1,'Visible','off') 3039 3051 set(handles.FileIndex_1,'Visible','off'); 3040 3052 set(handles.FileExt_1,'Visible','off'); … … 3118 3130 function FieldName_Callback(hObject, eventdata, handles) 3119 3131 %------------------------------------------------------------------------ 3132 3133 %% read data from uvmat 3120 3134 UvData=get(handles.uvmat,'UserData'); 3121 3135 list_fields=get(handles.FieldName,'String');% list menu fields 3122 3136 index_fields=get(handles.FieldName,'Value');% selected string index 3123 3137 field= list_fields{index_fields(1)}; % selected string 3124 3125 %% fill the coordinates and variables from selections in get_field3126 if isequal(field,'get_field...')3127 ParamIn=[];3128 if strcmp(get(handles.VelType,'Visible'),'on')3129 % we use the civ choice as default input3130 ParamIn.SwitchVarIndexTime='attribute';3131 ListVelType=get(handles.VelType,'String');3132 VelType=ListVelType{get(handles.VelType,'Value')};3133 switch VelType3134 case 'civ1'3135 ParamIn.TimeVarName='Civ1_Time';3136 ParamIn.vector_x='Civ1_U';3137 ParamIn.vector_y='Civ1_V';3138 ParamIn.vec_color='Civ1_C';3139 case 'filter1'3140 ParamIn.TimeVarName='Civ1_Time';3141 ParamIn.vector_x='Civ1_U_smooth';3142 ParamIn.vector_y='Civ1_V_smooth';3143 case 'civ2'3144 ParamIn.TimeVarName='Civ2_Time';3145 ParamIn.vector_x='Civ2_U';3146 ParamIn.vector_y='Civ2_V';3147 case 'filter2'3148 ParamIn.TimeVarName='Civ2_Time';3149 ParamIn.vector_x='Civ2_U_smooth';3150 ParamIn.vector_y='Civ2_V_smooth';3151 ParamIn.vec_color='Civ2_C';3152 end3153 end3154 set(handles.FixVelType,'visible','off')3155 set(handles.VelType,'Visible','off')3156 set(handles.VelType_1,'Visible','off')3157 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);3158 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];3159 GetFieldData=get_field(FileName,ParamIn);3160 FieldList={};3161 VecColorList={};3162 XName=GetFieldData.Coordinates.XVarName;3163 switch GetFieldData.FieldOption3164 case 'vectors'3165 UName=GetFieldData.PanelVectors.vector_x;3166 VName=GetFieldData.PanelVectors.vector_y;3167 XName=GetFieldData.Coordinates.XVarName;3168 YName=GetFieldData.Coordinates.YVarName;3169 CName=GetFieldData.PanelVectors.vec_color;3170 [FieldList,VecColorList]=set_field_list(UName,VName,CName);3171 case 'scalar'3172 AName=GetFieldData.PanelScalar.scalar;3173 XName=GetFieldData.Coordinates.XVarName;3174 YName=GetFieldData.Coordinates.YVarName;3175 FieldList={AName};3176 case '1D plot'3177 YName=GetFieldData.CheckPlot1D.ordinate;3178 end3179 set(handles.Coord_x,'String',{XName})3180 set(handles.Coord_y,'String',{YName})3181 set(handles.FieldName,'Value',1)3182 set(handles.FieldName,'String',[FieldList; {'get_field...'}]);3183 set(handles.ColorScalar,'Value',1)3184 set(handles.ColorScalar,'String',VecColorList);3185 UvData.FileType{1}='netcdf';3186 set(handles.uvmat,'UserData',UvData)3187 run0_Callback(hObject, eventdata, handles)3188 return %no further action3189 end3190 3191 3192 3193 %read the rootfile input display3194 3138 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3195 3139 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3196 3140 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3197 if isequal(field,'image') 3198 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3199 imagename=UvData.Field.Civ2_ImageA; 3200 elseif isfield(UvData.Field,'Civ1_ImageA')% 3201 imagename=UvData.Field.Civ1_ImageA; 3202 else 3203 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3204 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3205 end 3206 if ~exist(imagename,'file') 3207 [FileName,PathName] = uigetfile( ... 3208 {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; 3209 '*.jpg',' jpeg image files'; ... 3210 '*.png','.png image files'; ... 3211 '*.tif','.tif image files'; ... 3212 '*.avi;*.AVI','.avi movie files'; ... 3213 '*.vol','.volume images (png)'; ... 3214 '*.*', 'All Files (*.*)'}, ... 3215 'Pick an image',imagename); 3216 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3217 imagename=[PathName FileName]; 3218 end 3219 % display the selected field and related information 3220 display_file_name(handles,imagename)%display the image 3221 return 3222 else 3223 ext=get(handles.FileExt,'String'); 3224 if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file 3225 [FileName,PathName] = uigetfile( ... 3226 {'*.nc', ' (*.nc)'; 3227 '*.nc',' netcdf files'; ... 3228 '*.*', 'All Files (*.*)'}, ... 3229 'Pick a netcdf file',FileBase); 3230 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3231 FullFileName=[PathName FileName]; 3141 3142 switch field 3143 3144 case 'get_field...' 3145 %% fill the coordinates and variables from selections in get_field 3146 ParamIn=[]; 3147 % in case of civ data, we use the civ choice as default input for the GUI get_field 3148 if strcmp(get(handles.VelType,'Visible'),'on') 3149 ParamIn.SwitchVarIndexTime='attribute'; 3150 ListVelType=get(handles.VelType,'String'); 3151 VelType=ListVelType{get(handles.VelType,'Value')}; 3152 switch VelType 3153 case 'civ1' 3154 ParamIn.TimeVarName='Civ1_Time'; 3155 ParamIn.vector_x='Civ1_U'; 3156 ParamIn.vector_y='Civ1_V'; 3157 ParamIn.vec_color='Civ1_C'; 3158 case 'filter1' 3159 ParamIn.TimeVarName='Civ1_Time'; 3160 ParamIn.vector_x='Civ1_U_smooth'; 3161 ParamIn.vector_y='Civ1_V_smooth'; 3162 case 'civ2' 3163 ParamIn.TimeVarName='Civ2_Time'; 3164 ParamIn.vector_x='Civ2_U'; 3165 ParamIn.vector_y='Civ2_V'; 3166 case 'filter2' 3167 ParamIn.TimeVarName='Civ2_Time'; 3168 ParamIn.vector_x='Civ2_U_smooth'; 3169 ParamIn.vector_y='Civ2_V_smooth'; 3170 ParamIn.vec_color='Civ2_C'; 3171 end 3172 end 3173 3174 % VelType menu desactivated 3175 set(handles.FixVelType,'visible','off') 3176 set(handles.VelType,'Visible','off') 3177 set(handles.VelType_1,'Visible','off') 3178 3179 %read selection from get_field 3180 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3181 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3182 GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field 3183 FieldList={}; 3184 VecColorList={}; 3185 XName=GetFieldData.Coordinates.Coord_x; 3186 switch GetFieldData.FieldOption 3187 case 'vectors' 3188 UName=GetFieldData.PanelVectors.vector_x; 3189 VName=GetFieldData.PanelVectors.vector_y; 3190 XName=GetFieldData.Coordinates.Coord_x; 3191 YName={GetFieldData.Coordinates.Coord_y}; 3192 CName=GetFieldData.PanelVectors.vec_color; 3193 [FieldList,VecColorList]=set_field_list(UName,VName,CName); 3194 case 'scalar' 3195 AName=GetFieldData.PanelScalar.scalar; 3196 XName=GetFieldData.Coordinates.Coord_x; 3197 YName={GetFieldData.Coordinates.Coord_y}; 3198 FieldList={AName}; 3199 case '1D plot' 3200 YName=GetFieldData.PanelOrdinate.ordinate; 3201 XName=GetFieldData.Coordinates.Coord_x; 3202 end 3203 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; 3204 if strcmp(TimeNameStr,'file index') 3205 set(handles.TimeName,'String',''); 3206 else 3207 set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]); 3208 end 3209 if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index 3210 set(handles.NomType,'String','*') 3211 set(handles.RootFile,FileName) 3212 end 3213 % set(handles.TimeValue,'String' SwitchVarIndexTime 3214 set(handles.Coord_x,'String',XName) 3215 if ischar(YName) 3216 YName={YName}; 3217 end 3218 set(handles.Coord_y,'Data',YName) 3219 set(handles.FieldName,'Value',1) 3220 set(handles.FieldName,'String',[FieldList; {'get_field...'}]); 3221 set(handles.ColorScalar,'Value',1) 3222 set(handles.ColorScalar,'String',VecColorList); 3223 UvData.FileType{1}='netcdf'; 3224 set(handles.uvmat,'UserData',UvData) 3225 run0_Callback(hObject, eventdata, handles) 3226 3227 case 'image' 3228 %% look for image corresponding to civ data 3229 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3230 imagename=UvData.Field.Civ2_ImageA; 3231 elseif isfield(UvData.Field,'Civ1_ImageA')% 3232 imagename=UvData.Field.Civ1_ImageA; 3233 else 3234 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3235 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3236 end 3237 if ~exist(imagename,'file') 3238 imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); 3239 if isempty(imagename) 3240 return 3241 end 3242 end 3232 3243 % display the selected field and related information 3233 display_file_name( handles,FullFileName) 3234 return 3235 end 3236 end 3237 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); 3238 set(handles.FileIndex,'String',indices) 3239 3240 %common to Fields_1_Callback 3241 list_fields_1=get(handles.FieldName_1,'String');% list menu fields 3242 field_1=''; 3243 if ~isempty(list_fields_1) 3244 field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string 3245 end 3246 if isequal(field,'image')||isequal(field_1,'image') 3247 set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons 3248 set(handles.num_Npx,'Visible','on') 3249 set(handles.num_Npy,'Visible','on') 3250 else 3251 set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons 3252 set(handles.num_Npx,'Visible','off') 3253 set(handles.num_Npy,'Visible','off') 3254 end 3255 if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) 3256 run0_Callback(hObject, eventdata, handles) 3257 end 3244 display_file_name(handles,imagename)%display the image 3245 % otherwise 3246 % ext=get(handles.FileExt,'String'); 3247 % if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file 3248 % [FileName,PathName] = uigetfile( ... 3249 % {'*.nc', ' (*.nc)'; 3250 % '*.nc',' netcdf files'; ... 3251 % '*.*', 'All Files (*.*)'}, ... 3252 % 'Pick a netcdf file',FileBase); 3253 % if ~ischar(FileName),return,end %abandon if the browser is cancelled 3254 % FullFileName=[PathName FileName]; 3255 % % display the selected field and related information 3256 % display_file_name( handles,FullFileName) 3257 % return 3258 % end 3259 end 3260 % indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); 3261 % set(handles.FileIndex,'String',indices) 3262 % 3263 % %common to Fields_1_Callback 3264 % list_fields_1=get(handles.FieldName_1,'String');% list menu fields 3265 % field_1=''; 3266 % if ~isempty(list_fields_1) 3267 % field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string 3268 % end 3269 % if isequal(field,'image')||isequal(field_1,'image') 3270 % set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons 3271 % set(handles.num_Npx,'Visible','on') 3272 % set(handles.num_Npy,'Visible','on') 3273 % else 3274 % set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons 3275 % set(handles.num_Npx,'Visible','off') 3276 % set(handles.num_Npy,'Visible','off') 3277 % end 3278 % if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) 3279 % run0_Callback(hObject, eventdata, handles) 3280 % end 3258 3281 3259 3282 %---------------------------------------------------------------- … … 3261 3284 function FieldName_1_Callback(hObject, eventdata, handles) 3262 3285 %------------------------------------------------- 3286 3287 %%%%%% TODO: modify like FieldName_Callback 3263 3288 %% read input data 3264 3289 check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered … … 3664 3689 end 3665 3690 if strcmp(transform_name,'more...'); 3666 [FileName, PathName] = uigetfile( ... 3667 {'*.m', ' (*.m)'; 3668 '*.m', '.m files '; ... 3669 '*.*', 'All Files (*.*)'}, ... 3670 'Pick the transform function', prev_path); 3671 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3672 path_transform_fct =fullfile(PathName,FileName); 3673 if isempty(regexp(FileName,'\.m$'))% detect file extension .m 3674 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 3675 return 3676 else 3677 transform_name=regexprep(FileName,'\.m',''); 3678 end 3679 ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu 3680 if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) 3681 menu=[menu(1:end-1);{transform_name};{'more...'}]; 3682 ichoice=numel(menu)-1; 3683 end 3684 list_path{ichoice}=PathName;%update the list fo fct paths 3685 set(handles.TransformName,'String',menu) 3686 set(handles.TransformName,'Value',ichoice) 3687 3688 % save the new menu in the personal file 'uvmat_perso.mat' 3689 dir_perso=prefdir;%personal Matalb directory 3690 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 3691 if exist(profil_perso,'file') 3692 nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat 3693 if nb_builtin<numel(list_path) 3694 for ilist=nb_builtin+1:numel(list_path) 3695 transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; 3696 end 3697 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 3691 transform_fct=uigetfile_uvmat('Pick the transform function',prev_path,'.m'); 3692 % [FileName, PathName] = uigetfile( ... 3693 % {'*.m', ' (*.m)'; 3694 % '*.m', '.m files '; ... 3695 % '*.*', 'All Files (*.*)'}, ... 3696 % 'Pick the transform function', prev_path); 3697 % if ~ischar(FileName),return,end %abandon if the browser is cancelled 3698 % path_transform_fct =fullfile(PathName,FileName); 3699 if ~isempty(transform_fct) 3700 [PathName,transform_name]=fileparts(transform_fct); 3701 % if isempty(regexp(FileName,'\.m$'))% detect file extension .m 3702 % msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 3703 % return 3704 % else 3705 % transform_name=regexprep(FileName,'\.m',''); 3706 % end 3707 ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu 3708 if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) 3709 menu=[menu(1:end-1);{transform_name};{'more...'}]; 3710 ichoice=numel(menu)-1; 3711 end 3712 list_path{ichoice}=PathName;%update the list fo fct paths 3713 set(handles.TransformName,'String',menu) 3714 set(handles.TransformName,'Value',ichoice) 3715 3716 % save the new menu in the personal file 'uvmat_perso.mat' 3717 dir_perso=prefdir;%personal Matalb directory 3718 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 3719 if exist(profil_perso,'file') 3720 nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat 3721 if nb_builtin<numel(list_path) 3722 for ilist=nb_builtin+1:numel(list_path) 3723 transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; 3724 end 3725 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 3726 end 3698 3727 end 3699 3728 end … … 4460 4489 hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface 4461 4490 list_str=get(hlist_object,'String');%objet list 4462 % if isequal(floor(hObject),hObject) %case of an index 4463 if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj 4464 if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') 4465 hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 4491 if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj 4492 if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') 4493 hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 4494 for iview=1:length(hdisplay) 4495 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4496 ObjectData=get(hdisplay(iview),'UserData'); 4497 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject) 4498 delete(ObjectData.SubObject); 4499 end 4500 if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint) 4501 delete(ObjectData.DeformPoint); 4502 end 4503 delete(hdisplay(iview)) 4504 end 4505 ishandle(hdisplay(iview)) 4506 end 4507 for iobj=IndexObj+1:length(UvData.ProjObject) 4508 hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; 4466 4509 for iview=1:length(hdisplay) 4467 4510 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4468 ObjectData=get(hdisplay(iview),'UserData'); 4469 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject) 4470 delete(ObjectData.SubObject); 4471 end 4472 if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint) 4473 delete(ObjectData.DeformPoint); 4474 end 4475 delete(hdisplay(iview)) 4476 end 4477 ishandle(hdisplay(iview)) 4478 end 4479 for iobj=IndexObj+1:length(UvData.ProjObject) 4480 hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; 4481 for iview=1:length(hdisplay) 4482 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4483 PlotData=get(hdisplay(iview),'UserData'); 4484 PlotData.IndexObj=iobj-1; 4485 set(hdisplay(iview),'UserData',PlotData); 4486 end 4511 PlotData=get(hdisplay(iview),'UserData'); 4512 PlotData.IndexObj=iobj-1; 4513 set(hdisplay(iview),'UserData',PlotData); 4487 4514 end 4488 4515 end 4489 4516 end 4490 UvData.ProjObject(IndexObj)=[]; 4491 if ~isempty(list_str) 4492 list_str(IndexObj)=[]; 4493 end 4494 end 4495 % elseif ishandle(hObject)%object handle 4496 % userdata=get(hObject,'UserData'); 4497 % if ishandle(userdata)%the selected line depends on a parent line 4498 % hdisplay=userdata;% the parent object becomes the current one 4499 % else 4500 % hdisplay=hObject;% the selected object becomes the current one 4501 % end 4502 % PlotData=get(hdisplay,'UserData'); 4503 % if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject) 4504 % delete(PlotData.SubObject); 4505 % end 4506 % if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint) 4507 % delete(PlotData.DeformPoint); 4508 % end 4509 % delete(hdisplay); 4510 % if isfield(PlotData,'IndexObj') 4511 % IndexObj=PlotData.IndexObj; 4512 % if isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj 4513 % if isfield(UvData,'ProjObject')& length(UvData.ProjObject) > IndexObj 4514 % UvData.ProjObject(IndexObj)=[]; 4515 % end 4516 % list_str(IndexObj)=[]; 4517 % end 4518 % end 4519 % end 4517 end 4518 UvData.ProjObject(IndexObj)=[]; 4519 if ~isempty(list_str) 4520 list_str(IndexObj)=[]; 4521 end 4522 end 4520 4523 set(huvmat,'UserData',UvData); 4521 4524 set(hlist_object,'String',list_str) … … 4677 4680 ylim=get(newaxes,'YLim'); 4678 4681 set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) 4679 time_str=get(handles. abs_time,'String');4682 time_str=get(handles.TimeValue,'String'); 4680 4683 set(htitle,'String',['t=' time_str]) 4681 4684 set(handles.speed,'Value',1) … … 4684 4687 runpm(hObject,eventdata,handles,increment)% run plus 4685 4688 drawnow 4686 time_str=get(handles. abs_time,'String');4689 time_str=get(handles.TimeValue,'String'); 4687 4690 if ishandle(htitle) 4688 4691 set(htitle,'String',['t=' time_str]) … … 4797 4800 end 4798 4801 4799 %% append a new line to the list of projection objects A METTRE PLUS TARD 4800 % ListObject=get(handles.ListObject,'String'); 4801 % if isempty(ListObject) 4802 % ListObject={''}; 4803 % end 4804 % if ~strcmp(ListObject{end},'') 4805 % ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object 4806 % set(handles.ListObject,'String',ListObject) 4807 % end 4808 % IndexObj=length(ListObject); 4809 % set(handles.ListObject,'Value',IndexObj) 4802 %% initiate the new projection object 4810 4803 UvData=get(handles.uvmat,'UserData'); 4811 % UvData.ProjObject{IndexObj}=[]; %create a new empty object4812 % UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object4813 % UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation4814 % set(handles.uvmat,'UserData',UvData)4815 4816 %% initiate the new projection object4817 4804 data.Name=data.Type;% default name=type 4818 4805 data.Coord=[0 0]; %default … … 4843 4830 hchild=get(hset_object,'children'); 4844 4831 set(hchild,'enable','on') 4845 4846 4847 set(handles.delete_object,'Visible','on') 4832 set(handles.delete_object,'Visible','on')% make the object delete button visible 4848 4833 4849 4834 %------------------------------------------------------------------------ … … 5393 5378 set(handles.Slider1,'Visible','on') 5394 5379 set(handles.Slider2,'Visible','on') 5395 %ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1;5396 %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2;5397 % ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1;5398 %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2;5399 5380 set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3)) 5400 5381 set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3)) … … 5417 5398 5418 5399 5419 5420 function time_var_1_Callback(hObject, eventdata, handles)5421 % hObject handle to time_var_1 (see GCBO)5422 % eventdata reserved - to be defined in a future version of MATLAB5423 % handles structure with handles and user data (see GUIDATA)5424 5425 % Hints: get(hObject,'String') returns contents of time_var_1 as text5426 % str2double(get(hObject,'String')) returns contents of time_var_1 as a double5427 5428 5429 % --- Executes during object creation, after setting all properties.5430 function time_var_1_CreateFcn(hObject, eventdata, handles)5431 % hObject handle to time_var_1 (see GCBO)5432 % eventdata reserved - to be defined in a future version of MATLAB5433 % handles empty - handles not created until after all CreateFcns called5434 5435 % Hint: edit controls usually have a white background on Windows.5436 % See ISPC and COMPUTER.5437 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))5438 set(hObject,'BackgroundColor','white');5439 end
Note: See TracChangeset
for help on using the changeset viewer.