Changeset 648 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jun 9, 2013, 10:31:58 PM (11 years ago)
Author:
sommeria
Message:

get_field updated, several bugs corrected,open_uvmat suppressd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r646 r648  
    518518SubDir=get(handles.SubDir,'String');
    519519fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir));
     520
    520521if ~isempty(fileinput_1)
    521     % [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);
    522     % if ~ischar(FileName),return,end %abandon if the browser is cancelled
    523     % fileinput_1=[PathName FileName];%complete file name
    524522   
    525523    % refresh the current displayed field
     
    720718end
    721719
     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]);
     725if strcmp(FileType,'txt')
     726    edit(fileinput)
     727    return
     728elseif strcmp(FileType,'xml')
     729    editxml(fileinput)
     730     return
     731elseif strcmp(FileType,'figure')
     732    open(fileinput)
     733     return
     734end
     735
    722736%% set the mouse pointer to 'watch'
    723737set(handles.uvmat,'Pointer','watch')
     
    750764    set(handles.NomType_1,'Visible','on');
    751765end
    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 exists
    757 [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]);
    758766
    759767%% open the file or fill the GUI uvmat according to the detected file type
     
    945953    end
    946954    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
    947960    ColorType='truecolor';
    948961elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
     
    10121025    end
    10131026end
    1014 if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time))
     1027if (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
     1033else
    10151034    XmlData.Time=Time; %time set by video
    10161035end
     
    10211040end
    10221041
    1023 %% store last index in handles.lat_i and .last_j
     1042%% store last index in handles.MaxIndex_i and .MaxIndex_j
    10241043nbfield=max(max(max(i2_series)));
    10251044if isempty(nbfield)
     
    10331052    %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    10341053    if isequal(size(XmlData.Time,1),1)
    1035         %NomType=get(handles.NomType,'String');
    10361054        XmlData.Time=(XmlData.Time)';
    10371055    end
    10381056end
    1039 last_i_cell=get(handles.last_i,'String');
     1057last_i_cell=get(handles.MaxIndex_i,'String');
    10401058if isempty(nbfield)
    10411059    last_i_cell{index}='';
     
    10431061    last_i_cell{index}=num2str(nbfield);
    10441062end
    1045 set(handles.last_i,'String',last_i_cell)
    1046 last_j_cell=get(handles.last_j,'String');
     1063set(handles.MaxIndex_i,'String',last_i_cell)
     1064last_j_cell=get(handles.MaxIndex_j,'String');
    10471065if isempty(nbfield_j)
    10481066     last_j_cell{index}='';
     
    10501068     last_j_cell{index}=num2str(nbfield_j);
    10511069end
    1052 set(handles.last_j,'String',last_j_cell);
     1070set(handles.MaxIndex_j,'String',last_j_cell);
    10531071
    10541072%% store geometric calibration in UvData
     
    10931111%% update the data attached to the uvmat interface
    10941112if ~isempty(TimeUnit)
    1095     set(handles.time_var,'String',['time (' TimeUnit ')'])
     1113    set(handles.TimeName,'String',['time (' TimeUnit ')'])
    10961114end
    10971115UvData.TimeUnit=TimeUnit;
    10981116UvData.XmlData{index}=XmlData;
    10991117UvData.NewSeries=1;
    1100 % UvData.MovieObject=MovieObject;
    11011118
    11021119%display warning message
     
    11791196set(handles.j1,'Visible',state_j)
    11801197set(handles.j2,'Visible',state_j)
    1181 set(handles.last_j,'Visible',state_j);
     1198set(handles.MaxIndex_j,'Visible',state_j);
    11821199%set(handles.frame_j,'Visible',state_j);
    11831200set(handles.j_text,'Visible',state_j);
     
    13771394            end
    13781395        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);
    13941414else % desactivate mask display
    13951415    MaskData=get(handles.CheckMask,'UserData');
     
    21532173    ParamIn.FieldName=FieldName;
    21542174    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');
    21602176    ParamIn.Coord_y=get(handles.Coord_y,'Data');
    2161 %     if ~isempty(YNameMenu)
    2162 %         ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value'));
    2163 %     end
    21642177end
    21652178check_tps = 0;         
     
    21762189    set(handles.num_Npy,'String',num2str(ParamOut.Npy));
    21772190end
    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
    21842198Field{1}.ZIndex=z_index; %used for multiplane 3D calibration
    21852199
     
    21962210        return
    21972211    end
    2198    % Name=FileName_1;
    21992212    switch UvData.FileType{2}
    22002213        case {'civx','civdata','netcdf'};
     
    23742387%% display time
    23752388abstime=[];%default inputs
    2376 abstime_1=[];
    23772389dt=[];
    23782390TimeUnit='';
     
    23902402    siz=size(UvData.XmlData{1}.Time);
    23912403    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
    23922405        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
    23932406        dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     
    24232436% look for timing in the input file if not defined in a xml file or movie
    24242437if 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
    24362453end
    24372454% if ~isequal(numel(abstime),1)
     
    24412458%       abstime_1=[];
    24422459% end 
    2443 set(handles.abs_time,'String',num2str(abstime,5))
    2444 set(handles.abs_time_1,'String',num2str(abstime_1,5))
     2460abstime_1=[];
     2461TimeName_1=get(handles.TimeName_1,'String');
     2462if ~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
     2464end
     2465set(handles.TimeValue_1,'String',num2str(abstime_1,5))
    24452466if isempty(dt)||isequal(dt,0)
    24462467    set(handles.Dt_txt,'String','')
     
    24992520
    25002521%% analyse input field
    2501 %test_x=0;
    2502 %test_z=0;% test for unstructured z coordinate
    2503 %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure
    2504 % if ~isempty(errormsg)
    2505 %     errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error
    2506 %     return
    2507 % end
    25082522[CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
    25092523if ~isempty(errormsg)
     
    25172531    NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates
    25182532end
    2519 
    2520 %UvData.Field=get_bounds(UvData.Field);
    25212533
    25222534%% get bounds and mesh (needed  to propose default options for projection objects)
     
    30363048    set(handles.SubDir_1,'Visible','off');
    30373049    set(handles.NomType_1,'Visible','off');
    3038     set(handles.abs_time_1,'Visible','off')
     3050    set(handles.TimeValue_1,'Visible','off')
    30393051    set(handles.FileIndex_1,'Visible','off');
    30403052    set(handles.FileExt_1,'Visible','off');
     
    31183130function FieldName_Callback(hObject, eventdata, handles)
    31193131%------------------------------------------------------------------------
     3132
     3133%% read data from uvmat
    31203134UvData=get(handles.uvmat,'UserData');
    31213135list_fields=get(handles.FieldName,'String');% list menu fields
    31223136index_fields=get(handles.FieldName,'Value');% selected string index
    31233137field= list_fields{index_fields(1)}; % selected string
    3124 
    3125 %% fill the coordinates and variables from selections in get_field
    3126 if isequal(field,'get_field...')
    3127     ParamIn=[];
    3128     if strcmp(get(handles.VelType,'Visible'),'on')
    3129         % we use the civ choice as default input
    3130         ParamIn.SwitchVarIndexTime='attribute';
    3131         ListVelType=get(handles.VelType,'String');
    3132         VelType=ListVelType{get(handles.VelType,'Value')};
    3133         switch VelType
    3134             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         end
    3153     end
    3154     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.FieldOption
    3164         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     end
    3179     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 action
    3189 end
    3190 
    3191 
    3192 
    3193 %read the rootfile input display
    31943138[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    31953139FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    31963140[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
     3142switch 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
    32323243        % 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
     3259end
     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
    32583281
    32593282%----------------------------------------------------------------
     
    32613284function FieldName_1_Callback(hObject, eventdata, handles)
    32623285%-------------------------------------------------
     3286
     3287%%%%%% TODO: modify like FieldName_Callback
    32633288%% read input data
    32643289check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered
     
    36643689end
    36653690if 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
    36983727        end
    36993728    end
     
    44604489hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface
    44614490list_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;
     4491if  ~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;
    44664509            for iview=1:length(hdisplay)
    44674510                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);
    44874514                end
    44884515            end
    44894516        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
     4522end
    45204523set(huvmat,'UserData',UvData);
    45214524set(hlist_object,'String',list_str)
     
    46774680ylim=get(newaxes,'YLim');
    46784681set(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');
     4682time_str=get(handles.TimeValue,'String');
    46804683set(htitle,'String',['t=' time_str])
    46814684set(handles.speed,'Value',1)
     
    46844687            runpm(hObject,eventdata,handles,increment)% run plus
    46854688            drawnow
    4686             time_str=get(handles.abs_time,'String');
     4689            time_str=get(handles.TimeValue,'String');
    46874690            if ishandle(htitle)
    46884691             set(htitle,'String',['t=' time_str])
     
    47974800end
    47984801
    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
    48104803UvData=get(handles.uvmat,'UserData');
    4811 % UvData.ProjObject{IndexObj}=[]; %create a new empty object
    4812 % UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
    4813 % UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
    4814 % set(handles.uvmat,'UserData',UvData)
    4815 
    4816 %% initiate the new projection object
    48174804data.Name=data.Type;% default name=type
    48184805data.Coord=[0 0]; %default
     
    48434830hchild=get(hset_object,'children');
    48444831set(hchild,'enable','on')
    4845 
    4846 
    4847 set(handles.delete_object,'Visible','on')
     4832set(handles.delete_object,'Visible','on')% make the object delete button visible
    48484833
    48494834%------------------------------------------------------------------------
     
    53935378            set(handles.Slider1,'Visible','on')
    53945379            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;
    53995380            set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3))
    54005381            set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3))
     
    54175398
    54185399
    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 MATLAB
    5423 % handles    structure with handles and user data (see GUIDATA)
    5424 
    5425 % Hints: get(hObject,'String') returns contents of time_var_1 as text
    5426 %        str2double(get(hObject,'String')) returns contents of time_var_1 as a double
    5427 
    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 MATLAB
    5433 % handles    empty - handles not created until after all CreateFcns called
    5434 
    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.