www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xreginterprbf/gui_rbfpane.m
function lyt = gui_rbfpane( m, action, figh, p, varargin ) %GUI_RBFPANE Create part of GUI for rbf settings of xreginterprbf object % LYT=GUI_RBFPANE(M,'layout',FIG,P) creates a layout object % with callbacks defined for updating the model pointed to by P. % FIG is the figure to create it in. % % LYT=GUI_RBFPANE(M,'layout',FIG,P,'callback,CBSTR) attaches a % callback string, CBSTR, which is fired when the model definition % is changed. The string may contain the tokens %MODEL% and %POINTER% % which will be replaced with the current model and the pointer before % the callback is executed. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. switch lower(action) case 'layout' cbstr=''; if nargin>4 for n=1:2:length(varargin) switch lower(varargin{n}) case 'callback' cbstr=varargin{n+1}; end end end lyt=i_createlyt(figh,p,cbstr); end return % -------------------------------------------------------------------------| function lyt=i_createlyt(figh,p,callback) ud.callback=callback; ud.pointer=p; ud.figure=figh; m=p.info; udp = xregGui.RunTimePointer; udp.LinkToObject(figh); kernelList = { 'multiquadric','recmultiquadric','gaussian',... 'thinplate','logisticrbf','wendland','linearrbf','cubicrbf'}; kernel = get( m, 'kernel' ); ud.popupKernel = uicontrol( 'Parent', figh,... 'Style','popupmenu',... 'Tag', 'kernel_popup', ... 'String',kernelList,... 'Value',find( strcmpi( kernel, kernelList ) ), ... 'Callback',{@i_kernel,udp},... 'Visible','off',... 'Interruptible','off',... 'HorizontalAlignment','left',... 'BackgroundColor','w'); ud.editWidth = uicontrol( 'Parent', figh,... 'Style','edit',... 'Tag', 'editWidth', ... 'String', num2str( get( m, 'width' ) ), ... 'HorizontalAlignment','left',... 'BackgroundColor','w',... 'Callback',{@i_width,udp},... 'Visible','off'); val=find(strcmp(num2str(get(m,'cont')),{'0','2','4','6'})); ud.popupContinuity = uicontrol( 'Parent', figh,... 'Style','popupmenu',... 'String',{ '0', '2', '4', '6'},... 'Value',val,... 'Callback',{@i_continuity,udp},... 'Visible','off',... 'Interruptible','off',... 'HorizontalAlignment','left',... 'Tag', 'continuity',... 'BackgroundColor','w'); ud.lctrlKernel = xregGui.labelcontrol( ... 'parent',figh,... 'Control', ud.popupKernel,... 'String','Kernel:',... 'Enable','on', ... 'ControlSize', 120, ... 'ControlSizeMode', 'relative',... 'LabelSize', 120, ... 'LabelSizeMode', 'relative'); ud.lctrlWidth = xregGui.labelcontrol( ... 'parent',figh,... 'Control', ud.editWidth,... 'String','Width:',... 'Enable','on', ... 'ControlSize', 120, ... 'ControlSizeMode', 'relative',... 'LabelSize', 120, ... 'LabelSizeMode', 'relative'); ud.lctrlContinuity = xregGui.labelcontrol( ... 'parent',figh,... 'Control', ud.popupContinuity,... 'string','Continuity:',... 'enable','on', ... 'ControlSize', 120, ... 'ControlSizeMode', 'relative',... 'LabelSize', 120, ... 'LabelSizeMode', 'relative'); lyt = xreggridbaglayout(figh,... 'dimension',[4 1],... 'rowsizes',[20 20 20 -1],... 'gapy',5,'gapx',7,... 'border',[7 7 7 7],... 'elements',{... ... ud.lctrlKernel; ... ud.lctrlWidth;... ud.lctrlContinuity; ... [] } ); udp.info = ud; i_enableWdith(udp,kernel); i_enableContinuity(udp,kernel); return % -------------------------------------------------------------------------| function i_kernel(h,evt,udp) ud=udp.info; m=ud.pointer.info; value = get( ud.popupKernel, 'Value' ); kernelList = get( ud.popupKernel, 'String' ); kernel = kernelList{ value }; set( m, 'kernel', kernel ); i_enableWdith(udp,kernel); i_enableContinuity(udp,kernel); ud.pointer.info = m; i_firecb(ud.callback,ud.pointer); return % -------------------------------------------------------------------------| function i_width(h,evt,udp) ud=udp.info; m=ud.pointer.info; width = str2num( get( ud.editWidth, 'String' ) ); if ~isempty(width) & width > eps, % if a valid number is entered for the width, set the edit box and % the model set( ud.editWidth, 'String', num2str( width ) ); m = set( m, 'width', width ); else % if the width string doesn't read as a number or is too small, get the % last width value from the model and set the edit box width = get( m, 'width' ); set( ud.editWidth, 'String', num2str( width ) ); end ud.pointer.info = m; i_firecb(ud.callback,ud.pointer); return % -------------------------------------------------------------------------| function i_continuity(h,evt,udp) ud=udp.info; m=ud.pointer.info; value = get( ud.popupContinuity, 'Value' ); list = get( ud.popupContinuity, 'String' ); continuity = list{ value }; set( m, 'cont', str2num( continuity ) ); ud.pointer.info = m; i_firecb(ud.callback,ud.pointer); return % -------------------------------------------------------------------------| function i_enableWdith(udp,kernel) if any( strcmpi( kernel, {'thinplate', 'linearrbf', 'cubicrbf'} ) ), set( udp.info.lctrlWidth, 'Enable', 'off' ); else set( udp.info.lctrlWidth, 'Enable', 'on' ); end return % -------------------------------------------------------------------------| function i_enableContinuity(udp,kernel) if strcmpi( kernel, 'wendland' ), set( udp.info.lctrlContinuity, 'Enable', 'on' ); else set( udp.info.lctrlContinuity, 'Enable', 'off' ); end return % -------------------------------------------------------------------------| function i_firecb(cbstr,ptr) % execute callback xregcallback(cbstr,ptr.info,[]); return % EOF