www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@localavfit/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',...
        'Visible','off',...
        'String','Current model:',...
        'HorizontalAlignment','left');
    ud.modelSetup=xreguicontrol('Parent',figh,...
        'Style','push',...
        'Visible','off',...
        'String','Set Up...',...
        'Interruptible','off');
    ud.modelString= axestext(figh,...
        'visible','off',...
        'fontsize',10,...
        'clipping','on',...
        'verticalalignment','middle');

    % data
    udh= ud.modelSetup;

    % callbacks
    set(ud.modelSetup,'Callback',{@i_mdlchng,udh});

    % note: below (in the ELSE) we find the handle to the button (holds userdata)
    % as the *last* element in the gblayout. Think if you change this
    lyt=xreggridbaglayout(figh,...
        'dimension',[4,3],...
        'rowsizes',[17, 20, 5, 25],...
        'colsizes',[10, -1, 65],...
        'mergeblock',{[1 1],[1,3]},...
        'mergeblock',{[2 2],[2,3]},...
        'elements',{...
        text1,[],[],[],...
        [],ud.modelString,[],[],...
        [],[],[],ud.modelSetup});
    set(ud.modelSetup,'UserData',ud);
else %% get the userdata from the handle of the button
    el = get(figh,'elements');
    ud=get(el{end},'UserData');
    ud.pointer=p;
    set(el{end},'UserData',ud);
    lyt=figh;
end
i_setvalues(ud,p);



function i_setvalues(ud,p)

set(ud.modelString,'String',str_func(p.info,1));



function i_mdlchng(h,EventData,udh)
ud=get(udh,'UserData');
m=ud.pointer.info;

[msub,OK]= gui_ModelSetup(get(m,'model'));
if OK
    m = set(m,'model',msub);

    m= SetFeat(m,'default');

    ud.pointer.info= m;
end

set(ud.modelString,'String',str_func(m,1));