www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optim/ConstraintListView.m
classdef ConstraintListView < cageview.optim.OptimItemListView %cgoptimgui.ConstraintListView class % cgoptimgui.ConstraintListView extends cageview.optim.OptimItemListView. % % cgoptimgui.ConstraintListView 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' % SelectedConstraint - Property is of type 'int' % ProjectPointer - Property is of type 'MATLAB array' % % cgoptimgui.ConstraintListView methods: % gettitle - Return string to use as title for view % Copyright 2005-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. methods % constructor block function obj = ConstraintListView(varargin) %COSNSTRAINTLISTVIEW Constructor for ConstraintListView % OBJ = COSNSTRAINTLISTVIEW(PROP, VALUE) constructs a view that displays % information about optimization constraint items. % Call the inherited constructor obj@cageview.optim.OptimItemListView(varargin{ : }); % converted super class constructor call % attach the constraint actions obj.Actions = obj.MessageService.Actions.Constraints; obj.hList.UIContextMenu = obj.pCreateContextMenu; end % ConstraintListView end % constructor block methods % public methods %---------------------------------------- function str = gettitle(obj) %#ok<MANU> %GETTITLE Return string to use as title for view % STR = GETTITLE(OBJ) returns a string that should be used as a title for % the container the view sits in. str = 'Constraints'; end % gettitle %---------------------------------------- function editItem(obj) %EDITITEM Edit an item % EDITITEM(OBJ) is called when the currently selected item is % double-clicked or otherwise activated. If the item is editable, an % appropriate dialog should be displayed for editing it. execute(obj.Actions.Edit) end % editItem end % public methods methods(Access=protected) %---------------------------------------- function pFillList(obj,~,~) %PFILLLIST Redraw the list % PFILLLIST(OBJ) redraws the list. obj.hList.Peer.setStoreSwingCalls(true); pFillList@cageview.optim.OptimItemListView(obj); if obj.hasData ms = obj.MessageService; optim = ms.getOptim; obj.hList.Peer.setItemEnabled(getConstraintEnabled(optim)); n = getNumConstraints(optim); if ms.SelectedConstraint>0 && ms.SelectedConstraint<=n % select constraint in table obj.SelectedItemIndex = ms.SelectedConstraint; obj.hList.Peer.selectRows(ms.SelectedConstraint-1); % set the Enable constraint state enstate = getConstraintEnabled(optim, ms.SelectedConstraint); cActions = ms.Actions.Constraints; cActions.Enable.Selected = enstate; else ms.SelectedConstraint = 0; obj.SelectedItemIndex = 0; obj.hList.selectRows([]); end else obj.hList.Peer.setItemEnabled([]); obj.hList.selectRows([]); end obj.hList.Peer.setStoreSwingCalls(false); end % pFillList %---------------------------------------- function names = pGetAdditionalDataNames(~) %PGETADDITIONALDATANAMES Return the column names for additional data % PGETADDITIONALDATANAMES(OBJ) returns a cell array containing the names % of the additional data columns that should be added to the list. The % length of this cell array must match the number of columns in the output % of PGETADDITIONALDATAVALUES. names = {'Application Point Set'}; end % pGetAdditionalDataNames %---------------------------------------- function values = pGetAdditionalDataValues(obj, items) %PGETADDITIONALDATAVALUES Return the values for additional data % VALUES = PGETADDITIONALDATAVALUES(OBJ, ITEMS) returns a cell array % containing the values of the additional data that should be added to % the list. The number of columns of this cell array must match the length % of the output of PGETADDITIONALDATANAMES and the number of rows must % match the length of ITEMS. values = cell(1,0); if obj.hasData optim = obj.MessageService.getOptim; DS= getOptimDatasets(optim); values = DS.getSummary('Constraints',items); end end % pGetAdditionalDataValues %---------------------------------------- function items = pGetItems(obj) %PGETITEMS Get the items that should be listed % ITEMS = PGETITEMS(OBJ) returns a cell array containing the items that % should be contained in the list. if obj.hasData optim = obj.MessageService.getOptim; items = getConstraint(optim); else items = cell(1,0); end end % pGetItems %---------------------------------------- function [codes, status] = pGetStatusStrings(obj, items) %#ok<INUSD> %PGETSTATUSSTRINGS Return the status strings for the items. % [CODES, STATUS] = PGETSTATUSSTRINGS(OBJ, ITEMS) returns the status % codes and strings for the items specified. optim = obj.MessageService.getOptim; [codes, status] = checkConstraints(optim); end % pGetStatusStrings %---------------------------------------- function pPostSetMessageService(obj) %PPOSTSETMESSAGESERVICE Method that is called when the message service is set % PPOSTSETMESSAGESERVICE(OBJ) is called in response to a new message % service being set in the object. pPostSetMessageService@cageview.optim.OptimItemListView(obj) obj.addMessageServiceListener( ... { 'ConstraintChanged','DatasetChanged'}, ... { @obj.pFillList, @obj.pFillList } ... ); % Update display obj.pFillList; end % pPostSetMessageService %---------------------------------------- function pSelectionChanged(obj) %PSELECTIONCHANGED Perform actions when the selection changes % PSELECTIONCHANGED(OBJ) is called when the selection in the list is % altered. pSelectionChanged@cageview.optim.OptimItemListView(obj); obj.MessageService.SelectedConstraint = obj.SelectedItemIndex; end % pSelectionChanged end end % classdef