www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@surfaceoptions/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 lineoptions objects to which this object is connected.
%

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


onoff = {'off','on'};
edgecolor_options = {'none','k'};

d = xregdialog('name','Surface and Movie Options');
xregcenterfigure(d, [261 190]);

val = i_findValue(onoff,obj.box)~=1;
showbox = xreguicontrol('Parent',d,'Style','checkbox','Value',val, ...
    'String', 'Show box round axes');

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

val = i_findValue(edgecolor_options,obj.edgecolor)~=1;
showmesh = xreguicontrol('Parent',d,'Style','checkbox','Value',val, ...
    'String', 'Show surface mesh');

linkaxes = xreguicontrol('Parent',d,'Style','checkbox','Value',obj.linkRotation, ...
    'String', 'Link rotation of axes');

commonz = xreguicontrol('Parent',d,'Style','checkbox','Value',obj.common_zrange, ...
    'String', 'Use common Z-range in all axes');

showtime = xreguicontrol('Parent',d,'Style','checkbox','Value',obj.show_time, ...
    'String', 'Show value of time variable in movies');

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',[8 3],...
    'rowsizes',[20 20 20 20 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]},...
    'mergeblock',{[3 3],[1 3]},...
    'mergeblock',{[4 4],[1 3]},...
    'mergeblock',{[5 5],[1 3]},...
    'mergeblock',{[6 7],[1 3]},...
    'elements',{showbox, [], [];...
                showgrid, [], [];...
                showmesh, [], [];...
                linkaxes, [], [];...
                commonz, [], [];...
                showtime, [], [];...
                [], [], [];...
                [], 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.box = onoff{get(showbox,'Value')+1};
    obj.grid = onoff{get(showgrid,'Value')+1};
    obj.edgecolor = edgecolor_options{get(showmesh,'Value')+1};
    obj.linkRotation = get(linkaxes,'Value');
    obj.common_zrange = get(commonz,'Value');
    obj.show_time = get(showtime,'Value');

    if ~isempty(obj.hLineOptions)
        obj.hLineOptions.grid = obj.grid;
        obj.hLineOptions.common_yrange = obj.common_zrange;
        obj.hLineOptions.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');