Coyote Graphics Routines

Date: Fri Mar 27 12:14:20 2015

single page | use frames     summary     class     fields     routine details     file attributes

.\

cgpswindow.pro

Utilities, Graphics


This function is used to calculate the size of a PostScript window that has the same aspect ratio (ratio of height to width) as the current display graphics window. It creates the largest possible PostScript output window with the desired aspect ratio. This assures that PostScript output looks similar, if not identical, to normal graphics output on the display.

Examples

To create a PostScript output window with the same aspect ratio as the curently active display window, type:

pageInfo = cgPSWINDOW() SET_PLOT, 'PS' DEVICE, _Extra=pageInfo
To configure the PRINTER device:
pageInfo = cgPSWINDOW(/Printer, Fudge=0.25) SET_PLOT, 'PRINTER' DEVICE, _Extra=pageInfo

Author information

Author

FANNING SOFTWARE CONSULTING:

David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com

Copyright

Copyright (c) 1996-2014, Fanning Software Consulting, Inc.

History

Change History:

Written by: David W. Fanning, November 1996. Fixed a bug in which the YOFFSET was calculated incorrectly in Landscape mode. 12 Feb 97. Took out a line of code that wasn't being used. 14 Mar 97. Added correct units keyword to return structure. 29 JUN 98. DWF Fixed a bug in how landscape offsets were calculated. 19 JUL 99. DWF. Fixed a bug in the way margins were used to conform to my original conception of the program. 19 JUL 99. DWF. Added Landscape and Portrait fields to the return structure. 19 JUL 99. DWF. Added PageSize keyword, changed MARGIN keyword, and completely rewrote most of the intenal code. 9 FEB 2000. DWF. Fixed a bug in how I calculated the aspect ratio. 1 MAR 2000. DWF. Added PRINTER keyword to return proper offset values for the PRINTER device, where the offset location is not rotated. 1 MAR 2000. DWF. Added PRINTER fudge factors to take into account that printer offsets are calculated from the printable area of the paper, rather than the corner of the paper. 8 AUG 2000. DWF. Changed the default margin to 0.05 from 0.15. 29 Nov 2004, DWF. Added EUROPEAN keyword and set LANDSCAPE mode if window wider than higher as the default if LANDSCAPE is not set. 13 Dec 2010. DWF. Added ASPECTRATIO keyword to allow user-specified window aspect ratio. 13 Dec 2010. DWF. Depreciated EUROPEAN keyword in favor of METRIC. 31 Jan 2011. DWF. Now setting LANDSCAPE=0 if aspect GT 1 and not set otherwise. 19 Feb 2013. DWF. Renamed cgPSWIndow from PSWindow. 10 Feb 2014. DWF. Added SANE_OFFSETS keyword. 10 Feb 2014. DWF.

Routines

result = cgPSWINDOW_ASPECT( [aspectRatio] [, MARGIN=float] [, WINDOWASPECT=float])

This function produces a position vector in the output window, given a desired aspect ratio and window size.

result = cgPSWINDOW( [ASPECTRATIO=float] [, /CM] [, /EUROPEAN] [, FUDGE=float] [, /LANDSCAPE] [, MARGIN=float] [, /METRIC] [, PAGESIZE=string] [, /PRINTER] [, /SANE_OFFSETS] [, XFUDGE=float] [, YFUDGE=float])

This function returns a keyword structure that can be used to configure the PostScript device for graphics output.

Routine details

top cgPSWINDOW_ASPECT

result = cgPSWINDOW_ASPECT( [aspectRatio] [, MARGIN=float] [, WINDOWASPECT=float])

This function produces a position vector in the output window, given a desired aspect ratio and window size.

Return value

A four-element vector that can be used as the normal "position" vector to locate graphics in display output.

Parameters

aspectRatio in optional type=float default=1.0

The desired aspect ratio of the output "window" on the output device. The aspect ratio is calculated as the ratio height/width.

Keywords

MARGIN in optional type=float default=0.15

