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

    function varargout = xregDefineTests(action,varargin)
%XREGDEFINETESTS Test Groupings GUI.
%
%  XREGDEFINETESTS creates and controls the Test Groupings GUI in the Data
%  Editor.

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



switch lower(action)
case 'create'
	[varargout{1:3}] = i_createFigure(varargin{:});
case 'variableclicked'
	i_variableClicked;
case 'celledited'
	i_cellEdited;
end


%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function [OK, ss, groupDefn] = i_createFigure(pf, ss, groupDefn,EnableOneStage)
fh = mvf('DefineTests');
if ~isempty(fh)
	delete(fh);
end

if nargin < 3
	groupDefn = {};
end
if nargin < 4
	EnableOneStage = true;
end

dlg = mbcgui.container.Dialog('Name', 'Define Test Groupings',...
    'Size', [700 600], ...
    'Owner', pf, ...
    'Buttons', 'OK_CANCEL_HELP', ...
    'CloseAction', 'CANCEL', ...
    'HelpCode', 'xreg_defineTestGroups', ...
    'Tag', 'DefineTests');
f = dlg.Figure;

[mainLayout, ud] = i_createLayout(f, ss,EnableOneStage);
set(f, 'UserData', ud);
dlg.Content = mainLayout;

i_setInputArgs(groupDefn, ud);

closeMode = dlg.showDialog();

OK = 0;
switch closeMode
case 'OK'
	[ss, groupDefn] = i_defineSweepset;
	OK = 1;
end
delete(dlg);

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function [layout, ud] = i_createLayout(fh, ss,EnableOneStage)

topPanel = mbcgui.container.layoutpanel(...
    'Parent', fh, ...
    'BorderType', 'beveledin', ...
    'LayoutBorder', [10 10 10 10]);

varList = uicontrol('Style','list',...
	'Parent',topPanel,...
	'BackgroundColor',[1 1 1],...
	'String', get(ss, 'Name'),...
	'Callback',@i_listClicked);

varText = axestext(topPanel,...
	'string', 'Variables:',...
	'verticalalignment', 'bottom');

popText = axestext(topPanel,...
	'string', 'Test number variable:',...
	'verticalalignment', 'bottom');
	
popAlias = uicontrol('Style', 'popup',...
	'Parent', topPanel,...
	'BackgroundColor', [1 1 1],...
	'String', [{'none'} ;get(ss, 'Name')],...
	'Callback', @i_popupClicked);

reorderCheck = uicontrol('Style','check',...
	'Parent',topPanel,...
	'Callback', @i_reorderClicked,...
    'Tag','SortData',...
	'String', 'Sort records before grouping');

origGroupCheck = uicontrol('Style','check',...
	'Parent',topPanel,...
	'Callback', @i_origGroupClicked,...
    'Tag','OriginalGroups',...
    'Enable',mbconoff(EnableOneStage),...
	'String', 'Show original test groups');

onePerRecordCheck = uicontrol('Style','check',...
	'Parent',topPanel,...
	'Callback', @i_onePerRecordClicked,...
    'Tag','OneStageData',...
    'Enable',mbconoff(EnableOneStage),...
	'String', 'One-stage data');

rightTopGrid = xreggridbaglayout(topPanel,...
    'packstatus', 'off', ...
	'dimension', [9 1],...
	'elements', {varText varList [] onePerRecordCheck reorderCheck origGroupCheck [] popText popAlias},...
	'gapy', 2,...
	'rowsizes', [10 -1 5 20 20 20 5 10 20]);

btAdd = xregGui.iconuicontrol('parent', topPanel,...
	'TooltipString', 'Add Variable',...
	'TransparentColor', [0 255 0],...
	'ImageFile', xregrespath('addObject.bmp'),...
	'callback', @i_addVariableClicked);
if isempty(get(varList, 'String'))
    set(btAdd, 'Enable', 'off');
end

