Changeset 389 for trunk/src/uvmat.m
- Timestamp:
- Apr 8, 2012, 11:11:38 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r388 r389 42 42 % .NewSeries: =1 when the first view of a new field series is displayed, else 0 43 43 % .filename:(char string) 44 % .VelType:(char string) type of velocity field selected45 % .VelType_1:(char string) REMPLACER LE CELL ACTUEL46 44 % .FieldName: (char string) main field selected('image', 'velocity'...) 47 % .FieldName_1:(char string) second field selected('image', 'velocity'...)48 45 % .CName: (char string)name of the scalar used for vector colors 49 46 % .MovieObject{1}: movie object representing an input movie 50 47 % .MovieObject{2}: idem for a second input series (_1) 51 48 % .filename_1 : last second input file name (to deal with a constant second input without reading again the file) 52 % .VelType_1: last velocity type (VelType, civ2...) for the second input series53 % .FieldName_1: last field name(velocity, vorticity...) for the second input series54 49 % .ZMin, .ZMax: range of the z coordinate 55 50 %..... to complement … … 1892 1887 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow 1893 1888 drawnow 1894 %filename=read_file_boxes(handles);1895 1889 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 1896 1890 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; … … 1899 1893 [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); 1900 1894 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; 1901 % filename_1=read_file_boxes_1(handles);1902 1895 end 1903 1896 num_i1=stra2num(get(handles.i1,'String')); … … 1983 1976 FieldName= list_fields{index_fields}; % selected field 1984 1977 if ~strcmp(FieldName,'get_field...') 1985 TestVelType=get(handles.FixVelType,'Value'); 1986 if TestVelType 1987 VelType=setfield(handles);% read the velocity type. 1978 if get(handles.FixVelType,'Value') 1979 VelTypeList=get(handles.VelType,'String'); 1980 VelType=VelTypeList{get(handles.VelType,'Value')}; 1981 % VelType=setfield(handles);% read the velocity type. 1988 1982 end 1989 1983 end … … 2043 2037 case {'civx','civdata','netcdf'}; 2044 2038 list_fields=get(handles.Fields_1,'String');% list menu fields 2045 index_fields=get(handles.Fields_1,'Value');% selected string index 2046 FieldName_1= list_fields{index_fields}; % selected field 2039 FieldName_1= list_fields{get(handles.Fields_1,'Value')}; % selected field 2047 2040 if ~strcmp(FieldName,'get_field...') 2048 TestVelType=get(handles.FixVelType,'Value'); 2049 if TestVelType 2050 VelType_1=setfield(handles);% read the velocity type. 2041 if get(handles.FixVelType,'Value') 2042 VelTypeList=get(handles.VelType_1,'String'); 2043 VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. 2044 % VelType_1=setfield(handles);% read the velocity type. 2051 2045 end 2052 2046 end … … 2074 2068 test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged 2075 2069 if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie) 2076 if isfield(UvData,'filename_1') && isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')2077 test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1)&& strcmp(FieldName_1,UvData.FieldName_1);2070 if isfield(UvData,'filename_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1') 2071 test_keepdata_1= strcmp(filename_1,UvData.filename_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1); 2078 2072 end 2079 2073 end 2080 2074 if test_keepdata_1 2081 Field{2}=UvData.Field_1; 2075 Field{2}=UvData.Field_1;% keep the stored field 2082 2076 else 2083 2077 ParamIn.FieldName=FieldName_1; … … 2136 2130 set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu 2137 2131 else 2138 if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')2132 if (~strcmp(FileType_1,'netcdf')&&~strcmp(FileType_1,'civdata')&&~strcmp(FileType_1,'civx'))|| isequal(FieldName_1,'get_field...') 2139 2133 set(handles.VelType_1,'Visible','off') 2140 2134 else … … 2162 2156 if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); 2163 2157 set(handles.SubField,'Value',1); 2164 %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'2165 2158 set(handles.RootPath_1,'String','"') 2166 2159 set(handles.RootFile_1,'String','"') 2167 2160 set(handles.SubDir_1,'String','"'); 2168 2161 indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); 2169 %[indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');2170 2162 set(handles.FileIndex_1,'String',indices) 2171 2163 set(handles.FileExt_1,'String','"'); … … 2183 2175 %% store the current open names, fields and vel types in uvmat interface 2184 2176 UvData.filename_1=filename_1; 2185 UvData.VelType_1=[];%default2186 UvData.FieldName_1=[];2187 if isfield(ParamOut_1,VelType)2188 UvData.VelType_1=ParamOut_1.VelType;2189 end2190 if isfield(ParamOut_1,FieldName)2191 UvData.FieldName_1=ParamOut_1.FieldName;2192 end2193 2177 2194 2178 %% apply coordinate transform or other user fct … … 2209 2193 end 2210 2194 %px to phys or other transform on field 2211 if ~isempty(transform) 2195 if ~isempty(transform) 2212 2196 if length(Field)>=2 2213 2197 Field{2}.ZIndex=z_index; … … 2219 2203 Field{1}=transform(Field{1},XmlData); 2220 2204 end 2221 end 2222 2223 2224 %% update tps in phys coordinates if needed 2225 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') 2226 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],1500,0); 2205 %% update tps in phys coordinates if needed 2206 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') 2207 Field{1}.X=Field{1}.X(Field{1}.FF==0); 2208 Field{1}.Y=Field{1}.Y(Field{1}.FF==0); 2209 Field{1}.U=Field{1}.U(Field{1}.FF==0); 2210 Field{1}.V=Field{1}.V(Field{1}.FF==0); 2211 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0); 2212 end 2213 if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) 2214 %update tps in phys coordinates if needed 2215 if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') 2216 Field{2}.X=Field{2}.X(Field{2}.FF==0); 2217 Field{2}.Y=Field{1}.Y(Field{2}.FF==0); 2218 Field{2}.U=Field{1}.U(Field{2}.FF==0); 2219 Field{2}.V=Field{1}.V(Field{2}.FF==0); 2220 [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0); 2221 end 2222 end 2227 2223 end 2228 2224 2229 2225 %% calculate scalar 2230 if strcmp(FileType(1:3),'civ') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)% 2231 Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1},VelType); 2232 end 2233 if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) 2234 %update tps in phys coordinates if needed 2235 if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') 2236 [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0); 2237 end 2238 Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2},VelType_1); 2226 if (strcmp(FileType,'civdata')||strcmp(FileType,'civx'))&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)% 2227 Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1},ParamOut.VelType); 2228 end 2229 if numel(Field)==2 && ~test_keepdata_1 && (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') 2230 Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2},ParamOut_1.VelType); 2239 2231 end 2240 2232 … … 2387 2379 end 2388 2380 else 2389 % create a default projection2390 UvData.Object{1}.ProjMode='projection';%main plotting plane2391 UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat2392 set(handles.ListObject,'Value',1);2393 list_object=get(handles.ListObject,'String');2394 if isempty(list_object)2395 list_object={''};2396 elseif ~isempty(list_object{1})2397 list_object=[{''};list_object];2398 end2399 set(handles.ListObject,'String',list_object);2400 % set(handles.list_object_2,'String',list_object);2381 % % create a default projection 2382 % UvData.Object{1}.ProjMode='projection';%main plotting plane 2383 % UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat 2384 % set(handles.ListObject,'Value',1); 2385 % list_object=get(handles.ListObject,'String'); 2386 % if isempty(list_object) 2387 % list_object={''}; 2388 % elseif ~isempty(list_object{1}) 2389 % list_object=[{''};list_object]; 2390 % end 2391 % set(handles.ListObject,'String',list_object); 2392 % % set(handles.list_object_2,'String',list_object); 2401 2393 end 2402 2394 testnewseries=UvData.NewSeries; … … 2783 2775 var_FixFlag(1:nb_vectors)=AxeData.FF;% 2784 2776 fin=close(nc); 2785 2786 %-------------------------------------------------------------------2787 %determines the fields to read from the interface2788 %------------------------------------------------------------------2789 function VelType=setfield(handles)2790 VelTypeList=get(handles.VelType,'String');2791 index=get(handles.VelType,'Value');2792 VelType=VelTypeList{index};2793 2794 %-------------------------------------------------------------------2795 %determines the veltype of the second field to read from the iinterface2796 %------------------------------------------------------------------2797 function VelType=setfield_1(handles)2798 VelTypeList=get(handles.VelType_1,'String');2799 index=get(handles.VelType_1,'Value');2800 VelType=VelTypeList{index};2801 2777 2802 2778 %--------------------------------------------------- … … 2966 2942 set(handles.num_Npy,'Visible','off') 2967 2943 end 2968 setfield(handles);% update the field structure ('civ1'....)2969 2944 if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) 2970 2945 run0_Callback(hObject, eventdata, handles) … … 2980 2955 if check_new && isfield(UvData,'XmlData') 2981 2956 UvData.XmlData{2}=UvData.XmlData{1}; 2957 end 2958 if isfield(UvData,'Field_1') 2959 UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) 2982 2960 end 2983 2961 list_fields=get(handles.Fields,'String');% list menu fields … … 3062 3040 end 3063 3041 set(handles.uvmat,'UserData',UvData) 3064 setfield(handles);% update the field structure ('civ1'....)3042 % setfield(handles);% update the field structure ('civ1'....) 3065 3043 if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) 3066 3044 run0_Callback(hObject, eventdata, handles) … … 3072 3050 function menu=set_veltype_display(Civ,FileType) 3073 3051 %------------------------------------------------------------------------ 3074 if isequal(Civ,0)3075 imax=0;3076 elseif isequal(Civ,1) || isequal(Civ,2)3077 imax=1;3078 elseif isequal(Civ,3)3079 imax=3;3080 elseif isequal(Civ,4) || isequal(Civ,5)3081 imax=4;3082 elseif isequal(Civ,6) %patch23083 imax=6;3084 end3085 3052 if ~exist('FileType','var') 3086 3053 FileType='civx'; … … 3088 3055 switch FileType 3089 3056 case 'civx' 3090 menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; 3057 menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; 3058 if isequal(Civ,0) 3059 imax=0; 3060 elseif isequal(Civ,1) || isequal(Civ,2) 3061 imax=1; 3062 elseif isequal(Civ,3) 3063 imax=3; 3064 elseif isequal(Civ,4) || isequal(Civ,5) 3065 imax=4; 3066 elseif isequal(Civ,6) %patch2 3067 imax=6; 3068 end 3091 3069 case 'civdata' 3092 menu={'civ1';'civ-filter1';'filter1';'civ2';'civ-filter2';'filter2'}; 3093 end 3070 menu={'civ1';'filter1';'civ2';'filter2'}; 3071 if isequal(Civ,0) 3072 imax=0; 3073 elseif isequal(Civ,1) || isequal(Civ,2) 3074 imax=1; 3075 elseif isequal(Civ,3) 3076 imax=2; 3077 elseif isequal(Civ,4) || isequal(Civ,5) 3078 imax=3; 3079 elseif isequal(Civ,6) %patch2 3080 imax=4; 3081 end 3082 end 3083 3084 3085 3094 3086 menu=menu(1:imax); 3095 3087 … … 3107 3099 3108 3100 set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) 3101 UvData=get(handles.uvmat,'UserData'); 3109 3102 %refresh field with a second filename=first fiel name 3110 3103 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow … … 3113 3106 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3114 3107 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3115 %filename=read_file_boxes(handles); 3116 3117 index=get(handles.VelType_1,'Value'); 3118 if index==1 3108 % VelTypeList=get(handles.VelType_1,'String'); 3109 % VelType_1=VelTypeList{get(handles.VelType_1,'Value')}; 3110 if isempty(InputFile.VelType_1) 3119 3111 filename_1='';% we plot the current field without the second field 3120 3112 set(handles.SubField,'Value',0) … … 3123 3115 [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); 3124 3116 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; 3125 %filename_1=read_file_boxes_1(handles); %read the current second field 3117 % UvData.VelType{2}=InputFile.VelType_1; 3126 3118 else 3127 3119 filename_1=filename;% we compare two fields in the same file 3120 UvData.FileType{2}=UvData.FileType{1}; 3121 % UvData.VelType{2}=InputFile.VelType_1; 3128 3122 set(handles.SubField,'Value',1) 3129 3123 end 3130 3124 if isfield(UvData,'Field_1') 3125 UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists 3126 end 3127 set(handles.uvmat,'UserData',UvData) 3131 3128 num_i1=stra2num(get(handles.i1,'String')); 3132 3129 num_i2=stra2num(get(handles.i2,'String')); … … 4456 4453 4457 4454 %read the file 4458 % t=xmltree(fileinput);4459 % data=convert(t);4460 4455 data=xml2struct(fileinput); 4461 4456 data.enable_plot=1; 4462 [pp,data.Name]=fileparts(FileName); 4463 %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4457 [tild,data.Name]=fileparts(FileName); 4464 4458 hset_object=findobj(allchild(0),'tag','set_object'); 4465 4459 if ~isempty(hset_object) … … 4490 4484 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4491 4485 data.enable_plot=1; 4492 transform_list=get(handles.transform_fct,'String');4493 val=get(handles.transform_fct,'Value');4494 %data.CoordType=transform_list{val};4495 4486 data.Coord=[0 0]; %default 4496 4487 if isfield(UvData,'Field') 4497 4488 Field=UvData.Field; 4498 4489 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 4499 data.RangeX=Field.Mesh; 4500 data.RangeY=Field.Mesh; 4501 data.DX=Field.Mesh; 4502 data.DY=Field.Mesh; 4490 ord=10^(floor(log10(Field.Mesh)));%order of magnitude 4491 if Field.Mesh/ord>=5 4492 mesh=5*ord; 4493 elseif Field.Mesh/ord>=2 4494 mesh=2*ord; 4495 else 4496 mesh=ord; 4497 end 4498 data.RangeX=mesh; 4499 data.RangeY=mesh; 4500 data.DX=mesh; 4501 data.DY=mesh; 4503 4502 elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image 4504 4503 np=size(Field.A); … … 4516 4515 end 4517 4516 end 4518 % if isfield(data,'Type') && isequal(data.Type,'line')4519 % if isfield(data,'DX')4520 % data.Coord=[[0 0 0];[data.DX 0 0]]; %default4521 % else4522 % data.Coord=[[0 0 0];[1 0 0]]; %default4523 % end4524 % end4525 4517 if ishandle(handles.UVMAT_title) 4526 4518 delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered 4527 4519 end 4528 %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters4529 4520 set_object(data,handles);% call the set_object interface 4530 4521 set(handles.MenuObject,'checked','on') … … 4533 4524 CheckZoom_Callback(handles.uvmat, [], handles) 4534 4525 set(handles.delete_object,'Visible','on') 4535 % set(handles._title,'Visible','on')4536 % set(handles.view_field_title,'Visible','on')4537 4526 4538 4527 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.