www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevtestplan/EnableMenus.m

    function OK = EnableMenus(T,View)
%ENABLEMENUS  Update enable status of browser menus and toolbar buttons
%
%  OK = ENABLEMENUS(TP, VIEWDATA)

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

% Menu items: [View.menus.testplan]
%    1. 'Set Up &Inputs...'
%    2.  'Set Up &Model...'
%    3.  'Design &Experiment'
%    4.  '&Boundary Constraints'
%    5.  '&Summary Statistics...'
%    6.  '&New Data...'
%    7.  'Select &Data...'
%    8.  'Validation Data...'
%    9.  'Make &Template...'
%    10. 'E&xport Point-by-point models...'


OK = 1;
NStages = length(T.DesignDev);

toolbarEnable = {'on', 'on', 'on', 'on', 'on', 'on', 'on'};
tpMenuEnable = {'on', 'on', 'on', 'on', 'on', 'on', 'on', 'on', 'on','on'};
viewMenuEnable = {'on', 'on'};

% Set multimodel export off by default
tpMenuEnable{10} = 'off';

if NStages>1
    Stage= find(strcmp(get(View.hHSM.hBorder,'Selected'),'on'));
    IsPointByPoint = strcmpi(type(T),'point-by-point');
    if ~isempty(Stage)
        % a model is selected
        tpMenuEnable{1} = 'off';
        if Stage==1
            % if we are in the first stage of a 2 stage (local) we can't have
            % Summary Stats
            tpMenuEnable{5} = 'off';
        end
        
        if Stage>1 && IsPointByPoint
            % disable model menus
            tpMenuEnable{2} = 'off';
            tpMenuEnable{5} = 'off';
            viewMenuEnable{2} = 'off';
        end
        
        
    else
        % a port is selected
        tpMenuEnable{2} = 'off';
        tpMenuEnable{5} = 'off';
        viewMenuEnable{2} = 'off';
        % find which port is selected
        Port= find(strcmp(get(View.hHSM.pBorder,'Selected'),'on'));
        if Port>NStages
            % outport selected
            % no model 
            tpMenuEnable(1:2) = {'off'};
        end
    end
    if numChildren(T)>0 && nfactors(getModel(T.DesignDev)) ==2
        % multimodel menu
        tpMenuEnable{10} = 'on';
    end
end

if T.Matched
    % validation data
    tpMenuEnable{8}= 'on';
    % boundary model
    tpMenuEnable{4}= 'on';
    toolbarEnable{4} = 'on';
else
    viewMenuEnable{1} = 'off';
    % validation data
    tpMenuEnable{8}= 'off';
    % boundary model
    tpMenuEnable{4}= 'off';
    toolbarEnable{4} = 'off';
end

if numChildren(T)>0 && all(hasBestExportModel(T))
    % export to CAGE and Simulink
    toolbarEnable{5} = 'on';
    toolbarEnable{6} = 'on';
    enableButtons(View.Workflow,3:4)
else
    toolbarEnable{5} = 'off';
    toolbarEnable{6} = 'off';
    disableButtons(View.Workflow,3:4)
end
set(View.menus.testplan, {'Enable'}, tpMenuEnable(:));
set(View.menus.viewchild,{'Enable'}, viewMenuEnable(:));
set(View.toolbarBtns,    {'Enable'}, toolbarEnable(:));