btRemove = xregGui.iconuicontrol('parent', topPanel,...
	'TooltipString', 'Remove Variable',...
	'TransparentColor', [0 255 0],...
	'ImageFile', xregrespath('removeObject.bmp'),...
	'enable', 'off',...
	'callback', @i_deleteVariable);

btUp = xregGui.iconuicontrol('parent', topPanel,...
	'TooltipString', 'Move Variable Up',...
	'TransparentColor', [0 255 0],...
	'ImageFile', xregrespath('moveUp.bmp'),...
	'enable', 'off',...
	'callback', {@i_move, -1});

btDown = xregGui.iconuicontrol('parent', topPanel,...
	'TooltipString', 'Move Variable Down',...
	'TransparentColor', [0 255 0],...
	'ImageFile', xregrespath('moveDown.bmp'),...
	'enable', 'off',...	
	'callback', {@i_move, +1});

midTopGrid = xreggridbaglayout(topPanel,...
	'dimension', [5 1],...
	'elements', {[] btUp btDown btAdd btRemove},...
	'gapy', 5,...
	'rowsizes', [50 20 20 20 20]);

varTable = xregtable(topPanel,...
	'rows.number', 1,...
	'cols.number', 5,...
	'rows.size', 20,...
	'rows.spacing', 0,...
	'rows.fixed', 1,...
	'cols.size', 70,...
	'cols.spacing', 0,...
	'frame.box', 'on',...
	'frame.Hborder', [1 0],...
	'frame.Vborder', [1 0],...	
	'frame.backgroundcolor', [1 1 1],...
	'zeroindex', [2 1],...
	'defaultcelltype', 'uiedit');

set(varTable, 'cells.rowselection', [1 1],...
	'cells.string', {'Variable' 'Min' 'Max' 'Tolerance' 'Group By'},...
	'cells.type', 'uipushbutton');

topGrid = xreggridbaglayout(topPanel,...
	'dimension', [1 3],...
	'elements', {varTable midTopGrid rightTopGrid},...
	'gapx', 10,...
	'colsizes', [351 20 200]);

set(topPanel, 'LayoutComponent', {topGrid});

% Create uicontext menu for plotAxes
m = uicontextmenu('Parent', fh);

XDataPerPixel = max(1, size(ss,1))/500;
plotAxes = xregGui.scrollaxes(...
    'Parent', fh,...
    'Position', [10 10 600 250], ...
	'UIContextMenu', m,...	
	'ZoomMode', 'x',...
	'XdataPerPixel', XDataPerPixel, ...
    'BorderType', 'beveledin', ...
    'InnerBorder', [30 40 20 30]);
Leg = plotAxes.construct(@createLegend);

ud.pLegend = xregGui.RunTimePointer(Leg);
ud.menu.showLegend = uimenu(m, 'Label', 'Show Legend', 'Callback', @i_swapShowLegend);
ud.menu.printFigure = uimenu(m,'Label', 'Print to Figure', 'Callback', @i_copyPlot);

layout = xregsplitlayout(fh,...
	'orientation', 'ud',...
	'dividerwidth', 4,...
	'dividerstyle', 'flat',...
	'top', topPanel,...
	'bottom', plotAxes,...
	'minwidth', [200 140]);

% Create a listener for changes to the position of plotAxes and set the YLim appropriately
schema.prop(plotAxes, 'positionListener', 'handle');
plotAxes.positionListener = handle.listener(plotAxes, plotAxes.findprop('position'), 'PropertyPostSet', @i_plotAxesPositionChanged);

