Changeset 16 for trunk/Postscript/closeps.pro
- Timestamp:
- 05/02/06 11:17:47 (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Postscript/closeps.pro
r14 r16 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: closeps5 ; NAME: closeps 6 6 ; 7 ; PURPOSE: ferme de l'environement Postscript7 ; PURPOSE: Close the Postscript mode 8 8 ; 9 ; CALLING SEQUENCE: closeps9 ; CALLING SEQUENCE: closeps 10 10 ; 11 11 ; KEYWORD PARAMETERS: 12 ; INFOWIDGET: un long integer qui doit etre l''id du windget13 ; que l''on souhaite detruire (cf. openps.pro)14 12 ; 15 ; COMMON BLOCKS: 16 ; common.pro 13 ; INFOWIDGET: A long integer giving the id of the information 14 ; widget (created by openps) that we have de destroy at 15 ; the end of closeps (when the postscript is done) 17 16 ; 18 ; SIDE EFFECTS: qd sauveps (variable globale) ne 0 les postscript est 19 ; annopte par un numero qd il s''appelle idl.ps sinon par son nom. le 20 ; nom est suivit de la date. 17 ; COMMON BLOCKS: cm_4ps 18 ; 19 ; SIDE EFFECTS: when archive_ps ne 0, we add the name and the date 20 ; at the bottom left corner of the postcript page. If the 21 ; postscript is called idl.ps we change its name to number.ps 22 ; (number automatically found to be 1 larger that any of the 23 ; existing ps file) 21 24 ; 22 25 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 23 26 ; 21/12/98 27 ; June 2005: Sebastien Masson, english version with new commons 24 28 ;- 25 29 ;------------------------------------------------------------ 26 30 ;------------------------------------------------------------ 27 31 ;------------------------------------------------------------ 28 pro closeps, INFOWIDGET = infowidget 29 @common 32 PRO closeps, INFOWIDGET = infowidget 33 ; 34 IF lmgr(/demo) EQ 1 THEN return 30 35 ;------------------------------------------------------------ 31 ; si sauve ps different de 0 on sauve le ps sur maia automatiquement 32 ; ou apres une question. 36 ; include commons 37 @cm_4ps 38 IF NOT keyword_set(key_forgetold) THEN BEGIN 39 @updatenew 40 ENDIF 41 ; 42 IF !d.name NE 'PS' THEN GOTO, last_part 33 43 ;------------------------------------------------------------ 34 if sauveps NE 0 then begin 44 ; if archive_ps /= 0 we will add its name and the date at the bottom 45 ; left corner of the page (in case if the postscript will be archived 46 ; in printps 35 47 ;------------------------------------------------------------ 36 ; on recupere le nom du fichier postscript qui vient d''etre cree 37 ; si ce nom est idl.ps on numerote le postscript avec le numero 38 ; contenu dans derniernumps.dat 48 IF keyword_set(archive_ps) THEN BEGIN 39 49 ;------------------------------------------------------------ 40 spawn,'which "ls"' , ls 41 spawn,ls[0]+' -t '+psdir+'*ps' , nomps 42 nomps = nomps[0] 43 nomps = strmid(nomps,rstrpos(nomps,'/')+1) 44 if nomps EQ 'idl.ps' then begin 45 ; on recupere le numero du dernier fichier sauvegarde 46 ; rq: ce numero est incremente uniquement qd on fait une impression 47 restore,'derniernumps.dat' 48 nomps = strtrim(numfichps, 1) 49 endif 50 ; we get the name of the latest created postscript. 50 51 ;------------------------------------------------------------ 51 ; on annote le postscript 52 psdir = isadirectory(psdir, title = 'Select psdir') 53 nameps = file_search(psdir+'*.ps' $ 54 , /test_regular, /test_write, /nosort) 55 dates = (file_info(nameps)).mtime 56 lastdate = (reverse(sort(temporary(dates))))[0] 57 nameps = nameps[lastdate] 58 nameps = file_basename(nameps, '.ps') 59 ; If this name is idl.ps then we change it to the number.ps 60 IF nameps EQ 'idl' then BEGIN 61 ; get the name of all the *.ps or *.ps.gz files available in psdir 62 allps = file_search(psdir+'*[.ps|.ps.gz|.pdf]', /test_regular, /nosort) 63 allps = file_basename(file_basename(allps,'.gz'),'.ps') 64 allps = file_basename(allps,'.pdf') 65 ; find which of these names corresponds to numbers... 66 ; get ascii codes of the names 67 testnumb = byte(allps) 68 ; longest name 69 maxstrlen = (size(testnumb, /dimensions))[0] 70 ; ascii codes can be 0 or between byte('0') and byte('9') 71 testnumb = testnumb EQ 0 OR $ 72 (testnumb GE (byte('0'))[0] AND testnumb LE (byte('9'))[0]) 73 testnumb = where(total(testnumb, 1) EQ maxstrlen, count) 74 IF count NE 0 THEN BEGIN 75 ; get the largest number 76 psnumber = fix(allps[testnumb]) 77 psnumber = (psnumber[reverse(sort(psnumber))])[0] + 1 78 ENDIF ELSE psnumber = 0 79 nameps = strtrim(psnumber, 2) 80 ENDIF 52 81 ;------------------------------------------------------------ 53 date = byte(systime(0)) ; on crecupere la date 54 xyouts, !d.x_px_cm,!d.y_px_cm $ 55 ,nomps+') '+string(date[4:10])+string(date[20:23]), /device, charsize = .75 56 endif 82 ; we annote the postscript 57 83 ;------------------------------------------------------------ 58 if !d.name EQ 'PS' then device,/close 84 date = byte(systime(0)) ; we get the date 85 xyouts, !d.x_px_cm, !d.y_px_cm $ 86 , nameps+') '+string(date[4:10])+string(date[20:23]) $ 87 , /device, charsize = .75 88 ENDIF 89 ;------------------------------------------------------------ 90 ; close the postcript mode 91 device, /close 92 ; 93 last_part: 94 ; 59 95 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 60 96 CASE thisOS of 61 'MAC': SET_PLOT, thisOS 62 'WIN': SET_PLOT, thisOS 63 ELSE: SET_PLOT, 'X' 64 ENDCASE 65 tvlct, rouge, vert,bleu 97 'MAC': SET_PLOT, thisOS 98 'WIN': SET_PLOT, thisOS 99 ELSE: SET_PLOT, 'X' 100 ENDCASE 101 def_myuniquetmpdir 102 colorfile = myuniquetmpdir + 'original_colors.dat' 103 IF file_test(colorfile, /regular) THEN BEGIN 104 restore, colorfile 105 file_delete, colorfile, /quiet 106 ; reload the original colors 107 tvlct, red, green, blue 108 ENDIF 66 109 !p.font = -1 110 ; force background color to the last color (white) 67 111 !p.BACKGROUND=(!d.n_colors-1) < 255 68 112 !p.color=0
Note: See TracChangeset
for help on using the changeset viewer.