www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/+xregdesgui/DesignProjView.m
classdef DesignProjView < xregdesgui.DesignView %xregdesgui.DesignProjView class % xregdesgui.DesignProjView extends xregdesgui.DesignView. % % xregdesgui.DesignProjView 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.DesignProjView methods: % 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 (SetAccess=protected, AbortSet) %GObject Property is of type 'MATLAB array' GObject = []; end methods % constructor block function obj = DesignProjView(varargin) %DESIGNPROJVIEW Constructor for designprojview objects % DESIGNPROJVIEW(Property, Value, ...) creates a new designprojview % object. This is the base class for all nD projection views of a design. % Call superclass constructor obj@xregdesgui.DesignView(varargin{ : }); % converted super class constructor call % Create action for properties dialog obj.Options.Actions = mbcgui.actions.StatefulAction(@i_editprefs, 'Plot &Properties...', 'Edit View Properties',''); % Create the nD graph object G = obj.createDisplay; obj.GObject = G; obj.ContentHandle = G; % Force DMS change update now obj.pPostSetMessageService; function i_editprefs(~, ~) obj.GObject = prefsgui(obj.GObject); end end %---------------------------------------- function delete(obj) %delete destructor if ~mbcgui.util.isBeingDestroyed(obj.Parent) delete(obj.GObject); end end % delete end % structor block methods % public methods %---------------------------------------- function G = createDisplay(obj) %#ok<MANU> %CREATEDISPLAY Create the graph object for the view % G = CREATEDISPLAY(OBJ) creates the nD graph object that is used for the % display. G = []; end % createDisplay %---------------------------------------- function pUpdateGraph(obj, ~,~) %PUPDATEGRAPH Update the nD graph object's data % PUPDATEGRAPH(OBJ) updates the nD graphs copy of the design data. if obj.hasData d = obj.MessageService.getdesign; if ~isempty(d) lims = designlimits(d); buffer = 100*[-eps eps]; for k = 1:length(lims) lims{k} = lims{k}+buffer; lims{k} = invcode(model(d), lims{k}(:), k)'; end set(obj.GObject,'data',invcode(model(d),factorsettings(d)),... 'factors',factors(d),... 'limits',lims); else set(obj.GObject, 'data', [], 'factors', {}); end else set(obj.GObject, 'data', [], 'factors', {}); end end % pUpdateGraph %---------------------------------------- function pUpdateTestNums(obj, ~,~) %PUPDATETESTNUMS Update the test number display on the graph % PUPDATETESTNUMS(OBJ) updates the settings for test number display on the % nD graph object. if ~isempty(obj.MessageService) pProp = obj.MessageService.findprop('DesignShowTestNumbers'); else pProp = []; end if ~isempty(pProp) if obj.MessageService.DesignShowTestNumbers==1 set(obj.GObject, 'datatags', 'enumerate'); elseif obj.MessageService.DesignShowTestNumbers==2 set(obj.GObject, 'datatags', 'coincident'); else set(obj.GObject, 'datatags', 'none'); end else set(obj.GObject, 'datatags', 'none'); end end % pUpdateTestNums %---------------------------------------- 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. This method % removes 60 pixels that are used by the factor selectors on screen. ms = minsize(obj.GObject); s = get(obj.GObject,'Position'); if any(s(3:4)<ms) sz = obj.Position(3:4); else sz = obj.Position(3:4) - [0 60]; end 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. plotobj = printcopy(obj.GObject, fig); newobj = obj.addPrintTitle(plotobj); 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('DesignChange',@obj.pUpdateGraph) ... ); pProp = obj.MessageService.findprop('DesignShowTestNumbers'); if ~isempty(pProp) L = event.proplistener(obj.MessageService, pProp, 'PostSet', @obj.pUpdateTestNums); obj.addMessageServiceListener(L); end end obj.pUpdateGraph; obj.pUpdateTestNums; end % pPostSetMessageService end end % classdef