Changeset 16 for trunk/Postscript


Ignore:
Timestamp:
05/02/06 11:17:47 (18 years ago)
Author:
pinsard
Message:

upgrade of POSTSCRIPT/Postscript according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

Location:
trunk/Postscript
Files:
1 added
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Postscript/closeps.pro

    r14 r16  
    33;------------------------------------------------------------ 
    44;+ 
    5 ; NAME:closeps 
     5; NAME: closeps 
    66; 
    7 ; PURPOSE:ferme de l'environement Postscript 
     7; PURPOSE: Close the Postscript mode 
    88; 
    9 ; CALLING SEQUENCE:closeps 
     9; CALLING SEQUENCE: closeps 
    1010; 
    1111; KEYWORD PARAMETERS: 
    12 ;         INFOWIDGET: un long integer qui doit etre l''id du windget 
    13 ;         que l''on souhaite detruire (cf. openps.pro) 
    1412; 
    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) 
    1716; 
    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) 
    2124; 
    2225; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 
    2326;                       21/12/98 
     27; June 2005: Sebastien Masson, english version with new commons  
    2428;- 
    2529;------------------------------------------------------------ 
    2630;------------------------------------------------------------ 
    2731;------------------------------------------------------------ 
    28 pro closeps, INFOWIDGET = infowidget 
    29 @common 
     32PRO closeps, INFOWIDGET = infowidget 
     33; 
     34   IF lmgr(/demo) EQ 1 THEN return 
    3035;------------------------------------------------------------ 
    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 
    3343;------------------------------------------------------------ 
    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  
    3547;------------------------------------------------------------ 
    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 
    3949;------------------------------------------------------------ 
    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.  
    5051;------------------------------------------------------------ 
    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 
    5281;------------------------------------------------------------ 
    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 
    5783;------------------------------------------------------------ 
    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; 
     93last_part: 
     94; 
    5995   thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
    6096   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 
    66109   !p.font = -1 
     110; force background color to the last color (white) 
    67111   !p.BACKGROUND=(!d.n_colors-1) < 255 
    68112   !p.color=0 
  • trunk/Postscript/openps.pro

    r14 r16  
    55; NAME:openps 
    66; 
    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 
    108; 
    11 ; CALLING SEQUENCE:openps[,nomfich] 
     9; CALLING SEQUENCE:openps[,nameps] 
    1210; 
    13 ; INPUTS: 
    14 ;        nomfich: string donnant le nom du fichier ps a ouvrir, evite 
    15 ; 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. 
    1614; 
    1715; KEYWORD PARAMETERS: 
    1816; 
    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. 
    2438 
     39; COMMON BLOCKS: cm_4ps 
     40; 
    2541; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 
    2642;                       21/12/98 
    27 ; 1/2/98: ajout de nomfich en input 
     43; 1/2/98: ajout de nameps en input 
    2844; 1/9/1999: ajout du mot cle FILENAME et du widget 
     45; June 2005: Sebastien Masson, cleaning, english version with new commons  
    2946;- 
    3047;------------------------------------------------------------ 
    3148;------------------------------------------------------------ 
    3249;------------------------------------------------------------ 
    33 pro openps, nomfichier, FILENAME = filename, INFOWIDGET = infowidget, _extra = ex 
    34 @common 
    35    if !d.name EQ 'PS' then device,/close 
     50pro 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 
     62IF NOT keyword_set(key_forgetold) THEN BEGIN 
     63@updatenew 
     64ENDIF 
     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 
    3669   set_plot,'ps' 
    3770;------------------------------------------------------------ 
    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 
    3974;------------------------------------------------------------ 
    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 
    4283;------------------------------------------------------------ 
    43 ; on choisit le nom du fichier 
     84; we define the name of the file 
    4485;------------------------------------------------------------ 
    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) 
    5196;------------------------------------------------------------ 
    52 ; on determine xsize, ysize, xoffset et  yoffset  
     97; we define xsize, ysize, xoffset et  yoffset  
    5398;------------------------------------------------------------ 
    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. 
    59106   ENDIF ELSE BEGIN  
    60       xs = grandfeuille 
    61       ys = petitfeuille 
    62       xoff = 0 
    63       yoff = grandfeuille 
     107      xs = max(page_size) 
     108      ys = min(page_size) 
     109      xoff = 0. 
     110      yoff = max(page_size) 
    64111   ENDELSE  
    65112;------------------------------------------------------------ 
    66 ; on ouvre le postcript  
     113; We define the device of the postscript mode 
    67114;------------------------------------------------------------ 
    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...') 
    73125; 
    74    if arg_present(infowidget) then $ 
    75     infowidget = xnotice('Creation du Postscript en cours...') 
    76 ; 
    77    return 
     126   RETURN 
    78127END 
    79128 
Note: See TracChangeset for help on using the changeset viewer.