Viewing contents of file '../idllib/contrib/tappin/graffer/graff_hard.pro'
function Graff_hard, pdefs, no_set=no_set

;+
; GRAFF_HARD
;	Make a hardcopy
;
; Usage:
;	ichange = graff_hard(pdefs)
;
; Return value
;	ichange	int	1 if changed, 0 if not
;
; Argument:
;	pdefs	struct	in/out	The plot definition structure.
;
; Keyword:
;	no_set		input	If set and non-zero, then don't call
;				gr_hardopts to set up the options.
;				
; History:
;	Carved from graffer: 17/8/95; SJT
;	Added no_set key: 8/9/95; SJT
;	Made to function returning "cancel" state: 18/12/96; SJT
;	Change STRPOS to RSTRPOS in filename generation: 23/3/98; SJT
;-

tname = pdefs.name
if (((dp = rstrpos(tname, '.'))) ne -1) then  $
  tname = strmid(tname, 0, dp)
tname = pdefs.dir+tname

h = pdefs.hardset
if (not keyword_set(no_set)) then begin
    ido = gr_hardopts(h, pdefs.ids.graffer, tname, pdefs.popflag)
    if (ido eq -1) then return, 0
endif

pdefs.hardset = h

cpl = float(!D.x_size)/float(!D.x_ch_size)

dev = !D.name
set_plot, 'ps'


!P.font = 0

if (h.eps) then file = tname+'.eps' $
else file = tname+'.ps'

handle_value, pdefs.data, data, /no_copy
locs = where((data.type eq -4 or data.type eq 9) and $
             (data.zopts.format eq 1 or $
              (data.zopts.format eq 0 and data.zopts.fill eq 1)), nim)

handle_value, pdefs.data, data, /no_copy, /set
if (nim ne 0) then bits = 8 $
else bits = 8*h.colour > 1

device, file = file,  encapsu = h.eps, bits = bits, color = $
  h.colour
if (h.colour) then graff_colours, pdefs

psize = gr_get_page(h.psize, h.orient)

if (h.eps) then begin 
    if h.orient then device, /portrait $
    else device, /landscape
endif else if (h.orient) then device, /portrait, xoffset = h.off(0), $
  yoffset = h.off(1) $
else  device, /landscape, xoffset = h.off(1), yoffset = $
  psize(0)-h.off(0)

device, xsize = h.size(0), ysize = h.size(1)

bold = h.font.wg_sl and 1
ital = (h.font.wg_sl and 2)/2

case h.font.family of
    0: device, /courier, bold = bold, oblique = ital
    1: device, /helvetica, bold = bold, oblique = ital
    2: device, /helvetica, /narrow, bold = bold, oblique = ital
    3: device, /schoolbook, bold = bold, italic = ital
    4: device, /palatino, bold = bold, italic = ital
    5: device, /times, bold = bold, italic = ital
    6: device, /avantgarde, /book, oblique = ital
    7: device, /avantgarde, /demi, oblique = ital
    8: device, /bkman, /demi, italic = ital
    9: device, /bkman, /light, italic = ital
    10: device, /zapfchancery, /medium, /italic
    11: device, /zapfdingbats
    12: device, /symbol
endcase

ncpl = float(!D.x_size)/float(!D.x_ch_size)
csiz = ncpl/cpl

gr_plot_object, pdefs, /no_null, charsize = csiz, /plot_all, grey_ps = $
  h.colour eq 0

if (h.timestamp) then begin
    st = string(getenv('USER'), systime(), pdefs.version, $
                format = "(A,' @ ',A,' from V',I0,'.',I2.2)")
    xyouts, /norm, .98, .01, st, charsize = 0.67, align = 1.0
endif

device, /close

set_plot, dev
if (not h.eps) then begin
    spawn, h.action(0)+' '+tname+'.ps '+h.action(1), cmdout
    graff_msg, pdefs.ids.message, cmdout
endif else graff_msg, pdefs.ids.message, 'Output file is: '+file

!P.font = -1

graff_colours, pdefs

return, keyword_set(no_set) eq 0

end