www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregGui/@scrollaxes/doYdraw.m

    function doYdraw(h)
%DOYDRAW Redraw values for ylims
%

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.


pos=max(h.Position(4)-1,1);

yl=h.Yviewlim;
yl_delt=yl(2)-yl(1);
vwydelt=yl_delt;

% Adjust the ylim to account for the fact that part of the axes is hidden
% under the scrollbars.
yl_delt=(pos/max(1,(pos-h.decsize)))*yl_delt;

yl_delt=fix(1e8*yl_delt)/1e8;

% Ensure the ylim diff is not 0
yl_delt = max(eps(yl(2)), yl_delt);
yl=[yl(2)-yl_delt yl(2)];

tot_delt=h.Ylim(2)-h.Ylim(1);
diff=tot_delt-vwydelt;
if (h.Yviewcenter-h.Ycenter)~=0
    val=0.5+((h.Yviewcenter-h.Ycenter)/diff);
else
    val=0.5;
end

% remove fp errors that push val outside of acceptable range
val=max(val,0);
val=min(val,1);

set(h.AxesHandle, 'YLim', yl);
set(h.HGobj(2),'Value',val);

if diff<(1e-10*yl_delt)
    set(h.HGobj(2),'Enable','off');
else
    major_step = vwydelt/diff;
    minor_step = min([1 10/diff major_step]);
    set(h.HGobj(2),'Enable','on','SliderStep',[minor_step major_step]);
end