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

    function h = rbfprune(pmdev,UpdateFcn)
%RBFPRUNE Constructor for prune dialog
%
%  OBJ = RBFPRUNE(P_MDEV) creates an RBF center-pruning dialog for the
%  given modeldev object.

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

mv_busy('Creating prune figure... ');

% Class constructor
h = xregMdlGui.rbfprune;

% Store the mdev pointer
h.ptrMdev = pmdev;
if nargin>1
    h.UpdateFcn = UpdateFcn;
end

% Create the figure window in the correct place, with windows backgound color
scr = get(0,'ScreenSize');
fsize= [scr(3)*0.35 scr(4)*0.6];

% create the figure
fH = xregfigure(...
     'Visible','off',...
     'WindowStyle','modal',...
     'Name','Number of Centers Selector',...
     'CloseRequestFcn',{@i_callbacks,h,'cancel'}, ...
     'Tag', 'prune');
h.figure = fH;
xregcenterfigure(fH,fsize,mvf);


% Create the GUI
btMINIMISE = uicontrol('Parent',fH,...
   'Style','push',...
   'Position',[0 0 65 25],...
   'String','Minimize',...
   'Visible','off',...
   'Callback',{@i_callbacks,h,'btminimise'});

btCLEAR = uicontrol('Parent',fH,...
   'Style','push',...
   'Position',[0 0 65 25],...
   'String','Clear',...
   'Visible','off',...
   'Callback',{@i_callbacks,h,'btclear'});

lbNCENTERS = uicontrol('Parent',fH,...
   'Style','text',...
   'BackgroundColor',get(fH,'Color'),...
   'String','Ncenters:',...
   'Visible','off',...
   'Position',[0 0 65 15]);

h.editH = uicontrol('Parent',fH,...
   'Style','edit',...
   'BackgroundColor',[1 1 1],...
   'Enable','on',...
   'Visible','off',...
   'Callback',{@i_callbacks,h,'edncenters'});

h.popH = uicontrol('Parent',fH,...
   'Style','popup',...
   'String','Hello',...
   'BackgroundColor',[1 1 1],...
   'Enable','on',...
   'Visible','off',...
   'Callback',{@i_callbacks,h,'chooser'});

btOK = uicontrol('Parent',fH,...
   'Style','push',...
   'Position',[0 0 65 25],...
   'String','OK',...
   'Visible','off',...
   'Callback',{@i_callbacks,h,'ok'});

btCANCEL = uicontrol('Parent',fH,...
   'Style','push',...
   'Position',[0 0 65 25],...
   'String','Cancel',...
   'Visible','off',...
   'Callback',{@i_callbacks,h,'cancel'});

btHELP=mv_helpbutton(fH,'xreg_rbfPrune');

h.refitH = uicontrol('Parent',fH,...
   'Style','checkbox',...
   'Position',[0 0 65 25],...
   'String','Refit Widths on Close',...
   'Visible','off');

botToolbar = xreggridbaglayout(fH,...
    'dimension',[1,5],...
    'elements',{h.refitH,[],btOK,btCANCEL,btHELP},...
    'colsizes',[150,-1,65,65,65],...
    'gapx',7, ...
    'border', [20 0 0 0]);
  
toolbar = xreggridbaglayout(fH,...
   'dimension',[1,7],...
   'elements',{[],h.popH,[],btMINIMISE,btCLEAR,lbNCENTERS,h.editH},...
   'gapx',10,...
   'ColSizes',[-1, 150, -1, 80,80,80,80]);


% Create axes and graph2d axes for plotting
h.AxesH = axes('Parent',fH,'Units','pixels','Box','on', ...
    'Visible','off', 'NextPlot', 'add',...
    'ButtonDownFcn', @(h,evt) mv_zoom(h), ...
    'XGrid', 'on', 'YGrid', 'on');
ax = mbcgui.widget.AxesPanel(...
    'AxesHandle', h.AxesH, ...
    'Border', [40 30 10 20], ...
    'Visible', 'off');
h.Graph2d = mvgraph2d(fH, 'Visible','off');
% Turn off TeX interpreter for graph2d axes
set(get(h.Graph2d.axes,'YLabel'),'Interpreter','none');
set(get(h.Graph2d.axes,'XLabel'),'Interpreter','none');
set(h.Graph2d.axes,'Box','on');
set(h.Graph2d,'Grid','on');

g2dlyt = xreglayerlayout(fH, 'border', [10 0 10 0], 'elements', {h.Graph2d});
pane = xreggridbaglayout(fH, ...
    'dimension', [5 1], ...
    'rowsizes', [-1 -1 25 5 25], ...
    'gapy', 10, ...
    'border', [7 7 7 7], ...
    'elements', {g2dlyt, ax, toolbar, [], botToolbar});

% set layout to be managed by xregfigure
set(h.figure, 'LayoutManager', pane);
set(pane, 'packstatus', 'on');

% Initialise some stuff...
model = h.ptrMdev.model;
% set ncenters to the model's ncenters
centers = get(model,'centers');
h.NCenters = size(centers(Terms(model)),1);
h.LineH = 0;

% Print the correct value of ncenters in the editbox
set(h.editH,'String',num2str(h.NCenters),'UserData',num2str(h.NCenters));

% Draw the lines
h.drawLines;

% Draw the residuals
h.drawResiduals;

% update plots
h.updatePlot;

% delete the wait
mv_busy('delete');

h.InternalListeners = [handle.listener(h,h.findprop('NCenters'),'PropertyPostSet',{@i_NCenterChangedCallback}),...
        handle.listener(h,h.findprop('CurrentLineIndex'),'PropertyPostSet',{@i_LineIndexChangedCallback})];

% Finally set things visible
repack(pane);
set(pane,'Visible','on');

set(h.figure,'Visible','on');




%%%%%%%%%%%%
% Internal Functions
%%%%%%%%%%%%

% button callback dispatch function
function i_callbacks(src, evt, obj, arg)
doButtonCallback(obj,arg);

% listener callback dispatch
function i_NCenterChangedCallback(src,evt)
obj = evt.AffectedObject;
updatePlot(obj);

% listener callback dispatch
function i_LineIndexChangedCallback(src,evt)
obj = evt.AffectedObject;
updatePlot(obj);