www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/+xregdatagui/DataPlot3DView.m

    classdef DataPlot3DView < xregdatagui.AbstractGraphView
    %xregdatagui.DataPlot3DView class
    %   xregdatagui.DataPlot3DView extends xregdatagui.AbstractGraphView.
    %
    %    xregdatagui.DataPlot3DView 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'
    %       Display - Property is of type 'MATLAB array' (read only)
    %       MessageService - Property is of type 'handle' (read only)
    %       UIContextMenu - Property is of type 'MATLAB array'
    %       Listeners - Property is of type 'handle vector' (read only)
    %
    %    xregdatagui.DataPlot3DView methods:
    %       gettitle - A short description of the function
    %       pCreateDisplay - DOCREATEDISPLAY Create all uicontrols and visual components for this view
    
    %  Copyright 2015 The MathWorks, Inc. and Ford Global Technologies, Inc.
    
    properties (Constant)
        %ViewInfo view description
        ViewInfo = { @xregdatagui.DataPlot3DView;
            '&3D Plot';
            xregrespath('3dscatter.bmp');
            '3D Plot';
            1};
    end
    
    properties
        %XFactor selected X Factor
        XFactor = '';
        %YFactor selected Y Factor
        YFactor = '';
        %ZFactor selected Z Factor
        ZFactor = '';
    end
    
    methods  % constructor block
        function obj = DataPlot3DView(varargin)
        %DataPlot3DView constructor
        %   OUT = DataPlot3DView(IN)
        
        % Do the setup stuff from inside the abstractGraphView constructor
        obj@xregdatagui.AbstractGraphView(varargin{ : }); % converted super class constructor call
        
        
        end  % dataplot3dview
        
    end  % constructor block
    
    methods  % public methods
        %----------------------------------------
        function [out] = gettitle(in) %#ok<MANU>
        %GETTITLE view title
        %    OUT = GETTITLE(IN)
        
        out = '3D Data Plot';
        end  % gettitle
        
        
        function [out] = serializeView(obj)
        %SERIALIZEVIEW save settings for multiple data plots
        %    OUT = SERIALIZEVIEW(IN)
        
        if obj.MessageService.hasData
            out.SelectAllTests = obj.SelectAllTests;
            f = get(obj.GraphObject,'factors');
            out.XFactor = f{get(obj.GraphObject,'currentxfactor')};
            out.YFactor = f{get(obj.GraphObject,'currentyfactor')};
            out.ZFactor = f{get(obj.GraphObject,'currentzfactor')};
        else
            out = [];
        end
        
        end  % serializeView
        
        function deserializeView(obj,s)
        %deserializeView appled saved settings for 3D data plot
        
        if ~isempty(s)
            % set Action state for SelectAllTests
            obj.SelectAllTests = s.SelectAllTests;
            obj.XFactor = s.XFactor;
            obj.YFactor = s.YFactor;
            obj.ZFactor = s.ZFactor;
            obj.Options.Actions(2).Selected = obj.SelectAllTests;
            obj.pUpdateDisplay
        end
        
        end
        
        %----------------------------------------
        function G = pCreateDisplay(obj, ~)
        %DOCREATEDISPLAY Create all uicontrols and visual components for this view
        %
        %  DOCREATEDISPLAY(OBJ)
        %
        
        G = mvgraph3d(obj.Parent, ...
            'frame', 'off', ...
            'Type', 'scatter',...
            'enable', obj.Enable,...
            'Callback',@obj.onChangeFactor);
        obj.ContentHandle = G;
        end  % pCreateDisplay
        
        function pssDataChangedUpdate(obj, ~,~)
        %PSSDATACHANGEDUPDATE updates the view on receipt of a "ssDataChanged"
        
        % default graph view update
        pssDataChangedUpdate@xregdatagui.AbstractGraphView(obj)
        % select factors
        f = get(obj.GraphObject,'factors');
        args = {};
        [OK,pos]= ismember(obj.XFactor,f);
        if ~isempty(obj.XFactor) && OK;
            args = [args {'currentxfactor',pos}];
        end
        [OK,pos]= ismember(obj.YFactor,f);
        if ~isempty(obj.YFactor) && OK;
            args = [args {'currentyfactor',pos}];
        end
        [OK,pos]= ismember(obj.ZFactor,f);
        if ~isempty(obj.ZFactor) && OK;
            args = [args {'currentzfactor',pos}];
        end
        if ~isempty(args)
            set(obj.GraphObject,args{:});
        end
        
        end
        
        
        function onChangeFactor(obj,~,~)
        %onChangeFactor change X or Y factor
        %  may need to redraw test numbers
        
        g = obj.GraphObject;
        f = get(g,'factors');
        obj.XFactor = f{get(g,'currentxfactor')};
        obj.YFactor = f{get(g,'currentyfactor')};
        obj.ZFactor = f{get(g,'currentzfactor')};
        
        end
        
    end  % public methods
    
end  % classdef