www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@mmSiteGraphView/pUpdateTolPatch.m

    function pUpdateTolPatch(obj)
%PUPDATETOLPATCH Update display of tolerance patches
%
%  PUPDATETOLPATCH(OBJ) updates the position of the tolerance patches.

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


if ~isempty(obj.MessageService) ...
        && length(obj.MessageService.SwitchInputs)==2

    ms = obj.MessageService;
    axisorder = ms.AxisOrder;
    bps = ms.Breakpoints;
    abstol = getAbsoluteTolerance(ms.SampleTakenModel);
    
    [X, Y] = ndgrid(bps{axisorder(2)}, bps{axisorder(1)});
    abstol = abstol(axisorder([2 1]));
    verts = [X(:)' - abstol(1), Y(:)' - abstol(2); ...
        X(:)' - abstol(1), Y(:)' + abstol(2); ...
        X(:)' + abstol(1), Y(:)' + abstol(2); ...
        X(:)' + abstol(1), Y(:)' - abstol(2)];
    verts = reshape(verts, numel(X)*4, 2);
    faces = reshape((1:size(verts, 1)), 4, numel(X))';
    
    set(obj.hTolerancePatch, 'Vertices', verts, 'Faces', faces);
else
    set(obj.hTolerancePatch, 'Vertices', [], 'Faces', []);
end