function cl=closeimage %CLOSEIMAGE Close the actual image % % K = CLOSEIMAGE % % Closeimage is the function utilized to close the actual image and % restore the default condition. It is used from the close menu item and % it is called before loading a file and before exiting alex. % The return value K is 1 if the closing was completed or 0 on unsuccess. % For example 0 is returnded pressing Cancel from the dialog asking that % the image was modified. % % Customization: % Now if you are doing something with a Extrafun, it is possible that you % want to reset some variables or run another function upon closing the % image. This can be done setting the global string CloseImageFun to the % action to take. Infact this function will be evaluated as one of the % first instruction of closeimage. To clear variables, they must be % defined global in the Extrafun and in the CloseImageFun. This will % help to keep the progam more general and easy to costumize. % % Claudio Aug. 16 (1995) % % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global Handleframeax Handleimgax FullFname Note_txt Note_lab global I H isModify Clipboard ZoomFactor Oldzoomstatus global counter TVzrange global CloseImageFun Undofun AutoZrange cl=1; if ~isobj(Handleimgax) % Image has already been closed return; end if isempty(AutoZrange) AutoZrange=1; end if isModify > 1 r=alexdlg(['|File: ' FullFname '|| Has been modified.|| Save it?']); if strcmp(r, 'Yes') save_image(FullFname); end if strcmp(r, 'Cancel') cl=0; return; end end if isstr(CloseImageFun) eval(CloseImageFun); end CloseImageFun=''; f=watchon; statusbar(['Closing image ' FullFname]); setviewmode('TOPVIEW'); TVzrange=[]; ZoomFactor=[]; Oldzoomstatus=1; imagetitle(''); set(Handleframeax, 'ButtonDownFcn', ''); setalexmenu('off'); %closeviewer; if AutoZrange clearzrange; end delete(Handleimgax); if isobj(Note_txt) delete(Note_txt); end if isobj(Note_lab) delete(Note_lab); end % Now clear the general global variables I=[]; H=[]; setclipboard([]); Undofun=''; setzoomstatus(1); clearstatusbar; watchoff(f); return