ud.plotAxes = plotAxes;
ud.varTable = varTable;
ud.varList = varList;
ud.popAlias = popAlias;
ud.reorderCheck = reorderCheck;
ud.origGroupCheck = origGroupCheck;
ud.onePerRecordCheck = onePerRecordCheck;
ud.ss = ss;
ud.newss = ss;
ud.btUp = btUp;
ud.btDown = btDown;
ud.btRemove = btRemove;
ud.btAdd = btAdd;
ud.RowsDisabled = [];

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_setInputArgs(args, ud)
if ~isempty(args)
	vars = args{1};
	tols = args{2};
	for i = 1:length(vars)
		varName = vars{i};
		if strcmp(varName, '#rec')
			set(ud.onePerRecordCheck, 'Value', 1);
			i_addVariable(ud.varTable, 'RECORD NO', 1, size(ud.ss, 1), 1);
		elseif ~isempty(find(ud.ss, varName)) 
			% Get the Min and Max values of the variable being added
            ssVarList = ud.ss(:, varName);
            v = get(SetMinMax(ssVarList), {'Min' 'Max'});
            min = v{1}{1};
            max = v{2}{1};
			i_addVariable(ud.varTable, varName, min, max, tols(i));
		end
	end
    % LEGACY CHECK - is reorder a character string which indicates it's
    % been specifically set in ssf/loadobj. Need to change this to a
    % boolean
    if ischar(args{3})
        args{3} = true;
    end
	set(ud.reorderCheck, 'Value', args{3});
	% Check args{4} exists
	if length(args) > 3 && ischar(args{4})
		ind = find(ud.ss, args{4});
      if isempty(ind)
         ind = 0;
      end
		set(ud.popAlias, 'Value', ind + 1);
	end
	i_defineSweepset;
	i_update;
end

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_update
[ud, f] = i_getThisHandle;
set(f,'Pointer','watch');
try %#ok<TRYNC>
	i_updateButtons(ud);
	i_updatePlot(ud);
end
set(f,'Pointer','arrow');


%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_updateButtons(ud)
% Find the selected table row from the toggle button values
btValue = ud.varTable(:,1).value;
selected = find(btValue);
DELETE_ENABLED = 'off';
ADD_ENABLED = 'on';
MOVE_UP_ENABLED = 'off';
MOVE_DOWN_ENABLED = 'off';
if ~isempty(selected)
	DELETE_ENABLED = 'on';
	if selected < length(btValue)
		MOVE_DOWN_ENABLED = 'on';
	end
	if selected > 1
		MOVE_UP_ENABLED = 'on';
	end
end
if isempty(get(ud.varList, 'String'))
    ADD_ENABLED = 'off';
end
set(ud.btUp, 'Enable', MOVE_UP_ENABLED);
set(ud.btDown, 'Enable', MOVE_DOWN_ENABLED);
set(ud.btRemove, 'Enable', DELETE_ENABLED);
set(ud.btAdd, 'Enable', ADD_ENABLED);

	
%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_updatePlot(ud, mode)

% mode allows callers to switch between normal and "standalone" (for plot
% copying) modes.  Normal mode assumes that the axes are scrollaxes.
if nargin<4
    mode = 'normal';
end

% Which variables have been selected
vars = ud.varTable(:,1).string;
% Lets not try and display 'RECORD NO' if it exists
validVars = find(~(ismember(vars, 'RECORD NO') & get(ud.onePerRecordCheck, 'Value')));
vars = vars(validVars);
if isempty(vars)
	% Ensure that empty vars is numeric otherwise sweepset/find fails
	vars = [];
end
% Which sweepset to display
ud.plotAxes.clear;

% Destroy legend manually to avoid a redraw bug
oldLegend = ud.pLegend.info;
if ~isempty(oldLegend) && ishandle(oldLegend)
    delete(oldLegend);
end

if strcmpi(mode, 'normal')
    [h, hLegend] = ud.plotAxes.construct(@(hAxes) plot(ud.newss(:,vars),'*','CODE','SWEEPLINES', ...
        'm-','FORCESWEEPLINES', 'Parent', hAxes, 'MarkerSize', 2));
    ud.pLegend.info = hLegend;
else
    h = ud.plotAxes.construct(@(hAxes) plot(ud.newss(:,vars),'*','CODE','SWEEPLINES', ...
        'm-','FORCESWEEPLINES', 'Parent', hAxes, ...
        'LEGEND', 'off', 'MarkerSize', 2));
    hLegend = [];
end

if get(ud.origGroupCheck, 'Value') && strcmp(get(ud.origGroupCheck, 'Enable'), 'on')
    h = ud.plotAxes.construct(@(hAxes) iPlotOrigGroup(ud, hAxes, hLegend)); 
