www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregMdlGui/@modelpane/doModel.m
function doModel(obj, evt) %DOMODEL Update model representation % % DOMODEL(OBJ) updates the panel when the model is changed. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. [Lines, Bold, Indent] = obj.pGetModelText; obj.hAxes.clear; if isempty(Lines) set(obj.hAxes,'xlim',[0 1],'ylim',[0 1],'Xviewpos',0.5,'Yviewpos',0.5); if ~isempty(obj.EmptyDisplayString) hTxt = text(obj.hAxes, ... 'Position', [0 0], ... 'VerticalAlignment', 'top', ... 'HorizontalAlignment', 'left', ... 'String', obj.EmptyDisplayString); set(hTxt, 'Units', 'pixels'); sz = get(hTxt, 'Extent'); set(hTxt, 'Units', 'data'); set(obj.hAxes,'xlim',[-5 sz(3)+5],'ylim',[-sz(4)-5 5],'Xviewpos',-5,'Yviewpos',5); else set(obj.hAxes,'xlim',[0 1],'ylim',[0 1],'Xviewpos',0.5,'Yviewpos',0.5); end else pos = obj.Position; set(obj.hAxes,'xlim',[0 pos(3)],'ylim',[0 pos(4)],'Xviewpos',0,'Yviewpos',pos(4)); dims = obj.hAxes.construct(@(hAx) i_createmodeltext(hAx, Lines, Indent, Bold)); set(obj.hAxes,'xlim',[-5 dims(2)+5],'ylim',[-5 dims(1)+5],'Xviewpos',-5,'Yviewpos',dims(1)+5); end function dims = i_createmodeltext(hAx, Lines, Indent, Bold) [dims(1), dims(2)] = xregtextlist(hAx,[0 0 0], Lines, Indent, Bold, 7, 15); ch = get(hAx,'Children'); set(ch,'Units','data');