www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/+xregdesgui/ModelView.m
classdef ModelView < xregdesgui.DesignView %xregdesgui.ModelView class % xregdesgui.ModelView extends xregdesgui.DesignView. % % xregdesgui.ModelView properties: % Parent - Property is of type 'MATLAB array' % Position - Property is of type 'rect' % Enable - Property is of type 'on/off' % Visible - Property is of type 'on/off' % UserData - Property is of type 'MATLAB array' % Tag - Property is of type 'string' % MessageService - Property is of type 'handle' % Options - Property is of type 'handle vector' % Actions - Property is of type 'handle vector' % UIContextMenu - Property is of type 'MATLAB array' % % xregdesgui.ModelView methods: % gettitle - Return a suitable title for a window % printSize - Returns the preferred printing size for the component % printCopy - Create a new component for printing the component display % Copyright 2015 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (Access=protected, AbortSet) %HMODELPANE Property is of type 'handle' hModelPane = []; end methods % constructor block function obj = ModelView(varargin) %MODELVIEW Constructor for ModelView object % OBJ = MODELVIEW(Property, Value, ...) constructs a new modelview object. obj@xregdesgui.DesignView(varargin{ : }); % converted super class constructor call obj.hModelPane = xregMdlGui.modelpane('Parent',obj.Parent, ... 'Visible',obj.Visible, ... 'Position',obj.Position); obj.pPostSetMessageService; obj.ContentHandle = obj.hModelPane; end % modelview end % constructor block methods end % set and get functions methods % public methods %---------------------------------------- function s = gettitle(obj) %#ok<MANU> %GETTITLE Return a suitable title for a window % GETTITLE(OBJ) returns a string that can be used as a title for the % display. s = 'Model Description'; end % gettitle %---------------------------------------- function pUpdate(obj, ~,~) %PUPDATE Update the view's display % PUPDATE(OBJ) updates the model information that is being displayed. if obj.hasData d = obj.MessageService.getdesign; obj.hModelPane.Model = model(d); else obj.hModelPane.Model = []; end end % pUpdate %---------------------------------------- function sz = printSize(obj) %PRINTSIZE Returns the preferred printing size for the component % SZ = PRINTSIZE(OBJ) returns a two element vector containing the % preferred width and height for printing the component. sz = obj.hModelPane.printSize; end % printSize %---------------------------------------- function newobj = printCopy(obj, fig) %PRINTCOPY Create a new component for printing the component display % % NEWOBJ = PRINTCOPY(OBJ, FIG) creates and returns a handle to a new % component, NEWOBJ, parented by the specified figure, FIG. The new % object will be used for printing a copy of the component OBJ. % Pass on to modelpane object hModelInfo = obj.hModelPane.printcopy(fig); newobj = obj.addPrintTitle(hModelInfo); end % printcopy end % public methods methods (Access=protected) %---------------------------------------- function pPostSetMessageService(obj) %PPOSTSETMESSAGESERVICE Respond to change of MessageService % PPOSTSETMESSAGESERVICE(OBJ) is called when the MessageService property is % changed. % Clear the listeners and add new ones obj.clearMessageServiceListeners; if ~isempty(obj.MessageService) obj.addMessageServiceListener( ... obj.MessageService.addlistener('Model',@obj.pUpdate) ... ); end obj.pUpdate; end % pPostSetMessageService end end % classdef