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

    function [OK, props] = plotPropertiesDlg(ss, parent, props)
%SWEEPPLOTPROPERTIESDLG property dialog for a sweepplot
%
%  [OK, PROPS] = PLOTPROPERTIESDLG(SS, PARENT, PROPS)
%

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

% Clear up any pre-existing figures
fh = mvf('sweepplotPlotPropertiesDlg');
if ~isempty(fh)
    delete(fh);
end

if nargin < 3
    props = [];
end

if nargin < 2
    parent = [];
end
if isgraphics(parent)
   parent = ancestor(parent,'figure');
end


dlg = mbcgui.container.Dialog('Name','2D Plot Properties',...
    'Tag','sweepplotPlotPropertiesDlg',...
    'Buttons','OK_CANCEL',...
    'Owner', parent,...
    'Size', [400 160],...
    'Resize', 'off');
fh = dlg.Figure;

[mainLayout, ud] = i_createLayout(fh, props);

dlg.Content = mainLayout;

ud.data.currentProps = props;

i_setCurrentProperties(ud);

OK = 0;
fh.UserData = ud;

closeAction = dlg.showDialog();

switch closeAction
    case 'OK'
        props = i_updateProperties;
        OK = 1;
end
delete(dlg);

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function [layout, ud] = i_createLayout(fh, ~, ~)
SC = xregGui.SystemColorsDbl;

[lineStyles, markStyles] = i_getLineAndMarkStyles;

lineEdit = uicontrol('Style', 'popupmenu',...
    'Parent', fh, ...
    'BackgroundColor', SC.WINDOW_BG,...
    'Tag','LineStyles',...
    'String', lineStyles);

markerEdit = uicontrol('Style', 'popupmenu',...
    'Parent', fh, ...
    'BackgroundColor', SC.WINDOW_BG,...
    'Value', 3,...
    'Tag','MarkerStyles',...
    'String', markStyles);

lineText = xregGui.labelcontrol('parent', fh, ...
    'String', 'Data linestyle:', ...
    'ControlSizeMode', 'relative', ...
    'ControlSize', 1, ...
    'LabelSizeMode', 'absolute', ...
    'LabelSize', 90, ...
    'Control', lineEdit);

markerText = xregGui.labelcontrol('parent', fh, ...
    'String', 'Data marker:', ...
    'ControlSizeMode', 'relative', ...
    'ControlSize', 1, ...
    'LabelSizeMode', 'absolute', ...
    'LabelSize', 90, ...
    'Control', markerEdit);

legendCheckbox = uicontrol('Style', 'checkbox',...
    'Parent', fh, ...
    'HorizontalAlignment','left',...
    'Value', 1,...
    'Tag','ShowLegend',...
    'String', 'Show legend');

gridCheckbox = uicontrol('Style', 'checkbox',...
    'Parent', fh, ...
    'HorizontalAlignment','left',...
    'Tag','ShowGrid',...
    'String', 'Show grid');

reorderCheckbox = uicontrol('Style', 'checkbox',...
    'Parent', fh, ...
    'HorizontalAlignment','left',...
    'Tag','ReorderData',...
    'String', 'Reorder X data');

baddataCheckbox = uicontrol('Style', 'checkbox',...
    'Parent', fh, ...
    'HorizontalAlignment','left',...
    'Tag','ShowBadData',...
    'String', 'Show removed data');

layout = xreggridbaglayout(fh,...
    'dimension', [4 3],...
    'mergeblock', {[1 1] [1 2]},...
    'mergeblock', {[2 2] [1 2]},...
    'gap', 7,...
    'colsizes', [90 -1 -1],...
    'rowsizes', [21 21 20 20], ...
    'packstatus', 'off',...
    'elements', {lineText, markerText, [], [],...
    [], [], reorderCheckbox, legendCheckbox,...
    [], [], gridCheckbox, baddataCheckbox});

ud.hand.lineEdit = lineEdit;
ud.hand.markerEdit = markerEdit;
ud.hand.reorderCheckbox = reorderCheckbox;
ud.hand.legendCheckbox = legendCheckbox;
ud.hand.gridCheckbox = gridCheckbox;
ud.hand.baddataCheckbox = baddataCheckbox;

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_setCurrentProperties(ud)

props = ud.data.currentProps;
[~, ~, propLineStyles, propMarkStyles] = i_getLineAndMarkStyles;

try
    set(ud.hand.lineEdit, 'Value', find(strcmp(props.dataLineStyle, propLineStyles)));
    set(ud.hand.markerEdit, 'Value', find(strcmp(props.dataMarker, propMarkStyles)));
    set(ud.hand.reorderCheckbox, 'Value', strcmp(props.reorderData, 'on'));
    set(ud.hand.legendCheckbox, 'Value', strcmp(props.showLegend, 'on'));
    set(ud.hand.gridCheckbox, 'Value', strcmp(props.showGrid, 'on'));
    set(ud.hand.baddataCheckbox, 'Value', strcmp(props.showBadData, 'on'));
end

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function props = i_updateProperties
ud = i_getThisHandle;

[~, ~, propLineStyles, propMarkStyles] = i_getLineAndMarkStyles;
checkboxValues = {'off' 'on'};

% Get the current properties
props.dataLineStyle = propLineStyles{get(ud.hand.lineEdit, 'Value')};
props.dataMarker = propMarkStyles{get(ud.hand.markerEdit, 'Value')};
props.reorderData = checkboxValues{get(ud.hand.reorderCheckbox, 'Value') + 1};
props.showLegend = checkboxValues{get(ud.hand.legendCheckbox, 'Value') + 1};
props.showGrid = checkboxValues{get(ud.hand.gridCheckbox, 'Value') + 1};
props.showBadData = checkboxValues{get(ud.hand.baddataCheckbox, 'Value') + 1};

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function [lineStyles, markStyles, propLineStyles, propMarkStyles] = i_getLineAndMarkStyles
lineStyles = {'None' 'Solid (-)' 'Dot-Dashed (-.)' 'Dashed (--)' 'Dotted (..)'};
markStyles = {'None' 'Dot' 'Circle' 'Cross' 'Plus' 'Asterisk' 'Square' 'Diamond'};
propLineStyles = {'none' '-' '-.' '--' ':'};
propMarkStyles = {'none' '.' 'o' 'x' '+' '*' 's' 'd'};

%------------------------------------------------------------------------
%
%------------------------------------------------------------------------
function i_close(~, ~, action)
[~, f] = i_getThisHandle;
set(f, 'closeAction', action);
set(f, 'Visible', 'off');

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