www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregMdlGui/@PolynomialSplineOrderEditor/PolynomialSplineOrderEditor.m
function obj = PolynomialSplineOrderEditor( varargin ) %POLYNOMIALSPLINEORDEREDITOR Constructor for PolynomialSplineOrderEditor object % % OBJ = POLYNOMIALSPLINEORDEREDITOR(Prop, Value, ...) constructs an object % for editing the order of the polynomial and choosng the spline variable % in an xreg3xspline. % Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc. % Is the first input argument a udd object derived from me? If it is then % we are being called as a super class constructor and don't have to % construct an object if nargin && isa(varargin{1}, 'xregMdlGui.PolynomialSplineOrderEditor') obj = varargin{1}; varargin(1) = []; else obj = xregMdlGui.PolynomialSplineOrderEditor; end % Call the inherited constructor % Call the inherited constructor P = com.mathworks.toolbox.mbc.gui.peer.PolynomialSplineOrderEditorPeer; obj.Table2D(P,... 'SelectionMode', 'SingleCell',... 'Editable', true,... 'ValueChangedCallback', @i_valueChange,... varargin{:}); obj.Peer.setRowHeaderWidth( 100 ); obj.Peer.setHeaderRenderSelection( false ); obj.Peer.setCornerString( 'Symbol' ); obj.Peer.setColumnData( {'Order', 'Spline'} ); % Attach property listeners obj.addPropertyListeners('model', @i_setModel); obj.pSetModel( obj.Model ); function i_valueChange(obj, evt) colIndex = evt.data.Columns; rowIndex = evt.data.Rows; newValue = evt.data.NewValue; if colIndex == 1 % this is an order change order = get( obj.Model, 'order' ); order( rowIndex ) = newValue; obj.Model = set( obj.Model, 'order', order ); type = 'Order'; elseif colIndex == 2 % this is a spline term change obj.Model = set( obj.Model, 'spline', double(rowIndex) ); type = 'SplineFactor'; end % change coefficients from zeros to default 1:n t = termorder( obj.Model ); t = max( t ); obj.Model = update( obj.Model, (1:t)' ); obj.pFireModelChangedEvent( type ); function i_setModel(obj, evt) m = evt.NewValue; obj.pSetModel( m );