end

% set all lines' HitTest to off so axes catches all mousebutton presses for zooming.
ud.plotAxes.construct(@(hAxes) set(findobj(hAxes, 'Type', 'line'), 'HitTest', 'off'));

% Ensure the axes text is drawn in black
ud.plotAxes.construct(@(hAxes) set(hAxes, 'XColor', [0 0 0], 'YColor', [0 0 0]));
ud.plotAxes.construct(@(hAxes) title(hAxes, [num2str(size(ud.newss, 3)) ' tests defined']));
ud.plotAxes.construct(@(hAxes) xlabel(hAxes, 'Record Number'));

if strcmpi(mode, 'normal')
    % Make sure zoommode is still set
    set(ud.plotAxes, 'ZoomMode', 'off');
    set(ud.plotAxes, 'ZoomMode', 'x');
    % Force a redraw by ensuring that YLim and XLim change
    pos = ud.plotAxes.position;
    numRec = size(ud.newss, 1);
    set(ud.plotAxes, 'YLim', [0 2], 'XLim', [0 numRec]);
    set(ud.plotAxes, 'YLim', [0 1], 'XLim', [1 numRec], 'Ydataperpixel', 1.15/pos(4));

    if strcmp(get(ud.menu.showLegend, 'Checked'), 'on')
        legend(h(1).Parent,'show')
    elseif ~isempty(hLegend);
        hLegend.Visible = 'off';
    end

    % Set table colors according to plot
    for i = 1:length(h)
        ud.varTable(validVars(i),4).color = get(h(i), 'Color');
    end
end


function h = iPlotOrigGroup(ud, hAxes, hLegend)
% Find current set of sweep delimiter lines
old_sl = findobj(hAxes, 'Tag', 'TestDelimiters');
NextPlotMode = hAxes.NextPlot;
hAxes.NextPlot = 'add';
% plot no data
h = plot(ud.ss(:,[]), 'CODE', 'SWEEPLINES', 'b-.', 'FORCESWEEPLINES', ...
    'Parent', hAxes, 'LEGEND', 'off');
hAxes.NextPlot = NextPlotMode;
% Add the original sweep lines to the legend
all_sl = findobj(hAxes, 'Tag', 'TestDelimiters');
new_sl = setdiff(all_sl, old_sl);
set(new_sl,'DisplayName', 'Original Test');


%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_plotAxesPositionChanged(~, evt)
plotAxes = evt.AffectedObject;
pos = plotAxes.position;
set(plotAxes, 'YLim', [0 1], 'Ydataperpixel', 1.15/pos(4));


%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_variableClicked
ud = i_getThisHandle;
% Which toggle button was clicked?
gcboUD = get(gcbo, 'UserData');
% Get its position in the scrollable table
[r, ~] = scrollindex(ud.varTable, gcboUD.row, gcboUD.col);
sel = (ud.varTable(:, 1)~=0);
selectedRow = r(sel(r));
% Don't select this one
sel(r) = 0;
% Ensure all other buttons are up
ud.varTable(sel,1).value = 0;
i_updateButtons(ud);
i_setSelectedHighlight(ud.varTable, selectedRow);

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_listClicked(~, ~)
[~, f] = i_getThisHandle;
if strcmp(get(f, 'SelectionType'), 'open')
	i_addVariableClicked;
end

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_popupClicked(~, ~)
i_defineSweepset;
i_update;

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_cellEdited
i_defineSweepset;
i_update;

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_reorderClicked(src, ~)
ud = i_getThisHandle;
if get(src, 'Value')
	set(ud.origGroupCheck, 'Enable', 'off');
else
	set(ud.origGroupCheck, 'Enable', 'on');
end	
i_defineSweepset;
i_update;

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_copyPlot(~, ~)
ud = i_getThisHandle;
% Plot into a new set of axes
newF = figure;
P = mbcgui.container.layoutpanel('Parent', newF, ...
    'Units', 'normalized', ...
    'Position', [0 0 1 1]);
