www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xreginterprbf/gui_globalmodsetup.m

    function [mout,ok]=gui_globalmodsetup(m,action,varargin)
%GUI_GLOBALMODSETUP  GUI for altering xreginterprbf settings
%
%   [M,OK]=GUI_GLOBALMODSETUP(M) creates a blocking GUI for choosing the
%   subclass of xreglinear and altering its settings.  OK indicates
%   whether the user pressed 'OK' or 'Cancel'.
%
%   LYT=GUI_GLOBALMODSETUP(M,'layout',FIG,P) creates a layout in figure
%   FIG, using the dynamic copy of a model in P.

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

if nargin<2
    action='figure';
end

switch lower(action)
    case 'figure'
        [mout,ok] = gui_ModelDialog(m,'Interpolating RBF Model Settings', varargin{:});

    case 'layout'
        mout = i_createlyt(varargin{:});
        ok = 1;

    case 'getclasslevel'
        mout = mfilename('class');

    case 'finalise'
        mout = m;

    otherwise
        error(message('mbc:xreginterprbf:InvalidArgument1'));
end




function lyt=i_createlyt(figh,p)

if ~isa(figh,'xregcontainer')
    ud.pointer = p;
    ud.figure = figh;
    m = p.info;

    rbfpart = get( m, 'rbfpart' );
    linearmodpart = get( m, 'linearmodpart' );
    om = getFitOpt( m );

    rbfp = xregGui.RunTimePointer( rbfpart );
    lmp  = xregGui.RunTimePointer( linearmodpart );
    omp  = xregGui.RunTimePointer( om );
    udp = xregGui.RunTimePointer;
    
    ud.btnAdvanced = uicontrol( ...
        'Parent',figh,...
        'Style','pushbutton',...
        'String','Advanced...', ...
        'Callback',{@i_btnAdvanced,p} );

    lytLinearFrame = mbcgui.container.layoutpanel(...
        'Parent', figh, ...
        'Visible', 'off', ...
        'Title', 'Polynomial part', ...
        'BorderType', 'etchedin');
    
    lytLinearPart = gui_globalmodpane( linearmodpart, 'layout', ...
        lytLinearFrame, lmp, 'Callback', {@i_updateLinearModPart,p,lmp} );
    set(lytLinearPart, 'Visible', 'on');
    ud.checkPolyFromKernel = uicontrol( 'Parent', lytLinearFrame,...
        'Style','checkbox',...
        'String', 'Polynomial from kernel', ...
        'Value',get( om, 'PolyFromKernel' ), ...
        'Min', 0, 'Max', 1, ...
        'Callback',{@i_polyFromKernel,p,omp,lytLinearPart,lmp},...
        'Interruptible','off');
    i_polyFromKernel(ud.checkPolyFromKernel,[],p,omp,lytLinearPart);
    lytLinearPartBorder = xreggridbaglayout( lytLinearFrame, ...
        'packstatus', 'off', ...
        'dimension', [2,1], ...
        'rowsizes', [20, -1], ...
        'gapy', 7, ...
        'border', [10 10 10 5], ...
        'elements', { ud.checkPolyFromKernel, lytLinearPart } );
    set(lytLinearFrame, 'LayoutComponent', {lytLinearPartBorder});

    lytRbfFrame = mbcgui.container.layoutpanel(...
        'Parent', figh, ...
        'Visible', 'off', ...
        'Title', 'RBF part', ...
        'BorderType', 'etchedin', ...
        'LayoutBorder', [10 10 10 5]);
    lytRbfPart = gui_rbfpane( m, 'layout', ...
        lytRbfFrame, rbfp, 'Callback', {@i_updateRbfPart,p,rbfp,lmp,lytLinearPart} );
    set(lytRbfPart, 'Visible', 'on');
    set(lytRbfFrame, 'LayoutComponent', {lytRbfPart});

    lyt = xreggridbaglayout(figh, ...
        'dimension', [2 4], ...
        'rowsizes', [-1 25], ...
        'colsizes', [85 -1 -1 85], ...
        'gapy', 10, ...
        'gapx', 7, ...
        'mergeblock', {[1 1], [1 2]}, ...
        'mergeblock', {[1 1], [3 4]}, ...
        'elements', {lytRbfFrame, ud.btnAdvanced, [],[], lytLinearFrame}, ...
        'userdata', udp);

else
    lyt = figh;
    udp = get(lyt, 'UserData');
    ud = udp.info;
    % update with new pointer
    ud.pointer = p;
end
udp.info = ud;



function i_btnAdvanced(~,~,p)
m=p.info;
om = getFitOpt( m );
om = gui_setup( om,'figure', {...
    'expanded',1,...
    'title', 'Advanced Options',...
    'topname', 'Fit algorithm'},...
    m );
m = setFitOpt( m, om );
p.info = m;


function i_updateLinearModPart(~,~,p,lmp)
p.info = set( p.info, 'linearmodpart', lmp.info );


function i_updateRbfPart(~,~,p,rbfp,lmp,lytLinearPart)
p.info = set( p.info, 'rbfpart', rbfp.info );
if getFitOpt(p.info,'PolyFromKernel')
    % make sure that the polynomial is set to the correct order
    p.info = check_degree(p.info,'Hard');
    % update linear order table
    mlin = get(p.info,'linearmodpart');
    lmp.info = mlin;
    gui_globalmodpane(mlin,'layout',lytLinearPart,lmp)
end


function i_polyFromKernel(h,~,p,omp,lyt,lmp)
if get( h, 'Value' ) == get( h, 'Max' ),
    omp.info = set( omp.info, 'PolyFromKernel', true );
    % make sure that the polynomial is set to the correct order
    p.info = setFitOpt( p.info, omp.info );
    p.info = check_degree(p.info,'Hard');

    % update linear order table
    mlin = get(p.info,'linearmodpart');
    lmp.info = mlin;
    gui_globalmodpane(mlin,'layout',lyt,lmp)
    % disable order table
    set( lyt, 'Enable', 'off' );
else
    omp.info = set( omp.info, 'PolyFromKernel', false );
    p.info = setFitOpt( p.info, omp.info );
    % enable order table
    set( lyt, 'Enable', 'on' );
end