www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optimoutput/ObjGraphViewCell.m

    classdef ObjGraphViewCell < mbcgui.widget.BasicContainer
    %cageview.optimoutput.ObjGraphViewCell class
    %   cageview.optimoutput.ObjGraphViewCell extends mbcgui.widget.BasicContainer.
    %
    %    cageview.optimoutput.ObjGraphViewCell 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.ObjGraphViewCell methods:
    %       setTableData - Table drawing interface function
    
    %  Copyright 2005-2015 The MathWorks, 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 = [];
        %HFUNCTIONLINE Property is of type 'MATLAB array'
        hFunctionLine = [];
        %HVALUELINE Property is of type 'MATLAB array'
        hValueLine = [];
        %HCONSTRAINTMARKER Property is of type 'handle'
        hConstraintMarker = [];
    end
    
    
    methods  % constructor block
        function obj = ObjGraphViewCell(varargin)
        %ObjGraphViewCell Constructor for ObjGraphViewCell objects
        %  OBJ = ObjGraphViewCell(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', ...
            'Units', 'pixels', ...
            'XTickLabel', '', ...
            'YTickLabel', '', ...
            'Box', 'on', ...
            'XGrid', 'on', ...
            'YGrid', 'on', ...
            'Tag', 'ObjectiveGraphOutputAxes');
        
        obj.hConstraintMarker = mbcgui.widget.IntervalPatch1D('Parent', obj.hAxes, ...
            'FaceColor', mbcbdrycolor);
        xregGui.setLegendData(obj.hConstraintMarker, 'Infeasible region');
        obj.hFunctionLine = line('Parent', obj.hAxes, ...
            'Color', [0 0 1], ...
            'XData', [], ...
            'YData', []);
        xregGui.setLegendData(obj.hFunctionLine, 'Objective 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, obj.hAxes});
        end  % ObjGraphViewCell
        
        
        
        
    end  % constructor block
    
    methods
    end   % set and get functions
    
    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 xdata, ydata, xlim, ylim, value, constraintedges
        %  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.hFunctionLine, 'XData', data.xdata, 'YData', data.ydata);
            set(obj.hValueLine, 'XData', [data.value, data.value] , 'YData', data.ylim);
            set(obj.hConstraintMarker, 'OpenIntervals', data.constraintedges);
        else
            sc = xregGui.SystemColorsDbl;
            set(obj.hAxes, ...
                'XLim', data.xlim, ...
                'YLim', data.ylim, ...
                'XGrid', 'off', ...
                'YGrid', 'off', ...
                'Color', sc.CTRL_BG);
            set(obj.hFunctionLine, 'XData', [], 'YData', []);
            set(obj.hValueLine, 'XData', [] , 'YData', []);
            set(obj.hConstraintMarker, 'OpenIntervals', NaN);
        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 ~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)
set(h, 'HitTest', evt.AffectedObject.HitTest);
end  % iSetHittest