www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregmultigraph2d/xregmultigraph2d.m

    function gr=xregmultigraph2d(varargin)
%XREGMULTIGRAPH2D Constructor for multi graph object
%
%   GR = XREGMULTIGRAPH2D constructs an xregmultigraph2d object.
%
%   GR = XREGMULTIGRAPH2D(FIG) constructs an xregmultigraph2d object in the
%   specified figure.
%
%   GR = XREGMULTIGRAPH2D('Property1', Value1,...) constructs the graph
%   with the specified properties.
%
%   GR = XREGMULTIGRAPH2D(FIG, 'Property1', Value1,...) constructs the
%   graph with the specified properties in the specified figure
%
%   See also MVGRAPH2D

%  Copyright 2000-2014 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin>0 && mbcgui.util.isComponentParent(varargin{1})
   figh=varargin{1};
   varargin(1) = [];
else
   figh=gcf;
end

% DATA STORAGE.  The different bits of data are stored as follows:
%
% general stuff vector in the axes
% copy of object in the patch
% tdata in xfactor
% xdata in xtext
% cdata in yfactor
% ydata in ytext
% visible in badim

% initial position
pos=[30 30 500 360];

gr.panel = uipanel('Parent', figh, ...
    'Units', 'pixels', ...
    'Position', pos, ...
    'Visible', 'off', ...
    'BorderType', 'line', ...
    'HighlightColor', 'k', ...
    'BackgroundColor', 'w', ...
    'HitTest', 'off');

cp=floor(pos(3:4).*0.5)-15;
gr.badim=mbcgui.widget.Image('Parent',gr.panel,...
    'ImageFile',pr_badim,...
    'Position',[cp 32 32],...
    'Visible','off');

ud = struct;
ud.userdata = [];
ud.type = 'single';
ud.tableptr = xregpointer;
ud.tableindex = [];
ud.pos = pos;
ud.axeschildren = [];
ud.oldy = 1;
ud.oldx = 1;
ud.limits = {};
ud.ylimits = {};
ud.xfactors = {};
ud.yfactors = {};
ud.checkedyfactors = [];
ud.grid = 1;
ud.exclusive = 1;
ud.transcolor = 'none';
ud.yunitstring = '';
ud.title = '';
ud.yseltype = 0;
ud.colorbar = 0;
ud.colorfactor = [];
ud.colorbarvalid = 0;
ud.colordatavalid = 0;
ud.excludestyle = 'blank';
ud.contextmenu = [];
ud.lines = [];
ud.patches = [];
ud.fillmask = [];
ud.marker = {};
ud.markercolor = [];
ud.checkedmcolor = [];
ud.checkedfillmask = 0;
ud.markersize = get(0,'DefaultLineMarkerSize');
ud.callback = [];
ud.singlecallback = [];
ud.multicallback = [];
ud.lastcalltype = 0;
ud.showframe = true;

gr.axes=axes('Parent',gr.panel,...
   'Units','pixels',...
   'Position',[50 80 pos(3)-80 pos(4)-105],...
   'Layer','top',...
   'Box','on',...
   'XLim',[0 1],...
   'YLim',[0 1],...
   'CLim',[0 1],...
   'UserData',ud,...
   'Color','w',...
   'ButtonDownFcn',@(h,evt) mv_zoom(h),...
   'FontSize',8);

gr.colorbar=xregcolorbar(gr.panel,...
   'callbackmode','external',...
   'frame','off',...
   'Visible','off');

gr.xfactor=uicontrol('Style','popupmenu',...
   'Parent',gr.panel,...
   'String',' ',...
   'BackgroundColor','w',...
   'Tag','1');
gr.xtext=uicontrol('Style','text',...
   'Parent',gr.panel,...
   'Position',[0 0 70 15],...
   'String','X-axis factor:',...
   'BackgroundColor','w',...
   'Enable','inactive');

gr.yfactor=uicontrol('Style','popupmenu',...
   'Parent',gr.panel,...
   'String',' ',...
   'BackgroundColor','w',...
   'Tag','2');
gr.ytext=uicontrol('Style','text',...
   'Parent',gr.panel,...
   'Position',[0 0 70 15],...
   'String','Y-axis factor:',...
   'BackgroundColor','w',...
   'Enable','inactive');

gr.controls=xreggridbaglayout(gr.panel, ...
    'packgroup','XX_XREGMULTIGRAPH2D', ...
    'dimension',[5,7],...
    'rowsizes',[-1 4 15 1 -1], ...
    'colsizes',[-1 70 -1 -1 70 -1 -1], ...
    'colratios',[1 1 3 2 1 3 1],...
    'mergeblock',{[2 4],[3 3]}, ...
    'mergeblock',{[2 4], [6 6]},...
    'elements',{[],[],[],[],[],[],[];...
    [],[],gr.xfactor,[],[],gr.yfactor,[];...
    [],gr.xtext,[],[],gr.ytext,[],[];...
    [],[],[],[],[],[],[];...
    [],[],[],[],[],[],[]},...
    'position',[1 1 pos(3) 50],...
    'packstatus','on');

gr=class(gr,'xregmultigraph2d');

set(gr.xfactor,'Callback',{@factor_change,gr,1});
set(gr.yfactor,'Callback',{@factor_change,gr,2});
set(gr.colorbar,'Callback',{@i_colorbarCB,gr});

% Make the label text bold
lbls=get(gr.axes,{'XLabel','YLabel'});
set([lbls{:}],'FontWeight','bold');

% set extra props if specified
if ~isempty(varargin)
    % Set properties that are passed in
    gr = set(gr,'visible','on','forcedraw', [1 1 1 1], varargin{:});
else
    set(gr.panel,'Visible','on');
    gr = set(gr,'forcedraw', [1 1 1 1]);
end


%-----------------
function i_colorbarCB(~,~,gr)
%-----------------
pr_plot(gr);