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

    function [m,ok]=gui_localmodopts(m,action,fig,p)
%GUI_LOCALMODOPTS  Local model options dialog
%
%   [M,OK]=GUI_LOCALMODOPTS(M) creates a modal dialog for setting up
%   options specific to the current local model class.  This function is
%   the default, creating a simple 'No options available dialog'.  Overload
%   it in local models which have additional options such as spline order.
%
%   LYT=GUI_LOCALMODOPTS(M,'layout',FIG,P) creates and returns a layout in
%   figure FIG, based around altering the model in the pointer P.  This
%   interface must be supported by overloaded methods.  FIG may also be an
%   existing layout object in which case the layout is updated with fresh
%   information from the model in P.

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


if nargin<2
    action='figure';
end

switch lower(action)
    case 'figure'
        [m,ok] = gui_localmodoptsdlg(m);
    case 'layout'
        m=i_createlyt(fig,p);
end


function lyt=i_createlyt(figh,p)

if ~isa(figh,'xregcontainer')
    ud.pointer=p;
    ud.figh=figh;
    text1=xreguicontrol('Parent',figh,...
        'Style','text',...
        'String','Order:',...
        'Visible','off',...
        'HorizontalAlignment','left',...
        'Position',[0 0 70 15]);
    ud.loword=xreguicontrol('Parent',figh,...
        'Style','edit',...
        'Visible','off',...
        'BackgroundColor','w',...
        'Interruptible','off',...
        'Position',[0 0 60 20]);

    % callbacks
    set(ud.loword, 'Callback', {@i_ordchng, ud.loword});

    flw2=xregflowlayout(figh,...
        'gap',5,...
        'border',[-5 0 0 0],...
        'orientation','left/center',...
        'elements',{text1,ud.loword});
    lyt=xregborderlayout(figh,...
        'north',flw2,...
        'innerborder',[0 0 0 20]);
    set(ud.loword,'UserData',ud);
else
    el = get(get(figh,'north'),'elements');
    ud=get(el{2},'UserData');
    ud.pointer=p;
    set(el{2},'UserData',ud);
    lyt=figh;
end
i_setvalues(ud,p);


function i_setvalues(ud,p)
m=p.info;
ord=order(m);
set(ud.loword,'String',ord);
return


function i_ordchng(src, evt, udh)
ud=get(udh,'UserData');

val=str2num(get(ud.loword,'String'));
m=ud.pointer.info;
ord=order(m);
% check val
if ~isscalar(val) || val~=floor(val) || val<0
    set(ud.loword,'String',ord);
else
    m=setorder(m,val);
    ud.pointer.info=m;
end