Viewing contents of file '../idllib/contrib/tappin/graffer/graff_props.pro'
pro Graff_props, file, title=title, subtitle=subtitle, $
charsize=charsize, thick=thick, corners=corners, $
aspect=aspect, comment=comment, xtitle=xtitle, $
xrange=xrange, xlog=xlog, xexact=xexact, $
xextend=xextend, xaxes=xaxes, xbox=xbox, $
xminor=xminor, xtime=xtime, xorigin=xorigin, $
xgrid=xgrid, xauto=xauto, $
ytitle=ytitle, $
yrange=yrange, ylog=ylog, yexact=yexact, $
yextend=yextend, yaxes=yaxes, ybox=ybox, $
yminor=yminor, ytime=ytime, yorigin=yorigin, $
ygrid=ygrid, yauto=yauto, display=display, $
graffer=graffer, ascii=ascii, h_orient=h_orient, $
h_colour=h_colour, h_eps=h_eps, h_xsize=h_xsize, $
h_ysize=h_ysize, h_xmargin=h_xmargin, $
h_ymargin=h_ymargin
;+
; GRAFF_PROPS
; User-callable interface to set global properties of a graffer
; file.
;
; Usage:
; graff_props, file, title=title, subtitle=subtitle, $
; charsize=charsize, thick=thick, corners=corners, $
; aspect=aspect, comment=comment, xtitle=xtitle, $
; xrange=xrange, xlog=xlog, xexact=xexact, $
; xextend=xextend, xaxes=xaxes, xbox=xbox, $
; xminor=xminor, xtime=xtime, xorigin=xorigin, $
; xgrid=xgrid, xauto=xauto, $
; ytitle=ytitle, $
; yrange=yrange, ylog=ylog, yexact=yexact, $
; yextend=yextend, yaxes=yaxes, ybox=ybox, $
; yminor=yminor, ytime=ytime, yorigin=yorigin, $
; ygrid=ygrid, yauto=yauto, display=display, $
; graffer=graffer, ascii=ascii
;
; Argument:
; file string input The graffer file to modify.
;
; Keywords:
; title input Set the plot title.
; subtitle input Set the subtitle for the plot.
; charsize input Set the character size to be used for
; axis labelling and plot annotations.
; thick input Set the line thickness to be used for
; drawing the axes.
; corners input Set the location of the plot in
; normalized coordinates by specifying
; the locations of the corners
; (4-elemant array [x0,y0, x1,y1])
; aspect input Set the location of the plot within
; the normalized coordinate system by
; aspect ratio and margin (2-element
; array [aspect, margin]
; N.B. Specifying both ASPECT &
; CORNERS is an error and the
; plot location is unchanged.
; comment input Set a descriptive comment for the
; whole file. (String array)
; [xy]title input Set the title for the specified axis.
; [xy]range input Set the range of the specified axis
; (2-element array).
; [xy]log input Set or unset the use of logarithmic
; axes.
; [xy]exact input Set or unset the exact range bit of
; the IDL axis style setting
; [xy]extend input Set or unset the extended range bit of
; the IDL axis style setting
; [xy]axes input Set or unset the axis plotting bit of
; the IDL axis style setting.
; [xy]box input Set or unset the "box-axis" bit in the
; IDL axis style setting
; [xy]minor input If set, then display minor ticks on
; the plot; if explicitly zero, then
; turn off the minor ticks.
; [xy]time input If set to zero, then turn off time
; labelling, otherwise this must be a
; structure with the following members:
; unit: - 0 == seconds
; - 1 == minutes
; - 2 == hours
; - 3 == days
; Gives the unit in which the
; time is expressed in the axis data.
; max_unit: gives the largest unit to
; display on the plot (same code as
; for unit)
; zero: gives the value to be used for
; the zero of the axis (expressed in
; units of max_unit
; [xy]origin input If set, then plot an axis at the origin.
; [xy]grid input Make a grid from the major ticks,
; using linestyle n-1 (0 == no grid).
; [xy]auto input If set, then perform an autoscale on
; the specified axis, the corresponding
; range setting takes precedence over
; this setting.
; display input If set, then display the plot on the
; current device.
; graffer input If set, then invoke GRAFFER after
; adding the dataset.
; ascii input If set, then save as an ASCII GRAFFER
; file (by default a binary graffer file
; is generated).
; h_orient input Set landscape(0) or portrait (1)
; orientation of the page.
; h_colour input Set or unset the generation of a
; colour (E)PS file.
; h_eps input Set or unset the generation of EPS
; file rather than PS (N.B. if h_eps is
; set and h_orient is not specified,
; then h_orient=1 is implied).
; h_[xy]size input Set the X(Y) dimension of the page in cm
; h_[xy]margin input Set the X(Y) offset of the page from
; the lower-left corner of the page.
;
; Restrictions:
; The ASPECT and CORNERS keys are exclusive (if both are given,
; both are ignored).
; [XY]RANGE overrides [XY]AUTO.
; The GRAFFER key overrides the DISPLAY key and the ASCII key.
; As yet the addition/modification of a key (legend) is not
; supported.
; Not all hardcopy options can be set.
;
; Side Effects:
; A graffer file is updated or created.
; The DISPLAY option will cause your device colour table to be
; changed.
;
; History:
; Original (uses some code from GRAFF_ADD): 12/3/98; SJT
; Added hardcopy settings: 13/3/98; SJT
;-
; Check that the necessary inputs are present
on_error, 2 ; Return to caller on error
if (n_params() ne 1) then message, "Must specify a GRAFFER file"
; Open the file
version = [2, 2]
f0 = file
graff_init, pdefs, f0, version = version
igot = graff_get(pdefs, f0, /no_set, /no_warn)
; Titles & other global options
if n_elements(title) ne 0 then pdefs.title = title
if n_elements(subtitle) ne 0 then pdefs.subtitle = subtitle
if n_elements(charsize) ne 0 then pdefs.charsize = charsize
if n_elements(thick) ne 0 then pdef.axthick = thick
case (keyword_set(aspect)+keyword_set(corners)) of
2: graff_msg, 0l, "Attempt to define position 2 ways -- ignoring both"
0:
1: begin
if (n_elements(aspect) eq 2) then begin
pdefs.aspect = aspect
pdefs.position = 0
endif else if (n_elements(position) eq 4) then begin
pdefs.aspect = 0
pdefs.position = position
endif else begin
graff_msg, 0l, "Invalid position setting -- ignored"
endelse
end
endcase
if (n_elements(comment) ne 0) then handle_value, /set, pdefs.remarks, $
comment
; X axis settings
if (n_elements(xrange) eq 2) then pdefs.xrange = xrange $ $
else if keyword_set(xauto) then gr_autoscale, pdefs, /xaxis, /ignore
if (n_elements(xtitle) ne 0) then pdefs.xtitle = xtitle
if (n_elements(xlog) ne 0) then xtype = keyword_set(xlog)
; Standard IDL style settings
if (n_elements(xexact) ne 0) then begin
if keyword_set(xexact) then pdefs.xsty.idl = pdefs.xsty.idl or 1 $
else pdefs.xsty.idl = pdefs.xsty.idl and (not 1)
endif
if (n_elements(xextend) ne 0) then begin
if keyword_set(xextend) then pdefs.xsty.idl = pdefs.xsty.idl or 2 $
else pdefs.xsty.idl = pdefs.xsty.idl and (not 2)
endif
if (n_elements(xaxes) ne 0) then begin
if keyword_set(xaxes) then pdefs.xsty.idl = pdefs.xsty.idl or 4 $
else pdefs.xsty.idl = pdefs.xsty.idl and (not 4)
endif
if (n_elements(xbox) ne 0) then begin
if keyword_set(xbox) then pdefs.xsty.idl = pdefs.xsty.idl or 8 $
else pdefs.xsty.idl = pdefs.xsty.idl and (not 8)
endif
; Extra settings
if (n_elements(xminor) ne 0) then begin
if (keyword_set(xminor)) then pdefs.xsty.extra = pdefs.xsty.extra $
or 1 $
else pdefs.xsty.extra = pdefs.xsty.extra and (not 1)
endif
if (n_elements(xorigin) ne 0) then begin
if (keyword_set(xorigin)) then pdefs.xsty.extra = pdefs.xsty.extra $
or 2 $
else pdefs.xsty.extra = pdefs.xsty.extra and (not 2)
endif
; time labelling
if (n_elements(xtime) ne 0) then begin
if (not keyword_set(xtime)) then pdefs.xsty.time = pdefs.xsty.time $
and (not 1) $
else begin
pdefs.xsty.time = 1 + 2*xtime.unit + 8*xtime.max_unit
pdefs.xsty.tzero = xtime.zero
endelse
endif
; Grid
if (n_elements(xgrid) ne 0) then pdefs.xsty.grid = xgrid
; Y axis settings
if (n_elements(yrange) eq 2) then pdefs.yrange = yrange $ $
else if keyword_set(yauto) then gr_autoscale, pdefs, /yaxis, /ignore
if (n_elements(ytitle) ne 0) then pdefs.ytitle = ytitle
if (n_elements(ylog) ne 0) then ytype = keyword_set(ylog)
; Standard IDL style settings
if (n_elements(yexact) ne 0) then begin
if keyword_set(yexact) then pdefs.ysty.idl = pdefs.ysty.idl or 1 $
else pdefs.ysty.idl = pdefs.ysty.idl and (not 1)
endif
if (n_elements(yextend) ne 0) then begin
if keyword_set(yextend) then pdefs.ysty.idl = pdefs.ysty.idl or 2 $
else pdefs.ysty.idl = pdefs.ysty.idl and (not 2)
endif
if (n_elements(yaxes) ne 0) then begin
if keyword_set(yaxes) then pdefs.ysty.idl = pdefs.ysty.idl or 4 $
else pdefs.ysty.idl = pdefs.ysty.idl and (not 4)
endif
if (n_elements(ybox) ne 0) then begin
if keyword_set(ybox) then pdefs.ysty.idl = pdefs.ysty.idl or 8 $
else pdefs.ysty.idl = pdefs.ysty.idl and (not 8)
endif
; Extra settings
if (n_elements(yminor) ne 0) then begin
if (keyword_set(yminor)) then pdefs.ysty.extra = pdefs.ysty.extra $
or 1 $
else pdefs.ysty.extra = pdefs.ysty.extra and (not 1)
endif
if (n_elements(yorigin) ne 0) then begin
if (keyword_set(yorigin)) then pdefs.ysty.extra = pdefs.ysty.extra $
or 2 $
else pdefs.ysty.extra = pdefs.ysty.extra and (not 2)
endif
; time labelling
if (n_elements(ytime) ne 0) then begin
if (not keyword_set(ytime)) then pdefs.ysty.time = pdefs.ysty.time $
and (not 1) $
else begin
pdefs.ysty.time = 1 + 2*ytime.unit + 8*ytime.max_unit
pdefs.ysty.tzero = ytime.zero
endelse
endif
; Grid
if (n_elements(ygrid) ne 0) then pdefs.ysty.grid = ygrid
; Hardcopy options.
if (n_elements(h_orient) ne 0) then pdefs.hardset.orient = $
keyword_set(h_orient)
if (n_elements(h_colour) ne 0) then pdefs.hardset.colour = $
keyword_set(h_colour)
if (n_elements(h_eps) ne 0) then begin
pdefs.hardset.eps = keyword_set(h_eps)
if (keyword_set(h_eps) and n_elements(h_orient) eq 0) then $
pdefs.hardset.orient = 1b
endif
if (n_elements(h_xsize) ne 0) then pdefs.hardset.size(0) = h_xsize
if (n_elements(h_ysize) ne 0) then pdefs.hardset.size(1) = h_ysize
if (n_elements(h_xmargin) ne 0) then pdefs.hardset.off(0) = h_xmargin
if (n_elements(h_ymargin) ne 0) then pdefs.hardset.off(1) = h_ymargin
; Display or enter Graffer?
if (keyword_set(graffer)) then begin
gr_bin_save, pdefs
graffer, file
return
endif else if (keyword_set(display)) then begin
graff_colours, pdefs
gr_plot_object, pdefs
endif
if (keyword_set(ascii)) then gr_asc_save, pdefs $
else gr_bin_save, pdefs
end