Changeset 187


Ignore:
Timestamp:
Feb 1, 2011, 1:07:28 AM (10 years ago)
Author:
sommeria
Message:

various bug repairs

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_indices.m

    r105 r187  
    155155    end
    156156    %NbDim(icell)=0;% nbre of space dimensions
    157     NbDim(icell)=numel(DimCell);
     157%     NbDim(icell)=numel(DimCell);
     158    NbDim(icell)=0;
    158159    test_coord=0;
    159160    if numel(VarIndex)>1     
  • trunk/src/get_field.m

    r180 r187  
    262262            end
    263263            if ~isempty(VarType{imax}.coord)
    264                 if numel(VarType{imax}.coord)>=maxdim-2
     264                if numel(VarType{imax}.coord)>=maxdim-2 && maxdim>=3
    265265                    set(handles.coord_z_scalar,'Value',VarType{imax}.coord(maxdim-2)+1)
    266266                end
     
    12141214   dir_perso=prefdir;
    12151215   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     1216   get_field_fct={};
    12161217   for ilist=nb_builtin+1:length(menu_str)-1
    12171218       ff=functions(list_func_handles{ilist});
  • trunk/src/mouse_down.m

    r177 r187  
    3030hhuvmat=guidata(huvmat);%handles of elements in uvmat
    3131UvData=get(huvmat,'UserData');
    32 currentfig=hObject;
    33 hhcurrentfig=guidata(currentfig);
     32FigData=get(hObject,'UserData');
     33if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
     34    hcurrentfig=get(get(FigData,'parent'),'parent');
     35else
     36    hcurrentfig=hObject;%usual plot
     37end
     38hhcurrentfig=guidata(hcurrentfig);
    3439test_zoom=get(hhcurrentfig.zoom,'Value');%test for zoom action, first priority
    3540test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
     
    5863%% determine the currently selected items
    5964hcurrentobject=gco;% current object handle (selected by the mouse)
    60 hcurrentfig=hObject;% current figure handle
     65%hcurrentfig=hObject;% current figure handle
    6166fig_tag=get(hcurrentfig,'Tag');
    6267tag_obj=get(gco,'Tag');%tag of the currently selected object
    6368xy=[];%default
    64 xy_fig=get(hcurrentfig,'CurrentPoint');% current point of the current figure (gcbo)
    65 hchild=get(hcurrentfig,'Children');%handles of all objects in the current figure
     69xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
     70hchild=get(hObject,'Children');%handles of all objects in the current figure
    6671haxes=[];
    6772
     
    106111    end
    107112end
    108 test2D=0;
    109 if isfield(AxeData,'NbDim')
    110     if isequal(AxeData.NbDim,2)
    111         test2D=1;
    112     end
    113 end
    114 if ~test2D     %desable  object creation and vector editing if NbDim different from 2
     113
     114%% desable  object creation and vector editing if NbDim different from 2
     115if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
    115116    test_create=0;
    116     test_edit_vect=0;
    117 end
    118 %delete the current zoom rectangle
     117    test_edit_vect=0;   
     118end
     119
     120%% delete the current zoom rectangle
    119121if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
    120122    delete(AxeData.CurrentRectZoom)
  • trunk/src/mouse_motion.m

    r173 r187  
    2828    return
    2929end
    30 currentfig=hObject;
     30FigData=get(hObject,'UserData');
     31if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
     32    currentfig=get(get(FigData,'parent'),'parent');
     33else
     34    currentfig=hObject;%usual plot
     35end
    3136hhcurrentfig=guidata(currentfig);
    3237test_zoom=get(hhcurrentfig.zoom,'Value');%test for zoom activated on the current figure
     
    6166pointershape='arrow';% default pointer is an arrow
    6267
    63 xy_fig=get(currentfig,'CurrentPoint');% current point of the current figure (gcbo)
    64 hchild=get(currentfig,'Children');%handles of all objects in the current figure
     68xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
     69hchild=get(hObject,'Children');%handles of all objects in the current figure
    6570
    6671%% loop on all the objects in the current figure and detect whether the mouse is over a plot  axes
     
    7479        htype=get(hchild(ichild),'Type');%type of the crrent child
    7580        %if the mouse is over an axis, look at the data
    76         if isequal(htype,'axes')
     81        if strcmp(htype,'axes')
    7782            haxes=hchild(ichild);
    7883            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     
    144149                                    VarName=Field.ListVarName{CellVarIndex{icell}(1)};
    145150                                    eval(['nxy=size(Field.' VarName ');']);
    146 %                                     nxy(1)=numel(y);
    147 %                                     nxy(2)=numel(x);
    148151                                    MaxAY=max(y(1),y(end)); %#ok<COLND>
    149152                                    MinAY=min(y(1),y(end)); %#ok<COLND>
  • trunk/src/plot_field.m

    r186 r187  
    101101%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    102102
    103 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,htext,PosColorbar)
     103function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar)
    104104% TODO:
    105105% use htext: handles of the text edit box (uicontrol)
    106106% introduce PlotParam.Hold: 'on' or 'off' (for curves)
    107 
    108107%default output
    109108if ~exist('PlotParam','var'),PlotParam=[];end;
    110 if ~exist('htext','var'),htext=[];end;
    111109if ~exist('PosColorbar','var'),PosColorbar=[];end;
    112110PlotType='text'; %default
    113111PlotParamOut=PlotParam;%default
    114 if isempty(Data)
    115     PlotType='none';
    116    return
    117 end
    118 % check input structure
    119 [Data,errormsg]=check_field_structure(Data);
    120 
    121 if ~isempty(errormsg)
    122     msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
    123     display(['input of plot_field/check_field_structure:: ' errormsg])
    124     return
    125 end
    126 
     112
     113%% test axes and figure
    127114testnewfig=1;%test to create a new figure (default)
    128115testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes
     
    130117    if ishandle(haxes)
    131118        if isequal(get(haxes,'Type'),'axes')
    132 %             axes(haxes)
    133119            testnewfig=0;
    134120            AxeData=get(haxes,'UserData');
     
    145131    PlotParam=read_plot_param(PlotParam);   
    146132end
    147 if testnewfig% create a new figure and axes if the plotting axes does not exist
     133% create a new figure and axes if the plotting axes does not exist
     134if testnewfig
    148135    hfig=figure;
    149136    if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
     
    163150end
    164151
    165 if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1)
    166     set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
    167 end
    168 
    169 %% check the cells of fields :
    170 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
     152%% check input structure
     153if ~isempty(Data)
     154    [Data,errormsg]=check_field_structure(Data);
     155
     156    if ~isempty(errormsg)
     157        msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
     158        display(['input of plot_field/check_field_structure:: ' errormsg])
     159        return
     160    end
     161
     162    %% check the cells of fields :
     163    [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
     164
     165    if ~isempty(errormsg)
     166        msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]);
     167        return
     168    end
     169    index_3D=find(NbDim>2,1);
     170    if ~isempty(index_3D)
     171        msgbox_uvmat('ERROR','volume plot not implemented yet');
     172        return
     173    end
     174    index_2D=find(NbDim==2,2);%find 2D fields (at most 2)
     175    index_1D=find(NbDim==1);
     176    index_0D=find(NbDim==0);
     177   
     178        %% set axes properties
     179    if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1)  %adjust the graph limits*
     180        set(haxes,'XLimMode', 'manual')
     181        set(haxes,'YLimMode', 'manual')
     182    else
     183        set(haxes,'XLimMode', 'auto')
     184        set(haxes,'YLimMode', 'auto')
     185    end
     186    if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1)
     187        set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
     188    else
     189        set(haxes,'DataAspectRatioMode','manual')
     190    end
     191else
     192    index_2D=[];
     193    index_1D=[];
     194    index_0D=[];
     195end
    171196
    172197%% plot if the input field is valid
     198PlotType='text';
     199errormsg=[];
     200AxeData=get(haxes,'UserData');
     201if isempty(index_2D)
     202    plot_plane([],[],[],haxes);%removes images or vector plots if any
     203else
     204         [xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar);
     205         AxeData.NbDim=2;
     206            if testzoomaxes && isempty(errormsg)
     207                [zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar);
     208                AxeData.ZoomAxes=zoomaxes;
     209            end
     210end
     211if isempty(index_1D)
     212     plot_profile([],[],[],haxes);%
     213else
     214        plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam);%
     215        if testzoomaxes
     216            [zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam);
     217            AxeData.ZoomAxes=zoomaxes;
     218        end
     219        PlotType='line';
     220end
     221htext=findobj(hfig,'Tag','text_display');
     222if ~isempty(htext)
     223    if isempty(index_0D)
     224        set(htext,'String',{''})
     225    else
     226        [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext);
     227    end
     228end
     229
    173230if ~isempty(errormsg)
    174     errormsg=['input of plot_field/find_field_indices: ' errormsg];
    175 else
    176     if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot
    177         [Data.NbDim]=max(NbDim);
    178     end
    179     if isequal(Data.NbDim,0)
    180             AxeData=plot_text(Data,htext);
    181             PlotType='text';
    182             errormsg=[];
    183     elseif isequal(Data.NbDim,1)
    184         [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
    185         if testzoomaxes
    186             [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
    187             AxeData.ZoomAxes=zoomaxes;
    188         end
    189         PlotType='line';
    190         errormsg=[];
    191     elseif isequal(Data.NbDim,2)
    192         ind_select=find(NbDim>=2);
    193         if numel(ind_select)>2
    194             errormsg='more than two fields to map';
    195         else
    196             [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);
    197             if testzoomaxes && isempty(errormsg)
    198                 [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
    199                 Data.ZoomAxes=zoomaxes;
    200             end
    201         end
    202     elseif isequal(Data.NbDim,3)
    203         errormsg='volume plot not implemented yet';
    204     end
    205 end
    206 if isempty(errormsg)
    207     set(haxes,'UserData',Data)
    208 else
    209231    msgbox_uvmat('ERROR', errormsg)
    210232end
    211233
    212 
     234%% update the parameters stored in AxeData
     235set(haxes,'UserData',AxeData)
     236
     237%% update the parameters stored in parent figure
     238FigData=get(hfig,'UserData');
     239tagaxes=get(haxes,'tag');
     240if isfield(FigData,tagaxes)
     241    eval(['FigData.' tagaxes '=Data'])
     242    set(hfig,'UserData',FigData)
     243end
     244             
    213245%-------------------------------------------------------------------
    214 function hdisplay=plot_text(FieldData,hdisplay_in)
     246function errormsg=plot_text(FieldData,CellVarIndex,htext)
    215247%-------------------------------------------------------------------
    216 if exist('hdisplay_in','var') && ~isempty(hdisplay_in) && ishandle(hdisplay_in) && isequal(get(hdisplay_in,'Type'),'uicontrol')
    217     hdisplay=hdisplay_in;
    218 else
    219     figure;%create new figure
    220     hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
    221 end
    222    
    223 ff=fields(FieldData);%list of field names
    224 vv=struct2cell(FieldData);%list of field values
    225 
    226 for icell=1:length(vv)
    227     Tabcell{icell,1}=ff{icell};
    228     ss=vv{icell};
    229     sizss=size(ss);
    230     if isnumeric(ss)
    231         if sizss(1)<=1 && length(ss)<5
    232             displ{icell}=num2str(ss);
    233         else
    234             displ{icell}=[class(ss) ', size ' num2str(size(ss))];
    235         end
    236     elseif ischar(ss)
    237         displ{icell}=ss;
    238     elseif iscell(ss)
    239         sizcell=size(ss);
    240         if sizcell(1)==1 && length(sizcell)==2 %line cell
    241            ssline='{''';
    242            for icolumn=1:sizcell(2)
    243                if isnumeric(ss{icolumn})
    244                    if size(ss{icolumn},1)<=1 && length(ss{icolumn})<5
    245                       sscolumn=num2str(ss{icolumn});%line vector
    246                    else
    247                       sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
    248                    end
    249                elseif ischar(ss{icolumn})
    250                    sscolumn=ss{icolumn};
    251                else
    252                    sscolumn=class(ss{icolumn});
    253                end
    254                if icolumn==1
    255                    ssline=[ssline sscolumn];
    256                else
    257                    ssline=[ssline ''',''' sscolumn];
    258                end
    259            end
    260            displ{icell}=[ssline '''}'];
    261         else
    262            displ{icell}=[class(ss) ', size ' num2str(sizcell)];
    263         end
    264     else
    265         displ{icell}=class(ss);
    266     end
    267     Tabcell{icell,2}=displ{icell};
    268 end
    269 Tabchar=cell2tab(Tabcell,': ');
    270 set(hdisplay,'String', Tabchar)
     248% if exist('hdisplay_in','var') && ~isempty(hdisplay_in) && ishandle(hdisplay_in) && isequal(get(hdisplay_in,'Type'),'uicontrol')
     249%     hdisplay=hdisplay_in;
     250% else
     251%     figure;%create new figure
     252%     hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
     253% end
     254errormsg=[];
     255txt_cell={};
     256for icell=1:length(CellVarIndex)
     257    VarIndex=CellVarIndex{icell};%  indices of the selected variables in the list data.ListVarName
     258% ff=fields(FieldData);%list of field names
     259% vv=struct2cell(FieldData);%list of field values
     260%
     261% for icell=1:length(vv)
     262    for ivar=1:length(VarIndex)
     263         VarName=FieldData.ListVarName{VarIndex(ivar)};
     264         eval(['VarValue=FieldData.' VarName ';'])
     265         if size(VarValue,1)~=1
     266             VarValue=VarValue';
     267         end
     268         txt=[VarName '=' num2str(VarValue)];
     269         txt_cell=[txt_cell;{txt}];
     270    end
     271end
     272
     273set(htext,'String',txt_cell)
     274%     txt_cell=[txt_cell {num2str(
     275%     Tabcell{icell,1}=ff{icell};
     276%     ss=vv{icell};
     277%     sizss=size(ss);
     278%     if isnumeric(ss)
     279%         if sizss(1)<=1 && length(ss)<5
     280%             displ{icell}=num2str(ss);
     281%         else
     282%             displ{icell}=[class(ss) ', size ' num2str(size(ss))];
     283%         end
     284%     elseif ischar(ss)
     285%         displ{icell}=ss;
     286%     elseif iscell(ss)
     287%         sizcell=size(ss);
     288%         if sizcell(1)==1 && length(sizcell)==2 %line cell
     289%            ssline='{''';
     290%            for icolumn=1:sizcell(2)
     291%                if isnumeric(ss{icolumn})
     292%                    if size(ss{icolumn},1)<=1 && length(ss{icolumn})<5
     293%                       sscolumn=num2str(ss{icolumn});%line vector
     294%                    else
     295%                       sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
     296%                    end
     297%                elseif ischar(ss{icolumn})
     298%                    sscolumn=ss{icolumn};
     299%                else
     300%                    sscolumn=class(ss{icolumn});
     301%                end
     302%                if icolumn==1
     303%                    ssline=[ssline sscolumn];
     304%                else
     305%                    ssline=[ssline ''',''' sscolumn];
     306%                end
     307%            end
     308%            displ{icell}=[ssline '''}'];
     309%         else
     310%            displ{icell}=[class(ss) ', size ' num2str(sizcell)];
     311%         end
     312%     else
     313%         displ{icell}=class(ss);
     314%     end
     315%     Tabcell{icell,2}=displ{icell};
     316% end
     317% Tabchar=cell2tab(Tabcell,': ');
     318% set(hdisplay,'String', Tabchar)
    271319
    272320
    273321%-------------------------------------------------------------------
    274 function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
     322function [haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
    275323%-------------------------------------------------------------------
    276 %TODO: modify existing plot if it exists
    277 
    278324hfig=get(haxes,'parent');
    279 AxeData=[];%data;
     325%suppress existing plot isf empty data
     326if isempty(data)
     327    hplot=findobj(haxes,'tag','plot_line');
     328    if ~isempty(hplot)
     329        delete(hplot)
     330    end
     331    hlegend=findobj(hfig,'tag','legend');
     332    if ~isempty(hlegend)
     333        delete(hlegend)
     334    end
     335    return
     336end
     337
    280338
    281339ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
     
    285343end
    286344% adjust the size of the plot to include the whole field,
    287 if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1)  %adjust the graph limits*
    288     set(haxes,'XLimMode', 'manual')
    289     set(haxes,'YLimMode', 'manual')
    290 else
    291     set(haxes,'XLimMode', 'auto')
    292     set(haxes,'YLimMode', 'auto')
    293 end
     345
    294346legend_str={};
    295347
     
    297349%initiate  the plot command
    298350plotstr='hhh=plot(';
    299 textmean={};
     351% textmean={};
    300352coord_x_index=[];
     353xtitle='';
     354ytitle='';
    301355test_newplot=1;
    302 % hh=findobj(haxes,'tag','plot_line');
    303 % num_curve=numel(hh);
    304 % icurve=0;
    305356
    306357%loop on input  fields
     
    311362    else
    312363        coord_x_index_cell=VarType{icell}.coord(1);
    313         if isequal(coord_x_index_cell,0)
    314             continue  % the cell has no abscissa, skip it
    315         end
    316         if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index)
    317             continue %all the selected variables must have the same first dimension
    318         else
    319             coord_x_index=coord_x_index_cell;
    320         end
     364         if isequal(coord_x_index_cell,0)
     365             continue  % the cell has no abscissa, skip it
     366         end
     367%         if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index)
     368%             %continue %all the selected variables must have the same first dimension
     369%         else
     370%             coord_x_index=coord_x_index_cell;
     371%         end
     372          coord_x_index=coord_x_index_cell;
    321373    end
    322374    testplot=ones(size(data.ListVarName));%default test for plotted variables
    323     xtitle=data.ListVarName{coord_x_index};
     375    xtitle=[xtitle data.ListVarName{coord_x_index}];
    324376    eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
    325377    if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units')
    326         xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')'];
     378        xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units '), '];
     379    else
     380        xtitle=[xtitle ', '];
    327381    end
    328382    eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
     
    344398        end
    345399    end
    346     %     test_newplot=0;%default
    347     %     if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves
    348     %         if ~isempty(VarType{icell}.discrete')
    349     %             charplot_0='+';
    350     %             LineStyle='none';
    351     %         else
    352     %             charplot_0='none';
    353     %             LineStyle='-';
    354     %         end
    355     %         for ivar=1:length(VarIndex)
    356     %             if testplot(VarIndex(ivar))
    357     %                 icurve=icurve+1;
    358     %                 VarName=data.ListVarName{VarIndex(ivar)};
    359     %                 eval(['data.' VarName '=squeeze(data.' VarName ');'])
    360     %                 set(hh(icurve),'LineStyle',LineStyle)
    361     %                 set(hh(icurve),'Marker',charplot_0)
    362     %                 set(hh(icurve),'XData',coord_x{icell})
    363     %                 eval(['yy=data.' VarName ';'])
    364     %                 set(hh(icurve),'YData',yy);
    365     %             end
    366     %         end
    367     %     else% new plot
    368400    if ~isempty(VarType{icell}.discrete')
    369401        charplot_0='''+''';
     
    374406        if testplot(VarIndex(ivar))
    375407            VarName=data.ListVarName{VarIndex(ivar)};
     408            ytitle=[ytitle VarName];
     409            if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units')
     410                ytitle=[ytitle '(' data.VarAttribute{VarIndex(ivar)}.units '), '];
     411            else
     412                ytitle=[ytitle ', '];
     413            end
    376414            eval(['data.' VarName '=squeeze(data.' VarName ');'])
    377415            plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
     
    381419                coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
    382420            end
    383             eval(['varmean=mean(double(data.' VarName '));']);%mean value
    384             textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
     421            %eval(['varmean=mean(double(data.' VarName '));']);%mean value
     422            %textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
    385423            if nbcomponent1==1|| nbcomponent2==1
    386424                legend_str=[legend_str {VarName}]; %variable with one component
     
    395433
    396434%% activate the plot
    397 if test_newplot && ~isequal(plotstr,'hhh=plot(')
    398     plotstr=[plotstr '''tag'',''plot_line'');'];
    399                 %execute plot (instruction  plotstr)
    400 %     set(hfig,'CurrentAxes',haxes)
    401 %     axes(haxes)% select the plotting axes for plot operation
    402     eval(plotstr)
    403    
    404                 %%%%%
     435if test_newplot && ~isequal(plotstr,'hhh=plot(') 
     436    set(hfig,'CurrentAxes',haxes)
     437    tag=get(haxes,'tag');
     438   
     439    %%%
     440    plotstr=[plotstr '''tag'',''plot_line'');'];   
     441    eval(plotstr)                  %execute plot (instruction  plotstr)
     442    %%%
     443   
     444    set(haxes,'tag',tag)
    405445    grid(haxes, 'on')
    406     hxlabel=xlabel(xtitle);
     446    hxlabel=xlabel(xtitle(1:end-2));% xlabel (removes ', ' at the end)
    407447    set(hxlabel,'Interpreter','none')% desable tex interpreter
    408448    if length(legend_str)>=1
    409         hylabel=ylabel(legend_str{end});
     449        hylabel=ylabel(ytitle(1:end-2));% ylabel (removes ', ' at the end)
    410450        set(hylabel,'Interpreter','none')% desable tex interpreter
    411451    end
     
    445485        set(htitle,'Interpreter','none')% desable tex interpreter
    446486    end
    447     % A REPRENDRE Mean
    448 %         hlist=findobj(gcf,'Style','listbox','Tag','liststat');
    449 %         if isempty(hlist)
    450 %             'text'
    451 %             textmean
    452 %             set(gca,'position',[0.13,0.2,0.775,0.73])
    453 %             uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean,'Tag','liststat');
    454 %         else
    455 %             set(hlist(1),'String',textmean)
    456 %         end
    457487end
    458488
    459489
    460490%-------------------------------------------------------------------
    461 function [AxeData,haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)
     491function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,PosColorbar)
    462492%-------------------------------------------------------------------
    463493
     
    478508hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
    479509hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
    480 AxeData=get(haxes,'UserData'); %default
    481 if ~isstruct(AxeData)% AxeData must be a structure
    482     AxeData=[];
    483 end
    484 AxeData.NbDim=2;
     510% AxeData=get(haxes,'UserData'); %default
     511% if ~isstruct(AxeData)% AxeData must be a structure
     512%     AxeData=[];
     513% end
     514% AxeData.NbDim=2;
    485515% if isfield(Data,'ObjectCoord')
    486516%     AxeData.ObjectCoord=Data.ObjectCoord;
     
    816846            end
    817847            set(hima,'Tag','ima','HitTest','off')
    818             set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)           
     848            set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)     
     849            uistack(hima, 'bottom')
    819850        % update an existing image
    820851        else
     
    831862        end
    832863    end
    833     if ~isstruct(AxeData)
    834         AxeData=[];
    835     end
     864%     if ~isstruct(AxeData)
     865%         AxeData=[];
     866%     end
    836867    test_ima=1;
    837868   
     
    885916       delete(hcol)
    886917    end
    887 %     AxeData.A=[];
    888 %     AxeData.AX=[];
    889 %     AxeData.AY=[];
    890918    PlotParamOut=rmfield(PlotParamOut,'Scalar');
    891919end
     
    902930    vec_V=reshape(vec_V,1,numel(vec_V));
    903931     MinMaxX=max(vec_X)-min(vec_X);
    904 %     MinMaxY=max(vec_Y)-min(vec_Y);
    905 %     AxeData.Mesh=sqrt((MinMaxX*MinMaxY)/length(vec_X));
    906932    if  ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')...
    907933               ||isempty(PlotParam.Vectors.VecScale)||~isa(PlotParam.Vectors.VecScale,'double') %automatic vector scale
    908934%         scale=[];
    909935        if test_false %remove false vectors
    910             indsel=find(AxeData.FF==0);%indsel =indices of good vectors
     936            %indsel=find(AxeData.FF==0);%indsel =indices of good vectors
    911937        else     
    912938            indsel=1:numel(vec_X);%
     
    10021028
    10031029%store the coordinate extrema occupied by the field
    1004 test_lim=0;
    1005 if test_vec
    1006     Xlim=[min(vec_X) max(vec_X)];
    1007     Ylim=[min(vec_Y) max(vec_Y)];
    1008     test_lim=1;
    1009     if test_ima%both background image and vectors coexist, take the wider bound
    1010         Xlim(1)=min(AX(1),Xlim(1));
    1011         Xlim(2)=max(AX(end),Xlim(2));
    1012         Ylim(1)=min(AY(end),Ylim(1));
    1013         Ylim(2)=max(AY(1),Ylim(2));
    1014     end
    1015 elseif test_ima %only image plot
    1016     Xlim(1)=min(AX(1),AX(end));
    1017     Xlim(2)=max(AX(1),AX(end));
    1018     Ylim(1)=min(AY(1),AY(end));
    1019     Ylim(2)=max(AY(1),AY(end));
    1020     test_lim=1;
    1021 end
    1022 AxeData.RangeX=Xlim;
    1023 AxeData.RangeY=Ylim;
    1024 % adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1
    1025 if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) && test_lim
    1026         if Xlim(2)>Xlim(1)
    1027             set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
    1028         end
    1029         if Ylim(2)>Ylim(1)
    1030             set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
    1031         end
    1032 end
    1033 if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1))
    1034      set(haxes,'DataAspectRatio',[1 1 1])
    1035 end
    1036 set(haxes,'YDir','normal')
    1037 set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']);
    1038 set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']);
    1039 PlotParamOut.x_units=x_units;
    1040 PlotParamOut.y_units=y_units;
    1041 
     1030if ~isempty(Data)
     1031    test_lim=0;
     1032    if test_vec
     1033        Xlim=[min(vec_X) max(vec_X)];
     1034        Ylim=[min(vec_Y) max(vec_Y)];
     1035        test_lim=1;
     1036        if test_ima%both background image and vectors coexist, take the wider bound
     1037            Xlim(1)=min(AX(1),Xlim(1));
     1038            Xlim(2)=max(AX(end),Xlim(2));
     1039            Ylim(1)=min(AY(end),Ylim(1));
     1040            Ylim(2)=max(AY(1),Ylim(2));
     1041        end
     1042    elseif test_ima %only image plot
     1043        Xlim(1)=min(AX(1),AX(end));
     1044        Xlim(2)=max(AX(1),AX(end));
     1045        Ylim(1)=min(AY(1),AY(end));
     1046        Ylim(2)=max(AY(1),AY(end));
     1047        test_lim=1;
     1048    end
     1049    AxeData.RangeX=Xlim;
     1050    AxeData.RangeY=Ylim;
     1051%    adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1
     1052    if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) && test_lim
     1053            if Xlim(2)>Xlim(1)
     1054                set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates
     1055            end
     1056            if Ylim(2)>Ylim(1)
     1057                set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate
     1058            end
     1059    end
     1060    if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1))
     1061         set(haxes,'DataAspectRatio',[1 1 1])
     1062    end
     1063    set(haxes,'YDir','normal')
     1064    set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']);
     1065    set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']);
     1066    PlotParamOut.x_units=x_units;
     1067    PlotParamOut.y_units=y_units;
     1068end
    10421069%-------------------------------------------------------------------
    10431070% --- function for plotting vectors
  • trunk/src/plot_object.m

    r183 r187  
    194194            theta=0;
    195195        else
    196             theta=angle(diff(xline)+i*diff(yline));
     196            theta=angle(diff(xline)+1i*diff(yline));
    197197            theta(length(xline))=theta(length(xline)-1);
    198198        end
     
    386386    end
    387387    set(hh,'Tag','proj_object')
    388     if test_patch
    389         hold on
     388     if test_patch
     389         hold on
    390390        hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
    391         set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
    392         PlotData.SubObject=hhh;   
    393     end
     391       set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
     392         PlotData.SubObject=hhh;   
     393     end
    394394    if isfield(PlotData,'SubObject')
    395395        set(PlotData.SubObject,'UserData',hh)%record the parent handles in the SubObjects
  • trunk/src/proj_field.m

    r186 r187  
    139139end
    140140
    141 
    142141%-----------------------------------------------------------------
    143142%project on a set of points
     
    346345                ProjData.X(ipoint,1)=ObjectData.Coord(ipoint,1);
    347346                ProjData.Y(ipoint,1)=ObjectData.Coord(ipoint,2);
    348                 i_int=[i_min:i_plus];
    349                 j_int=[j_min:j_plus];
     347                i_int=(i_min:i_plus);
     348                j_int=(j_min:j_plus);
    350349                ProjData.NbVal(ipoint,1)=length(j_int)*length(i_int);
    351                 if isempty(i_int) | isempty(j_int)
     350                if isempty(i_int) || isempty(j_int)
    352351                   for ivar=VarIndex   
    353352                        eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=NaN;']);
     
    387386ProjData.ListVarName={};
    388387ProjData.VarDimName={};
     388ProjData.VarAttribute={};
    389389
    390390Mesh=zeros(1,numel(FieldData.ListVarName));
    391391if isfield (FieldData,'VarAttribute')
    392     ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names
    393     for iattr=1:length(ProjData.VarAttribute)%initialization of variable attribute values
     392    %ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names
     393    for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values
    394394%         ProjData.VarAttribute{iattr}={};
    395         if isfield(ProjData.VarAttribute{iattr},'Unit')
    396             unit{iattr}=ProjData.VarAttribute{iattr}.Unit;
    397         end
    398         if isfield(ProjData.VarAttribute{iattr},'Mesh')
    399             Mesh(iattr)=ProjData.VarAttribute{iattr}.Mesh;
     395        if isfield(FieldData.VarAttribute{iattr},'Unit')
     396            unit{iattr}=FieldData.VarAttribute{iattr}.Unit;
     397        end
     398        if isfield(FieldData.VarAttribute{iattr},'Mesh')
     399            Mesh(iattr)=FieldData.VarAttribute{iattr}.Mesh;
    400400        end
    401401    end
     
    549549                eval(['ProjData.' VarName 'Histo=hist(double(FieldData.' VarName '(indsel,:)),ProjData.' VarName ');']); % histogram at predefined bin positions
    550550            end
    551             ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']}];
     551            ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}];
    552552            if test_Amat && testcolor
    553553                 ProjData.VarDimName=[ProjData.VarDimName  {VarName} {{VarName,'rgb'}} {'rgb'}];%{{'nb_point','rgb'}};
    554554            else
    555                ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'}];
    556             end
     555               ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'} {'nbpoint'} {'nbpoint'}];
     556            end
     557            ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
    557558        end
    558559    end
     
    20762077                            eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
    20772078                            %TODO : do a vertical average for a thick plane
    2078                             if test_interp(2) | test_interp(3)
     2079                            if test_interp(2) || test_interp(3)
    20792080                                eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');'])
    20802081                            end
  • trunk/src/set_object.m

    r186 r187  
    776776UvData.Object{IndexObj}=ObjectData;%update the current object properties
    777777UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
    778 
    779 %% plot the field projected on the object and store it the corresponding figue
    780 get(plotaxes,'tag')
     778set(huvmat,'UserData',UvData)
     779
     780%% plot the field projected on the object and store in the corresponding figue
    781781ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    782782[PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot
    783 if strcmp(projview,'view_field')
    784     ViewFieldData=get(hview_field,'UserData');
    785     ViewFieldData.axes3=ObjectData;
    786     set(hview_field,'UserData',ViewFieldData)
    787 else
    788     UvData.axes3=ObjectData;
    789 end
    790783
    791784%% update the GUI uvmat
     
    795788set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    796789%UvData.MouseAction='edit_object'; % set the edit button to 'on'
    797 set(huvmat,'UserData',UvData)
     790
    798791%------------------------------------------------------------------------
    799792% --- Executes on button press in MenuCoord.
  • trunk/src/uvmat.m

    r183 r187  
    217217UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
    218218UvData.OpenParam.CalSize=[0.28 1];
     219UvData.axes3=[];%initiate the record of plotted field
     220UvData.axes2=[];
     221UvData.axes1=[];
    219222
    220223%functions for the mouse and keyboard
     
    25202523    UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
    25212524end
     2525UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
     2526set(handles.uvmat,'UserData',UvData)
    25222527
    25232528%% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
     
    26122617            view_field(ObjectData)
    26132618        else
    2614             [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap});
     2619            [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
    26152620            write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
    26162621            if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
    26172622                ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
    26182623            end
    2619             if imap==1           
    2620                 UvData.axes3=ObjectData;
    2621             else
    2622                 ViewFieldData=get(view_field_handle,'UserData');
    2623                 ViewFieldData.axes3=ObjectData;
    2624                 set(view_field_handle,'UserData',ViewFieldData)
    2625             end
     2624%             if imap==1           
     2625%                 UvData.axes3=ObjectData;
     2626%             else
     2627%                 ViewFieldData=get(view_field_handle,'UserData');
     2628%                 ViewFieldData.axes3=ObjectData;
     2629%                 set(view_field_handle,'UserData',ViewFieldData)
     2630%             end
    26262631        end
    26272632        if isequal(PlotType,'none')
     
    26362641end
    26372642
    2638 %write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
    2639 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
    2640 set(handles.uvmat,'UserData',UvData)
    26412643
    26422644%% update the mask
     
    39283930histo_value=get(handles.histo1_menu,'Value');
    39293931FieldName=histo_menu{histo_value};
    3930 % UvData=get(huvmat,'UserData');
    39313932update_histo(handles.histo_u,huvmat,FieldName)
    39323933
     
    39393940histo_value=get(handles.histo2_menu,'Value');
    39403941FieldName=histo_menu{histo_value};
    3941 % UvData=get(huvmat,'UserData');
    39423942update_histo(handles.histo_v,huvmat,FieldName)
    39433943
     
    40024002            end
    40034003        end
    4004         set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
    4005         set(haxes,'YLimMode','auto')
    4006         plot_field(Histo,haxes);
     4004%         set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
     4005%         set(haxes,'YLimMode','auto')
     4006        PlotParam.Auto_xy=1;
     4007        plot_field(Histo,haxes,PlotParam);
    40074008    end
    40084009end
     
    41864187AxeData=UvData.axes3;
    41874188PlotParam=read_plot_param(handles);
    4188 [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
     4189[PP,PlotParamOut]= plot_field(AxeData,haxes,PlotParam);
    41894190write_plot_param(handles,PlotParamOut); %update the auto plot parameters
    41904191
     
    43074308    PlotHandles=guidata(hview_field);
    43084309end
    4309 if ~isempty(ProjData)
     4310% if ~isempty(ProjData)
     4311'TEST'
     4312ProjData
    43104313    plot_field(ProjData,PlotHandles.axes3,PlotHandles);
    4311 end
     4314% end
    43124315set(handles.uvmat,'UserData',UvData)
    43134316hother=findobj('Tag','proj_object');%find all the proj objects
     
    43634366    %     end
    43644367end
    4365 pause(0.1)
     4368% pause(0.1)
    43664369figure(hset_object)%put set_object in front
    43674370
  • trunk/src/view_field.m

    r180 r187  
    9090set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
    9191set(hObject,'CloseRequestFcn',{@closefcn})%
     92ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field)
     93set(handles.view_field,'UserData',ViewFieldData);%store the current field
    9294if ~exist('Field','var')
    9395    return
    9496end
    95 
     97'TESviewfield'
    9698[PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
    97 ViewFieldData.axes3=Field;
    98 set(handles.view_field,'UserData',ViewFieldData);%store the current field
     99
    99100if isfield(PlotParamOut,'Vectors')
    100101    set(handles.VECT_title,'Visible','on')
     
    285286    set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
    286287    update_plot(handles)
    287 %     axis(handles.axes3,'image')
    288288end
    289289
     
    699699%-------------------------------------------------------------------
    700700haxes= handles.axes3;
    701 %huvmat=findobj(allchild(0),'tag','uvmat');
    702 ProjField=get(haxes,'UserData');
     701
     702%ProjField=get(haxes,'UserData');
     703ViewFieldData=get(handles.view_field,'UserData');
     704ProjField=ViewFieldData.axes3;
     705%ProjField=get(haxes,'UserData');
    703706PlotParam=read_plot_param(handles);
    704707[PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
Note: See TracChangeset for help on using the changeset viewer.