www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@toGVDataModel/zoom.m
function zoom(obj, R, C, xscale, yscale) %ZOOM Activate zooming on a specified graph % % ZOOM(OBJ, R, C, XSCALE, YSCALE) zooms in on the graph at the location % (R, C). Depending on the other data model settings, the entire column % and/or row may simultaneously be zoomed. XSCALE and YSCALE specify the % amount to zoom in by in each direction. They are both 2-element vectors % containing a minimum and maximum value in the range 0->1 which specify % the fraction of the current zoomed range to zoom in on. % % Note that if you call zoom on a graph that is already zoomed the 2 zooms % will accumulate to produce a higher magnification. % Copyright 2000-2007 The MathWorks, Inc. and Ford Global Technologies, Inc. % Limit the x and y scales given to be 0->1 xscale = max(min(xscale, [1 1]), [0 0]); yscale = max(min(yscale, [1 1]), [0 0]); if obj.isGraphZoomed(R, C) obj.XZoomScales{C} = i_addzoom(obj.XZoomScales{C}, xscale); if obj.useCommonYAxis obj.YZoomScales{R} = i_addzoom(obj.YZoomScales{R}, yscale); else obj.YZoomScales{R, C} = i_addzoom(obj.YZoomScales{R, C}, yscale); end else if isempty(obj.IsYZoomed) i_initzoomdata(obj); end obj.XZoomScales{C} = xscale; if obj.useCommonYAxis obj.YZoomScales{R} = yscale; else obj.YZoomScales{R, C} = yscale; end end % Toggle flags to indicate that the correct graphs are now zoomed obj.IsXZoomed(C) = true; if obj.useCommonYAxis obj.IsYZoomed(R, :) = true; else obj.IsYZoomed(R, C) = true; end function i_initzoomdata(obj) sz = [getRowCount(obj), getColumnCount(obj)]; obj.IsYZoomed = false(sz); obj.IsXZoomed = false(1, sz(2)); obj.XZoomScales = cell(1, sz(2)); if obj.useCommonYAxis obj.YZoomScales = cell(1, sz(1)); else obj.YZoomScales = cell(sz); end function scale = i_addzoom(scale, newzoom) if isempty(scale) scale = newzoom; else range = scale(2) - scale(1); scale = scale(1) + newzoom.*range; end