www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@mmTableSetupView/mmTableSetupView.m
function obj = mmTableSetupView(varargin) %MMTABLESETUPVIEW Constructor for mmTableSetupView objects % % OBJ = MMTABLESETUPVIEW(PROP, VAL, ...) constructs a new mmTableSetupView % with the given property values. % Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin && isa(varargin{1}, 'cgtradeoffgui.mmTableSetupView') obj = varargin{1}; varargin(1) = []; else obj = cgtradeoffgui.mmTableSetupView; end % Call the inherited constructor obj.View(varargin{:}); % Make controls jt1 = com.mathworks.toolbox.mbc.gui.peer.NormaliserTablePeer; obj.hNormTable1 = mbcwidgets.Table1D(jt1, ... 'Parent', obj.Parent, ... 'SelectionMode', 'MultiRegion'); jt2 = com.mathworks.toolbox.mbc.gui.peer.NormaliserTablePeer; obj.hNormTable2 = mbcwidgets.Table1D(jt2, ... 'Parent', obj.Parent, ... 'SelectionMode', 'MultiRegion'); obj.addListeners(handle.listener(obj.hNormTable1, 'ValueChanged', ... {@i_editbps, obj, 1})); obj.addListeners(handle.listener(obj.hNormTable2, 'ValueChanged', ... {@i_editbps, obj, 2})); obj.hNormTable1.connect(obj, 'up'); obj.hNormTable2.connect(obj, 'up'); obj.hNormLabel1 = mbcgui.widget.Label('Parent', obj.Parent, ... 'HorizontalAlignment', 'left'); obj.hNormLabel2 = mbcgui.widget.Label('Parent', obj.Parent, ... 'HorizontalAlignment', 'left'); hRadios = xregGui.rbgroup('Parent', obj.Parent, ... 'nx', 2, 'ny', 1, ... 'String', {'Automatic', 'Manual'}, ... 'Value', [1 0], ... 'Callback', {@i_setbpmode, obj}); obj.hBPgenLabel = xregGui.labelcontrol('Parent', obj.Parent, ... 'String', 'Breakpoint settings:', ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 100, ... 'ControlSizeMode', 'relative', ... 'ControlSize', 1, ... 'Gap', 10, ... 'Control', hRadios); obj.hBPgenLabel.connect(obj, 'up'); hRowEdit = mbcgui.widget.Spinner('Parent', obj.Parent, ... 'Min', 2, ... 'Rule', 'int', ... 'Callback', {@i_editbplength, obj, 1}); hColEdit = mbcgui.widget.Spinner('Parent', obj.Parent, ... 'Min', 2, ... 'Rule', 'int', ... 'Callback', {@i_editbplength, obj, 2}); obj.hTableSize1 = xregGui.labelcontrol('Parent', obj.Parent, ... 'String', 'Table rows', ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 85, ... 'ControlSizeMode', 'absolute', ... 'ControlSize', 60, ... 'Gap', 5, ... 'Control', hRowEdit); obj.hTableSize1.connect(obj, 'up'); obj.hTableSize2 = xregGui.labelcontrol('Parent', obj.Parent, ... 'String', 'Table columns:', ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 85, ... 'ControlSizeMode', 'absolute', ... 'ControlSize', 60, ... 'Gap', 5, ... 'Control', hColEdit); obj.hTableSize2.connect(obj, 'up'); SC = xregGui.SystemColorsDbl; hAxis1 = uicontrol('Parent', obj.Parent, ... 'Style', 'Popupmenu', ... 'String', {''}, ... 'BackgroundColor', SC.WINDOW_BG, ... 'Tag', 'X-axis input', ... 'UserData', 2); hAxis2 = uicontrol('Parent', obj.Parent, ... 'Style', 'Popupmenu', ... 'String', {''}, ... 'BackgroundColor', SC.WINDOW_BG, ... 'Tag', 'Y-axis input', ... 'UserData', 1); set([hAxis1;hAxis2], 'Callback', {@i_editaxisorder, obj, hAxis1, hAxis2}); obj.hAxisLabel1 = xregGui.labelcontrol('Parent', obj.Parent, ... 'String', 'X-axis input:', ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 85, ... 'ControlSizeMode', 'absolute', ... 'ControlSize', 115, ... 'Gap', 5, ... 'Control', hAxis1); obj.hAxisLabel1.connect(obj, 'up'); obj.hAxisLabel2 = xregGui.labelcontrol('Parent', obj.Parent, ... 'String', 'Y-axis input:', ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 85, ... 'ControlSizeMode', 'absolute', ... 'ControlSize', 115, ... 'Gap', 5, ... 'Control', hAxis2); obj.hAxisLabel2.connect(obj, 'up'); hEditTables = uicontrol('Parent', obj.Parent, ... 'Style', 'pushbutton', ... 'String', 'Select Tables...', ... 'Callback', {@i_selecttables, obj}); obj.hNumTablesLabel = xregGui.labelcontrol('Parent', obj.Parent, ... 'String', 'Number of tables to create:', ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 160, ... 'ControlSizeMode', 'absolute', ... 'ControlSize', 85, ... 'Gap', 5, ... 'Control', hEditTables); obj.hNumTablesLabel.connect(obj, 'up'); obj.hDividerLine = xregGui.dividerline('parent', obj.Parent); obj.hDividerLine.connect(obj, 'up'); % Set positions of objects correctly pPostSetPosition(obj, []); % Hook up to the message service if it exists if ~isempty(obj.MessageService) obj.pPostSetMessageService; else obj.pUpdateSwitchNames; obj.pUpdateBreakpoints; obj.pUpdateTableSel; end function i_setbpmode(src, ~, obj) % react to selection of breakpoint mode if src.Selected==1 obj.MessageService.setAutoBreakpoints(true); else obj.MessageService.setAutoBreakpoints(false); end function i_editbps(~, evt, obj, index) % Get new breakpoints from tables and send to message service bps = obj.MessageService.Breakpoints; data = evt.Data.NewValue; if isvector(data) thisbp = bps{index}; thisbp(evt.data.Rows) = data(:); bps{index} = thisbp; obj.disableMessageServiceListeners; obj.MessageService.setBreakpoints(bps); obj.enableMessageServiceListeners; end function i_editaxisorder(src, ~, obj, hAxis1, hAxis2) axis = get(src, 'UserData'); newval = get(src, 'Value'); if newval==obj.MessageService.AxisOrder(axis) return end otherval = 3 - newval; if axis==1 neworder = [newval, otherval]; set(hAxis1, 'Value', otherval); else neworder = [otherval, newval]; set(hAxis2, 'Value', otherval); end obj.disableMessageServiceListeners; obj.MessageService.setAxisOrder(neworder); obj.enableMessageServiceListeners obj.pUpdateBreakpoints; function i_editbplength(src, ~, obj, dim) newlen = src.Value; bpidx = obj.MessageService.AxisOrder(dim); bps = obj.MessageService.Breakpoints; oldlen = length(bps{bpidx}); if oldlen<newlen bps{bpidx} = [bps{bpidx}; repmat(bps{bpidx}(end), newlen-oldlen, 1)]; obj.MessageService.setBreakpoints(bps); elseif oldlen>newlen bps{bpidx} = bps{bpidx}(1:newlen); obj.MessageService.setBreakpoints(bps); end function i_selecttables(~, ~, obj) % Open dialog to select the tables to create obj.selectTables;