Changeset 389 for trunk/src/uvmat.m


Ignore:
Timestamp:
Apr 8, 2012, 11:11:38 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected: object managing, tps filter...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r388 r389  
    4242%           .NewSeries: =1 when the first view of a new field series is displayed, else 0
    4343%           .filename:(char string)
    44 %           .VelType:(char string) type of velocity field selected
    45 %           .VelType_1:(char string)  REMPLACER LE CELL ACTUEL
    4644%           .FieldName: (char string) main field selected('image', 'velocity'...)
    47 %           .FieldName_1:(char string) second field selected('image', 'velocity'...)
    4845%           .CName: (char string)name of the scalar used for vector colors
    4946%          .MovieObject{1}: movie object representing an input movie
    5047%          .MovieObject{2}: idem for a second input series (_1)
    5148%          .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 series
    53 %          .FieldName_1: last field name(velocity, vorticity...) for the second input series
    5449%          .ZMin, .ZMax: range of the z coordinate
    5550%..... to complement
     
    18921887set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    18931888drawnow
    1894 %filename=read_file_boxes(handles);
    18951889[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    18961890filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     
    18991893    [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    19001894    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    1901    % filename_1=read_file_boxes_1(handles);
    19021895end
    19031896num_i1=stra2num(get(handles.i1,'String'));
     
    19831976            FieldName= list_fields{index_fields}; % selected field
    19841977            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.
    19881982                end
    19891983            end
     
    20432037        case {'civx','civdata','netcdf'};
    20442038            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
    20472040            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.
    20512045                end
    20522046            end
     
    20742068    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    20752069    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);
    20782072        end
    20792073    end
    20802074    if test_keepdata_1
    2081         Field{2}=UvData.Field_1;
     2075        Field{2}=UvData.Field_1;% keep the stored field
    20822076    else
    20832077        ParamIn.FieldName=FieldName_1;
     
    21362130    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
    21372131else
    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...')
    21392133        set(handles.VelType_1,'Visible','off')
    21402134    else
     
    21622156if  UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
    21632157        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'
    21652158        set(handles.RootPath_1,'String','"')
    21662159        set(handles.RootFile_1,'String','"')
    21672160        set(handles.SubDir_1,'String','"');
    21682161         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,'');
    21702162        set(handles.FileIndex_1,'String',indices)
    21712163        set(handles.FileExt_1,'String','"');
     
    21832175%% store the current open names, fields and vel types in uvmat interface
    21842176UvData.filename_1=filename_1;
    2185 UvData.VelType_1=[];%default
    2186 UvData.FieldName_1=[];
    2187 if isfield(ParamOut_1,VelType)
    2188     UvData.VelType_1=ParamOut_1.VelType;
    2189 end
    2190 if isfield(ParamOut_1,FieldName)
    2191     UvData.FieldName_1=ParamOut_1.FieldName;
    2192 end
    21932177
    21942178%% apply coordinate transform or other user fct
     
    22092193end
    22102194%px to phys or other transform on field
    2211 if ~isempty(transform) 
     2195if ~isempty(transform)
    22122196    if length(Field)>=2
    22132197        Field{2}.ZIndex=z_index;
     
    22192203        Field{1}=transform(Field{1},XmlData);
    22202204    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
    22272223end
    22282224
    22292225%% 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);
     2226if (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);
     2228end
     2229if 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);
    22392231end
    22402232
     
    23872379    end
    23882380else
    2389     % create a default projection
    2390     UvData.Object{1}.ProjMode='projection';%main plotting plane
    2391     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
    2392     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     end
    2399     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);
    24012393end
    24022394testnewseries=UvData.NewSeries;
     
    27832775var_FixFlag(1:nb_vectors)=AxeData.FF;%
    27842776fin=close(nc);
    2785 
    2786 %-------------------------------------------------------------------
    2787 %determines the fields to read from the interface
    2788 %------------------------------------------------------------------
    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 iinterface
    2796 %------------------------------------------------------------------
    2797 function VelType=setfield_1(handles)
    2798 VelTypeList=get(handles.VelType_1,'String');
    2799 index=get(handles.VelType_1,'Value');
    2800 VelType=VelTypeList{index};
    28012777
    28022778%---------------------------------------------------
     
    29662942    set(handles.num_Npy,'Visible','off')
    29672943end
    2968 setfield(handles);% update the field structure ('civ1'....)
    29692944if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    29702945    run0_Callback(hObject, eventdata, handles)
     
    29802955if check_new && isfield(UvData,'XmlData')
    29812956    UvData.XmlData{2}=UvData.XmlData{1};
     2957end
     2958if isfield(UvData,'Field_1')
     2959    UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read)
    29822960end
    29832961list_fields=get(handles.Fields,'String');% list menu fields
     
    30623040        end
    30633041        set(handles.uvmat,'UserData',UvData)
    3064         setfield(handles);% update the field structure ('civ1'....)
     3042%         setfield(handles);% update the field structure ('civ1'....)
    30653043        if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    30663044            run0_Callback(hObject, eventdata, handles)
     
    30723050function menu=set_veltype_display(Civ,FileType)
    30733051%------------------------------------------------------------------------
    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) %patch2
    3083     imax=6;
    3084 end
    30853052if ~exist('FileType','var')
    30863053    FileType='civx';
     
    30883055switch FileType
    30893056    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
    30913069    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
     3082end
     3083
     3084
     3085
    30943086menu=menu(1:imax);
    30953087
     
    31073099 
    31083100set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
     3101UvData=get(handles.uvmat,'UserData');
    31093102%refresh field with a second filename=first fiel name
    31103103set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
     
    31133106[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    31143107filename=[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')};
     3110if isempty(InputFile.VelType_1)
    31193111        filename_1='';% we plot the current field without the second field
    31203112        set(handles.SubField,'Value',0)
     
    31233115      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    31243116     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;
    31263118else
    31273119     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;
    31283122     set(handles.SubField,'Value',1)
    31293123end
    3130 
     3124if isfield(UvData,'Field_1')
     3125    UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists
     3126end
     3127set(handles.uvmat,'UserData',UvData)
    31313128num_i1=stra2num(get(handles.i1,'String'));
    31323129num_i2=stra2num(get(handles.i2,'String'));
     
    44564453
    44574454%read the file
    4458 % t=xmltree(fileinput);
    4459 % data=convert(t);
    44604455data=xml2struct(fileinput);
    44614456data.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);
    44644458hset_object=findobj(allchild(0),'tag','set_object');
    44654459if ~isempty(hset_object)
     
    44904484set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    44914485data.enable_plot=1;
    4492 transform_list=get(handles.transform_fct,'String');
    4493 val=get(handles.transform_fct,'Value');
    4494 %data.CoordType=transform_list{val};
    44954486data.Coord=[0 0]; %default
    44964487if isfield(UvData,'Field')
    44974488    Field=UvData.Field;
    44984489    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;
    45034502    elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
    45044503        np=size(Field.A);
     
    45164515    end
    45174516end
    4518 % if isfield(data,'Type') && isequal(data.Type,'line')
    4519 %     if isfield(data,'DX')
    4520 %         data.Coord=[[0 0 0];[data.DX 0 0]]; %default
    4521 %     else
    4522 %         data.Coord=[[0 0 0];[1 0 0]]; %default
    4523 %     end
    4524 % end
    45254517if ishandle(handles.UVMAT_title)
    45264518    delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
    45274519end
    4528 %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    45294520set_object(data,handles);% call the set_object interface
    45304521set(handles.MenuObject,'checked','on')
     
    45334524CheckZoom_Callback(handles.uvmat, [], handles)
    45344525set(handles.delete_object,'Visible','on')
    4535 % set(handles._title,'Visible','on')
    4536 % set(handles.view_field_title,'Visible','on')
    45374526
    45384527%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.