- Timestamp:
- 05/02/06 11:17:47 (18 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Obsolete/imprime.pro
r14 r16 7 7 ; 8 8 ; PURPOSE: 9 ; visualise puis imprime eventuellement un fichier Postcript. 10 ; depuis rhodes, le LODYC ou L''IPSL vers les imprimantes du LODYC ou 11 ; de l''IPSL. si le 12 ; fichier n''est pas ds le repertoire courant, on va voir s''il est 13 ; sur gaya dans POSTSCRIPT, si oui, on se propose de le rammener. 14 ; 15 ; CATEGORY: 16 ; traitement fichiers 17 ; 18 ; CALLING SEQUENCE: 19 ; imprime [,nomfichier] 20 ; 21 ; INPUTS: 22 ; 23 ; nomfichier: nom du fichier a imprimer. si nomfichier n''est 24 ; pas precise on prend le dernier postscript cree ds le 25 ; repertoire courant. 26 ; 27 ; KEYWORD PARAMETERS: 28 ; 29 ; /TRANS:imprime -si on le desire- sur un transparant 30 ; 31 ; /NB: obsolete 32 ; 33 ; COMMON BLOCKS: 34 ; common.pro 35 ; 36 ; SIDE EFFECTS: 37 ; 38 ; dans le cas ou le fichier est imprime, il y a possibilite de faire 39 ; un archivage sur gaya ds le repertoire POSTSCRIPT. l''archivage se 40 ; fait en fonction de la valeur de sauveps (variable globale) : 41 ; sauveps=1 : achivage automatique 42 ; sauveps=0 : on n''archive pas 43 ; sauveps a une autre valeur: on demande si on veut archiver a 44 ; chaque ps imprime. 45 ; 46 ; le nom du ps archive est le suivant: 47 ; un numero lorsque le ps s''appelle idl.ps 48 ; son nom ds les autres cas. 49 ; ce nom et la date apparaissent en bas a gauche du ps (ainsi que la 50 ; date de creation) 51 ; 52 ; Rq: avant d''etre envoye sur gaya le fichier est zippe. 53 ; 54 ; Dans le cas ou loginipsl est definit et la machipsl ne l''est 55 ; pas, on passe par la liaison ATM (bcp plus rapide) pour rappatrier le 56 ; fichier en local, sur le repertoire temporaire, avant de l''imprimer. 57 ; 58 ; RESTRICTIONS: verifier que rhodes est bien declare ds vos .rhosts en 59 ; local. 60 ; sur rhodes ds le .rhosts il faut : 61 ; 192.168.111.64 ipsllogin 62 ; a l''ipsl ds le .rhosts il faut : 63 ; rhodes-atm idrislogin 64 ; 65 ; EXAMPLE: 66 ; 67 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 68 ; 21/12/98 69 ; 25/8/19999 utilisation des widgets 70 ; 8/9/1999 utilisation de cw_bgroup 9 ; obsolete, use printps instead... 10 ; 11 ; MODIFICATION HISTORY: 12 ; June 2005: Sebastien Masson, english version 71 13 ;- 72 14 ;------------------------------------------------------------ 73 15 ;------------------------------------------------------------ 74 16 ;------------------------------------------------------------ 75 PRO imprime_event, event 76 @common 77 ; quel est le type d''evenement? 78 widget_control, event.id, get_uvalue=uval 79 ; case sur le type d''evenement 80 case uval.name OF 17 PRO imprime, filename, TRANS = trans, NB = nb 18 ; 19 ; this is working only with unix/linux/osX machines 20 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 21 CASE thisOS OF 22 'MAC':return 23 'WIN':return 24 ELSE: 25 ENDCASE 81 26 ;------------------------------------------------------------ 82 ; visualisation du Postscript27 ; call printps 83 28 ;------------------------------------------------------------ 84 'Visualiser':BEGIN 85 if key_portrait EQ 1 then sens = 'portrait' ELSE sens = 'seascape' 86 case event.value of 87 'Ghostview':spawn,'ghostview -a4 -quiet -'+sens+' '+psdir+uval.nomfich 88 'Ghostscript':spawn,'gs -sPAPERSIZE=a4 -q '+psdir+uval.nomfich 89 'Kghostview':spawn,'kghostview '+psdir+uval.nomfich 90 endcase 91 end 92 'Imprimer':BEGIN 29 CASE N_PARAMS() OF 30 0:printps 31 1:printps, filename 32 ELSE: BEGIN 33 ras = report('imprime accept only one element: psfilename') 34 return 35 END 36 ENDCASE 93 37 ;------------------------------------------------------------ 94 ; sauvegarde eventuelle sur gaya, lorsque sauveps ne 0 et que le 95 ; fichier vient d''etre cree 96 ;------------------------------------------------------------ 97 cd, current = olddir 98 cd, psdir 99 spawn,'which "ls"' , ls 100 spawn,ls[n_elements(ls)-1]+' -t *ps' , nomps 101 nomps=nomps[n_elements(nomps)-1] 102 cd, olddir 103 if sauveps NE 0 AND nomps[0] EQ uval.nomfich then begin 104 ;------------------------------------------------------------ 105 ; ds le cas ou sauveps ne 0 et ne 1 on pause une question pour savoir 106 ; si on doit le sauver 107 ;------------------------------------------------------------ 108 if sauveps NE 1 then begin 109 onsauve = report('Voulez-vous sauver le Postscript ?', /defaul_no, /question) 110 if onsauve EQ 0 THEN GOTO, passauver 111 endif 112 ;------------------------------------------------------------ 113 ; on change de nom qd le fichier s''appelle idl.ps 114 ;------------------------------------------------------------ 115 ; qd le fichier s''appelle idl.ps 116 if uval.nomfich eq 'idl.ps' then begin 117 ; on recupere le numero du dernier fichier sauvegarde 118 restore,'derniernumps.dat' 119 ; on lui change de nom : idl.ps en numero.ps 120 spawn, 'cp '+psdir+uval.nomfich+' '+psdir+strtrim(numfichps, 1)+'.ps' 121 nomfichgaya = strtrim(numfichps, 1)+'.ps' 122 ; on incremente le numero 123 numfichps = numfichps+1 124 save,numfichps,filename='derniernumps.dat' 125 ENDIF ELSE nomfichgaya = uval.nomfich 126 ;------------------------------------------------------------ 127 ; on gzip, on envoie sur gaya 128 ;------------------------------------------------------------ 129 spawn, 'gzip '+psdir+nomfichgaya ; on zip 130 spawn, 'maiaput '+psdir+nomfichgaya+'.gz POSTSCRIPT/'+nomfichgaya+'.gz' ; envoie sur gaya 131 if uval.nomfich eq 'idl.ps' then spawn, '\rm '+psdir+nomfichgaya+'.gz' $ ; on efface le fichier zipe 132 ELSE spawn, 'gunzip '+psdir+nomfichgaya+'.gz' ; on dezipe 133 ;------------------------------------------------------------ 134 endif 135 passauver: 136 ;------------------------------------------------------------ 137 ; selection de l''imprimante 138 ;------------------------------------------------------------ 139 case event.value of 140 'Phaser 740 T26':imprimante = 'ph26' 141 'Phaser 740 trans T26':imprimante = 'ph26T' 142 'Phaser 740 R/V T26':imprimante = 'ph26RV' 143 'HP Laser Jet Tour 26':imprimante = 'hpl26' 144 'HP Laser Jet Tour 26 R/V':imprimante = 'hpl26RV' 145 'sparc T26':imprimante = 'sparc' 146 'Phaser 740 T15':imprimante = 'ph15' 147 'Phaser 740 trans T15':imprimante = 'ph15T' 148 'Phaser 740 R/V T15':imprimante = 'ph15RV' 149 'HP Laser Jet Tour 15':imprimante = 'hpl15' 150 'HP Laser Jet Tour 15 R/V':imprimante = 'hpl15RV' 151 'sparc T15':imprimante = 'sparc2' 152 'CX T15':BEGIN & imprimante = 'CX' & GOTO, lodyc & end 153 'CX-trans T15':BEGIN & imprimante = 'CXtrans' & GOTO, lodyc & END 154 'SUN IPSL':imprimante = 'SUN' 155 'QMS-IPSL':imprimante = 'QMS' 156 'QMS-trans-IPSL':imprimante = 'QMS-trans' 157 ELSE: 158 endcase 159 ;------------------------------------------------------------ 160 ; ou je suis ??? 161 ;------------------------------------------------------------ 162 spawn, 'hostname', hostname & hostname = hostname[n_elements(hostname)-1] 163 if hostname EQ 'rhodes' then domainname = 'idris.fr' $ 164 ELSE spawn, 'domainname', domainname 165 domainname = domainname[n_elements(domainname)-1] 166 if domainname NE 'lodyc.jussieu.fr' AND domainname NE 'ipsl.jussieu.fr' $ 167 AND domainname NE 'idris.fr' then return 168 if domainname EQ 'lodyc.jussieu.fr' then GOTO, lodyc 169 ;------------------------------------------------------------ 170 ; choix du reseau surlequel on renvoie : IPSL ou LODYC et 171 ; specification du login, de la machine et du repertoire temporel ds 172 ; les 2 cas 173 ;------------------------------------------------------------ 174 if domainname EQ 'ipsl.jussieu.fr' then begin 175 machipsl = hostname 176 spawn, 'whoami', loginipsl & loginipsl = loginipsl[n_elements(loginipsl)-1] 177 endif 178 if n_elements(loginipsl) NE 0 THEN BEGIN 179 if loginipsl Eq '' THEN GOTO, lodyc 180 login = loginipsl ; si on a un login a l''ipsl et que machipsl n''est pas stipule 181 ; alors on utilise la liaison ATM entre perouse et rhodes. 182 if n_elements(machipsl) EQ 0 then machine = '192.168.111.64' $ 183 ELSE BEGIN 184 if machipsl EQ '' then machine = '192.168.111.64' $ 185 ELSE machine = machipsl+'.ipsl.jussieu.fr' 186 ENDELSE 187 reptemp = '/temp/'+login+'/' 188 ENDIF ELSE BEGIN 189 lodyc: 190 if domainname EQ 'lodyc.jussieu.fr' then begin 191 machlodyc = hostname 192 spawn, 'whoami', loginlodyc & loginlodyc = loginlodyc[n_elements(loginlodyc)-1] 193 endif 194 if n_elements(loginlodyc) EQ 0 THEN BEGIN 195 loginlodyc = xquestion('Quel est votre login au LODYC ?') 196 ENDIF 197 login = loginlodyc 198 machine = machlodyc+'.lodyc.jussieu.fr' 199 reptemp = '/usr/temp/'+login+'/' 200 ; on change le nom des imprimantes qd on est sur le reseau du lodyc 201 case imprimante of 202 'SUN':imprimante = 'sun-ipsl' 203 'QMS':imprimante = 'qms-ipsl' 204 'QMS-trans': imprimante = 'qmst-ipsl' 205 ELSE: 206 endcase 207 ENDELSE 208 ;------------------------------------------------------------ 209 ; je suis deja sur le bon reseau ou il faut faire des rsh? 210 ;------------------------------------------------------------ 211 spawn, 'whoami', whoami & whoami = whoami[n_elements(whoami)-1] 212 if whoami EQ login then BEGIN 213 spawn,'lpr -P'+imprimante+' '+psdir+uval.nomfich 214 spawn,'lpq -P'+imprimante+' -l', info 215 ENDIF ELSE BEGIN 216 ;------------------------------------------------------------ 217 ; copie du Postscript sur le repertoire temporel a jussieu 218 ;------------------------------------------------------------ 219 spawn,'rcp '+psdir+uval.nomfich+' '+login+'@'+machine+':'+reptemp+'.' 220 ;------------------------------------------------------------ 221 ; impression puis destruction du Postscript 222 ;------------------------------------------------------------ 223 ; print, 'rsh '+machine+' -l '+login+' lpr -P'+imprimante+' '+reptemp+uval.nomfich 224 spawn,'rsh '+machine+' -l '+login+' lpr -P'+imprimante+' '+reptemp+uval.nomfich 225 ;------------------------------------------------------------ 226 ; squate de l'imprimante utilisee 227 ;------------------------------------------------------------ 228 ; print, 'rsh '+machine+' -l '+login+' lpq -P'+imprimante+' -l' 229 spawn,'rsh '+machine+' -l '+login+' lpq -P'+imprimante+' -l', info 230 ; 231 ENDELSE 232 xdisplayfile, 'bidon', text = info, title = 'Info impression '+uval.nomfich $ 233 , height = n_elements(info) < 24 234 widget_control, event.top, /destroy ; on tue le widget 235 236 END 237 'quit':widget_control, event.top, /destroy ; on tue le widget 238 239 endcase 240 return 241 end 242 pro imprime,nomfichier,TRANS=trans, NB = nb 243 ; 244 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 245 CASE thisOS OF 246 'MAC':return 247 'WIN':return 248 ELSE: 249 ENDCASE 250 ; 251 @common 252 ;------------------------------------------------------------ 253 ; attribution du nom du fichier a imprimer 254 ;------------------------------------------------------------ 255 CASE N_PARAMS() OF 256 0: BEGIN 257 cd, current = olddir 258 cd, psdir 259 spawn,'which "ls"' , ls 260 spawn,ls[n_elements(ls)-1]+' -t *ps' , nomfich 261 nomfich=nomfich[n_elements(ls)-1] 262 cd, olddir 263 END 264 1: nomfich=nomfichier 265 else: BEGIN 266 ras = report('Mauvais nombre de parametre dans l''appel de IMPRIME') 267 return 268 END 269 endcase 270 ;------------------------------------------------------------ 271 ; on verifie que le fichier est ds le reertoire courant. 272 ; si il n''y est pas et on va voir s''il est sur gaya. 273 ;------------------------------------------------------------ 274 quelsfichiers = findfile(psdir+nomfich) 275 IF quelsfichiers[0] EQ '' THEN BEGIN ; il faut aller chercher le fichier sur gaya 276 spawn, 'whoami', whoami ; login a l''idris 277 ; le fichier zippe existe sur gaya ? 278 spawn,'rsh '+whoami+'@gaya.idris.fr ls POSTSCRIPT/'+nomfich+'.gz', resultat 279 if resultat[n_elements(resultat)-1] NE '' then BEGIN ; s''il existe on le rappatrie 280 gaya = report('le postscript est archive sur gaya. faire le gayaget?', /question, /defualt_no) 281 if gaya EQ 0 then return 282 print, 'gayaget POSTSCRIPT/'+nomfich+'.gz '+nomfich+'.gz ...' 283 spawn, 'gayaget POSTSCRIPT/'+nomfich+'.gz '+nomfich+'.gz' ; on le rappatrie sur rhodes 284 spawn, 'gunzip '+nomfich+'.gz ' ; on le dezippe 285 ENDIF ELSE BEGIN 286 print, 'le fichier '+nomfich+' n''existe pas' 287 print, 'le fichier '+nomfich+'.gz n''existe pas sur gaya ds le repertoire POSTSCRIPT' 288 return 289 ENDELSE 290 ENDIF 291 ;------------------------------------------------------------ 292 ;------------------------------------------------------------ 293 base = widget_base(/row, title = 'fichier Postscript: '+nomfich) 294 rien = cw_bgroup(base, ['Kghostview', 'Ghostview', 'Ghostscript'], /frame, label_top = 'Visualiser' $ 295 , uvalue = {name:'Visualiser', nomfich:nomfich}, /column, /return_name) 296 rien = cw_bgroup(base, ['Phaser 740 T26','Phaser 740 trans T26', 'Phaser 740 R/V T26' $ 297 , 'HP Laser Jet Tour 26', 'HP Laser Jet Tour 26 R/V' $ 298 , 'sparc T26', 'Phaser 740 T15', 'Phaser 740 trans T15' $ 299 , 'Phaser 740 R/V T15', 'CX T15', 'CX-trans T15'$ 300 , 'HP Laser Jet Tour 15', 'HP Laser Jet Tour 15 R/V', 'sparc T15' $ 301 , 'SUN IPSL', 'QMS-IPSL', 'QMS-trans-IPSL'], /frame $ 302 , label_top = 'Imprimer', uvalue = {name:'Imprimer', nomfich:nomfich} $ 303 , /column, /return_name) 304 rien = widget_button(base,value='quit', uvalue={name:'quit'}) 305 ;------------------------------------------------------------ 306 ;execution de la fentre de base et des sous-fenetres 307 widget_control,base,/realize 308 ;------------------------------------------------------------ 309 xmanager,'imprime',base, /no_block 310 ;------------------------------------------------------------ 311 return 312 end 38 return 39 END 313 40 314 41 -
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 -
trunk/Postscript/openps.pro
r14 r16 5 5 ; NAME:openps 6 6 ; 7 ; PURPOSE:ouverture de l''environement Postscript. au passage on sauve 8 ; la palette dans les vecteurs rouge, vert et bleu puis on palit la 9 ; couleur a l''aide ce palit. 7 ; PURPOSE:switch to postcript mode and define it 10 8 ; 11 ; CALLING SEQUENCE:openps[,n omfich]9 ; CALLING SEQUENCE:openps[,nameps] 12 10 ; 13 ; INPUTS:14 ; n omfich: string donnant le nom du fichier ps a ouvrir, evite15 ; que openps ose la question :'Nom du fichier Postscript?'11 ; OPTIONAL INPUT: 12 ; nameps: name of the postscript file. Extension '.ps' is added 13 ; if missing. It will be stored in the psdir directory. 16 14 ; 17 15 ; KEYWORD PARAMETERS: 18 16 ; 19 ; FILENAME: meme role que nomfich mais comme c''est un mot cle, 20 ; il peut passer a travers les differentes routines via 21 ; INFOWIDGET: a egaler a une variable qui contiendra l''id du 22 ; widget qui informe qu''un cree un widget. 23 ; _EXTRA: tous les mots cles se rapportant a la procedure device 17 ; FILENAME: to define the name of the postcript file through 18 ; a keyword rather than with nameps inut argument 19 ; (in this case the keyword can be pass through 20 ; different routines via _extra keyword). 21 ; 22 ; INFOWIDGET: If INFOWIDGET is present, it specifies a named 23 ; variable into which the id of the widget giving informations 24 ; about the postscript creation is stored as a long integer. 25 ; This id is needed by close ps to kill the information widget. 26 ; 27 ; KEEP_PFONT: activate to suppress the modification of !p.font 28 ; (by defaut we force !p.font = 0 to make smaller postscripts) 29 ; KEEPPFONT: same as keep_pfont 30 ; 31 ; LIGHTNESS: a scalar used to change the Lightness of the color 32 ; palette to be abble to adjust according to the printer we use, 33 ; the media (paper or slide)... 34 ; lightness < 1 to get lighter colors 35 ; > 1 to get darker colors 36 ; 37 ; _EXTRA: used to pass any keyword to device procedure. 24 38 ; 39 ; COMMON BLOCKS: cm_4ps 40 ; 25 41 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 26 42 ; 21/12/98 27 ; 1/2/98: ajout de n omfichen input43 ; 1/2/98: ajout de nameps en input 28 44 ; 1/9/1999: ajout du mot cle FILENAME et du widget 45 ; June 2005: Sebastien Masson, cleaning, english version with new commons 29 46 ;- 30 47 ;------------------------------------------------------------ 31 48 ;------------------------------------------------------------ 32 49 ;------------------------------------------------------------ 33 pro openps, nomfichier, FILENAME = filename, INFOWIDGET = infowidget, _extra = ex 34 @common 35 if !d.name EQ 'PS' then device,/close 50 pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $ 51 , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $ 52 , PORTRAIT = portrait, LANDSCAPE = landscape $ 53 , LIGHTNESS = Lightness,_extra = ex 54 ; 55 IF lmgr(/demo) EQ 1 THEN BEGIN 56 dummy = report('impossible to create a PS in demo mode') 57 return 58 ENDIF 59 ;------------------------------------------------------------ 60 ; include commons 61 @cm_4ps 62 IF NOT keyword_set(key_forgetold) THEN BEGIN 63 @updatenew 64 ENDIF 65 ;------------------------------------------------------------ 66 ; close the postcript device if we are already in postcsrit mode 67 IF !d.name EQ 'PS' THEN device, /close 68 ; switch to postscript mode 36 69 set_plot,'ps' 37 70 ;------------------------------------------------------------ 38 ; on sauve la palette ds rou, vert et bleu 71 ; if we use keyword Lightness 72 ; save the actual color palette in a temporary file 73 ; (to be restored when calling closeps 39 74 ;------------------------------------------------------------ 40 tvlct, rouge, vert, bleu, /get 41 palit,coefpalit 75 IF n_elements(Lightness) NE 0 THEN BEGIN 76 IF Lightness NE 1 THEN BEGIN 77 tvlct, red, green, blue, /get 78 def_myuniquetmpdir 79 save, red, green, blue, filename = myuniquetmpdir + 'original_colors.dat' 80 palit, Lightness, red, green, blue 81 ENDIF 82 ENDIF 42 83 ;------------------------------------------------------------ 43 ; on choisit le nom du fichier84 ; we define the name of the file 44 85 ;------------------------------------------------------------ 45 if keyword_set(filename) then nomfich = filename 46 if n_elements(nomfichier) NE 0 then nomfich = nomfichier 47 ; il faut choisir 48 if n_elements(nomfich) EQ 0 then $ 49 nomfich = xquestion('Nom du fichier Postscript?', 'idl.ps', /chkwid) 50 nomfich = isafile(file = nomfich, iodir = psdir, /new) 86 CASE 1 OF 87 n_params() EQ 1:nameps = namepsin 88 keyword_set(filename): nameps = filename 89 ELSE:nameps = xquestion('Name of the postscript file?', 'idl.ps', /chkwid) 90 ENDCASE 91 ; make sure that nameps ends with '.ps' 92 nameps = file_dirname(nameps, /mark_directory) + $ 93 file_basename(nameps, '.ps') + '.ps' 94 ; add path (psdir) and check that nameps is ok 95 nameps = isafile(nameps, iodir = psdir, /new) 51 96 ;------------------------------------------------------------ 52 ; on determine xsize, ysize, xoffset et yoffset97 ; we define xsize, ysize, xoffset et yoffset 53 98 ;------------------------------------------------------------ 54 if key_portrait EQ 1 then begin 55 xs = petitfeuille 56 ys = grandfeuille 57 xoff = 0 58 yoff = 0 99 IF keyword_set(portrait) OR keyword_set(landscape) THEN $ 100 key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape)) 101 if key_portrait EQ 1 then begin 102 xs = min(page_size) 103 ys = max(page_size) 104 xoff = 0. 105 yoff = 0. 59 106 ENDIF ELSE BEGIN 60 xs = grandfeuille61 ys = petitfeuille62 xoff = 0 63 yoff = grandfeuille107 xs = max(page_size) 108 ys = min(page_size) 109 xoff = 0. 110 yoff = max(page_size) 64 111 ENDELSE 65 112 ;------------------------------------------------------------ 66 ; on ouvre le postcript113 ; We define the device of the postscript mode 67 114 ;------------------------------------------------------------ 68 device, /color,/palatino,LANDSCAPE=1-key_portrait,PORTRAIT=key_portrait $ 69 ,xsize=xs,ysize=ys,xoffset=xoff,yoffset=yoff $ 70 ,filename=strcompress(nomfich, /remove_all) $ 71 ,bits_per_pixel=8,_extra = ex 72 !p.font=0 115 device, /color, /palatino, filename = strcompress(nameps, /remove_all) $ 116 , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $ 117 , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $ 118 , bits_per_pixel = 8, _extra = ex 119 ; to make smaller postcripts 120 IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $ 121 THEN !p.font = 0 122 ; show some informations 123 IF arg_present(infowidget) THEN $ 124 infowidget = xnotice('Postcript file is currently processed...') 73 125 ; 74 if arg_present(infowidget) then $ 75 infowidget = xnotice('Creation du Postscript en cours...') 76 ; 77 return 126 RETURN 78 127 END 79 128 -
trunk/ToBeReviewed/POSTSCRIPT/calibre.pro
r14 r16 8 8 ; characteres) des differentes marges, calcul posfenetre et posbar qui 9 9 ; servent a placer le dessin et la barre de couleur grace a 10 ; !p.position sur une feuille petitfeuille*grandfeuille (21*29.7)ou10 ; !p.position sur une feuille ou 11 11 ; sur une sortie ecran dont la fenetre a les memes proportions 12 12 ; … … 14 14 ; 15 15 ; CALLING SEQUENCE: 16 ; calibre, rapportyx,marge,margebar, petitdessin,posfenetre, posbar16 ; calibre, rapportyx,marge,margebar, smalldraw,posfenetre, posbar 17 17 ; 18 18 ; INPUTS: … … 30 30 ; couleur. tout est mesure en lignes de characteres 31 31 ; 32 ; petitdessin: 2 possiblites32 ; smalldraw: 2 possiblites 33 33 ; un vecteur de 4 elements donnant (en portrait ou 34 34 ; en landscape) la position de cadre ds lequel doit rentrer le … … 40 40 ; faire de le dessin, le nombre de lignes et enfin le numero de la 41 41 ; case que doit occuper le dessin (cf matlab). par ex pour faire 6 42 ; dessin en 2 colonnes et 3 lignes et occuper la 4 eme case, petit=[2,3,4]42 ; dessin en 2 colonnes et 3 lignes et occuper la 4 eme case, small=[2,3,4] 43 43 ; 44 44 ; KEYWORD PARAMETERS: 45 45 ; 46 46 ; /REMPLI:oblige le dessin a occuper l'espace maximum definit 47 ; par petitdessinsans resperter le rapport y sur x.48 ; 49 ; Y SURX: force le rapport y sur x a prendre la valeur50 ; rapportyx*y surx. ce mot cle est utile ds deux cas:51 ; 1) y surx=1 : oblige rapportyx a etre bien respecte sinon47 ; par smalldraw sans resperter le rapport y sur x. 48 ; 49 ; YXASPECT: force le rapport y sur x a prendre la valeur 50 ; rapportyx*yxaspect. ce mot cle est utile ds deux cas: 51 ; 1) yxaspect=1 : oblige rapportyx a etre bien respecte sinon 52 52 ; calibre se reserve le droit de changer un peu celui-ci dans 53 ; le cas ou le rapport d''aspect de petitdessin est trop54 ; different de celui de petitdessin.55 ; 2) y surx=n : multiplie par n le rapport d''aspect donne par53 ; le cas ou le rapport d''aspect de small dessin est trop 54 ; different de celui de smalldraw. 55 ; 2) yxaspect=n : multiplie par n le rapport d''aspect donne par 56 56 ; defaut.par ex ds plt, rapportyx est calcule pour que le 57 57 ; repere soit orthonorme, pour avoir un repere ou l''axe des y 58 ; est 2 fois plus dilate que celui des y Y SURX=258 ; est 2 fois plus dilate que celui des y YXASPECT=2 59 59 ; 60 60 ; PORTRAIT et LANDSCAPE: mots cles plus utilises mais tjs fonctionnels … … 84 84 ;------------------------------------------------------------ 85 85 ;------------------------------------------------------------ 86 pro calibre, rapportyx,marge,margebar, petitdessin,posfenetre, posbar $ 87 ,REMPLI=rempli,YSURX=ysurx,PORTAIT=portrait,LANDSCAPE=lanscape 88 ;------------------------------------------------------------ 89 @common 86 pro calibre, rapportyx, marge, margebar, smalldraw, posfenetre, posbar $ 87 , REMPLI = rempli, YXASPECT = yxaspect, PORTRAIT = portrait $ 88 , LANDSCAPE = lanscape, _extra = ex 89 ;--------------------------------------------------------- 90 @cm_4ps 91 IF NOT keyword_set(key_forgetold) THEN BEGIN 92 @updatenew 93 @updatekwd 94 ENDIF 95 ;--------------------------------------------------------- 96 ;------------------------------------------------------------ 90 97 tempsun = systime(1) ; pour key_performance 91 98 ;------------------------------------------------------------- 92 99 if keyword_set(portrait) then key_portrait=1 93 100 if keyword_set(landscape) then key_portrait=0 94 if keyword_set(y surx) then begin95 rapportyx=rapportyx*y surx101 if keyword_set(yxaspect) then begin 102 rapportyx=rapportyx*yxaspect 96 103 test2=0 97 104 endif else begin 98 y surx=1.105 yxaspect=1. 99 106 test2=1 100 endelse 107 ENDELSE 108 ; 109 mipgsz = min(page_size, max = mapgsz) 101 110 ;------------------------------------------------------------ 102 111 ; choix de Landscape ou Portrait … … 107 116 endif 108 117 ;------------------------------------------------------------- 109 ; si petitdessinest compte comme ds matlab118 ; si smalldraw est compte comme ds matlab 110 119 ;------------------------------------------------------------- 111 if n_elements( petitdessin) EQ 3 then begin112 if n_elements( margescadre) EQ 0 then margescadre= [1, 1, 1, 1]113 petitdessin = long(petitdessin)114 nbrecol = petitdessin[0]115 nbrelig = petitdessin[1]116 numero = petitdessin[2]-1120 if n_elements(smalldraw) EQ 3 then begin 121 if n_elements(page_margins) EQ 0 then page_margins = [1, 1, 1, 1] 122 smalldraw = long(smalldraw) 123 nbrecol = smalldraw[0] 124 nbrelig = smalldraw[1] 125 numero = smalldraw[2]-1 117 126 numlig = numero/nbrecol 118 127 numcol = numero-numlig*nbrecol 119 bas = petitfeuille*key_portrait+grandfeuille*(1-key_portrait)120 cote = grandfeuille*key_portrait+petitfeuille*(1-key_portrait)121 poscol = margescadre[0]+findgen(nbrecol+1)*(1.*(bas-(margescadre[0]+margescadre[1]))/nbrecol)122 poslig = cote- margescadre[3]-findgen(nbrelig+1)*(1.*(cote-(margescadre[2]+margescadre[3]))/nbrelig)123 petitdessin= [poscol[numcol], poslig[numlig+1], poscol[numcol+1], poslig[numlig]]128 bas = mipgsz*key_portrait+mapgsz*(1-key_portrait) 129 cote = mapgsz*key_portrait+mipgsz*(1-key_portrait) 130 poscol = page_margins[0]+findgen(nbrecol+1)*(1.*(bas-(page_margins[0]+page_margins[1]))/nbrecol) 131 poslig = cote-page_margins[3]-findgen(nbrelig+1)*(1.*(cote-(page_margins[2]+page_margins[3]))/nbrelig) 132 smalldraw = [poscol[numcol], poslig[numlig+1], poscol[numcol+1], poslig[numlig]] 124 133 endif 125 134 ;------------------------------------------------------------ … … 127 136 ;------------------------------------------------------------ 128 137 nombre_de_mots_ds_titre = 60. 129 !p.charsize=1.*( petitdessin[2]-petitdessin[0])*!d.x_px_cm / $138 !p.charsize=1.*(smalldraw[2]-smalldraw[0])*!d.x_px_cm / $ 130 139 (nombre_de_mots_ds_titre* !d.y_ch_size) 131 140 if !p.charsize gt 1 then !p.charsize=1 … … 140 149 ;------------------------------------------------------------ 141 150 if key_portrait eq 0 then begin 142 grand=petitdessin[2]-petitdessin[0]143 petit=petitdessin[3]-petitdessin[1]151 big=smalldraw[2]-smalldraw[0] 152 small=smalldraw[3]-smalldraw[1] 144 153 endif else begin 145 petit=petitdessin[2]-petitdessin[0]146 grand=petitdessin[3]-petitdessin[1]154 small=smalldraw[2]-smalldraw[0] 155 big=smalldraw[3]-smalldraw[1] 147 156 endelse 148 157 if key_portrait eq 0 then $ 149 rapportmax=1.*( petit-marge[3]-marge[1])/(grand-marge[2]-marge[0]) $150 else rapportmax=1.*( petit-marge[2]-marge[0])/(grand-marge[3]-marge[1])151 ;------------------------------------------------------------ 152 ; si y surxn'est pas specifie on modifie la valeur de rapportyx pour que158 rapportmax=1.*(small-marge[3]-marge[1])/(big-marge[2]-marge[0]) $ 159 else rapportmax=1.*(small-marge[2]-marge[0])/(big-marge[3]-marge[1]) 160 ;------------------------------------------------------------ 161 ; si yxaspect n'est pas specifie on modifie la valeur de rapportyx pour que 153 162 ; ca colle un peu plus aux proportions de la feuille 154 163 ;------------------------------------------------------------ … … 175 184 if key_portrait eq 0 then begin 176 185 if keyword_set(rempli) then begin 177 xs= grand178 ys= petit186 xs=big 187 ys=small 179 188 endif else begin 180 189 if rapportyx le rapportmax then begin 181 xs= grand182 ys=1.*( grand-marge[0]-marge[1])*rapportyx+marge[2]+marge[3]183 if ys gt petitthen begin184 xs=1.*( petit-marge[2]-marge[3])/rapportyx+marge[0]+marge[1]185 ys= petit190 xs=big 191 ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] 192 if ys gt small then begin 193 xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] 194 ys=small 186 195 endif 187 196 endif else begin 188 xs=1.*( petit-marge[2]-marge[3])/rapportyx+marge[0]+marge[1]189 ys= petit190 if xs gt grandthen begin191 xs= grand192 ys=1.*( grand-marge[0]-marge[1])*rapportyx+marge[2]+marge[3]197 xs=1.*(small-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] 198 ys=small 199 if xs gt big then begin 200 xs=big 201 ys=1.*(big-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] 193 202 endif 194 203 endelse 195 204 endelse 196 xoff=1.*( petit-ys)/2.+petitdessin[1]197 yoff=1.*( grand-xs)/2.+xs+grandfeuille-petitdessin[2]198 a=1.*( grandfeuille-yoff)/grandfeuille199 b=1.*xoff/ petitfeuille200 c=a+1.*xs/ grandfeuille201 d=b+1.*ys/ petitfeuille205 xoff=1.*(small-ys)/2.+smalldraw[1] 206 yoff=1.*(big-xs)/2.+xs+mapgsz-smalldraw[2] 207 a=1.*(mapgsz-yoff)/mapgsz 208 b=1.*xoff/mipgsz 209 c=a+1.*xs/mapgsz 210 d=b+1.*ys/mipgsz 202 211 endif $ 203 212 ;------------------------------------------------------------ … … 206 215 else begin 207 216 if keyword_set(rempli) then begin 208 xs= petit209 ys= grand217 xs=small 218 ys=big 210 219 endif else begin 211 220 if rapportyx le rapportmax then begin 212 xs= petit213 ys=1.*( petit-marge[0]-marge[1])*rapportyx+marge[2]+marge[3]214 if ys gt grandthen begin215 xs=1.*( grand-marge[2]-marge[3])/rapportyx+marge[0]+marge[1]216 ys= grand221 xs=small 222 ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] 223 if ys gt big then begin 224 xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] 225 ys=big 217 226 endif 218 227 endif else begin 219 xs=1.*( grand-marge[2]-marge[3])/rapportyx+marge[0]+marge[1]220 ys= grand221 if xs gt petitthen begin222 xs= petit223 ys=1.*( petit-marge[0]-marge[1])*rapportyx+marge[2]+marge[3]228 xs=1.*(big-marge[2]-marge[3])/rapportyx+marge[0]+marge[1] 229 ys=big 230 if xs gt small then begin 231 xs=small 232 ys=1.*(small-marge[0]-marge[1])*rapportyx+marge[2]+marge[3] 224 233 endif 225 234 endelse 226 235 endelse 227 xoff=1.*( petit-xs)/2.+petitdessin[0]228 yoff=1.*( grand-ys)/2.+petitdessin[1]229 a=1.*xoff/ petitfeuille230 b=1.*yoff/ grandfeuille231 c=a+1.*xs/ petitfeuille232 d=b+1.*ys/ grandfeuille236 xoff=1.*(small-xs)/2.+smalldraw[0] 237 yoff=1.*(big-ys)/2.+smalldraw[1] 238 a=1.*xoff/mipgsz 239 b=1.*yoff/mapgsz 240 c=a+1.*xs/mipgsz 241 d=b+1.*ys/mapgsz 233 242 xset = xoff 234 243 yset = yoff 235 244 endelse 236 245 ;------------------------------------------------------------ 237 bas= grandfeuille*(1-key_portrait)+petitfeuille*key_portrait238 cote= petitfeuille*(1-key_portrait)+grandfeuille*key_portrait246 bas=mapgsz*(1-key_portrait)+mipgsz*key_portrait 247 cote=mipgsz*(1-key_portrait)+mapgsz*key_portrait 239 248 posfenetre=[a,b,c,d]+[ marge[0]/bas, marge[2]/cote $ 240 249 ,-marge[1]/bas,-marge[3]/cote ] … … 243 252 ;------------------------------------------------------------ 244 253 if keyword_set(key_performance) THEN print, 'temps calibre', systime(1)-tempsun 254 255 IF NOT keyword_set(key_forgetold) THEN BEGIN 256 @updateold 257 ENDIF 258 245 259 return 246 260 end -
trunk/ToBeReviewed/POSTSCRIPT/ps.pro
r14 r16 46 46 ;------------------------------------------------------------ 47 47 ; on recupere le journal sous la forme d''un vecteur de string: 48 vectjournal = getfile( homedir+'idlsave.pro')48 vectjournal = getfile(myuniquetmpdir+'idlsave.pro') 49 49 ;FOR i = 0,n_elements(vectjournal)-1 DO print, vectjournal[i] 50 50 ;------------------------------------------------------------ 51 51 ; on coupe la derniere ligne qui est @ps 52 52 ;------------------------------------------------------------ 53 vectjournal = vectjournal[0:n_elements(vectjournal)-2 ] 53 IF strpos(vectjournal[n_elements(vectjournal)-1],'@ps') ne -1 then $ 54 vectjournal = vectjournal[0:n_elements(vectjournal)-2 ] 54 55 ;------------------------------------------------------------ 55 56 ; on le corrige si besoin est... … … 92 93 93 94 ; on le complete pour le transformer en une procedure equivalente a plein2dessin 94 vectjournal = ['reinitplt, /z,/invert' $95 ,'openps, infowidget= infowidget' $95 ; vectjournal = ['reinitplt, /z,/invert' $ 96 vectjournal = ['openps, infowidget= infowidget' $ 96 97 , vectjournal $ 97 98 ,'closeps, infowidget= infowidget' $ 98 ,' imprime' ]99 ,'printps' ] 99 100 ;FOR i = 0,n_elements(vectjournal)-1 DO print, vectjournal[i] 100 101 ; on reecrit idlsave.pro 101 putfile, homedir+'idlsave.pro', vectjournal102 putfile, myuniquetmpdir+'idlsave.pro', vectjournal 102 103 ; applique idlsave 103 cd, homedir 104 cd, current = curdir 105 cd, myuniquetmpdir 104 106 @idlsave 107 cd, curdir 105 108 ; on reouvre le journal et on y met les elements de 106 109 ; vectjournal sauf les 2 premieres lignes et les 3 dernieres lignes 107 journal 110 journal, myuniquetmpdir+'idlsave.pro' 108 111 for i = 2, n_elements(vectjournal)-3 DO $ 109 112 printf, !journal, vectjournal[i]
Note: See TracChangeset
for help on using the changeset viewer.