www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgbrowser/close.m
function close(h) %CLOSE Close the cage browser figure % % CLOSE(H) closes the cage browser down. % Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc. if h.GUIExists try % Save gui configuration ap = mbcprefs('mbc'); p = getpref(ap,'cgbrowser'); sp = get(h.Hand.Figure.TreeSplit,'split'); p.treew = sp(1); sp = get(h.Hand.Figure.ListSplit,'split'); p.listh = sp(1); sp = get(h.Hand.Toolbar.Split,'split'); p.tbsplit = sp; setpref(ap,'cgbrowser',p); catch warning(message('mbc:cgtools:cgbrowser:InvalidState')); end try % clean up current view OK = h.HideNode; catch OK = 0; end if OK % Initiate file save if necessary MP = h.RootNode.info; try cnode = h.CurrentNode; csubitem = h.CurrentSubItem; [MP,msg] = close(MP,0,[cnode,csubitem] ); catch msg = 'Unknown error during project close.'; end if ~isempty(msg) if ~(strcmp(msg,'File not saved') || strcmp(msg,'Cancel')) errordlg(msg,'Unable to save file','modal'); end h.ShowNode; h.ViewNode; return else try deleteproject(MP); catch warning(message('mbc:cgtools:cgbrowser:InvalidState1')); end try % Close surface viewer cgsurfaceviewer('close'); catch warning(message('mbc:cgtools:cgbrowser:InvalidState2')); end try % Make sure registered figures close h.destroyallsubfigures; catch warning(message('mbc:cgtools:cgbrowser:InvalidState3')); end try delete(h.Figure); catch warning(message('mbc:cgtools:cgbrowser:InvalidState4')); end try % perform shutdown tasks cg_shutdown; catch warning(message('mbc:cgtools:cgbrowser:InvalidState5')); end end else if ~isvalid(h.RootNode) warning(message('mbc:cgtools:cgbrowser:InvalidState6')); delete(h.Figure); end end end