Changeset 851 for trunk/src/series.m
- Timestamp:
- Jan 19, 2015, 9:29:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r845 r851 132 132 ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback 133 133 NbBuiltinAction=numel(ActionList); 134 set(handles.Action,'UserData',NbBuiltinAction) 134 135 [path_series,name,ext]=fileparts(which('series'));% path to the GUI series 135 136 path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series' 136 137 ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh 137 ActionPathList=cell(NbBuiltinAction, numel(ActionExtList));%initiate the cell matrix of Action fct paths138 ActionPathList=cell(NbBuiltinAction,1);%initiate the cell matrix of Action fct paths 138 139 ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members 139 140 RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh) … … 148 149 set(handles.RunMode,'String',RunModeList) 149 150 150 %% list of builtin transform functions in the me bu TransformName151 %% list of builtin transform functions in the menu TransformName 151 152 TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback 152 153 NbBuiltinTransform=numel(TransformList); … … 167 168 end 168 169 end 169 %get the list of previous cam apigns in the upper bar menu Open campaign170 %get the list of previous campaigns in the upper bar menu Open campaign 170 171 if isfield(h,'MenuCampaign') 171 172 for ifile=1:min(length(h.MenuCampaign),5) … … 526 527 iline=eventdata.Indices(1); 527 528 end 528 set(handles.InputTable,'UserData',iline); 529 set(handles.InputLine,'String',num2str(iline)); 530 % set(handles.InputTable,'UserData',iline); 529 531 530 532 %------------------------------------------------------------------------ … … 535 537 xx=double(get(handles.series,'CurrentCharacter')); %get the keyboard character 536 538 if ~isempty(xx) 537 switch xx 538 case 31 %downward arrow 539 InputTable=get(handles.InputTable,'Data'); 540 iline=get(handles.InputTable,'UserData'); 541 if isequal(iline,size(InputTable,1))% arrow downward 542 InputTable=[InputTable;InputTable(iline,:)];% create a new line as a copy of the last one 543 set(handles.InputTable,'Data',InputTable); 544 end 545 case 127 %key 'Suppress' 546 InputTable=get(handles.InputTable,'Data'); 547 iline=get(handles.InputTable,'UserData'); 548 if iline>1 549 InputTable(iline,:)=[];% suppress the current line if not the first 550 set(handles.InputTable,'Data',InputTable); 551 end 552 end 539 switch xx 540 case 31 %downward arrow 541 InputTable=get(handles.InputTable,'Data'); 542 iline=str2double(get(handles.InputLine,'String')); 543 if isequal(iline,size(InputTable,1))% arrow downward 544 InputTable=[InputTable;InputTable(iline,:)];% create a new line as a copy of the last one 545 set(handles.InputTable,'Data',InputTable); 546 end 547 case 127 %key 'Suppress' 548 ClearLine_Callback(hObject, eventdata, handles) 549 end 553 550 end 554 551 … … 609 606 %------------------------------------------------------------------------ 610 607 % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser 611 function errormsg=display_file_name(handles,Param,iview) 612 %------------------------------------------------------------------------ 613 % 608 %------------------------------------------------------------------------ 614 609 % INPUT: 615 610 % handles: handles of elements in the GUI … … 618 613 % or 'one': refresh the list 619 614 % 'append': add a new line to the input table 615 function errormsg=display_file_name(handles,Param,iview) 616 620 617 set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation) 621 618 drawnow … … 683 680 iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line 684 681 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 685 % SeriesData.ListViewMenu(iview)=zeros(1,nbview)686 682 elseif strcmp(iview,'one') % refresh the list of input file series 687 683 iview=1; %the first line in InputTable becomes the current line … … 702 698 SeriesData.FileInfo={}; 703 699 SeriesData.Time={}; 700 end 701 if iview >1 702 set(handles.InputLine,'String',num2str(iview)) 704 703 end 705 704 set(handles.InputTable,'Data',InputTable) … … 1487 1486 check_create=1; %need to create the result directory by default 1488 1487 while detect 1489 answer=msgbox_uvmat('INPUT_Y-N ',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']);1488 answer=msgbox_uvmat('INPUT_Y-N-Cancel',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); 1490 1489 if strcmp(answer,'Cancel') 1491 1490 set(handles.RUN,'backgroundcolor',[1 0 0]) … … 1818 1817 Param=rmfield(Param,'Pairs'); %info Pairs not needed for output 1819 1818 end 1819 Param.IndexRange.TimeSource=Param.IndexRange.TimeTable{end,1}; 1820 1820 Param.IndexRange=rmfield(Param.IndexRange,'TimeTable'); 1821 1821 empty_line=false(size(Param.InputTable,1),1); … … 1846 1846 drawnow 1847 1847 1848 %% check whether the input file(s) need to be refreshed 1849 % SeriesData=get(handles.series,'UserData');%hidden parameters 1850 % if ~isfield(SeriesData,'i1_series') 1851 % msgbox_uvmat('ERROR','The input field series needs to be refreshed: press REFRESH'); 1852 % return 1853 % end 1854 1848 1855 %% get Action name and path 1849 nb_builtin_ACTION=4; %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series)1856 NbBuiltinAction=get(handles.Action,'UserData'); %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series) 1850 1857 ActionList=get(handles.ActionName,'String');% list menu fields 1851 1858 ActionIndex=get(handles.ActionName,'Value'); … … 1870 1877 return 1871 1878 end 1872 [ ActionPath,ActionName,ActionExt]=fileparts(FileName);1879 [tild,ActionName,ActionExt]=fileparts(FileName); 1873 1880 1874 1881 % insert the choice in the menu ActionName 1875 1882 ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action 1876 if isempty(ActionIndex)%the input string does not exist in the menu 1883 PathName=regexprep(PathName,'/$',''); 1884 if ~isempty(ActionIndex) && ~strcmp(ActionPathList{ActionIndex},PathName)%compare the path to the existing fct 1885 ActionIndex=[]; % the selected path is different than the recorded one 1886 end 1887 if isempty(ActionIndex)%the qselected fct (with selected path) does not exist in the menu 1877 1888 ActionIndex= length(ActionList); 1878 1889 ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)];% the selected function is appended in the menu, before the last item 'more...' 1879 set(handles.ActionName,'String',ActionList)1890 ActionPathList=[ActionPathList; PathName]; 1880 1891 end 1881 1892 … … 1885 1896 if isempty(ActionExtIndex) 1886 1897 set(handles.ActionExt,'String',[ActionExtList;{ActionExt}]) 1887 ActionExtIndex=numel(ActionExtList)+1; 1888 ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath 1889 ActionPathList=[ActionPathList ActionPathNew]; 1890 end 1891 set(handles.ActionName,'UserData',ActionPathList); 1898 end 1892 1899 1893 1900 % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5) 1894 if length(ActionList)> nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu1895 nbremove=length(ActionList)- nb_builtin_ACTION-5;1896 ActionList( nb_builtin_ACTION+1:end-5)=[];1897 ActionPathList( nb_builtin_ACTION+1:end-4,:)=[];1901 if length(ActionList)>NbBuiltinAction+5; %nb_builtin_ACTION=nbre of functions always remaining in the initial menu 1902 nbremove=length(ActionList)-NbBuiltinAction-5; 1903 ActionList(NbBuiltinAction+1:end-5)=[]; 1904 ActionPathList(NbBuiltinAction+1:end-4,:)=[]; 1898 1905 ActionIndex=ActionIndex-nbremove; 1899 1906 end … … 1902 1909 set(handles.ActionName,'Value',ActionIndex) 1903 1910 set(handles.ActionName,'String',ActionList) 1911 set(handles.ActionName,'UserData',ActionPathList); 1904 1912 set(handles.ActionExt,'Value',ActionExtIndex) 1905 ActionPathList{ActionIndex,ActionExtIndex}=PathName;1913 % ActionPathList{ActionIndex,ActionExtIndex}=PathName; 1906 1914 1907 1915 %record the user defined menu additions in personal file profil_perso 1908 1916 dir_perso=prefdir; 1909 1917 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 1910 if nb_builtin_ACTION+1<=numel(ActionList)-11911 ActionListUser=ActionList( nb_builtin_ACTION+1:numel(ActionList)-1);1912 ActionPathListUser=ActionPathList( nb_builtin_ACTION+1:numel(ActionList)-1,:);1918 if NbBuiltinAction+1<=numel(ActionList)-1 1919 ActionListUser=ActionList(NbBuiltinAction+1:numel(ActionList)-1); 1920 ActionPathListUser=ActionPathList(NbBuiltinAction+1:numel(ActionList)-1); 1913 1921 ActionExtListUser={}; 1914 1922 if numel(ActionExtList)>2 … … 2259 2267 set(handles.series,'UserData',SeriesData) 2260 2268 set(handles.ActionName,'BackgroundColor',[1 1 1]) 2261 2262 %------------------------------------------------------------------------2263 % --- Executes on button press in ActionInput.2264 function ActionInput_Callback(hObject, eventdata, handles)2265 %------------------------------------------------------------------------2266 % if get(handles.ActionInput,'Value')2267 ActionName_Callback(hObject, eventdata, handles)2268 % end2269 2269 2270 2270 %------------------------------------------------------------------------ … … 2803 2803 function MenuImportConfig_Callback(hObject, eventdata, handles) 2804 2804 2805 %% use a starting file name for browserr2805 %% use a browser to choose the xml file containing the processing config 2806 2806 InputTable=get(handles.InputTable,'Data'); 2807 oldfile=InputTable{1,1}; 2807 oldfile=InputTable{1,1};%current path in InputTable 2808 2808 if isempty(oldfile) 2809 2809 % use a file name stored in prefdir … … 2818 2818 end 2819 2819 filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters 2820 %proceed only if a file has been introduced by the browser 2821 if ~isempty(filexml) 2822 Param=xml2struct(filexml);% read the input xml file as a Matlab structure 2823 % ask to stop current Action if button RUN is in action (another process is already running) 2824 if isequal(get(handles.RUN,'Value'),1) 2825 answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); 2826 if strcmp(answer,'Yes') 2827 STOP_Callback(hObject, eventdata, handles) 2828 else 2829 return 2830 end 2831 end 2832 Param.Action.RUN=0; %desactivate the input RUN=1 2833 fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters 2834 SeriesData=get(handles.series,'UserData'); 2835 if isfield(Param,'InputFields') 2836 ListField=Param.InputFields.FieldName; 2837 if ischar(ListField),ListField={ListField}; end 2838 set(handles.FieldName,'String',[ListField;{'get-field...'}]) 2839 set(handles.FieldName,'Value',1:numel(ListField)) 2840 set(handles.FieldName,'Visible','on') 2841 end 2842 if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters 2843 set(handles.ActionInput,'Visible','on') 2844 set(handles.ActionInput,'Value',0) 2845 Param.ActionInput.ConfigSource=filexml;% record the source of config for future info 2846 SeriesData.ActionInput=Param.ActionInput; 2847 end 2848 if isfield(Param,'ProjObject') %introduce projection object if relevant 2849 SeriesData.ProjObject=Param.ProjObject; 2850 end 2851 set(handles.series,'UserData',SeriesData) 2852 if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1) 2853 set(handles.ProjObject,'String',Param.ProjObject.Name) 2854 set(handles.ViewObject,'Visible','on') 2855 set(handles.EditObject,'Visible','on') 2856 set(handles.DeleteObject,'Visible','on') 2857 else 2858 set(handles.ProjObject,'String','') 2859 set(handles.ProjObject,'Visible','off') 2860 set(handles.ViewObject,'Visible','off') 2861 set(handles.EditObject,'Visible','off') 2862 set(handles.DeleteObject,'Visible','off') 2863 end 2864 set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated 2865 end 2866 2867 2868 2869 % -------------------------------------------------------------------- 2870 % function MenuImportParam_Callback(hObject, eventdata, handles) 2871 % %% use a starting file name for browserr 2872 % InputTable=get(handles.InputTable,'Data'); 2873 % oldfile=InputTable{1,1}; 2874 % if isempty(oldfile) 2875 % % use a file name stored in prefdir 2876 % dir_perso=prefdir; 2877 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 2878 % if exist(profil_perso,'file') 2879 % h=load (profil_perso); 2880 % if isfield(h,'RootPath') && ischar(h.RootPath) 2881 % oldfile=h.RootPath; 2882 % end 2883 % end 2884 % end 2885 % filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters 2886 % %proceed only if a file has been introduced by the browser 2887 % if ~isempty(filexml) 2888 % Param=xml2struct(filexml);% read the input xml file as a Matlab structure 2889 % % ask to stop current Action if button RUN is in action (another process is already running) 2890 % if isequal(get(handles.RUN,'Value'),1) 2891 % answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); 2892 % if strcmp(answer,'Yes') 2893 % STOP_Callback(hObject, eventdata, handles) 2894 % else 2895 % return 2896 % end 2897 % end 2898 % Param.Action.RUN=0; %desactivate the input RUN=1 2899 % if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange') 2900 % msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''') 2901 % return 2902 % end 2903 % Param=rmfield(Param,'InputTable');% do not refresh Input files and index range 2904 % Param=rmfield(Param,'IndexRange'); 2905 % fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters 2906 % SeriesData=get(handles.series,'UserData'); 2907 % if isfield(Param,'InputFields') 2908 % ListField=Param.InputFields.FieldName; 2909 % set(handles.FieldName,'String',[ListField;{'get-field...'}]) 2910 % set(handles.FieldName,'Value',1:numel(ListField)) 2911 % end 2912 % if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters 2913 % set(handles.ActionInput,'Visible','on') 2914 % set(handles.ActionInput,'Value',0) 2915 % Param.ActionInput.ConfigSource=filexml;% record the source of config for future info 2916 % SeriesData.ActionInput=Param.ActionInput; 2917 % end 2918 % if isfield(Param,'ProjObject') %introduce projection object if relevant 2919 % SeriesData.ProjObject=Param.ProjObject; 2920 % end 2921 % set(handles.series,'UserData',SeriesData) 2922 % if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1) 2923 % set(handles.ProjObject,'String',Param.ProjObject.Name) 2924 % set(handles.ViewObject,'Visible','on') 2925 % set(handles.EditObject,'Visible','on') 2926 % set(handles.DeleteObject,'Visible','on') 2927 % else 2928 % set(handles.ProjObject,'String','') 2929 % set(handles.ProjObject,'Visible','off') 2930 % set(handles.ViewObject,'Visible','off') 2931 % set(handles.EditObject,'Visible','off') 2932 % set(handles.DeleteObject,'Visible','off') 2933 % end 2934 % set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated 2935 % end 2936 2820 if isempty(filexml), return, end % quit function if an xml file has not been opened 2821 2822 %% fill the GUI series with the content of the xml file 2823 Param=xml2struct(filexml);% read the input xml file as a Matlab structure 2824 2825 % ask to stop current Action if button RUN is in action (another process is already running) 2826 if isequal(get(handles.RUN,'Value'),1) 2827 answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); 2828 if strcmp(answer,'Yes') 2829 STOP_Callback(hObject, eventdata, handles) 2830 else 2831 return 2832 end 2833 end 2834 Param.Action.RUN=0; %desactivate the input RUN=1 2835 2836 fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters 2837 SeriesData=get(handles.series,'UserData'); 2838 if isfield(Param,'InputFields') 2839 ListField=Param.InputFields.FieldName; 2840 if ischar(ListField),ListField={ListField}; end 2841 set(handles.FieldName,'String',[ListField;{'get-field...'}]) 2842 set(handles.FieldName,'Value',1:numel(ListField)) 2843 set(handles.FieldName,'Visible','on') 2844 end 2845 if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters 2846 set(handles.ActionInput,'Visible','on') 2847 set(handles.ActionInput,'Value',0) 2848 Param.ActionInput.ConfigSource=filexml;% record the source of config for future info 2849 SeriesData.ActionInput=Param.ActionInput; 2850 end 2851 if isfield(Param,'ProjObject') %introduce projection object if relevant 2852 SeriesData.ProjObject=Param.ProjObject; 2853 end 2854 set(handles.series,'UserData',SeriesData) 2855 if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1) 2856 set(handles.ProjObject,'String',Param.ProjObject.Name) 2857 set(handles.ViewObject,'Visible','on') 2858 set(handles.EditObject,'Visible','on') 2859 set(handles.DeleteObject,'Visible','on') 2860 else 2861 set(handles.ProjObject,'String','') 2862 set(handles.ProjObject,'Visible','off') 2863 set(handles.ViewObject,'Visible','off') 2864 set(handles.EditObject,'Visible','off') 2865 set(handles.DeleteObject,'Visible','off') 2866 end 2867 set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated 2937 2868 2938 2869 … … 3127 3058 ActionList=get(handles.ActionName,'String'); 3128 3059 ActionName=ActionList{get(handles.ActionName,'Value')}; 3129 % TransformPath='';3130 % if ~isempty(get(handles.ActionExt,'UserData'))3131 % TransformPath=get(handles.ActionExt,'UserData');3132 % end3133 % if strcmp(ActionExt,'.sh')3134 % set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'3135 % set(handles.ActionExt,'BackgroundColor',[1 1 0])3136 % ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']);3137 % if ~exist(ActionFullName,'file')3138 % answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');3139 % if strcmp(answer,'Yes')3140 % set(handles.ActionExt,'BackgroundColor',[1 1 0])3141 % path_uvmat=fileparts(which('series'));3142 % currentdir=pwd;3143 % cd(get(handles.ActionPath,'String'))% go to the directory of Action3144 % % addpath(get(handles.TransformPath,'String'))3145 % addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'3146 % % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'3147 % compile(ActionName,TransformPath)3148 % cd(currentdir)3149 % end3150 % else3151 % sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));3152 % m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));3153 % if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum3154 % set(handles.ActionExt,'BackgroundColor',[1 1 0])3155 % drawnow3156 % answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);3157 % if strcmp(answer,'Yes')3158 % path_uvmat=fileparts(which('series'));3159 % currentdir=pwd;3160 % cd(get(handles.ActionPath,'String'))% go to the directory of Action3161 % % addpath(get(handles.TransformPath,'String'))3162 % addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'3163 % addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'3164 % compile(ActionName,TransformPath)3165 % cd(currentdir)3166 % end3167 % end3168 % end3169 % set(handles.ActionExt,'BackgroundColor',[1 1 1])3170 % set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch3171 % end3172 3173 3060 3174 3061 function num_NbProcess_Callback(hObject, eventdata, handles) … … 3257 3144 end 3258 3145 ref_i=str2num(get(handles.num_first_i,'String')); 3259 ref_j=str2num(get(handles.num_first_j,'String')); 3146 ref_j=1;%default 3147 if strcmp(get(handles.num_first_j,'String'),'Visible') 3148 ref_j=str2num(get(handles.num_first_j,'String')); 3149 end 3260 3150 [ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j2_series{iview}); 3261 3151 displ_pair=update_listpair(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j1_series{iview},SeriesData.j2_series{iview},ModeMenu{ModeValue},... … … 3375 3265 Mode_Callback([],[]) 3376 3266 3377 3267 %------------------------------------------------------------------------ 3378 3268 % --- Executes on button press in ClearLine. 3269 %------------------------------------------------------------------------ 3379 3270 function ClearLine_Callback(hObject, eventdata, handles) 3380 % hObject handle to ClearLine (see GCBO)3381 % eventdata reserved - to be defined in a future version of MATLAB3382 % handles structure with handles and user data (see GUIDATA)3383 iline=get(handles.InputTable,'UserData');3384 3271 InputTable=get(handles.InputTable,'Data'); 3385 InputTable(iline,:)=[]; 3386 set(handles.InputTable,'Data',InputTable); 3272 iline=str2double(get(handles.InputLine,'String')); 3273 if size(InputTable,1)>1 3274 InputTable(iline,:)=[];% suppress the current line if not the first 3275 set(handles.InputTable,'Data',InputTable); 3276 end
Note: See TracChangeset
for help on using the changeset viewer.