www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@lineoptions/edit.m

    function obj = edit(obj,testmode)
%EDIT Interactively edit plot options
%
% obj = edit(obj)
%
% If changes are made, the notifyListeners method is called on this object
% and any surfaceoptions objects to which this object is connected.
%

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


d = xregdialog('name','Line Plot Options');
xregcenterfigure(d, [261 90]);

onoff = {'off','on'};
val = i_findValue(onoff,obj.grid)~=1;
showgrid = xreguicontrol('Parent',d,'Style','checkbox','Value',val, ...
    'String', 'Show grid lines');

commony = xreguicontrol('Parent',d,'Style','checkbox','Value',obj.common_yrange, ...
    'String', 'Use common Y-range in all axes');

okbtn = uicontrol('Parent',d,...
    'Style','pushbutton',...
    'Callback',{@i_finish,d,'ok'},...
    'String','OK');
cancbtn = uicontrol('Parent',d,...
    'Style','pushbutton',...
    'Callback',{@i_finish,d,'cancel'},...
    'String','Cancel');

ml = xreggridbaglayout(d,...
    'dimension',[4 3],...
    'rowsizes',[20 20 -1 25],...
    'colsizes',[-1 65 65],...
    'gapy',10,...
    'gapx',7,...
    'border',[7 7 7 7],...
    'mergeblock',{[1 1],[1 3]},...
    'mergeblock',{[2 2],[1 3]},...
    'elements',{showgrid,    [], [];...
                commony, [], [];...
                [], [], [];...
                [], okbtn, cancbtn} );

d.LayoutManager = ml;
set(ml,'packstatus','on');

if nargin>1 && testmode
    set(d,'Tag','ok');
else
    % this waits until the dialog is closed
    d.showDialog(okbtn);
end

tag = get(d,'Tag');
if strcmp(tag,'ok')
    % User clicked OK.  Apply the new settings
    obj.grid = onoff{get(showgrid,'Value')+1};
    obj.common_yrange = get(commony,'Value');

    if ~isempty(obj.hSurfaceOptions)
        obj.hSurfaceOptions.grid = obj.grid;
        obj.hSurfaceOptions.common_zrange = obj.common_yrange;
        obj.hSurfaceOptions.notifyOptionsListeners;
    end

    obj.notifyOptionsListeners;
end

delete(d);


%-------------------------
function val=i_findValue(strings,current)

val=1;
for i=1:length(strings)
    if strcmpi(strings{i},current)
        val=i;
        break;
    end
end


%-------------------------
function i_finish(src,evt,d,status)

set(d,'Tag',status);
set(d,'Visible','off');