h = printcopy(ud.plotAxes, P);
set(P, 'LayoutComponent', {h});



%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_swapShowLegend(src, ~)
ud = i_getThisHandle;
if strcmp(get(src, 'Checked'), 'on')
	state = 'off';
else
	state = 'on';
    set(ud.pLegend.info, 'Location', 'NorthWest');
end
set(src, 'Checked', state);
set(ud.pLegend.info, 'Visible', state);



%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_origGroupClicked(~, ~)
i_update;

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_onePerRecordClicked(src, ~)
ud = i_getThisHandle;
% Are we adding one record per sweep or removing
if get(src, 'Value')
	i_addVariable(ud.varTable, 'RECORD NO', 1, size(ud.ss, 1), 1);
	i_defineSweepset;
	i_update;
else
	% Select the row called '#rec' and delete it
	vars = ud.varTable(:,1).string;
	[~, indices] = intersect(vars, {'RECORD NO'});
	newValue = zeros(length(ud.varTable(:,1).value), 1);
	newValue(indices) = 1;
	ud.varTable(:,1).value = newValue;
	i_deleteVariable;
end

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_addVariableClicked(~, ~)
ud = i_getThisHandle;

% Get the name of the variable being added
varAdded = get(ud.varList, 'String');
varAdded = varAdded{get(ud.varList, 'Value')};
% If it's already in the list then ignore
if any(strcmp(varAdded, ud.varTable(:,1).string))
	return
end
% Get the Min and Max values of the variable being added
ssVarList = ud.ss(:, varAdded);

v = get(SetMinMax(ssVarList), {'Min' 'Max'});
min = v{1}{1};
max = v{2}{1};

if ud.onePerRecordCheck.Value
    % remove one test per record
    ud.onePerRecordCheck.Value = 0;
    i_onePerRecordClicked(ud.onePerRecordCheck ,[])
end
ssData =double(ssVarList);
if all(ssData==fix(ssData)) && length(unique(ssData))==length(ssData)
    % use a tolerance to split by integers
    tol = 0.5;
else
    tol = (max - min)/100;
end
i_addVariable(ud.varTable, varAdded, min, max, tol);
i_defineSweepset;
i_update;

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_addVariable(table, varName, min, max, tol)
% Get the new row to add a new row to the table
nextRow = size(table, 1) + 1;
set(table, 'rows.number', nextRow);

if strcmp(varName, 'RECORD NO')
    % Disable tolerance and group check for RECORD NO variable.
    EditEn = 'off';
    [ud, f] = i_getThisHandle;
    ud.RowsDisabled = [ud.RowsDisabled, nextRow-1];
    set(f, 'UserData', ud);
else
    EditEn = 'on';
end

% Add the toggle button as the first cell in the table
set(table, 'cells.rowselection',  [nextRow nextRow],...
	'cells.colselection', [1 1],...
	'cells.string', varName,...
	'cells.value',0,...
	'cells.type', 'uitogglebutton',...
	'cells.tooltipstring', 'Click to Select Row',...
	'cells.callback', [mfilename '(''variableClicked'')']);
% Add Min, Max and Tolerance values
set(table, 'cells.rowselection',  [nextRow nextRow],...
	'cells.colselection', [2 4],...
	'cells.value', [min max tol],...
	'cells.enable', 'off',...
 	'cells.backgroundcolor', [1 1 1],...
	'cells.callback', [mfilename '(''cellEdited'')'], ...
    'cells.colselection', [4 4],...
    'cells.enable', EditEn);
% Add display only check box
set(table, 'cells.rowselection',  [nextRow nextRow],...
	'cells.colselection', [5 5],...
	'cells.value',1,...
    'cells.enable', EditEn,...
 	'cells.backgroundcolor', [1 1 1],...
	'cells.type', 'uicheckbox',...
	'cells.callback', [mfilename '(''cellEdited'')']);


