Changeset 179 for trunk/src/plot_field.m


Ignore:
Timestamp:
Jan 9, 2011, 12:56:28 PM (13 years ago)
Author:
sommeria
Message:

various bug repairs, in particular for 3D fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r156 r179  
    164164end
    165165
    166 % check the cells of fields :
    167 % testnbdim=1;
     166%% check the cells of fields :
    168167[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
    169168
     169%% plot if the input field is valid
    170170if ~isempty(errormsg)
    171     msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg])
    172     display(['input of plot_field: ' errormsg])
    173     return
    174 end
    175 if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot
    176     [Data.NbDim]=max(NbDim);
    177 end
    178 errormsg=[];
    179 if isequal(Data.NbDim,0)
    180         AxeData=plot_text(Data,htext);
    181         PlotType='text';
     171    errormsg=['input of plot_field/find_field_indices: ' errormsg];
     172else
     173    if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot
     174        [Data.NbDim]=max(NbDim);
     175    end
     176    if isequal(Data.NbDim,0)
     177            AxeData=plot_text(Data,htext);
     178            PlotType='text';
     179            errormsg=[];
     180    elseif isequal(Data.NbDim,1)
     181        [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
     182        if testzoomaxes
     183            [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
     184            AxeData.ZoomAxes=zoomaxes;
     185        end
     186        PlotType='line';
    182187        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 if ~isempty(errormsg)
    206     msgbox_uvmat('ERROR','volume plot not implemented yet')
    207     return
    208 end
    209 
    210 %display (or delete) error message
    211 htext=findobj(haxes,'Tag','hTxt');
    212 if isfield(Data,'Txt')
    213     if isempty(htext)
    214         Xlim=get(haxes,'XLim');
    215         Ylim=get(haxes,'YLim');
    216         htext=text(Xlim(1),(Ylim(1)+Ylim(2))/2,Data.Txt,'Tag','hTxt','Color','r');
    217         set(htext,'Interpreter','none')
    218     else
    219         set(htext,'String',Data.Txt)
    220     end
    221 elseif ~isempty(htext)
    222     delete(htext)
    223 end
    224 
    225 % % set graph aspect ratio
    226 % if isfield(AxeData,'Mesh')
    227 %     Data.Mesh=AxeData.Mesh;
    228 % end
    229 
    230 %set(haxes,'UserData',AxeData)
    231 set(haxes,'UserData',Data)
    232 % if ~testnewfig
    233 % %set(0,'Children',hstack);%put back the initial figure stack after plot creation
    234 %
    235 % end
     188    elseif isequal(Data.NbDim,2)
     189        ind_select=find(NbDim>=2);
     190        if numel(ind_select)>2
     191            errormsg='more than two fields to map';
     192        else
     193            [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);
     194            if testzoomaxes && isempty(errormsg)
     195                [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
     196                Data.ZoomAxes=zoomaxes;
     197            end
     198        end
     199    elseif isequal(Data.NbDim,3)
     200        errormsg='volume plot not implemented yet';
     201    end
     202end
     203
     204if isempty(errormsg)
     205    set(haxes,'UserData',Data)
     206else
     207    msgbox_uvmat('ERROR', errormsg)
     208end
    236209
    237210
Note: See TracChangeset for help on using the changeset viewer.