Changeset 674 for trunk/src/uvmat.m
- Timestamp:
- Aug 23, 2013, 2:56:17 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r672 r674 442 442 %% display the selected field and related information 443 443 if ~isempty(fileinput) 444 set(handles.SubField,'Value',0) 445 desable_subfield(handles) 444 446 display_file_name(handles,fileinput) 445 447 end … … 450 452 %------------------------------------------------------------------------ 451 453 fileinput=get(hObject,'Label'); 454 set(handles.SubField,'Value',0) 455 desable_subfield(handles) 452 456 display_file_name( handles,fileinput) 453 %454 % % -----------------------------------------------------------------------455 % % --- Open again the file whose name has been recorded in MenuFile_2456 % 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_3463 % 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_4470 % 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_5477 % function MenuFile_5_Callback(hObject, eventdata, handles)478 % %------------------------------------------------------------------------479 % fileinput=get(handles.MenuFile_5,'Label');480 % display_file_name(handles,fileinput)481 457 482 458 … … 681 657 return 682 658 end 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 exists688 [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 return693 elseif strcmp(FileType,'xml')694 editxml(fileinput)695 return696 elseif strcmp(FileType,'figure')697 open(fileinput)698 return699 end700 701 %% set the mouse pointer to 'watch'702 set(handles.uvmat,'Pointer','watch')703 set(handles.RootPath,'BackgroundColor',[1 1 0])704 drawnow705 659 706 660 %% define the relevant handles for the first field series (index=1) or the second file series (index=2) … … 728 682 set(handles.FileExt_1,'Visible','on'); 729 683 set(handles.NomType_1,'Visible','on'); 684 set(handles.TimeName_1,'Visible','on') 685 set(handles.TimeValue_1,'Visible','on') 686 end 687 set(handles_RootPath,'BackgroundColor',[1 1 0])% paint edit box to yellow to visualise root file input 688 set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch' 689 drawnow 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 697 if strcmp(FileType,'txt') 698 edit(fileinput) 699 return 700 elseif strcmp(FileType,'xml') 701 editxml(fileinput) 702 return 703 elseif strcmp(FileType,'figure') 704 open(fileinput) 705 return 730 706 end 731 707 … … 820 796 %enable other menus 821 797 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')827 798 set(handles.MenuExport,'Enable','on') 828 799 set(handles.MenuExportFigure,'Enable','on') … … 854 825 end 855 826 856 %% set back the mouse pointer to arrow 857 set(handles.uvmat,'Pointer','arrow') 827 set(handles_RootPath,'BackgroundColor',[1 1 1])% paint back edit box to white to visualise end of root file input 828 set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow 858 829 859 830 … … 869 840 end 870 841 if index==1 871 handles_RootPath=handles.RootPath;872 842 handles_Fields=handles.FieldName; 873 843 elseif index==2 874 handles_RootPath=handles.RootPath_1;875 844 handles_Fields=handles.FieldName_1; 876 845 end 877 846 878 set(handles_RootPath,'BackgroundColor',[1 1 0])879 drawnow880 847 set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening 881 848 UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface … … 901 868 902 869 %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file 870 TimeUnit='';%default 871 TimeName='';%default 903 872 XmlData.Time=[];%default 904 XmlData.GeometryCalib=[];%default905 TimeUnit='';%default906 Time=[];907 873 imainfo=[]; 908 874 ColorType='falsecolor'; %default … … 912 878 TimeUnit='s'; 913 879 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)'; 916 882 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); 918 884 end 919 885 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'; 925 887 ColorType='truecolor'; 926 888 elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image 927 % testima=1;928 889 if ~isequal(SubDir,'') 929 890 imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); … … 948 909 949 910 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) 911 XmlData.GeometryCalib=[];%default 950 912 XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); 951 913 [tild,tild,DocExt]=fileparts(XmlFileName); … … 964 926 end 965 927 if ~isempty(XmlDataRead) 966 ImaDoc_str=['view ' DocExt]; 928 ImaDoc_str=['view ' DocExt]; % DocExt= '.xml' or .civ (obsolete case) 967 929 XmlData=XmlDataRead; 968 930 if isfield(XmlData,'TimeUnit') … … 990 952 end 991 953 end 992 if (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) && ((isfield(XmlData,'Time')&& ~isempty(XmlData.Time)))993 if index==1994 set(handles.TimeName,'String','xml')995 else996 set(handles.TimeName_1,'String','xml')997 end998 else999 XmlData.Time=Time; %time set by video1000 end1001 954 if 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 956 else 957 set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected 958 end 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 962 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ... 963 (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx')) 964 TimeName='xml'; 965 end 966 if index==1 967 set(handles.TimeName,'String',TimeName) 968 else 969 set(handles.TimeName_1,'String',TimeName) 970 set(handles.TimeName_1,'Visible','on') 1005 971 end 1006 972 … … 1014 980 nbfield_j=max(max(max(j1_series))); 1015 981 end 1016 if ~isempty(XmlData.Time)982 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) 1017 983 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 1018 984 if isequal(size(XmlData.Time,1),1) … … 1075 1041 1076 1042 %% update the data attached to the uvmat interface 1077 if ~isempty(TimeUnit)1078 set(handles.TimeName,'String',['time (' TimeUnit ')'])1079 end1080 1043 UvData.TimeUnit=TimeUnit; 1081 1044 UvData.XmlData{index}=XmlData; … … 1311 1274 %------------------------------------------------------------------------ 1312 1275 % --- Executes on button press in view_xml. 1276 %------------------------------------------------------------------------ 1313 1277 function 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 1281 if 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); 1283 else 1284 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 1285 end 1318 1286 option=get(handles.view_xml,'String'); 1319 if isequal(option,'view .xml') 1287 if isequal(option,'view .xml') 1320 1288 FileXml=fullfile(RootPath,[SubDir '.xml']); 1321 1289 if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir … … 1616 1584 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); 1617 1585 1586 % i1_1=i1; 1587 % i2_1=i2; 1588 % j1_1=j1; 1589 % j2_1=j2; 1618 1590 % 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;1623 1591 if CheckFixPair && isnumeric(increment) 1624 1592 if get(handles.scan_i,'Value')==1% case of scanning along index i … … 2214 2182 ParamIn_1.FieldName=FieldName_1; 2215 2183 ParamIn_1.VelType=VelType_1; 2216 ParamIn_1.GUIName='get_field_1';2184 %ParamIn_1.GUIName='get_field_1'; 2217 2185 end 2218 2186 [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); … … 2320 2288 end 2321 2289 2322 %% display time 2290 %% display time value of the current file 2323 2291 abstime=[];%default inputs 2324 2292 dt=[]; 2325 2293 TimeUnit=''; 2294 if isfield(UvData,'TimeUnit') 2295 TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo 2296 end 2326 2297 % time from xml file or video movie 2327 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') 2298 TimeName=get(handles.TimeName,'String');% indicate that time is from xml 2299 if strcmp(TimeName,'xml')||strcmp(TimeName,'video') 2328 2300 if isempty(num_i2)||isnan(num_i2) 2329 2301 num_i2=num_i1; … … 2337 2309 siz=size(UvData.XmlData{1}.Time); 2338 2310 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 xml2340 2311 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 2341 2312 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); … … 2345 2316 end 2346 2317 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 2318 end 2319 2320 % get time in the input file, not defined in a xml file or movie 2366 2321 if isempty(abstime) 2367 TimeName=get(handles.TimeName,'String');2368 2322 if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:')) 2369 2323 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file … … 2382 2336 end 2383 2337 set(handles.TimeValue,'String',num2str(abstime)) 2338 2339 %% display time value of the second current file if relevant 2384 2340 abstime_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:')) 2341 if ~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:')) 2387 2366 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)) 2369 end 2370 2390 2371 if isempty(dt)||isequal(dt,0) 2391 2372 set(handles.Dt_txt,'String','') … … 2397 2378 end 2398 2379 end 2380 2381 %% Time title with unit 2382 if isempty(abstime)&&isempty(abstime_1) 2383 Time_title=''; 2384 else 2385 Time_title='Time'; 2386 if ~isempty(TimeUnit) 2387 Time_title=['Time (' TimeUnit ')']; 2388 end 2389 end 2390 set(handles.Time_title,'String',Time_title) 2399 2391 2400 2392 %% store the current open names, fieldname and vel types in uvmat interface … … 2418 2410 end 2419 2411 end 2420 transform=get(handles.TransformPath,'UserData');2421 2412 switch nargin(transform) 2422 2413 case 4 … … 2538 2529 set(handles.ListObject_1,'String',{'plane'}) 2539 2530 end 2540 IndexObj (1)=get(handles.ListObject_1,'Value');%selected projection object for main view2541 if IndexObj (1)> numel(UvData.ProjObject)2542 IndexObj (1)=1;%select the first object if the selected one does not exist2531 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 2543 2534 set(handles.ListObject_1,'Value',1) 2544 2535 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 2548 2541 end 2549 2542 plot_handles{1}=handles; … … 2894 2887 fin=close(nc); 2895 2888 2896 %------------------------------------------------------------------- 2889 %----------------------------------------------------------------------- 2897 2890 % --- Executes on button press in SubField 2891 %----------------------------------------------------------------------- 2898 2892 function 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 2894 if get(handles.SubField,'Value')==0% if the subfield button is desactivated 2895 desable_subfield(handles) 2931 2896 transform_fct_list=get(handles.TransformName,'String'); 2932 2897 transform_fct=transform_fct_list(get(handles.TransformName,'Value')); … … 2938 2903 end 2939 2904 else 2940 %RootPath=get(handles.RootPath,'String');2941 %SubDir=get(handles.SubDir,'String');2942 2905 fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String')); 2943 2906 if isempty(fileinput_1) 2944 2907 set(handles.SubField,'Value',0) 2945 else 2946 2908 else 2947 2909 % refresh the current displayed field 2948 set(handles.SubField,'Value',1)2949 2910 display_file_name(handles,fileinput_1,2) 2950 2911 … … 2961 2922 set(handles.MenuFile_5,'Label',MenuFile_5) 2962 2923 end 2963 % MenuBrowse_1_Callback(hObject, eventdata, handles) 2964 end 2924 end 2925 2926 %----------------------------------------------------------------------- 2927 % --- desactivate display used for a second file series 2928 %----------------------------------------------------------------------- 2929 function desable_subfield(handles) 2930 2931 set(handles.RootPath_1,'String','') 2932 set(handles.RootFile_1,'String','') 2933 set(handles.SubDir_1,'String',''); 2934 set(handles.FileIndex_1,'String',''); 2935 set(handles.FileExt_1,'String',''); 2936 set(handles.RootPath_1,'Visible','off') 2937 set(handles.RootFile_1,'Visible','off') 2938 set(handles.SubDir_1,'Visible','off'); 2939 set(handles.NomType_1,'Visible','off'); 2940 set(handles.FileIndex_1,'Visible','off'); 2941 set(handles.FileExt_1,'Visible','off'); 2942 set(handles.TimeName_1,'String',''); 2943 set(handles.TimeName_1,'Visible','off'); 2944 set(handles.TimeValue_1,'String',''); 2945 set(handles.TimeValue_1,'Visible','off'); 2946 set(handles.FieldName_1,'Value',1);%set to blank state 2947 set(handles.VelType_1,'Value',1);%set to blank state 2948 set(handles.num_Opacity,'String','')% desactivate opacity setting 2949 FieldList=get(handles.FieldName,'String'); 2950 if 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 2953 else 2954 set(handles.FieldName_1,'String',{''})% set second field choice to blank 2955 end 2956 if ~strcmp(get(handles.VelType,'Visible'),'on') 2957 set(handles.VelType_1,'Visible','off') 2958 end 2959 UvData=get(handles.uvmat,'UserData'); 2960 if isfield(UvData,'XmlData_1') 2961 UvData=rmfield(UvData,'XmlData_1'); 2962 end 2963 set(handles.uvmat,'UserData',UvData); 2965 2964 2966 2965 %------------------------------------------------------------------------ 2967 2966 % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI 2968 2967 %------------------------------------------------------------------------ 2969 2968 function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) 2970 %------------------------------------------------------------------------ 2969 2971 2970 InputFile=read_GUI(handles.InputFile); 2972 2971 RootPath=InputFile.RootPath; … … 2979 2978 %------------------------------------------------------------------------ 2980 2979 % ---- read the data displayed for the second input rootfile windows 2980 %------------------------------------------------------------------------ 2981 2981 function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) 2982 %------------------------------------------------------------------------ 2982 2983 2983 RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window 2984 2984 if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') … … 3021 3021 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3022 3022 3023 switch field 3023 switch field 3024 3024 3025 3025 case 'get_field...' 3026 %% fill the coordinates and variables from selections in get_field3026 %% fill the coordinates and variables from selections in get_field 3027 3027 ParamIn=[]; 3028 3028 % in case of civ data, we use the civ choice as default input for the GUI get_field … … 3033 3033 switch VelType 3034 3034 case 'civ1' 3035 ParamIn.Time VarName='Civ1_Time';3035 ParamIn.TimeAttrName='Civ1_Time'; 3036 3036 ParamIn.vector_x='Civ1_U'; 3037 3037 ParamIn.vector_y='Civ1_V'; 3038 3038 ParamIn.vec_color='Civ1_C'; 3039 3039 case 'filter1' 3040 ParamIn.Time VarName='Civ1_Time';3040 ParamIn.TimeAttrName='Civ1_Time'; 3041 3041 ParamIn.vector_x='Civ1_U_smooth'; 3042 3042 ParamIn.vector_y='Civ1_V_smooth'; 3043 3043 case 'civ2' 3044 ParamIn.Time VarName='Civ2_Time';3044 ParamIn.TimeAttrName='Civ2_Time'; 3045 3045 ParamIn.vector_x='Civ2_U'; 3046 3046 ParamIn.vector_y='Civ2_V'; 3047 3047 case 'filter2' 3048 ParamIn.Time VarName='Civ2_Time';3048 ParamIn.TimeAttrName='Civ2_Time'; 3049 3049 ParamIn.vector_x='Civ2_U_smooth'; 3050 3050 ParamIn.vector_y='Civ2_V_smooth'; … … 3056 3056 set(handles.FixVelType,'visible','off') 3057 3057 set(handles.VelType,'Visible','off') 3058 %set(handles.VelType_1,'Visible','off')3059 3058 3060 3059 %read selection from get_field … … 3077 3076 case '1D plot' 3078 3077 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) 3084 3080 end 3085 3081 if ~strcmp(GetFieldData.FieldOption,'civdata...') 3086 3082 XName=GetFieldData.Coordinates.Coord_x; 3087 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;3088 if strcmp(TimeNameStr,'file index')3089 set(handles.TimeName,'String','');3090 else3091 set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);3092 end3093 if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index3094 set(handles.NomType,'String','*')3095 set(handles.RootFile,FileName)3096 end3097 % set(handles.TimeValue,'String' SwitchVarIndexTime3098 set(handles.Coord_x,'String',XName)3099 if ischar(YName)3100 YName={YName};3101 end3102 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 end3110 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 3112 3108 case 'image' 3113 %% look for image corresponding to civ data3109 %% look for image corresponding to civ data 3114 3110 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3115 3111 imagename=UvData.Field.Civ2_ImageA; … … 3128 3124 % display the selected field and related information 3129 3125 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) 3142 3128 end 3143 3129 … … 3192 3178 end 3193 3179 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=''; 3195 3182 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3196 3183 imagename=UvData.Field.Civ2_ImageA; … … 3198 3185 imagename=UvData.Field.Civ1_ImageA; 3199 3186 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) 3217 3195 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 3223 3199 end 3224 3200 otherwise … … 3234 3210 set(handles.uvmat,'UserData',UvData) 3235 3211 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 plot3212 TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot 3237 3213 check_refresh=0; 3238 3214 end … … 4575 4551 %------------------------------------------------------------------------ 4576 4552 function Menuline_x_Callback(hObject, eventdata, handles) 4577 msgbox_uvmat('ERROR','option not yet implemented, use line') 4578 return 4553 4579 4554 data.Type='line_x'; 4580 4555 data.ProjMode='projection';%default … … 4586 4561 % ----------------------------------------------------------------------- 4587 4562 function Menuline_y_Callback(hObject, eventdata, handles) 4588 msgbox_uvmat('ERROR','option not yet implemented, use line') 4589 return 4563 4590 4564 data.Type='line_y'; 4591 4565 data.ProjMode='projection';%default … … 4676 4650 data.Name=data.Type;% default name=type 4677 4651 data.Coord=[0 0]; %default 4652 check_plot=0; 4678 4653 if isfield(UvData,'Field') 4679 4654 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 4680 4661 if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) 4681 4662 data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; … … 4684 4665 data.RangeY=UvData.Field.CoordMesh; 4685 4666 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 ; 4687 4670 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 4689 4673 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 ; 4690 4677 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 4692 4680 case {'rectangle','ellipse'} 4693 4681 data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; … … 4700 4688 data.DY=UvData.Field.CoordMesh; 4701 4689 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 4690 end 4691 4709 4692 hset_object=set_object(data,handles);% call the GUI set_object 4710 4693 hchild=get(hset_object,'children'); 4711 4694 set(hchild,'enable','on') 4712 4695 set(handles.DeleteObject,'Visible','on')% make the object delete button visible 4696 if check_plot 4697 hhset_object=guidata(hset_object); 4698 set_object('PLOT_Callback',1,[],hhset_object);% call the GUI set_object 4699 end 4713 4700 4714 4701 %------------------------------------------------------------------------ … … 4717 4704 %get the object file 4718 4705 fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml'); 4719 4720 4706 if ~isempty(fileinput) 4721 4707 %read the file
Note: See TracChangeset
for help on using the changeset viewer.