www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgdatasetgui/@table/copyRequest.m

    function copyRequest(obj, SelObject)
%COPYREQUEST Execute a copy operation on the table selection
%
%  COPYREQUEST(OBJ, SELOBJECT) copies the data specified by the rows and
%  columns in the AsyncTableModelEvent object SELOBJECT.

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


if ~isempty(obj.DatasetPointer)
    pDataset = obj.DatasetPointer;
    hDataset = pDataset.info;
    
    data = get(hDataset, 'Data');
    row_selection = SelObject.getRowIndices+1;
    col_selection = obj.pConvertDisplayToDataset(SelObject.getColumnIndices+1);

    data = data(row_selection, col_selection);
    
    % Check whether all the rows were selected and use the factor names as
    % part of the copy if so 
    if size(data, 1) == get(hDataset, 'numpoints')
        heads = get(hDataset, col_selection, 'factors');
        if ~iscell(heads)
            heads = {heads};
        end
        mbcutils.Clipboard.guiCopy(data, heads);
    else
        mbcutils.Clipboard.guiCopy(data);
    end
end