www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optimoutput/ConGraphView.m
classdef ConGraphView < mbcgui.multiview.View %cageview.optimoutput.ConGraphView class % cageview.optimoutput.ConGraphView extends mbcgui.multiview.View. % % cageview.optimoutput.ConGraphView 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' % % cageview.optimoutput.ConGraphView methods: % canPrint - Check whether component can be printed % createDefaultWindowContainer - Create an appropriate container for the view % gettitle - Return string to use as title for view % printSize - Returns the preferred printing size for the component % printCopy - Create a printer-friendly copy of pairwiseproj % redraw - Redraw the constraint graphs. % Copyright 2005-2016 The MathWorks, Inc. properties (Access=protected, AbortSet) %HTABLE Property is of type 'handle' hTable = []; end methods % constructor block function obj = ConGraphView(varargin) %ConGraphView Constructor for ConGraphView % OBJ = ConGraphView(PROP, VALUE) constructs a class that displays % the constraint left-hand and right-hand side slices from a % multi-objective optimization. % Call the inherited constructor obj@mbcgui.multiview.View(varargin{ : }); % converted super class constructor call data = cageview.optimoutput.ConGraphViewData; obj.hTable = mbcgui.widget.ClassicTable('Parent',obj.Parent, ... 'Visible', obj.Visible, ... 'ShowRowHeaders',true, ... 'ShowColumnHeaders',true,... 'RowHeaderWidth', 65,... 'ColumnHeaderWidth', 60,... 'MinimumCellSize', [150 150],... 'UseVectorDrawMethod',false,... 'MainConstructor',@i_createMainObject,... 'RowConstructor', @i_createRowHeadObject,... 'ColumnConstructor', @i_createColHeadObject, ... 'MainData', data, ... 'RowHeaderData', data, ... 'ColumnHeaderData', data, ... 'RowGap', 0, ... 'ColumnGap',0, ... 'ColumnHeaderPosition', 'bottom', ... 'MaximumObjectCacheSize', 15); obj.hTable.TopLeftCorner = obj.hTable.newCornerComponent('panel'); obj.hTable.BottomRightCorner = obj.hTable.newCornerComponent; % Provide data with table handle so it can cache data efficiently data.hTable = obj.hTable; obj.addListeners(event.listener(data, 'YLimUpdated', mbcutils.callback(@i_ylimrepaint, obj.hTable))); % Add a spacer object that makes room for viewing an exponent on the top % graph Spacer = obj.hTable.newCornerComponent('panel'); Cards = xregcardlayout(obj.Parent, ... 'Visible', obj.Visible, ... 'CurrentCard', 2, ... 'NumCards', 2); attach(Cards, Spacer, 1); G = xreggridbaglayout(obj.Parent, ... 'Dimension', [2 2], ... 'Rowsizes', [10 -1], ... 'ColSizes', [65 -1], ... 'MergeBlock', {[2 2], [1 2]}, ... 'Elements', {Cards, obj.hTable}); obj.ContentHandle = G; obj.addListeners( ... event.listener(obj.hTable, ... 'DisplaySizeChanged', mbcutils.callback(@i_spacervisible, Cards))); if ~isempty(obj.MessageService) obj.pPostSetMessageService; end % Create option action options AG = mbcgui.actions.ActionGroup('', '&Graph Size'); AG.MenuType = 'submenu'; A1 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 0, AG}, ... '&Display All Graphs'); A2 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 100, AG}, ... '&Small'); A3 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 150, AG}, ... '&Medium'); A3.Selected = true; A4 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 200, AG}, ... '&Large'); AG.Actions = [A1 A2 A3 A4]; obj.Options.Actions = AG; end % ConGraphView end % constructor block methods % public methods %---------------------------------------- function out = canPrint(obj) %CANPRINT Check whether component can be printed % CANPRINT(OBJ) returns true if 10x10 grid or less d = obj.hTable.MainData; out = hasData(obj) && d.getRowCount<=10 && d.getColumnCount<=10; end % canPrint %---------------------------------------- function hPane = createDefaultWindowContainer(obj,PanelHandle) %CREATEDEFAULTWINDOWCONTAINER Create an appropriate container for the view % HCONAINER = CREATEDEFAULTWINDOWCONTAINER(OBJ) creates and returns a % handle to a ViewContainer that has been set up to contain OBJ. The % container should be appropriate for viewing OBJ in a standard % application window. The default implementation creates a % PanelTitleViewContainer. if nargin>1 % User suplied Panel Parent = get(PanelHandle,'Parent'); OtherArgs = {'PanelHandle',PanelHandle}; else % Use the View's parent Parent = get(View,'Parent'); OtherArgs = {}; end SC = xregGui.SystemColorsDbl; hPane = mbcgui.multiview.PanelTitleViewContainer( ... 'Parent', Parent, ... 'Visible', obj.Visible, ... 'BackgroundColor', SC.CTRL_BG, ... 'View', obj,... OtherArgs{:}); end % createDefaultWindowContainer %---------------------------------------- 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 = 'Constraint Graphs'; end % gettitle %---------------------------------------- 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 % scales the current screen size so that each graph maintains its aspect % ratio. % Get size of central table region sz = obj.Position(3:4) - [65 50]; % Scale size by number of missing graphs nShowing = obj.hTable.getDisplaySize; nTotal = [obj.hTable.MainData.getRowCount, obj.hTable.MainData.getColumnCount]; if all(nShowing>0) sz = sz.*fliplr(nTotal./nShowing); end end % printSize %---------------------------------------- function newobj = printCopy(obj, fig) %PRINTCOPY Create a printer-friendly copy of pairwiseproj % LYT = PRINTCOPY(OBJ,FIG) % Evaluate data for all cells now since they will need to be all shown data = obj.hTable.MainData; data.fillDataCache; % Copy data for the exported graph set newdata = data.copy; newtable = mbcgui.widget.ClassicTable('Parent',fig, ... 'Position',fig.Position,... 'ShowRowHeaders',false, ... 'ShowColumnHeaders',false,... 'MinimumCellSize', [0 0],... 'UseVectorDrawMethod',false,... 'MainConstructor',@i_createMainObjectPrintable,... 'MainData', newdata, ... 'Rowgap', 0,'ColumnGap',0); newobj = xreglayerlayout(fig, ... 'border', [40 35 0 0], ... 'elements', {newtable}); end % printcopy %---------------------------------------- function redraw(obj, Type) %REDRAW Redraw the constraint graphs. % REDRAW(OBJ) redraws all of the constraint graphs. % REDRAW(OBJ, TYPE) redraws the graphs to the specified level. Valid % values for TYPE are 'full' and 'confeas'. if nargin<2 Type = 'full'; end obj.hTable.MainData.MessageService = obj.MessageService; switch Type case 'confeas' obj.hTable.MainData.resetFeasibility; case 'full' obj.hTable.MainData.reset; end obj.hTable.update; end % redraw end % public methods methods (Access=protected) %---------------------------------------- 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@mbcgui.multiview.View(obj) if ~isempty(obj.MessageService) % Add redraw events obj.addMessageServiceListener( {'ObjectChanged', ... 'FeasibleToleranceChanged', ... 'SliceDirectionChanged', ... 'CurrentFocusChanged'}, ... {{@i_refresh, obj, 'full'}, ... {@i_refresh, obj, 'confeas'}, ... {@i_refresh, obj, 'full'}, ... {@i_refresh, obj, 'full'}}); end obj.redraw; end % pPostSetMessageService end end % classdef function h = i_createMainObject(P) h = cageview.optimoutput.ConGraphViewCell('Parent',P, 'Visible','off'); end % i_createMainObject function h = i_createRowHeadObject(P) h = mbcgui.widget.SharedAxisHeader('Parent', P, ... 'Visible', 'off', ... 'Orientation', 'vertical', ... 'AxisEdgeOffset', 10, ... 'AxisFrontOffset', 8); end % i_createRowHeadObject function h = i_createColHeadObject(P) h = mbcgui.widget.SharedAxisHeader('Parent', P, ... 'Visible', 'off', ... 'Orientation', 'horizontal', ... 'AxisEdgeOffset', 15, ... 'AxisFrontOffset', 8); end % i_createColHeadObject function i_setgraphsize(src, ~, hTable, size, AG) hTable.MinimumCellSize = [size size]; set(AG.Actions, 'Selected', false); src.Selected = true; end % i_setgraphsize % Repaint table rows if a ylim is altered when new sweeps are calculated function i_ylimrepaint(~, evt, hTable) hTable.paintRows(evt.data.Rows); end % i_ylimrepaint % Set spacer visibility to match that of the corner component function i_spacervisible(src, ~, Cards) sz = src.getDisplaySize; if any(sz>0) set(Cards, 'CurrentCard', 1); else set(Cards, 'CurrentCard', 2); end end % i_spacervisible function i_refresh(~, ~, obj, Type) % Refresh all the table data obj.redraw(Type); end % i_refresh function h = i_createMainObjectPrintable(P) h = cageview.optimoutput.ConGraphViewCell('parent',P, ... 'visible','off', ... 'LabelEdgeAxes', true, ... 'Hittest', 'on'); end % i_createMainObjectPrintable