www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cgtools/CageTableProvider.m

    classdef CageTableProvider < mbcutils.TableProviderSource
    %CageTableProvider class  Used for finding information about CAGE tables
    
    %  Copyright 2015 The MathWorks, Inc.

    
    properties (Access=private)
        %CAGEProjectPointer Pointer to a CAGE session
        CAGEProjectPointer
    end
    
    methods
        function obj = CageTableProvider(CAGEProjectPointer)
            %CageTableProvider Constructor for CageTableProvider
            % Will use pointer specified otherwise will use the current
            % CAGE session
            if nargin < 1
                CAGEProjectPointer = get(cgbrowser,'RootNode');
            end
            obj.CAGEProjectPointer = CAGEProjectPointer;
        end
        
        function [names, pTables] = getTableList(obj, type)
            %getTableList Returns a list of all the tables of a certain type
            pTables = gettables(obj.CAGEProjectPointer.info,type);
            isSimple = pveceval(pTables, @(t)issimpletable(t));
            pTables = pTables([isSimple{:}]);
            numberOfTables = length(pTables);
            names=cell(numberOfTables, 1);
            for i=1:numberOfTables
                tableName = getname(pTables(i).info);
                pAxes = pTables(i).get('axesptrs');
                switch type
                    case '1d'
                        name = sprintf('%s(%s)', tableName, getname(pAxes.info));
                    case '2d'
                        name = sprintf('%s(%s,%s)', tableName, getname(pAxes(1).info), getname(pAxes(2).info));
                    otherwise
                        error('mbc:cgtools:unknownOption', 'Unknown type specified')
                end
                names{i} = sprintf('%s', name);
            end
        end
        
        function [tableName, inputNames] = getTableFactorNames(obj, type, index)
            %getTableFactorNames Returns the table name and inputs for a table
            pTables = gettables(obj.CAGEProjectPointer.info, type);
            isSimple = pveceval(pTables, @(t)issimpletable(t));
            pTables = pTables([isSimple{:}]);
            pSelected = pTables(index);
            
            tableName = getname(pSelected.info);
            pAxes = pSelected.get('axesptrs');
            switch type
                case '1d'
                    inputNames = {getname(pAxes(1).info)};
                case '2d'
                    inputNames = {getname(pAxes(1).info), getname(pAxes(2).info)};
                otherwise
                    error('mbc:cgtools:unknownOption', 'Unknown type specified')
            end
        end
        
        function [breakPoints, values] = getTableValues(obj, type, index)
            %getTableValues Returns the breakpoints and values of a table
            pTables = gettables(obj.CAGEProjectPointer.info,type);
            isSimple = pveceval(pTables, @(t)issimpletable(t));
            pTables = pTables([isSimple{:}]);
            pSelected = pTables(index);
            
            values = pSelected.get('values');
            switch type
                case '1d'
                    breakPoints{1} = pSelected.get('axes');
                case '2d'
                    breakPoints = pSelected.get('axes');
                otherwise
                    error('mbc:cgtools:unknownOption', 'Unknown type specified')
            end
        end
    end
end