www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optimoutput/ConGraphViewCell.m
classdef ConGraphViewCell < mbcgui.widget.BasicContainer %cageview.optimoutput.ConGraphViewCell class % cageview.optimoutput.ConGraphViewCell extends mbcgui.widget.BasicContainer. % % cageview.optimoutput.ConGraphViewCell 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' % LabelEdgeAxes - Property is of type 'bool' % HitTest - Property is of type 'on/off' % % cageview.optimoutput.ConGraphViewCell methods: % setTableData - Table drawing interface function % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (AbortSet) %LABELEDGEAXES Property is of type 'bool' LabelEdgeAxes end properties (AbortSet, SetObservable) %HITTEST Property is of type 'on/off' HitTest = 'off'; end properties (Access=protected, AbortSet) %HAXES Property is of type 'MATLAB array' hAxes = []; %HLHSLINE Property is of type 'MATLAB array' hLHSLine = []; %HRHSLINE Property is of type 'MATLAB array' hRHSLine = []; %HCONREGIONPATCH Property is of type 'MATLAB array' hConRegionPatch = []; %HVALUELINE Property is of type 'MATLAB array' hValueLine = []; end methods % constructor block function obj = ConGraphViewCell(varargin) %ConGraphViewCell Constructor for ConGraphViewCell objects % OBJ = ConGraphViewCell(PROP, VAL, ...) % Call the inherited constructor obj@mbcgui.widget.BasicContainer(varargin{ : }); % converted super class constructor call obj.ContentHandle = mbcgui.widget.AxesContainer(... 'Parent', obj.Parent, ... 'Visible', obj.Visible, ... 'Border', [15 10 15 10]); obj.hAxes = obj.ContentHandle.AxesHandle; set(obj.hAxes, ... 'HitTest', obj.HitTest, ... 'Layer', 'top', ... 'XTickLabel', '', ... 'YTickLabel', '', ... 'Box', 'on', ... 'XGrid', 'on', ... 'YGrid', 'on'); obj.hConRegionPatch = patch('Parent', obj.hAxes, ... 'XData', [], ... 'YData', [], ... 'FaceColor', mbcbdrycolor, ... 'EdgeColor', 'k', ... 'LineStyle', '-', ... 'HitTest', 'off'); xregGui.setLegendData(obj.hConRegionPatch, 'Infeasible region'); obj.hRHSLine = line('Parent', obj.hAxes, ... 'Color', [1 0 0], ... 'XData', [], ... 'YData', [], ... 'HitTest', 'off'); xregGui.setLegendData(obj.hRHSLine, 'Right-hand side value'); obj.hLHSLine = line('Parent', obj.hAxes, ... 'Color', [0 0 1], ... 'XData', [], ... 'YData', [], ... 'HitTest', 'off'); xregGui.setLegendData(obj.hLHSLine, 'Left-hand side value'); obj.hValueLine = line('Parent', obj.hAxes, ... 'HitTest', 'off', ... 'Color', [1 0.5 0], ... 'LineWidth', 3, ... 'XData', [0 0], ... 'YData', [0 1]); xregGui.setLegendData(obj.hValueLine, 'Solution value'); obj.addPropertyListeners('HitTest', @iSetHittest); end % ConGraphViewCell end % constructor block methods % public methods %---------------------------------------- function setTableData(obj, R, C, dataobj) %SETTABLEDATA Table drawing interface function % SETTABLEDATA(OBJ, ROW, COL, DATA) where DATA should be a structure % containing the fields lhsdata, rhsdata, ydata, xlim, ylim, value, % comparisontype and showdata. data = dataobj.getCellData(R, C); if data.showdata set(obj.hAxes, ... 'XLim', data.xlim, ... 'YLim', data.ylim, ... 'XGrid', 'on', ... 'YGrid', 'on', ... 'Color', 'w'); set(obj.hValueLine, 'XData', [data.value, data.value] , 'YData', data.ylim); set(obj.hLHSLine, 'XData', data.xdata, 'YData', data.lhsdata); set(obj.hRHSLine, 'XData', data.xdata, 'YData', data.rhsdata); if strcmp(data.comparisontype, '<=') set(obj.hConRegionPatch, 'XData', [data.xdata, data.xdata([end 1])], ... 'YData', [data.rhsdata+dataobj.FeasibilityTol data.ylim(2) data.ylim(2)]); elseif strcmp(data.comparisontype, '>=') set(obj.hConRegionPatch, 'XData', [data.xdata, data.xdata([end 1])], ... 'YData', [data.rhsdata-dataobj.FeasibilityTol data.ylim(1) data.ylim(1)]); else % Equality constraint: leave a small gap EqTol = 0.01*diff(data.ylim); set(obj.hConRegionPatch, 'XData', [data.xdata, data.xdata([end 1]) data.xdata, data.xdata([end 1])], ... 'YData', [data.rhsdata+EqTol data.ylim(2) data.ylim(2) data.rhsdata-EqTol data.ylim(1) data.ylim(1)]); end else sc = xregGui.SystemColorsDbl; set(obj.hAxes, ... 'XLim', data.xlim, ... 'YLim', data.ylim, ... 'XGrid', 'off', ... 'YGrid', 'off', ... 'Color', sc.CTRL_BG); set(obj.hValueLine, 'XData', [], 'YData', []); set(obj.hLHSLine, 'XData', [] , 'YData', []); set(obj.hRHSLine, 'XData', [] , 'YData', []); set(obj.hConRegionPatch, 'XData', [] , 'YData', []); end if obj.LabelEdgeAxes % Use extra data to add tick labels and axes labels if this set of axes % is at an edge of the table. This functionality is used for printing % the graphs if ~isempty(data.ylabel) set(obj.hAxes, 'YTickLabelMode', 'auto'); mbcylabel(obj.hAxes, data.ylabel, 'Interpreter', 'none'); else set(obj.hAxes, 'YTickLabel', {}); mbcylabel(obj.hAxes, ''); end if data.confeas set(get(obj.hAxes, 'YLabel'), 'BackgroundColor', 'none'); else set(get(obj.hAxes, 'YLabel'), 'BackgroundColor', mbcbdrycolor); end if ~isempty(data.xlabel) set(obj.hAxes, 'XTickLabelMode', 'auto'); mbcxlabel(obj.hAxes, data.xlabel, 'Interpreter', 'none'); else set(obj.hAxes, 'XTickLabel', {}); mbcxlabel(obj.hAxes, ''); end end end % setTableData end % public methods end % classdef function iSetHittest(~, evt) h = evt.AffectedObject; set(h, 'HitTest', h.HitTest); end % iSetHittest