www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/+xregdesgui/DesignPackage.m
classdef DesignPackage < mbcgui.multiview.AbstractMessageService %xregdesgui.DesignPackage class % xregdesgui.DesignPackage extends mbcgui.multiview.AbstractMessageService. % % xregdesgui.DesignPackage properties: % DesignShowTestNumbers - Property is of type 'int' % DesignSelectedPoints - Property is of type 'MATLAB array' % % xregdesgui.DesignPackage methods: % addlistener - Create a listener to an event % getDataName - Get a name for the data being displayed % getdesign - Retrieve design from object % hasData - Check whether the MessageService contains viewable data % setdesign - Set a new design into package % Copyright 2015 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (AbortSet, SetObservable) %DESIGNSHOWTESTNUMBERS Property is of type 'int' DesignShowTestNumbers = 0; %DESIGNSELECTEDPOINTS Property is of type 'MATLAB array' DesignSelectedPoints = []; %Actions Actions end properties (Access=protected, AbortSet) %DESIGN Property is of type 'MATLAB array' Design = []; end events (NotifyAccess=private) AnyChange DesignChange ConstraintChange LockChange ItemChange ModelDesignChange NameChange Model Busy Idle end % events methods % public methods %---------------------------------------- function L=addlistener(h,eventname,callback,varargin) %ADDLISTENER Create a listener to an event % L = ADDLISTENER(h, event, callback, {prop-val pairs}) creates and % returns a listener to the named event. % Sort out event argument PROP=false; switch lower(eventname) case 'design' eventname='DesignChange'; case {'constraints','constraint'} eventname='ConstraintChange'; case 'any' eventname='AnyChange'; case 'lock' eventname='LockChange'; case 'item' eventname='ItemChange'; case 'modeldesign' eventname='ModelDesignChange'; case 'model' eventname = 'Model'; case 'showtestnumbers' PROP=true; eventname='DesignShowTestNumbers'; case 'selectedpoints' PROP=true; eventname='DesignSelectedPoints'; case 'name' eventname='NameChange'; end if PROP L=event.proplistener(h,h.findprop(eventname),'PostSet',callback); else L=event.listener(h,eventname,callback); end end % addlistener %---------------------------------------- function nm = getDataName(obj) %GETDATANAME Get a name for the data being displayed % % NM = GETDATANAME(OBJ) returns a string that is the name of the data % that is being encapsulated by the message service. The name of the % current design is returned for the designpackage. if obj.hasData nm = name(obj.getdesign); else nm = '<Unknown>'; end end % getDataName %---------------------------------------- function d=getdesign(h) %GETDESIGN Retrieve design from object % des=h.getdesign d=h.Design; end % getdesign %---------------------------------------- function ret = hasData(obj) %HASDATA Check whether the MessageService contains viewable data % RET = HASDATA(OBJ) returns true if the MessagerService object contains % a data object that can provide any viewing data. ret = ~isempty(obj.Design); end % hasData %---------------------------------------- function setdesign(h,d,varargin) %SETDESIGN Set a new design into package % SETDESIGN(h, des, events) sets des into h and then sends the listed % events. Valid options for events are: % % design % constraints % all % lock % item % model % name h.Design=d; for n=1:length(varargin) switch varargin{n} case 'design' notify(h,'DesignChange'); notify(h,'ModelDesignChange'); notify(h,'AnyChange'); case {'constraints','constraint'} notify(h,'ConstraintChange'); notify(h,'AnyChange'); case 'lock' notify(h,'LockChange'); notify(h,'AnyChange'); case 'item' notify(h,'ItemChange'); notify(h,'LockChange'); notify(h,'DesignChange'); notify(h,'ConstraintChange'); notify(h,'Model'); notify(h,'AnyChange'); case 'all' notify(h,'ItemChange'); notify(h,'LockChange'); notify(h,'DesignChange'); notify(h,'ConstraintChange'); notify(h,'Model'); notify(h,'AnyChange'); case 'model' notify(h,'Model'); notify(h,'ModelDesignChange'); notify(h,'AnyChange'); case 'name' notify(h,'NameChange'); notify(h,'AnyChange'); end end end % setdesign function busy(obj,msg) %busy send event that MessageService is busy % busy(obj,msg) if nargin<2 msg = ''; end data.Message = msg; evt = xregEventData(data); notify(obj,'Busy',evt); end function idle(obj) %idle send event that MessageService is idle % idle(obj) notify(obj,'Idle'); end end % public methods end % classdef