www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@contouroptions/edit.m
function obj = edit(obj,testmode) %CONTOURPLOT/EDIT Interactively edit options for coutour plots % % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. d = xregdialog('name','Contour Plot Options'); xregcenterfigure(d,[261 150]); onoff = {'off','on'}; val = i_findValue(onoff,obj.grid)~=1; showgrid = xreguicontrol('Parent',d,'Style','checkbox','Value',val, ... 'String', 'Show grid lines'); fill = xreguicontrol('Parent',d,'Style','checkbox','Value',obj.fill, ... 'String','Fill area between contours'); showlabels = xreguicontrol('Parent',d,'Style','checkbox','Value',obj.labels, ... 'String','Show contour labels'); sc=xregGui.SystemColorsDbl; numlines = xreguicontrol('Parent',d,'Style','edit',... 'String',num2str(obj.numlines),... 'BackgroundColor',sc.WINDOW_BG); lb3 = xregGui.labelcontrol('parent',d,'control',numlines,... 'gap',5,'string','Number of contour lines:'); gl = xreggridbaglayout(d,'dimension',[4,2],'elements',{showgrid,fill,showlabels,lb3},... 'gapy',5,'rowsizes',[20 20 20 20], 'colsizes', [200 -1]); 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',[2 3],... 'rowsizes',[-1 25],... 'colsizes',[-1 65 65],... 'gapy',10,... 'gapx',7,... 'border',[7 7 7 7],... 'mergeblock',{[1 1],[1 3]},... 'elements',{gl,[],[],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.fill = get(fill,'Value'); obj.labels = get(showlabels,'Value'); n = str2num(get(numlines,'String')); if (isempty(n) | n>100) n=10; end obj.numlines = n; 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');