Changeset 674 for trunk/src/uvmat.m


Ignore:
Timestamp:
Aug 23, 2013, 2:56:17 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired, in particula timing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r672 r674  
    442442%% display the selected field and related information
    443443if ~isempty(fileinput)
     444    set(handles.SubField,'Value',0)
     445    desable_subfield(handles)
    444446    display_file_name(handles,fileinput)
    445447end
     
    450452%------------------------------------------------------------------------
    451453fileinput=get(hObject,'Label');
     454    set(handles.SubField,'Value',0)
     455    desable_subfield(handles)
    452456display_file_name( handles,fileinput)
    453 %
    454 % % -----------------------------------------------------------------------
    455 % % --- Open again the file whose name has been recorded in MenuFile_2
    456 % function MenuFile_2_Callback(hObject, eventdata, handles)
    457 % %------------------------------------------------------------------------
    458 % fileinput=get(handles.MenuFile_2,'Label');
    459 % display_file_name(handles,fileinput)
    460 %
    461 % % -----------------------------------------------------------------------
    462 % % --- Open again the file whose name has been recorded in MenuFile_3
    463 % function MenuFile_3_Callback(hObject, eventdata, handles)
    464 % %------------------------------------------------------------------------
    465 % fileinput=get(handles.MenuFile_3,'Label');
    466 % display_file_name(handles,fileinput)
    467 %
    468 % % -----------------------------------------------------------------------
    469 % % --- Open again the file whose name has been recorded in MenuFile_4
    470 % function MenuFile_4_Callback(hObject, eventdata, handles)
    471 % %------------------------------------------------------------------------
    472 % fileinput=get(handles.MenuFile_4,'Label');
    473 % display_file_name(handles,fileinput)
    474 %
    475 % % -----------------------------------------------------------------------
    476 % % --- Open again the file whose name has been recorded in MenuFile_5
    477 % function MenuFile_5_Callback(hObject, eventdata, handles)
    478 % %------------------------------------------------------------------------
    479 % fileinput=get(handles.MenuFile_5,'Label');
    480 % display_file_name(handles,fileinput)
    481457
    482458
     
    681657    return
    682658end
    683 
    684 %% detect root name, nomenclature and indices in the input file name:
    685 [FilePath,FileName,FileExt]=fileparts(fileinput);
    686 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    687 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    688 [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]);
    689 
    690 if strcmp(FileType,'txt')
    691     edit(fileinput)
    692     return
    693 elseif strcmp(FileType,'xml')
    694     editxml(fileinput)
    695      return
    696 elseif strcmp(FileType,'figure')
    697     open(fileinput)
    698      return
    699 end
    700 
    701 %% set the mouse pointer to 'watch'
    702 set(handles.uvmat,'Pointer','watch')
    703 set(handles.RootPath,'BackgroundColor',[1 1 0])
    704 drawnow
    705659
    706660%% define the relevant handles for the first field series (index=1) or the second file series (index=2)
     
    728682    set(handles.FileExt_1,'Visible','on');
    729683    set(handles.NomType_1,'Visible','on');
     684    set(handles.TimeName_1,'Visible','on')
     685    set(handles.TimeValue_1,'Visible','on')
     686end
     687set(handles_RootPath,'BackgroundColor',[1 1 0])% paint edit box to yellow to visualise root file input
     688set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch'
     689drawnow
     690
     691%% detect root name, nomenclature and indices in the input file name:
     692[FilePath,FileName,FileExt]=fileparts(fileinput);
     693% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     694% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
     695[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]);
     696
     697if strcmp(FileType,'txt')
     698    edit(fileinput)
     699    return
     700elseif strcmp(FileType,'xml')
     701    editxml(fileinput)
     702     return
     703elseif strcmp(FileType,'figure')
     704    open(fileinput)
     705     return
    730706end
    731707
     
    820796        %enable other menus
    821797        set(handles.MenuOpenCampaign,'Enable','on')
    822 %         set(handles.MenuCampaign_1,'Enable','on')
    823 %         set(handles.MenuCampaign_2,'Enable','on')
    824 %         set(handles.MenuCampaign_3,'Enable','on')
    825 %         set(handles.MenuCampaign_4,'Enable','on')
    826 %         set(handles.MenuCampaign_5,'Enable','on')
    827798        set(handles.MenuExport,'Enable','on')
    828799        set(handles.MenuExportFigure,'Enable','on')
     
    854825end
    855826
    856 %% set back the mouse pointer to arrow
    857 set(handles.uvmat,'Pointer','arrow')
     827set(handles_RootPath,'BackgroundColor',[1 1 1])% paint back edit box to white to visualise end of root file input
     828set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow
    858829
    859830
     
    869840end
    870841if index==1
    871     handles_RootPath=handles.RootPath;
    872842    handles_Fields=handles.FieldName;
    873843elseif index==2
    874     handles_RootPath=handles.RootPath_1;
    875844    handles_Fields=handles.FieldName_1;
    876845end
    877846
    878 set(handles_RootPath,'BackgroundColor',[1 1 0])
    879 drawnow
    880847set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening
    881848UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
     
    901868
    902869%% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     870TimeUnit='';%default
     871TimeName='';%default
    903872XmlData.Time=[];%default
    904 XmlData.GeometryCalib=[];%default
    905 TimeUnit='';%default
    906 Time=[];
    907873imainfo=[];
    908874ColorType='falsecolor'; %default
     
    912878    TimeUnit='s';
    913879    if isempty(j1_series); %frame index along i
    914         Time=zeros(imainfo.NumberOfFrames+1,2);
    915         Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     880        XmlData.Time=zeros(imainfo.NumberOfFrames+1,2);
     881        XmlData.Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    916882    else
    917         Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     883        XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    918884    end
    919885    set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    920     if index==1
    921     set(handles.TimeName,'String','video')
    922     else
    923         set(handles.TimeName_1,'String','video')
    924     end
     886    TimeName='video';
    925887    ColorType='truecolor';
    926888elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
    927 %     testima=1;
    928889    if ~isequal(SubDir,'')
    929890        imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
     
    948909
    949910%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
     911XmlData.GeometryCalib=[];%default
    950912XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt);
    951913[tild,tild,DocExt]=fileparts(XmlFileName);
     
    964926    end
    965927    if ~isempty(XmlDataRead)
    966         ImaDoc_str=['view ' DocExt];   
     928        ImaDoc_str=['view ' DocExt];  % DocExt= '.xml' or .civ (obsolete case)
    967929        XmlData=XmlDataRead;
    968930        if isfield(XmlData,'TimeUnit')
     
    990952    end
    991953end
    992 if (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) && ((isfield(XmlData,'Time')&& ~isempty(XmlData.Time)))
    993     if index==1
    994     set(handles.TimeName,'String','xml')
    995     else
    996        set(handles.TimeName_1,'String','xml')
    997     end
    998 else
    999     XmlData.Time=Time; %time set by video
    1000 end
    1001954if isempty(ImaDoc_str)
    1002     set(handles.view_xml,'Visible','off')
    1003 else
    1004     set(handles.view_xml,'String',ImaDoc_str)
     955    set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected
     956else
     957    set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected
     958end
     959
     960%% Define timing
     961% time not set by the input file: images or civ data: indicate that time is read from the xml file
     962if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ...
     963        (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))
     964    TimeName='xml';
     965end
     966if index==1
     967    set(handles.TimeName,'String',TimeName)
     968else
     969    set(handles.TimeName_1,'String',TimeName)
     970    set(handles.TimeName_1,'Visible','on')
    1005971end
    1006972
     
    1014980    nbfield_j=max(max(max(j1_series)));
    1015981end
    1016 if ~isempty(XmlData.Time)
     982if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
    1017983    %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    1018984    if isequal(size(XmlData.Time,1),1)
     
    10751041
    10761042%% update the data attached to the uvmat interface
    1077 if ~isempty(TimeUnit)
    1078     set(handles.TimeName,'String',['time (' TimeUnit ')'])
    1079 end
    10801043UvData.TimeUnit=TimeUnit;
    10811044UvData.XmlData{index}=XmlData;
     
    13111274%------------------------------------------------------------------------
    13121275% --- Executes on button press in view_xml.
     1276%------------------------------------------------------------------------
    13131277function view_xml_Callback(hObject, eventdata, handles)
    1314 %------------------------------------------------------------------------
    1315 %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
    1316  [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    1317 FileBase=fullfile(RootPath,RootFile);
     1278
     1279% if TimeName defined, open the xml file corresponding to the first file
     1280% series, else open the xml file corresponding to the second series
     1281if isempty(get(handles.TimeName,'String'))% open the xml file corresponding to the secodn file series
     1282    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     1283else
     1284   [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     1285end
    13181286option=get(handles.view_xml,'String');
    1319 if isequal(option,'view .xml')
     1287if isequal(option,'view .xml')     
    13201288    FileXml=fullfile(RootPath,[SubDir '.xml']);
    13211289    if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir
     
    16161584CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
    16171585
     1586%         i1_1=i1;
     1587%         i2_1=i2;
     1588%         j1_1=j1;
     1589%         j2_1=j2;
    16181590% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
    1619         i1_1=i1;
    1620         i2_1=i2;
    1621         j1_1=j1;
    1622         j2_1=j2;
    16231591if CheckFixPair && isnumeric(increment)
    16241592    if get(handles.scan_i,'Value')==1% case of scanning along index i
     
    22142182        ParamIn_1.FieldName=FieldName_1;
    22152183        ParamIn_1.VelType=VelType_1;
    2216         ParamIn_1.GUIName='get_field_1';
     2184        %ParamIn_1.GUIName='get_field_1';
    22172185        end 
    22182186        [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
     
    23202288end           
    23212289
    2322 %% display time
     2290%% display time value of the current file
    23232291abstime=[];%default inputs
    23242292dt=[];
    23252293TimeUnit='';
     2294if isfield(UvData,'TimeUnit')
     2295TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo
     2296end
    23262297% time from xml file or video movie
    2327 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
     2298TimeName=get(handles.TimeName,'String');% indicate that time is from xml
     2299if strcmp(TimeName,'xml')||strcmp(TimeName,'video')
    23282300    if isempty(num_i2)||isnan(num_i2)
    23292301        num_i2=num_i1;
     
    23372309    siz=size(UvData.XmlData{1}.Time);
    23382310    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)
    2339         set(handles.TimeName,'String','xml')% indicate that time is from xml
    23402311        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
    23412312        dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     
    23452316        end
    23462317    end
    2347     if numel(UvData.XmlData)==2
    2348         if isempty(i2_1)
    2349             i2_1=num_i1;
    2350         end
    2351         if isempty(j1_1)
    2352             j1_1=1;
    2353         end
    2354         if isempty(j2_1)
    2355             j2_1=j1_1;
    2356         end
    2357         siz=size(UvData.XmlData{2}.Time);
    2358         if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
    2359             abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
    2360             Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
    2361         end
    2362     end
    2363 end
    2364 
    2365 %% look for timing in the input file if not defined in a xml file or movie
     2318end
     2319
     2320% get time in the input file, not defined in a xml file or movie
    23662321if isempty(abstime)
    2367     TimeName=get(handles.TimeName,'String');
    23682322    if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:'))
    23692323        abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file
     
    23822336end
    23832337set(handles.TimeValue,'String',num2str(abstime))
     2338
     2339%% display time value of the second current file if relevant
    23842340abstime_1=[];
    2385 TimeName_1=get(handles.TimeName_1,'String');
    2386 if ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
     2341if ~isempty(FileName_1)
     2342    TimeName_1=get(handles.TimeName_1,'String');% indicate whether time is from xml or video
     2343    % time from xml file or video movie as a second file series
     2344    if strcmp(TimeName_1,'xml')||strcmp(TimeName_1,'video')
     2345        if numel(UvData.XmlData)==2
     2346            if isempty(i2_1)
     2347                i2_1=num_i1;
     2348            end
     2349            if isempty(j1_1)
     2350                j1_1=1;
     2351            end
     2352            if isempty(j2_1)
     2353                j2_1=j1_1;
     2354            end
     2355            siz=size(UvData.XmlData{2}.Time);
     2356            if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
     2357                abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
     2358                Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
     2359            end
     2360        end
     2361    end
     2362   
     2363    % get time in the input file of the second series, not defined in a xml file or movie
     2364    if isempty(abstime_1) && numel(Field)==2 &&...
     2365            ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
    23872366        abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file
    2388 end
    2389 set(handles.TimeValue_1,'String',num2str(abstime_1,5))
     2367    end
     2368    set(handles.TimeValue_1,'String',num2str(abstime_1,5))
     2369end
     2370
    23902371if isempty(dt)||isequal(dt,0)
    23912372    set(handles.Dt_txt,'String','')
     
    23972378    end
    23982379end
     2380
     2381%% Time title with unit
     2382if isempty(abstime)&&isempty(abstime_1)
     2383    Time_title='';
     2384else
     2385    Time_title='Time';
     2386    if ~isempty(TimeUnit)
     2387        Time_title=['Time (' TimeUnit ')'];
     2388    end
     2389end
     2390set(handles.Time_title,'String',Time_title)
    23992391
    24002392%% store the current open names, fieldname and vel types in uvmat interface
     
    24182410        end
    24192411    end
    2420     transform=get(handles.TransformPath,'UserData');
    24212412    switch nargin(transform)
    24222413        case 4
     
    25382529        set(handles.ListObject_1,'String',{'plane'})
    25392530    end
    2540     IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
    2541     if IndexObj(1)> numel(UvData.ProjObject)
    2542         IndexObj(1)=1;%select the first object if the selected one does not exist
     2531    IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view
     2532    if IndexObj> numel(UvData.ProjObject)
     2533        IndexObj=1;%select the first object if the selected one does not exist
    25432534        set(handles.ListObject_1,'Value',1)
    25442535    end
    2545     IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view
    2546     if isequal(IndexObj(2),IndexObj(1))
    2547         IndexObj(2)=[];
     2536    if get(handles.CheckViewField,'Value')
     2537        IndexObj_2=get(handles.ListObject,'Value');%selected projection object for view_field
     2538        if ~isequal(IndexObj_2,IndexObj(1))
     2539            IndexObj(2)=IndexObj_2;
     2540        end
    25482541    end
    25492542    plot_handles{1}=handles;
     
    28942887fin=close(nc);
    28952888
    2896 %-------------------------------------------------------------------
     2889%-----------------------------------------------------------------------
    28972890% --- Executes on button press in SubField
     2891%-----------------------------------------------------------------------
    28982892function SubField_Callback(hObject, eventdata, handles)
    2899 %-------------------------------------------------------------------
    2900 UvData=get(handles.uvmat,'UserData');
    2901 if get(handles.SubField,'Value')==0% if the subfield button is desactivated   
    2902     set(handles.RootPath_1,'String','')
    2903     set(handles.RootFile_1,'String','')
    2904     set(handles.SubDir_1,'String','');
    2905     set(handles.FileIndex_1,'String','');
    2906     set(handles.FileExt_1,'String','');
    2907     set(handles.RootPath_1,'Visible','off')
    2908     set(handles.RootFile_1,'Visible','off')
    2909     set(handles.SubDir_1,'Visible','off');
    2910     set(handles.NomType_1,'Visible','off');
    2911     set(handles.TimeValue_1,'Visible','off')
    2912     set(handles.FileIndex_1,'Visible','off');
    2913     set(handles.FileExt_1,'Visible','off');
    2914     set(handles.FieldName_1,'Value',1);%set to blank state
    2915     set(handles.VelType_1,'Value',1);%set to blank state
    2916     set(handles.num_Opacity,'String','')% desactivate opacity setting
    2917     FieldList=get(handles.FieldName,'String');
    2918     if numel(FieldList)>1   % if a choice of fields exists
    2919         set(handles.FieldName_1,'Value',1)% set second field choice to blank
    2920         set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
    2921     else
    2922         set(handles.FieldName_1,'String',{''})% set second field choice to blank
    2923     end
    2924     if ~strcmp(get(handles.VelType,'Visible'),'on')
    2925         set(handles.VelType_1,'Visible','off')
    2926     end
    2927     if isfield(UvData,'XmlData_1')
    2928         UvData=rmfield(UvData,'XmlData_1');
    2929     end
    2930     set(handles.uvmat,'UserData',UvData);
     2893
     2894if get(handles.SubField,'Value')==0% if the subfield button is desactivated 
     2895    desable_subfield(handles)
    29312896    transform_fct_list=get(handles.TransformName,'String');
    29322897    transform_fct=transform_fct_list(get(handles.TransformName,'Value'));
     
    29382903    end 
    29392904else
    2940     %RootPath=get(handles.RootPath,'String');
    2941     %SubDir=get(handles.SubDir,'String');
    29422905    fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String'));
    29432906    if isempty(fileinput_1)
    29442907        set(handles.SubField,'Value',0)
    2945     else
    2946        
     2908    else       
    29472909        % refresh the current displayed field
    2948         set(handles.SubField,'Value',1)
    29492910        display_file_name(handles,fileinput_1,2)
    29502911       
     
    29612922        set(handles.MenuFile_5,'Label',MenuFile_5)
    29622923    end
    2963     %     MenuBrowse_1_Callback(hObject, eventdata, handles)
    2964 end
     2924end
     2925
     2926%-----------------------------------------------------------------------
     2927% --- desactivate display used for a second file series
     2928%-----------------------------------------------------------------------
     2929function desable_subfield(handles)
     2930   
     2931set(handles.RootPath_1,'String','')
     2932set(handles.RootFile_1,'String','')
     2933set(handles.SubDir_1,'String','');
     2934set(handles.FileIndex_1,'String','');
     2935set(handles.FileExt_1,'String','');
     2936set(handles.RootPath_1,'Visible','off')
     2937set(handles.RootFile_1,'Visible','off')
     2938set(handles.SubDir_1,'Visible','off');
     2939set(handles.NomType_1,'Visible','off');
     2940set(handles.FileIndex_1,'Visible','off');
     2941set(handles.FileExt_1,'Visible','off');
     2942set(handles.TimeName_1,'String','');
     2943set(handles.TimeName_1,'Visible','off');
     2944set(handles.TimeValue_1,'String','');
     2945set(handles.TimeValue_1,'Visible','off');
     2946set(handles.FieldName_1,'Value',1);%set to blank state
     2947set(handles.VelType_1,'Value',1);%set to blank state
     2948set(handles.num_Opacity,'String','')% desactivate opacity setting
     2949FieldList=get(handles.FieldName,'String');
     2950if numel(FieldList)>1   % if a choice of fields exists
     2951    set(handles.FieldName_1,'Value',1)% set second field choice to blank
     2952    set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
     2953else
     2954    set(handles.FieldName_1,'String',{''})% set second field choice to blank
     2955end
     2956if ~strcmp(get(handles.VelType,'Visible'),'on')
     2957    set(handles.VelType_1,'Visible','off')
     2958end
     2959UvData=get(handles.uvmat,'UserData');
     2960if isfield(UvData,'XmlData_1')
     2961    UvData=rmfield(UvData,'XmlData_1');
     2962end
     2963set(handles.uvmat,'UserData',UvData);
    29652964
    29662965%------------------------------------------------------------------------
    29672966% --- read the data displayed for the input rootfile windows (new): TODO use read_GUI
    2968 
     2967%------------------------------------------------------------------------
    29692968function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles)
    2970 %------------------------------------------------------------------------
     2969
    29712970InputFile=read_GUI(handles.InputFile);
    29722971RootPath=InputFile.RootPath;
     
    29792978%------------------------------------------------------------------------
    29802979% ---- read the data displayed for the second input rootfile windows
     2980%------------------------------------------------------------------------
    29812981function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles)
    2982 %------------------------------------------------------------------------
     2982
    29832983RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
    29842984if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
     
    30213021[tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
    30223022
    3023 switch field 
     3023switch field
    30243024   
    30253025    case 'get_field...'
    3026     %% fill the coordinates and variables from selections in get_field
     3026        %% fill the coordinates and variables from selections in get_field
    30273027        ParamIn=[];
    30283028        % in case of civ data, we use the civ choice as default input for the GUI get_field
     
    30333033            switch VelType
    30343034                case 'civ1'
    3035                     ParamIn.TimeVarName='Civ1_Time';
     3035                    ParamIn.TimeAttrName='Civ1_Time';
    30363036                    ParamIn.vector_x='Civ1_U';
    30373037                    ParamIn.vector_y='Civ1_V';
    30383038                    ParamIn.vec_color='Civ1_C';
    30393039                case 'filter1'
    3040                     ParamIn.TimeVarName='Civ1_Time';
     3040                    ParamIn.TimeAttrName='Civ1_Time';
    30413041                    ParamIn.vector_x='Civ1_U_smooth';
    30423042                    ParamIn.vector_y='Civ1_V_smooth';
    30433043                case 'civ2'
    3044                     ParamIn.TimeVarName='Civ2_Time';
     3044                    ParamIn.TimeAttrName='Civ2_Time';
    30453045                    ParamIn.vector_x='Civ2_U';
    30463046                    ParamIn.vector_y='Civ2_V';
    30473047                case 'filter2'
    3048                     ParamIn.TimeVarName='Civ2_Time';
     3048                    ParamIn.TimeAttrName='Civ2_Time';
    30493049                    ParamIn.vector_x='Civ2_U_smooth';
    30503050                    ParamIn.vector_y='Civ2_V_smooth';
     
    30563056        set(handles.FixVelType,'visible','off')
    30573057        set(handles.VelType,'Visible','off')
    3058         %set(handles.VelType_1,'Visible','off')
    30593058       
    30603059        %read selection from get_field
     
    30773076            case '1D plot'
    30783077                YName=GetFieldData.PanelOrdinate.ordinate;
    3079             case 'civdata...'%return to civdata from get_field
    3080                % [FieldList,VecColorList]=set_field_list('U','V','C');
    3081                 set(handles.FieldName,'Value',2)
    3082                 set(handles.FixVelType,'visible','on')
    3083                 set(handles.VelType,'Visible','on')
     3078            case 'civdata...'%reinitiate input, return to automatic civ data reading
     3079                display_file_name(handles,FileName,1)
    30843080        end
    30853081        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    30863082            XName=GetFieldData.Coordinates.Coord_x;
    3087         TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
    3088         if strcmp(TimeNameStr,'file index')
    3089             set(handles.TimeName,'String','');
    3090         else
    3091             set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);
    3092         end
    3093         if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index
    3094             set(handles.NomType,'String','*')
    3095             set(handles.RootFile,FileName)
    3096         end
    3097         %     set(handles.TimeValue,'String' SwitchVarIndexTime
    3098         set(handles.Coord_x,'String',XName)
    3099         if ischar(YName)
    3100             YName={YName};
    3101         end
    3102         set(handles.Coord_y,'Data',YName)
    3103         set(handles.FieldName,'Value',1)
    3104         set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
    3105         set(handles.ColorScalar,'Value',1)
    3106         set(handles.ColorScalar,'String',VecColorList);
    3107         UvData.FileType{1}='netcdf';
    3108         set(handles.uvmat,'UserData',UvData)
    3109         end
    3110         run0_Callback(hObject, eventdata, handles)
    3111         
     3083            TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
     3084            if strcmp(TimeNameStr,'file index')
     3085                set(handles.TimeName,'String','');
     3086            else
     3087                set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);
     3088            end
     3089            if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index
     3090                set(handles.NomType,'String','*')
     3091                set(handles.RootFile,FileName)
     3092            end
     3093            %     set(handles.TimeValue,'String' SwitchVarIndexTime
     3094            set(handles.Coord_x,'String',XName)
     3095            if ischar(YName)
     3096                YName={YName};
     3097            end
     3098            set(handles.Coord_y,'Data',YName)
     3099            set(handles.FieldName,'Value',1)
     3100            set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
     3101            set(handles.ColorScalar,'Value',1)
     3102            set(handles.ColorScalar,'String',VecColorList);
     3103            UvData.FileType{1}='netcdf';
     3104            set(handles.uvmat,'UserData',UvData)
     3105            run0_Callback(hObject, eventdata, handles)
     3106        end
     3107       
    31123108    case 'image'
    3113     %% look for image corresponding to civ data
     3109        %% look for image corresponding to civ data
    31143110        if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
    31153111            imagename=UvData.Field.Civ2_ImageA;
     
    31283124        % display the selected field and related information
    31293125        display_file_name(handles,imagename)%display the image
    3130      otherwise
    3131 %         ext=get(handles.FileExt,'String');
    3132 %         if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
    3133 %             [FileName,PathName] = uigetfile( ...
    3134 %                 {'*.nc', ' (*.nc)';
    3135 %                 '*.nc',' netcdf files'; ...
    3136 %                 '*.*',  'All Files (*.*)'}, ...
    3137 %                 'Pick a netcdf file',FileBase);
    3138 %             if ~ischar(FileName),return,end %abandon if the browser is cancelled
    3139 %             FullFileName=[PathName FileName];
    3140             % display the selected field and related information
    3141              run0_Callback(hObject, eventdata, handles)
     3126    otherwise
     3127        run0_Callback(hObject, eventdata, handles)
    31423128end
    31433129
     
    31923178        end
    31933179    case 'image'
    3194         % get the image name corresponding to the current netcdf name (no unique correspondance)
     3180        %% look for image corresponding to civ data
     3181        imagename='';
    31953182        if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
    31963183            imagename=UvData.Field.Civ2_ImageA;
     
    31983185            imagename=UvData.Field.Civ1_ImageA;
    31993186        else
    3200             SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
    3201             imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
    3202         end
    3203         if ~exist(imagename,'file') % browse for images if it is not found
    3204             [FileName,PathName] = uigetfile( ...
    3205                 {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
    3206                 '*.jpg',' jpeg image files'; ...
    3207                 '*.png','.png image files'; ...
    3208                 '*.tif','.tif image files'; ...
    3209                 '*.avi;*.AVI','.avi movie files'; ...
    3210                 '*.vol','.volume images (png)'; ...
    3211                 '*.*',  'All Files (*.*)'}, ...
    3212                 'Pick an image',imagename);
    3213             if ~ischar(FileName),return,end %abandon if the browser is cancelled
    3214             imagename=[PathName FileName];
    3215         end
    3216         if ~ischar(imagename)% quit if the browser has  been closed
     3187            SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     3188            imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     3189        end
     3190        if ~exist(imagename,'file')
     3191            imagename=uigetfile_uvmat('Pick an image file',imagename,'image');
     3192           
     3193        end
     3194        if isempty(imagename)
    32173195            set(handles.SubField,'Value',0)
    3218         else %valid browser input:  display the selected image
    3219             set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons
    3220             set(handles.num_Npx,'Visible','on')
    3221             set(handles.num_Npy,'Visible','on')
    3222             display_file_name(handles,imagename,2)%display the imag
     3196            return
     3197        else
     3198            display_file_name(handles,imagename,2)%display the image as second field
    32233199        end
    32243200    otherwise
     
    32343210                set(handles.uvmat,'UserData',UvData)
    32353211                set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
    3236                 transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
     3212                TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
    32373213                 check_refresh=0;
    32383214             end             
     
    45754551%------------------------------------------------------------------------
    45764552function Menuline_x_Callback(hObject, eventdata, handles)
    4577     msgbox_uvmat('ERROR','option not yet implemented, use line')
    4578     return
     4553
    45794554data.Type='line_x';
    45804555data.ProjMode='projection';%default
     
    45864561% -----------------------------------------------------------------------
    45874562function Menuline_y_Callback(hObject, eventdata, handles)
    4588     msgbox_uvmat('ERROR','option not yet implemented, use line')
    4589     return
     4563
    45904564data.Type='line_y';
    45914565data.ProjMode='projection';%default
     
    46764650data.Name=data.Type;% default name=type
    46774651data.Coord=[0 0]; %default
     4652check_plot=0;
    46784653if isfield(UvData,'Field')
    46794654    Field=UvData.Field;
     4655    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     4656         data.Coord=[0 0 0]; %default
     4657    end
     4658    if isfield(Field,'CoordUnit')
     4659        data.CoordUnit=Field.CoordUnit;
     4660    end
    46804661    if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh)
    46814662        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     
    46844665                data.RangeY=UvData.Field.CoordMesh;
    46854666            case 'line_x'
    4686                 data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     4667                check_plot=1; %plot the line directly when set_object is opened
     4668                data.Type='line';
     4669                data.RangeX=UvData.Field.XMin ;
    46874670                data.RangeY=UvData.Field.CoordMesh;
    4688                 data.Coord=[0 (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis
     4671                data.Coord=[UvData.Field.XMin (UvData.Field.YMin +UvData.Field.YMax)/2;...
     4672                           UvData.Field.XMax (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis
    46894673            case 'line_y'
     4674                check_plot=1; %plot the line directly when set_object is opened
     4675                data.Type='line';
     4676                data.RangeX=UvData.Field.YMin ;
    46904677                data.RangeY=UvData.Field.CoordMesh;
    4691                 data.Coord=[(UvData.Field.XMin +UvData.Field.XMax)/2 0];% put line at the middle of the x axis
     4678                data.Coord=[(UvData.Field.XMin+UvData.Field.XMax)/2 UvData.Field.YMin;...
     4679                            (UvData.Field.XMin +UvData.Field.XMax)/2 UvData.Field.YMax];% put line at the middle of the y axis
    46924680            case {'rectangle','ellipse'}
    46934681                data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     
    47004688        data.DY=UvData.Field.CoordMesh;
    47014689    end
    4702     if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
    4703          data.Coord=[0 0 0]; %default
    4704     end
    4705     if isfield(Field,'CoordUnit')
    4706         data.CoordUnit=Field.CoordUnit;
    4707     end
    4708 end
     4690end
     4691
    47094692hset_object=set_object(data,handles);% call the GUI set_object
    47104693hchild=get(hset_object,'children');
    47114694set(hchild,'enable','on')
    47124695set(handles.DeleteObject,'Visible','on')% make the object delete button visible
     4696if check_plot
     4697    hhset_object=guidata(hset_object);
     4698    set_object('PLOT_Callback',1,[],hhset_object);% call the GUI set_object
     4699end
    47134700
    47144701%------------------------------------------------------------------------
     
    47174704%get the object file
    47184705fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml');
    4719 
    47204706if ~isempty(fileinput)
    47214707    %read the file
Note: See TracChangeset for help on using the changeset viewer.