www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@cset_pb/propertypage.m

    function out=propertypage(obj,action,varargin)
% PROPERTYPAGE  Create a property gui for CandidateSet
%
%
%   This should be overloaded by child classes
%
%   Interface:  Lyt=propertypage(cs,'layout',fig);
%               Lyt=propertypage(cs,'update',lyt,p_cs,model);
%               Lyt=propertypage(cs,'enable',lyt,enstate);

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


switch lower(action)
    case 'layout'
        out=i_createlyt(obj, varargin{:});
    case 'update'
        out=i_update(varargin{:});
    case 'enable'
        out=i_setenable(varargin{:});
end


function lyt = i_createlyt(obj, figh, varargin)

% create new layout in figure
pUD = xregGui.RunTimePointer;
ud.pointer = [];
ud.figure = figh;
ud.model = [];
ud.callback = '';
for n=1:2:length(varargin)
    switch lower(varargin{n})
        case 'callback'
            ud.callback = varargin{n+1};
    end
end
ud.enable = 1;

SC = xregGui.SystemColorsDbl;
[ud.Nr, ud.Nrstr] = pr_getrunopts;
ud.cpedt = xreguicontrol('Parent',figh,...
   'Style','popupmenu',...
   'BackgroundColor',SC.WINDOW_BG,...
   'String',ud.Nrstr, ...
   'Callback', {@i_cpchng,pUD});
ud.cptxt = xregGui.labelcontrol('parent',figh,...
   'LabelSizeMode','absolute',...
   'LabelSize',150,...
   'ControlSizeMode','absolute',...
   'ControlSize',70,...
   'gap',5,...
   'string','Number of experimental runs:',...
   'Control',ud.cpedt);
[ud.RangeTable, ud.RangeTableUpdate] = pRangeEditor(obj, figh, ...
    ud.pointer, ud.model, ud.callback);
ud.RangeLabel = xreguicontrol('Parent',figh, ...
    'Style', 'text', ...
    'HorizontalAlignment', 'left', ...
    'String', 'Range of values:');

lyt = xreggridbaglayout(figh, ...
    'userdata', pUD, ...
    'dimension', [4 1], ...
    'rowsizes', [20 10 15 -1], ...
    'elements', {ud.cptxt, [], ud.RangeLabel, ud.RangeTable});

ud.layout=lyt;
pUD.info = ud;



% External update function. 
function lyt = i_update(lyt,p,m)
% update current layout
pUD = get(lyt,'UserData');
ud = pUD.info;
ud.pointer = p;
ud.model = m;
ud = i_setvalues(ud);
pUD.info = ud;


function ud=i_setvalues(ud)
cs = ud.pointer.info;
nf = nfactors(cs);
Nr = ud.Nr(ud.Nr>nf);
str = ud.Nrstr(ud.Nr>nf);
set(ud.cpedt, 'String',str, 'Value',find(Nr==get(cs,'runs')));

% Set up the range table
ud.RangeTableUpdate(ud.pointer, ud.model);


function lyt=i_setenable(lyt,state)
pUD = get(lyt,'UserData');
ud = pUD.info;
set(ud.cptxt,'Enable',state);
set(ud.RangeTable, 'Enable', state);


function i_cpchng(obj,nul,pUD)
ud = pUD.info;
val = get(ud.cpedt,'Value');
str = get(ud.cpedt,'String');
ud.pointer.info = set(ud.pointer.info,'qruns',sscanf(str{val},'%d'));
pUD.info = ud;
i_firecb(ud);


function i_firecb(ud)
xregcallback(ud.callback,ud.layout,[]);