www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@nodesel/nodesel.m

    function h=nodesel(fig,nodes,selection)
%NODESEL Constructor
%
% Creates a panel containing the list of
% nodes from which the user selects those for which 
% to view plots.
%
% h = nodesel(fig,nodes,selection)
%
% where fig is a figure, nodes is an array of cgnode pointers, and
% selection is optional and contains the indices of the nodes to be
% selected initially.

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


h = cgsurfview.nodesel;
h.Parent = fig;

listpeer = com.mathworks.toolbox.mbc.gui.peer.ItemListTablePeer;
list = mbcwidgets.Table1D(listpeer, ...
    'parent',fig, ...
    'selectionmode', 'multirow');
list.Peer.setColumnWidths([120 100 155]);
list.Peer.setColumnData({'Item', 'Type', 'Inputs'});
list.Peer.setIconBaseLocation(cgrespath);
h.list = list;
list.connect(h, 'up');

h.eventlistener = handle.listener(list, 'SelectionChanged', {@i_SelectionChangeList,h});
h.selectionlistener = handle.listener(h, h.findprop('selection'),...
                                'PropertyPostSet', {@i_SelectionChangeProg,h});

h.setnodes(nodes,selection);
h.layout = list;
h.connect(xregfigurehook(fig), 'up');


%------------------------------
% Called in response to a click on the list.  Sets member
% variable "selection", and sends event "NodeSelectionChange" if
% the selection has changed.
function i_SelectionChangeList(src, evt, obj)
newsel = evt.data.SelectedDataRows;
set(obj.selectionlistener,'Enable','off');
obj.selection = newsel; % we don't want to set the selection in the list again
set(obj.selectionlistener,'Enable','on');
send(obj,'NodeSelectionChange', handle.EventData(obj,'NodeSelectionChange'));

%------------------------------
% Called in response to a progammatic change of member variable
% "selection".  Sends event "NodeSelectionChange".
function i_SelectionChangeProg(ignore1,ignore2,obj)
obj.list.selectRows(obj.selection)
send(obj,'NodeSelectionChange', handle.EventData(obj,'NodeSelectionChange'));