%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_deleteVariable(~, ~)
[ud, f] = i_getThisHandle;
% Find the selected table row from the toggle button values
selected = find(ud.varTable(:,1).value);
% If selected is the special 'RECORD NO' button then turn off the one test check box
if strcmp(ud.varTable(selected,1).string, 'RECORD NO')
	set(ud.onePerRecordCheck, 'Value', 0)
end
% How many variable rows are there
numRows = length(ud.varTable(:,1).value);
% generate a new row order such that the row to be deleted is at the end
newOrder = [1:selected-1 selected + 1:numRows selected];
i_reorder(ud.varTable, newOrder);

% Resize the table
ud.varTable(end,:).delete;
set(ud.varTable, 'rows.number', size(ud.varTable, 1)-1);

% Remove this row from disabled list if required.
ud = get(f, 'UserData');
ud.RowsDisabled = setdiff(ud.RowsDisabled, numRows);
set(f, 'UserData', ud);

i_defineSweepset;
i_update;
i_setSelectedHighlight(ud.varTable, [])

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_move(~, ~, dirn)
ud = i_getThisHandle;
% Find the selected table row from the toggle button values
sel = find(ud.varTable(:,1).value);
newSel = sel + dirn;
% How many variable rows are there
numRows = length(ud.varTable(:,1).value);
% If none are selected or we try to move beyond the edge then return
if isempty(sel) || newSel < 1 || newSel > numRows
	return
end
% Get the smaller and larger of i and i + dirn
low = min([sel newSel]);
high = max([sel newSel]);
% Reorder the arrays
newOrder = [1:low-1 high low high+1:numRows];
i_reorder(ud.varTable, newOrder);
i_defineSweepset;
i_update;
i_setSelectedHighlight(ud.varTable, newSel)

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_reorder(table, newRowOrder)
% Internal function to reorder the rows in the table
oldStr = table.string;
oldVal = table.value;
table.string = oldStr(newRowOrder,:);
table.value = oldVal(newRowOrder,:);

% Redo the table's enabled and disabled rows
[ud, f] = i_getThisHandle;
[~, ud.RowsDisabled] = ismember( ud.RowsDisabled, newRowOrder );
set(f, 'UserData', ud);
table(:, 4:5).enable = 'on';
table(ud.RowsDisabled,4:5).enable = 'off';

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_setSelectedHighlight(table, selectedRows)
% How many variable rows are there
numRows = length(table(:,1).value);
unselectedRows = setxor(1:numRows, selectedRows);
table(unselectedRows,2:end).backgroundcolor = [1 1 1];
table(selectedRows,2:end).backgroundcolor = [0.8 0.8 1];

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function [ss, args] = i_defineSweepset
[ud, f] = i_getThisHandle;
% Get variable names to define sweepset on
vars = ud.varTable(:,1).string;
% Ensure that vars is a cell array
if ~iscell(vars)
	vars = {vars};
end
% Do we have a variable called 'RECORD NO' in vars
if get(ud.onePerRecordCheck, 'Value')
	vars(ismember(vars, {'RECORD NO'})) = {'#rec'};
end
% Get the tolerance on the variables
tol = ud.varTable(:, 4).value;
% Which variables are we grouping by
groupBy = (ud.varTable(:,5)~=0);
tol = tol(groupBy);
vars = vars(groupBy);
% Is record reordering allowed
reorder = get(ud.reorderCheck, 'Value');
% Define test alias
testAlias = get(ud.popAlias, 'Value');
testAliasStr = get(ud.popAlias, 'String');
if testAlias > 1
	testAlias = testAliasStr{testAlias};
else
	testAlias = 0;
end
% Define the function arguments for the output
args = {vars tol reorder testAlias};
% Redefine the sweepset
ss = DefineSweepSet(ud.ss, args{:});
ud.newss = ss;
% Update the userdata
set(f, 'UserData', ud);

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function [ud, f] = i_getThisHandle
f=mvf('DefineTests');
ud=get(f,'UserData');

function leg = createLegend(hAxes)

leg = legend(hAxes);
set(leg,'Visible', 'off', ...
    'Interpreter', 'none')