Changeset 180 for trunk/src/get_field.m


Ignore:
Timestamp:
Jan 18, 2011, 10:50:40 PM (13 years ago)
Author:
sommeria
Message:

rationalisation of uvmat, introduction of the new function read_field, links with get_field, several bug repairs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r179 r180  
    4545%------------------------------------------------------------------------
    4646% --- Executes just before get_field is made visible.
    47 function get_field_OpeningFcn(hObject, eventdata, handles,filename,Field,haxes)
    48 %------------------------------------------------------------------------
    49 global nb_builtin
    50 
    51 %% look at the existing figues in the work space
     47function get_field_OpeningFcn(hObject, eventdata, handles,filename,multiple)
     48%------------------------------------------------------------------------
     49global nb_builtin % nbre of functions to include by default in the menu of  functions called by RUN
     50
     51%% look at the existing figures in the work space
    5252browse_fig(handles.list_fig)
    5353
     
    6161set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
    6262
    63 %% prepare the list of builtin fcts and set their paths
    64 menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included by default in 'get_field.m'
     63%% prepare the list of RUN fcts and set their paths
     64% functions included by default in 'get_field.m
     65menu_str={'PLOT';'FFT';'filter_band';'histogram'};
    6566nb_builtin=numel(menu_str);
    6667path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
     
    7879rmpath(fullfile(path_uvmat,'get_field'))
    7980dir_perso=prefdir;
     81
     82% look for functions previously used (names and paths saved in the personal file uvmat_perso.mat):
    8083profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    8184if exist(profil_perso,'file')
    82     % menu={'RUN';'raw2phys';'histogram';'FFT';'peaklocking'};
    8385      h=load (profil_perso);
    8486     if isfield(h,'get_field_fct') && iscell(h.get_field_fct)
     
    99101     end
    100102end
     103
    101104menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
    102105fct_handle=fct_handle(testexist==1);
     
    110113if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
    111114    set(handles.inputfile,'String',filename)% prefill the input file name
    112     set(handles.inputfile,'Enable','off')% desactivate the input file edit box   
    113   %  set(handles.list_fig,'Value',2)% plotting axes =uvmat selected
    114   %  set(handles.list_fig,'Visible','off')%
    115     set(handles.RUN,'String','REFRESH')% passive mode, get_field used to define the field for uvamt
    116     set(handles.MenuOpen,'Visible','off')
    117     set(handles.MenuExport,'Visible','off')
    118     set(handles.MenuHelp,'Visible','off')
    119     inputfile_Callback(hObject, eventdata, handles)
     115    Field=nc2struct(filename);% reads the whole field
     116    if isfield(Field,'Txt')
     117        msgbox_uvmat('ERROR',Field.Txt)
     118    else
     119        set(handles.figure1,'UserData',Field);
     120        Field_input(eventdata,handles,Field);
     121    end
    120122else  %master mode
    121123    set(handles.inputfile,'String','')   
    122     set(handles.RUN,'String','RUN')%
     124%     set(handles.RUN,'String','RUN')%
    123125    % load the list of previously browsed files for the upper bar menu Open
    124126    dir_perso=prefdir;
     
    143145    end
    144146end
    145 %transfer input field  in slave mode
    146 if exist('Field','var') && isstruct(Field)
    147         Field_input(eventdata,handles,Field)
    148 %         if exist('haxes','var')
    149 %             'TESTget'
    150 %             get(haxes,'Tag')
    151 %             Field.PlotAxes=haxes;
    152 %         end
    153     set(hObject,'UserData',Field);
    154 end
    155 
     147
     148%% remove already opened get_field GUI with name get_field
     149if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence
     150    hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI
     151    if length(hget_field)>1
     152        delete(hget_field(2))
     153    end
     154else
     155    set(hObject,'name','get_field_1')
     156end
    156157
    157158
     
    163164
    164165%------------------------------------------------------------------------
    165 % --- Executes on button press in browse.
    166 function browse_Callback(hObject, eventdata, handles)
    167 %------------------------------------------------------------------------
    168 
    169 %------------------------------------------------------------------------
     166% --- Executes when a new input file name is introduced.
    170167function inputfile_Callback(hObject, eventdata, handles)
    171168%------------------------------------------------------------------------
     
    178175Field_input(eventdata,handles,Field);
    179176end
    180 
    181 %------------------------------------------------------------------------
     177huvmat=findobj(allchild(0),'tag','uvmat');
     178if ~isempty(huvmat)
     179    delete(huvmat)%delete uvmat for plot reinitialisation
     180end
     181
     182%------------------------------------------------------------------------
     183% --- update the display when a new field is introduced.
    182184function Field_input(eventdata,handles,Field)
    183185%------------------------------------------------------------------------
     
    256258                set(handles.coord_y_scalar,'Value',VarType{imax}.coord_y+1)
    257259            end
     260            if ~isempty(VarType{imax}.coord_z)
     261                set(handles.coord_z_scalar,'Value',VarType{imax}.coord_z+1)
     262            end
    258263            if ~isempty(VarType{imax}.coord)
    259                 set(handles.coord_y_scalar,'Value',VarType{imax}.coord(1)+1)
    260                 if numel(VarType{imax}.coord)>=2
    261                     set(handles.coord_x_scalar,'Value',VarType{imax}.coord(2)+1)
     264                if numel(VarType{imax}.coord)>=maxdim-2
     265                    set(handles.coord_z_scalar,'Value',VarType{imax}.coord(maxdim-2)+1)
    262266                end
     267                if numel(VarType{imax}.coord)>=maxdim-1
     268                    set(handles.coord_y_scalar,'Value',VarType{imax}.coord(maxdim-1)+1)
     269                end
     270                if numel(VarType{imax}.coord)>=maxdim
     271                    set(handles.coord_x_scalar,'Value',VarType{imax}.coord(maxdim)+1)
     272                end     
    263273            end
    264274        end
     
    272282function ordinate_Callback(hObject, eventdata, handles)
    273283%------------------------------------------------------------------------
    274 %update_field(hObject, eventdata, handles)
    275 % A REVOIR
    276284hselect_field=get(handles.inputfile,'parent');
    277285Field=get(hselect_field,'UserData');
    278 % xindex=get(handles.abscissa,'Value');
    279286list=get(handles.ordinate,'String');
    280287yindex=get(handles.ordinate,'Value');
     
    298305coord_x_index=coord_x_index(coord_x_index~=0);
    299306set(handles.abscissa,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
    300 % Field.VarIndex.y=yindex;
    301 % set(hselect_field,'UserData',Field);
    302 %update_UserData(handles)
    303307
    304308%------------------------------------------------------------------------
     
    794798%---------------------------------------------------------
    795799% --- Executes on button press in RUN.
     800
    796801function RUN_Callback(hObject, eventdata, handles)
    797802%---------------------------------------------------------
     
    799804index=get(handles.list_fig,'value');
    800805figstring=figcell{index};
     806
     807% plot requested in uvmat
    801808if isequal(figstring,'uvmat')
     809    inputfile=get(handles.inputfile,'String');
    802810    huvmat=findobj(allchild(0),'tag','uvmat');
    803     hhuvmat=guidata(huvmat);
    804     uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
     811    if isempty(huvmat)
     812        inputfile=get(handles.inputfile,'String');
     813        uvmat(inputfile)
     814    else
     815        hhuvmat=guidata(huvmat);
     816        uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
     817    end
     818   
     819% other kind of plot
    805820else
    806     huvmat=findobj(allchild(0),'tag','uvmat');
    807     delete(huvmat)%
    808821    index=get(handles.ACTION,'Value');
    809822    list_func=get(handles.ACTION,'UserData');
     
    10771090set(handles.attributes,'String',Tabchar);
    10781091
    1079 % list_var=get(handles.dimensions,'String');
    1080 % val=get(handles.dimensions,'Value');
    1081 
    10821092% update dimensions;
    10831093if isfield(Field,'ListDimName')
     
    11091119end 
    11101120
     1121%------------------------------------------------------------------------
    11111122% --- Executes on button press in check_1Dplot.
    11121123function check_1Dplot_Callback(hObject, eventdata, handles)
     1124%------------------------------------------------------------------------
    11131125val=get(handles.check_1Dplot,'Value');
    11141126if isequal(val,0)
    11151127    set(handles.Panel1Dplot,'Visible','off')
    1116 %      set(handles.scalar,'Visible','off')
    1117 %     set(handles.ordinate,'Max',2.0)%allow multiple ordinate input option
    1118 %     if isequal(get(handles.check_vector,'Value'),0);
    1119 %         set(handles.coord_z_vectors_scalar,'Visible','off')
    1120 %     end
    11211128else
    11221129    set(handles.Panel1Dplot,'Visible','on')
    1123 %     set(handles.scalar,'Visible','on')
    1124 %     val=get(handles.ordinate,'Value');
    1125 %     val=val(1);
    1126 %     set(handles.ordinate,'Value',val);%suppress multiple ordinates
    1127 %     set(handles.ordinate,'Max',1.0);%suppress multiple ordinate input option
    1128 %       set(handles.coord_z_vectors_scalar,'Visible','on')
    1129 end
    1130 
     1130end
     1131
     1132%------------------------------------------------------------------------
    11311133% --- Executes on button press in check_scalar.
    11321134function check_scalar_Callback(hObject, eventdata, handles)
     1135%------------------------------------------------------------------------
    11331136val=get(handles.check_scalar,'Value');
    11341137if isequal(val,0)
     
    11381141end
    11391142
    1140 %---------------------------
     1143%------------------------------------------------------------------------
    11411144% --- Executes on button press in check_vector.
    11421145function check_vector_Callback(hObject, eventdata, handles)
     1146%------------------------------------------------------------------------
    11431147val=get(handles.check_vector,'Value');
    11441148if isequal(val,0)
     
    11481152end
    11491153
    1150 %-----------------------------
     1154%------------------------------------------------------------------------
    11511155function mouse_up_gui(ggg,eventdata,handles)
     1156%------------------------------------------------------------------------
    11521157if isequal(get(ggg,'SelectionType'),'alt')
    11531158    message=''; 
     
    11641169end
    11651170
    1166 %---------------------------------------------
     1171%------------------------------------------------------------------------
    11671172% --- Executes on selection change in ACTION.
     1173%------------------------------------------------------------------------
    11681174function ACTION_Callback(hObject, eventdata, handles)
    11691175global nb_builtin
     
    11751181% add a new function to the menu
    11761182if isequal(ACTION,'more...')
    1177 %     pathfct=fileparts(path_get_field);
    1178 %     browse_name=fullfile(path_get_field,'FIELD_FCT');
    1179 %     if length(list_path)>nb_builtin
    1180 %         browse_name=list_path{end};% initialize browser with  the path of the last introduced function
    1181 %     end
    11821183    [FileName, PathName] = uigetfile( ...
    11831184       {'*.m', ' (*.m)';
     
    13001301     end
    13011302end
    1302 list=['view_field';list];
     1303list=['uvmat';list];
    13031304set(menu_handle,'Value',1)
    13041305set(menu_handle,'String',list)
Note: See TracChangeset for help on using the changeset viewer.