An optional margin to calculate around the edge of the output window. A number between 0.0 and 0.35.

WINDOWASPECT in optional type=float

The aspect ratio of the "window" the graphics output will be displayed in.

top cgPSWINDOW

result = cgPSWINDOW( [ASPECTRATIO=float] [, /CM] [, /EUROPEAN] [, FUDGE=float] [, /LANDSCAPE] [, MARGIN=float] [, /METRIC] [, PAGESIZE=string] [, /PRINTER] [, /SANE_OFFSETS] [, XFUDGE=float] [, YFUDGE=float])

This function returns a keyword structure that can be used to configure the PostScript device for graphics output.

Return value

The output value is a named structure defined like this:

pageInfo = {CGPSWINDOW_STRUCT, XSIZE:0.0, YSIZE:0.0, $ XOFSET:0.0, YOFFSET:0.0, INCHES:0, PORTRAIT:0, LANDSCAPE:0}
The units of the four size fields are inches unless the CM or METRIC keywords are set. The output can be used to immediately configure the PostScript or Printer device, like this:
Set_Plot, 'PS' ; or 'PRINTER' Device, _Extra=pageInfo

Keywords

ASPECTRATIO in optional type=float default=1.0

The desired aspect ratio of the output "window" on the output device. The aspect ratio is calculated as the ratio height/width.

CM in optional type=boolean default=0

Set this keyword to return sizes and offsets in centimeters instead of inches.

EUROPEAN in optional type=boolean default=0

A depreciated keyword. Use Metric instead.

FUDGE in optional type=float

A quick way to set symetrical XFUDGE and YFUDGE factors. If this keyword is set to a value, XFUDGE and YFUDGE keywords are set to the same value. Fudge factors are used only with some printers and generally only when output is being sent to the PRINTER device. See the description of the XFudge and YFudge keywords for additional information.

LANDSCAPE in optional type=boolean default=0

Set this keyword to return sizes and offsets in landscape mode.

MARGIN in optional type=float default=0.15

An optional margin to calculate around the edge of the output window. A number between 0.0 and 0.35.

METRIC in optional type=boolean default=0

Set this keyword to change the Pagesize to A4 and set the CM keyword for metric or European measurements.

PAGESIZE in optional type=string default=LETTER

Set this keyword to a string indicating the type of PostScript page size you want. Allowed values are "LETTER", "LEGAL", and "A4".

PRINTER in optional type=boolean default=0

Set this keyword to produce keyword values appropriate for the PRINTER device.

SANE_OFFSETS in optional type=boolean default=0.0

Configuring the PostScript device when in Landscape mode is pretty much insane. The problem is the PostScript page rotates and the X and Y offsets change directions, although the X and Y sizes do not. Nevertheless, this is how it is done, so normally these insane, mixed up values are returned so they can be passed directly to the PostScript device. Coyote Graphics routines, however, reply on cgPS_Config to configure the PostScript device, and this routine uses sane offset values, which are *always* calculated from the lower-left corner of the display window, no matter how the page is rotated. If you are passing these values into cgPS_Config, you want to set this keyword.

XFUDGE in optional type=float

Printers calculate the offset point from the printable edge of the paper (sometimes), rather from the corner of the paper. For example, on my Lexmark printer, both X and Y offsets are calculated from a point 0.25 inches in from the edge. This keyword allows you to set a "fudge" factor that will be subtracted from the XOFFSET that is returned to the user. This allows you to create output that is centered on the page. The fudge factor should be in the same units as the returned size and offset values.

YFUDGE in optional type=float

Printers calculate the offset point from the printable edge of the paper (sometimes), rather from the corner of the paper. For example, on my Lexmark printer, both X and Y offsets are calculated from a point 0.25 inches in from the edge. This keyword allows you to set a "fudge" factor that will be subtracted from the YOFFSET that is returned to the user. This allows you to create output that is centered on the page. The fudge factor should be in the same units as the returned size and offset values.

File attributes

Modification date: Fri Mar 27 11:07:38 2015
Lines: 389
Docformat: rst rst