Changeset 517 for trunk/src/get_field.m


Ignore:
Timestamp:
Aug 17, 2012, 11:47:16 PM (9 years ago)
Author:
sommeria
Message:

various bugs corrected. get_field now used in a passive way from uvmat: variable names are transferred from get_field to uvmat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r512 r517  
    6060%% prepare the list of RUN fcts and set their paths
    6161% functions included by default in 'get_field.m
    62 menu_str={'PLOT';'FFT';'filter_band'};
    63 nb_builtin=numel(menu_str);
    64 path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
    65 addpath(fullfile(path_uvmat,'get_field'))
    66 testexist=zeros(size(menu_str'));%default
    67 for ilist=1:length(menu_str)
    68     if exist(menu_str{ilist},'file')
    69         fct_handle{ilist,1}=str2func(menu_str{ilist});
    70         testexist(ilist)=1;
    71     else
    72         fct_handle{ilist,1}=[];
    73         testexist(ilist)=0;
    74     end
    75 end
    76 rmpath(fullfile(path_uvmat,'get_field'))
    77 dir_perso=prefdir;
     62% menu_str={'PLOT';'FFT';'filter_band'};
     63% nb_builtin=numel(menu_str);
     64% path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
     65% addpath(fullfile(path_uvmat,'get_field'))
     66% testexist=zeros(size(menu_str'));%default
     67% for ilist=1:length(menu_str)
     68%     if exist(menu_str{ilist},'file')
     69%         fct_handle{ilist,1}=str2func(menu_str{ilist});
     70%         testexist(ilist)=1;
     71%     else
     72%         fct_handle{ilist,1}=[];
     73%         testexist(ilist)=0;
     74%     end
     75% end
     76% rmpath(fullfile(path_uvmat,'get_field'))
     77% dir_perso=prefdir;
    7878
    7979% look for functions previously used (names and paths saved in the personal file uvmat_perso.mat):
    80 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    81 if exist(profil_perso,'file')
    82       h=load (profil_perso);
    83      if isfield(h,'get_field_fct') && iscell(h.get_field_fct)
    84          for ilist=1:length(h.get_field_fct)
    85             [path,file]=fileparts(h.get_field_fct{ilist});
    86             addpath(path)       
    87             if exist(file,'file')
    88                 h_func=str2func(file);
    89                 testexist=[testexist 1];
    90              else
    91                 h_func=[];
    92                 testexist=[testexist 0];
    93              end
    94              fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
    95              rmpath(path)
    96              menu_str=[menu_str; {file}];
    97          end
    98      end
    99 end
    100 
    101 menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
    102 fct_handle=fct_handle(testexist==1);
    103 menu_str=[menu_str;{'more...'}];
    104 set(handles.ACTION,'String',menu_str)
    105 set(handles.ACTION,'UserData',fct_handle)% store the list of path in UserData of ACTION
    106 set(handles.path_action,'String',fullfile(path_uvmat,'get_field'))
    107 set(handles.ACTION,'Value',1)% PLOT option selected
     80% profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     81% if exist(profil_perso,'file')
     82%       h=load (profil_perso);
     83%      if isfield(h,'get_field_fct') && iscell(h.get_field_fct)
     84%          for ilist=1:length(h.get_field_fct)
     85%             [path,file]=fileparts(h.get_field_fct{ilist});
     86%             addpath(path)       
     87%             if exist(file,'file')
     88%                 h_func=str2func(file);
     89%                 testexist=[testexist 1];
     90%              else
     91%                 h_func=[];
     92%                 testexist=[testexist 0];
     93%              end
     94%              fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
     95%              rmpath(path)
     96%              menu_str=[menu_str; {file}];
     97%          end
     98%      end
     99% end
     100
     101% menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
     102% fct_handle=fct_handle(testexist==1);
     103% menu_str=[menu_str;{'more...'}];
     104% set(handles.ACTION,'String',menu_str)
     105% set(handles.ACTION,'UserData',fct_handle)% store the list of path in UserData of ACTION
     106% set(handles.path_action,'String',fullfile(path_uvmat,'get_field'))
     107% set(handles.ACTION,'Value',1)% PLOT option selected
    108108
    109109%% settings for 'slave' mode, called by uvamt, or 'master' mode
     
    122122
    123123%% load the list of previously browsed files for the upper bar menu Open
    124 dir_perso=prefdir;
    125 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%
    126 if exist(profil_perso,'file')
    127     h=load (profil_perso);
    128     if isfield(h,'MenuFile_1')
    129         set(handles.MenuFile_1,'Label',h.MenuFile_1);
    130     end
    131     if isfield(h,'MenuFile_1')
    132         set(handles.MenuFile_2,'Label',h.MenuFile_2);
    133     end
    134     if isfield(h,'MenuFile_1')
    135         set(handles.MenuFile_3,'Label',h.MenuFile_3);
    136     end
    137     if isfield(h,'MenuFile_1')
    138         set(handles.MenuFile_4,'Label',h.MenuFile_4);
    139     end
    140     if isfield(h,'MenuFile_1')
    141         set(handles.MenuFile_5,'Label',h.MenuFile_5);
    142     end
    143 end
     124% dir_perso=prefdir;
     125% profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%
     126% if exist(profil_perso,'file')
     127%     h=load (profil_perso);
     128%     if isfield(h,'MenuFile_1')
     129%         set(handles.MenuFile_1,'Label',h.MenuFile_1);
     130%     end
     131%     if isfield(h,'MenuFile_1')
     132%         set(handles.MenuFile_2,'Label',h.MenuFile_2);
     133%     end
     134%     if isfield(h,'MenuFile_1')
     135%         set(handles.MenuFile_3,'Label',h.MenuFile_3);
     136%     end
     137%     if isfield(h,'MenuFile_1')
     138%         set(handles.MenuFile_4,'Label',h.MenuFile_4);
     139%     end
     140%     if isfield(h,'MenuFile_1')
     141%         set(handles.MenuFile_5,'Label',h.MenuFile_5);
     142%     end
     143% end
    144144
    145145%% put the GUI on the lower right of the sceen
     
    831831function RUN_Callback(hObject, eventdata, handles)
    832832%---------------------------------------------------------
    833 set(handles.RUN,'BackgroundColor',[1 1 0])% mark use of RUN action
    834 test_fig=get(handles.SelectFigure,'Value');
    835 
    836 % plot requested in uvmat
    837 if ~test_fig
    838     inputfile=get(handles.inputfile,'String');
    839     huvmat=findobj(allchild(0),'tag','uvmat');
    840     if isempty(huvmat)
    841         input.InputFile=inputfile;
    842         input.FieldsString={'get_field...'};
    843         uvmat(input)
    844     else
    845         set(huvmat,'Visible','on')%make uvmat visible (bugs can hide it in some cases)
    846         hhuvmat=guidata(huvmat);
    847         set(hhuvmat.Fields,'Value',1)
    848         set(hhuvmat.Fields,'String',{'get_field...'})
    849         uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
    850     end
    851    
    852 % other kind of plot
    853 else  %TODO: check and update: add plot on an existing axes
    854     figcell=get(handles.list_fig,'String');
    855     index=get(handles.list_fig,'value');
    856     figstring=figcell{index};
    857     index=get(handles.ACTION,'Value');
    858     list_func=get(handles.ACTION,'UserData');
    859     h_fun=list_func{index};
    860     set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    861     drawnow
    862     SubField=h_fun(handles.get_field);%handles.figure1 =handles of the GUI get_field
    863     if ~isempty(SubField)
    864         plot_get_field(SubField,handles)
    865     end
    866     browse_fig(handles.list_fig); %update the list of new existing figures
    867 end
    868 set(handles.RUN,'BackgroundColor',[1 0 0])
     833% set(handles.RUN,'BackgroundColor',[1 1 0])% mark use of RUN action
     834% test_fig=get(handles.SelectFigure,'Value');
     835%
     836% % plot requested in uvmat
     837% if ~test_fig
     838%     inputfile=get(handles.inputfile,'String');
     839%     huvmat=findobj(allchild(0),'tag','uvmat');
     840%     if isempty(huvmat)
     841%         input.InputFile=inputfile;
     842%         input.FieldsString={'get_field...'};
     843%         uvmat(input)
     844%     else
     845%         set(huvmat,'Visible','on')%make uvmat visible (bugs can hide it in some cases)
     846%         hhuvmat=guidata(huvmat);
     847%         set(hhuvmat.Fields,'Value',1)
     848%         set(hhuvmat.Fields,'String',{'get_field...'})
     849%         uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
     850%     end
     851%   
     852% % other kind of plot
     853% else  %TODO: check and update: add plot on an existing axes
     854%     figcell=get(handles.list_fig,'String');
     855%     index=get(handles.list_fig,'value');
     856%     figstring=figcell{index};
     857%     index=get(handles.ACTION,'Value');
     858%     list_func=get(handles.ACTION,'UserData');
     859%     h_fun=list_func{index};
     860%     set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
     861%     drawnow
     862%     SubField=h_fun(handles.get_field);%handles.figure1 =handles of the GUI get_field
     863%     if ~isempty(SubField)
     864%         plot_get_field(SubField,handles)
     865%     end
     866%     browse_fig(handles.list_fig); %update the list of new existing figures
     867% end
     868% set(handles.RUN,'BackgroundColor',[1 0 0])
     869huvmat=findobj(allchild(0),'tag','uvmat');
     870if ~isempty(huvmat)
     871         set(huvmat,'Visible','on')%make uvmat visible (bugs can hide it in some cases)
     872         hhuvmat=guidata(huvmat);
     873         get_field_GUI=read_GUI(handles.get_field);
     874         if isfield(get_field_GUI,'PanelVectors')
     875             set(hhuvmat.Coord_x,'value',1)
     876             set(hhuvmat.Coord_y,'value',1)
     877             set(hhuvmat.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors})
     878             set(hhuvmat.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors})
     879             UName=get_field_GUI.PanelVectors.vector_x;
     880             VName=get_field_GUI.PanelVectors.vector_y;
     881             menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}];
     882             menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}];
     883             FieldsMenu=get(hhuvmat.Fields,'String');
     884             Fields=FieldsMenu{get(hhuvmat.Fields,'Value')};
     885             if strcmp(Fields,'get_field...')
     886                  set(hhuvmat.Fields,'Value',1)
     887                 set(hhuvmat.Fields,'String',menu_str)
     888             else %get_field has been called by Fields_1
     889                  set(hhuvmat.Fields_1,'Value',1)
     890                 set(hhuvmat.Fields_1,'String',menu_str)
     891             end
     892             ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color));
     893             if ~isempty(ind_menu)
     894             set(hhuvmat.ColorScalar,'Value',ind_menu)
     895             else
     896                 set(hhuvmat.ColorScalar,'Value',1)
     897             end
     898               set(hhuvmat.ColorScalar,'String',menu_color)
     899         end
     900end
     901delete(handles.get_field)
     902%         set(hhuvmat.Fields,'String',{'get_field...'})
     903%         uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
     904%     end
    869905
    870906%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.