source: trunk/SRC/Postscript/openps.pro @ 231

Last change on this file since 231 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

  • Property svn:keywords set to Id
File size: 4.4 KB
RevLine 
[2]1;+
2;
[129]3; @file_comments
[136]4; switch to postscript mode and define it
[2]5;
[136]6; @param namepsin {in}{optional}
7; name of the postscript file.
8; Extension '.ps' is added if missing. It will be stored in the psdir directory.
[2]9;
[129]10; @keyword FILENAME
[231]11; to define the name of the postscript file through a keyword rather than with
[186]12; nameps input argument (in this case the keyword can be pass through
[129]13; different routines via _EXTRA keyword).
[16]14;
[129]15; @keyword INFOWIDGET
[231]16; If INFOWIDGET is present, it specifies a named variable into which the id of
17; the widget giving information about the postscript creation is stored as a
[186]18; long integer.
[231]19; This id is needed by <pro>closeps</pro> to kill the information widget.
[16]20;
[129]21; @keyword KEEP_PFONT
22; activate to suppress the modification of !p.font
[230]23; (by default we force !p.font = 0  to make smaller postscripts)
[129]24;
[118]25; @keyword PORTRAIT
[136]26;
[118]27; @keyword LANDSCAPE
[16]28;
[136]29; @keyword KEEPPFONT
30; same as keep_pfont
[16]31;
[136]32; @keyword LIGHTNESS
33; a scalar used to change the Lightness of the color palette to be able to
34; adjust according to the printer we use, the media (paper or slide)...
35; > 1 to get darker colors
[16]36;
[136]37; @keyword _EXTRA
[231]38; Used to pass keywords to <pro>device<pro>.
[136]39;
[231]40; @uses
41; cm_4ps
[118]42;
[104]43; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
44; 21/12/98
[16]45; 1/2/98: ajout de nameps en input
[2]46; 1/9/1999: ajout du mot cle FILENAME et du widget
[118]47; June 2005: Sebastien Masson, cleaning, english version with new commons
48;
[230]49; @version
50; $Id$
[118]51;
[2]52;-
[231]53;
[16]54pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $
55            , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $
56            , PORTRAIT = portrait, LANDSCAPE = landscape $
57            , LIGHTNESS = Lightness,_extra = ex
58;
[114]59;
60  compile_opt idl2, strictarrsubs
61;
[16]62   IF lmgr(/demo) EQ 1 THEN BEGIN
63      dummy = report('impossible to create a PS in demo mode')
64      return
65   ENDIF
[231]66;
[16]67@cm_4ps
68IF NOT keyword_set(key_forgetold) THEN BEGIN
69@updatenew
70ENDIF
71;------------------------------------------------------------
[136]72; close the postscript device if we are already in postscript mode
[16]73   IF !d.name EQ 'PS' THEN device, /close
74; switch to postscript mode
[2]75   set_plot,'ps'
76;------------------------------------------------------------
[16]77; if we use  keyword Lightness
78; save the actual color palette in a temporary file
79; (to be restored when calling closeps
[2]80;------------------------------------------------------------
[16]81   IF n_elements(Lightness) NE 0 THEN BEGIN
82     IF Lightness NE 1 THEN BEGIN
83       tvlct, red, green, blue, /get
84       def_myuniquetmpdir
85       save, red, green, blue, filename = myuniquetmpdir + 'original_colors.dat'
86       palit, Lightness, red, green, blue
87     ENDIF
88   ENDIF
[2]89;------------------------------------------------------------
[16]90; we define the name of the file
[2]91;------------------------------------------------------------
[16]92   CASE 1 OF
93     n_params() EQ 1:nameps = namepsin
94     keyword_set(filename): nameps = filename
95     ELSE:nameps = xquestion('Name of the postscript file?', 'idl.ps', /chkwid)
96   ENDCASE
97; make sure that nameps ends with '.ps'
98   nameps = file_dirname(nameps, /mark_directory) + $
99            file_basename(nameps, '.ps') + '.ps'
100; add path (psdir) and check that nameps is ok
101   nameps = isafile(nameps, iodir = psdir, /new)
[2]102;------------------------------------------------------------
[118]103; we define xsize, ysize, xoffset et  yoffset
[2]104;------------------------------------------------------------
[69]105   IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $
[16]106     key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape))
[69]107
[16]108   if key_portrait EQ 1 then begin
109      xs = min(page_size)
110      ys = max(page_size)
111      xoff = 0.
112      yoff = 0.
[118]113   ENDIF ELSE BEGIN
[16]114      xs = max(page_size)
115      ys = min(page_size)
116      xoff = 0.
117      yoff = max(page_size)
[118]118   ENDELSE
[2]119;------------------------------------------------------------
[16]120; We define the device of the postscript mode
[2]121;------------------------------------------------------------
[16]122   device, /color, /palatino, filename = strcompress(nameps, /remove_all) $
123           , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $
124           , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $
[167]125           , bits_per_pixel = 8, language_level = 2, _extra = ex
[16]126; to make smaller postcripts
127   IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $
[118]128   THEN !p.font = 0
[16]129; show some informations
130   IF arg_present(infowidget) THEN $
131    infowidget = xnotice('Postcript file is currently processed...')
[2]132;
[16]133   RETURN
[2]134END
Note: See TracBrowser for help on using the repository browser.