casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
casa::PSDriver Class Reference

Low level interface between PSPixelCanvas{ColorTable} and PostScript. More...

#include <PSDriver.h>

Classes

struct  PageInfo
 The PageInfo struct is used internally to supply descriptions of the various page types. More...
 
class  PSInfo
 PSInfo is used to supply comment fields for the PostScript header and other information that needs to be available when the PSDriver object is created. More...
 
class  PSState
 Holds our copy of the current transformation matrix. More...
 

Public Types

enum  ColorSpace {
  UNKNOWNSPACE,
  INDEXED,
  GRAY,
  RGB,
  HSV,
  HSB
}
 The various color spaces PSDriver knows about. More...
 
enum  LineStyle {
  UNKNOWNSTYPE,
  SOLID,
  DASHED,
  DASHDASH
}
 Different line types that can be drawn. More...
 
enum  {
  NUMCOLORS,
  BITSPERCOMPONENT
}
 Constants describing the the length of the indexed color table and the number of bits per color component. More...
 
enum  Dimension {
  POINTS,
  INCHES,
  MM
}
 
enum  Layout {
  PORTRAIT,
  LANDSCAPE,
  EPS,
  EPS_PORTRAIT,
  EPS_LANDSCAPE
}
 
enum  ImageOptions {
  NOIMGOPTS,
  SMOOTH
}
 
enum  MediaSize {
  USERPAGE,
  LETTER,
  NA_LETTER,
  LEGAL,
  NA_LEGAL,
  NA_10X13_ENVELOPE,
  NA_9X12_ENVELOPE,
  NA_NUMBER_10_ENVELOPE,
  NA_7X9_ENVELOPE,
  NA_9X11_ENVELOPE,
  NA_10X14_ENVELOPE,
  NA_6X9_ENVELOPE,
  NA_10X15_ENVELOPE,
  A,
  B,
  C,
  D,
  E,
  ISO_A0,
  ISO_A1,
  ISO_A2,
  ISO_A3,
  ISO_A4,
  A4,
  ISO_A5,
  ISO_A6,
  ISO_A7,
  ISO_A8,
  ISO_A9,
  ISO_A10,
  ISO_B0,
  ISO_B1,
  ISO_B2,
  ISO_B3,
  ISO_B4,
  ISO_B5,
  ISO_B6,
  ISO_B7,
  ISO_B8,
  ISO_B9,
  ISO_B10,
  ISO_C0,
  ISO_C1,
  ISO_C2,
  ISO_C3,
  ISO_C4,
  ISO_C5,
  ISO_C6,
  ISO_C7,
  ISO_C8,
  ISO_DESIGNATED,
  JIS_B0,
  JIS_B1,
  JIS_B2,
  JIS_B3,
  JIS_B4,
  JIS_B5,
  JIS_B6,
  JIS_B7,
  JIS_B8,
  JIS_B9,
  JIS_B10
}
 
enum  TextAlign {
  AlignCenter,
  AlignLeft,
  AlignTop,
  AlignRight,
  AlignBottom,
  AlignTopLeft,
  AlignTopRight,
  AlignBottomLeft,
  AlignBottomRight
}
 
typedef struct
casa::PSDriver::PageInfo 
pageinfo_
 The PageInfo struct is used internally to supply descriptions of the various page types. More...
 

Public Member Functions

 PSDriver ()
 Generic PostScript. More...
 
 PSDriver (std::ostream &out)
 
 PSDriver (const char *filename)
 
 PSDriver (std::ostream &out, const MediaSize, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 PSDriver (const casacore::String &fname, const MediaSize, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 PSDriver (const char *fname, const MediaSize, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 PSDriver (std::ostream &out, const Dimension dim, const float x0, const float y0, const float x1, const float y1, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 PSDriver (const casacore::String &outname, const Dimension dim, const float x0, const float y0, const float x1, const float y1, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 PSDriver (const casacore::String &outname, const MediaSize, const Dimension dim, const float x0, const float y0, const float x1, const float y1, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 PSDriver (const char *outname, const Dimension dim, const float x0, const float y0, const float x1, const float y1, const Layout=PORTRAIT, PSInfo *info=NULL)
 
 ~PSDriver ()
 
void setColorSpace (const ColorSpace)
 Set/get desired color space. More...
 
ColorSpace colorSpace () const
 
void setColor (const float rh, const float gs, const float bv)
 Set current color used for text and vectors. More...
 
void setColor (const float color)
 Set color value for indexed and gray scale modes. More...
 
void setBackgroundColor (const float rh, const float gs, const float bv, const ColorSpace=RGB)
 Color to be used for dashes. More...
 
void setBackgroundColor (const float color, const ColorSpace=INDEXED)
 Set color value for indexed and gray scale modes. More...
 
void setIndexColor (const float indx)
 Change color space then set color. More...
 
void setRGBColor (const float r, const float g, const float b)
 
void setHSVColor (const float h, const float s, const float v)
 
void setHSBColor (const float h, const float s, const float b)
 
void storeColors (const int start, const int len, const float *r, const float *g, const float *b)
 Load color tables with contents of a, b & c. More...
 
void storeColorValues (const int len, const int *indexes, const float *a, const float *b, const float *c)
 Scatter load the colortable. More...
 
void storeColor (const int index, const float r, const float g, const float b)
 Store 1 color. More...
 
void setLinearRamps (const int ncolors)
 Load linear ramps (0..1.0) into the first ncolors entries. More...
 
void translate (const float x, const float y)
 Current transform matrix is changed by the given values, not replaced. More...
 
void scale (const float x, const float y)
 Change scale by x/y. More...
 
void rotate (const float degrees)
 Rotate by # degrees. More...
 
void setDashLength (const float length)
 Set the length of dashes. More...
 
void drawImage (const float x0, const float y0, const int width, const int height, const float xsize, const float ysize, const casacore::uShort *data, const int bpc=0, const ColorSpace=INDEXED, const int imageopts=0)
 
void gsave ()
 Save/restore graphics state. More...
 
void grestore ()
 
void setLineStyle (const LineStyle)
 
void lineWidth (const float w)
 w = 1.0 means 0.005". More...
 
void moveTo (const float x, const float y)
 
void lineTo (const float x, const float y, const int stroke=1)
 
void drawPolygon (const int len, const float *x, const float *y, const int fill=0)
 
void drawPolyline (const int len, const float *x, const float *y, const int close=0, const int fill=0)
 
void drawLine (const float x0, const float y0, const float x1, const float y1)
 
void drawLines (const int len, const float *x1, const float *y1, const float *x2, const float *y2)
 
void drawRectangle (const float x0, const float y0, const float x1, const float y1, const int fill=0)
 
void drawFilledRectangle (const float x0, const float y0, const float x1, const float y1)
 
void drawPoint (const float x, const float y, const float radius=1.0)
 
void drawPoints (const int len, const float *x, const float *y, const float radius=1.0)
 
void drawColoredPoints (const int len, const float *x, const float *y, const float *colors, const float radius=1.0)
 
void drawText (const float x, const float y, const char *str, const TextAlign algn=AlignBottomLeft, const float angle=0)
 
br><strong>Caution:</strong><em>  PSDriver just passes the name to the output file;

It can't know whether the font really exists on the output device;
Set font using current font scaling. More...

 
void setFont (const char *fn)
 
void findFont (const char *fn, const float scale)
 Use font with supplied scaling. More...
 
void setDefaultFontScale (const float scl)
 Set/Get font scaling used with setFont. More...
 
float getDefaultFontScale () const
 
void pageSize (float &width, float &height, const casacore::Bool userCoords=true)
 
casacore::Bool getBoundingBox (float &x0, float &y0, float &x1, float &y1, const casacore::Bool userCoords=true) const
 Return bounding box. More...
 
casacore::Bool haveBoundingBox () const
 Returns true if bounding box size was given to the constructor. More...
 
void comment (const char *)
 Put a comment in the output file. More...
 
void comment (const casacore::String &)
 
void pushMatrix ()
 Push/pop transform matrix. More...
 
void popMatrix ()
 
void newPage ()
 
void flush ()
 Flush the output. More...
 
void finish ()
 Done. More...
 
void clipRect (const float x0, const float y0, const float width, const float height)
 Set clipping rectangle. More...
 
void toPoints (const float xin, const float yin, float &xout, float &yout, const casacore::Bool absolute=true) const
 Do forward or reverse transformation on a point. More...
 
void fromPoints (const float xin, const float yin, float &xout, float &yout, const casacore::Bool absolute=true) const
 
const char * dimensionToString () const
 
Dimension dimension () const
 
casacore::Bool isEPS () const
 Is the output EPS? Portrait? More...
 
casacore::Bool isPortrait () const
 

Static Public Member Functions

static int bytesToAscii85 (const char *in, const int inlength, char *out)
 
static int uShorts8ToAscii85 (const casacore::uShort *in, const int inlength, char *out)
 
static int uShorts12ToAscii85 (const casacore::uShort *in, const int width, const int height, char *out)
 Converts in to ASCII85 bytes using only lower 12 bits of each integer. More...
 
static char * encodeUShorts (const int width, const int height, int &bpc, const casacore::uShort *data, int &outlen)
 Encode data as ASCII85 chars. More...
 
static float pointsToInches (const float in)
 Miscellaneous functions to convert between typical scalings. More...
 
static float pointsToMM (const float in)
 
static float inchesToPoints (const float in)
 
static float mmToPoints (const float in)
 
static float toPoints (const float in, const Dimension indem)
 
static float fromPoints (const float in, const Dimension indem)
 
static const char * dimensionToString (const PSDriver::Dimension dim)
 Return a string representation of a dimension. More...
 
static const PSDriver::PageInfopageInfo (const PSDriver::MediaSize)
 Given a paper type, return a pointer to its description. More...
 
static const PSDriver::PageInfogetPageInfo (const int indx)
 Return page description for index indx. More...
 
static const PSDriver::PageInfolookupPageInfo (const char *name)
 Lookup for a page description using the name field. More...
 
static int numPageTypes ()
 

Private Types

enum  { STATESTACKLENGTH }
 Length of internal state(transform) stack. More...
 

Private Member Functions

void newPath ()
 
void stroke ()
 
void closePath ()
 
void init (std::ostream &output, const ColorSpace cs, const PageInfo *, const Layout, PSInfo *)
 
void initname (const casacore::String &name, const ColorSpace cs, const PageInfo *, const Layout, PSInfo *)
 
void bbCheck (const float x, const float y, const casacore::Bool userCoords=true)
 Compare x/y to current bounding box. More...
 
void bbCheck ()
 
void setCurrXY (const float x, const float y, const casacore::Bool userCoords=true)
 
void getCurrXY (float &x, float &y, const casacore::Bool userCoords=true)
 
void startDocument ()
 
void emitHeader ()
 Code writers. More...
 
void emitProlog ()
 
void emitTrailer ()
 
void emitShowPage (const int force=0)
 
void emitPageNum ()
 
void emitSetup ()
 
void emitColorSpace (const ColorSpace)
 
void emitLineStyle (const LineStyle)
 
void emitDashLength (const float length)
 
void emitLineWidth (const float w)
 
void emitMoveTo (const float x, const float y)
 
void emitLineTo (const float x, const float y, const int stroke=1)
 
void emitPolyline (const int len, const float *x, const float *y, const int close, const int fill)
 
void emitPolygon (const int len, const float *x, const float *y, const int fill)
 
void emitLine (const float x0, const float y0, const float x1, const float y1)
 
void emitLines (const int len, const float *x1, const float *y1, const float *x2, const float *y2)
 
void emitRectangle (const float x, const float y, const float width, const float height, const int fill)
 
void emitPoint (const float x, const float y, const float radius=1.0)
 
void emitPoints (const int len, const float *x, const float *y, const float radius=1.0)
 
void emitRotate (const float degrees)
 Rotate by degrees. More...
 
void emitScale (const float x, const float y)
 Scale. More...
 
void emitTranslate (const float x, const float y)
 Change origin. More...
 
void emitFindFont (const char *fn, const float scale)
 
void emitText (const float x, const float y, const char *str, const TextAlign=AlignBottomLeft, const float angle=0)
 Draw text starting at point x, y. More...
 
void emitString (const char *str)
 Just throw a string on the stack and leave it there. More...
 
void emitImage (const float matrix[6], const int width, const int height, const int bpc, const int smooth, const char *ascii85, const int len, const ColorSpace=INDEXED)
 Draw a width x height PS image. More...
 
void emitStoreColors (const int start, const int len, const float *a, const float *b, const float *c)
 Load color tables with contents of a, b & c. More...
 
void emitStoreColorValues (const int len, const int *indexes, const float *a, const float *b, const float *c)
 Load color tables given an array of colors and their corresponding indexes. More...
 
void emitStoreColors (const int color, const int start, const int len, const float *ary)
 Internal helper function. More...
 
void emitStoreColor (const int index, const float r, const float g, const float b)
 Load one value into color table. More...
 
void emitSetColor (const ColorSpace cs, const int index)
 Set curren`t color. More...
 
void emitSetColor (const ColorSpace cs, const float a, const float b, const float c)
 
void emitSetLinearRamps (const int ncolors)
 Load color first ncolors entries in the tables with linear ramps scaled 0..1. More...
 
void emitGSave ()
 
void emitGRestore ()
 
void emitPushMatrix ()
 
void emitPopMatrix ()
 
void emitClipRect (const float x0, const float y0, const float width, const float height)
 
void emitBackgroundColor (const float a, const float b, const float c, const ColorSpace cs)
 
void emitBoundingBox ()
 Write value of bounding box to output. More...
 
void pushState ()
 
void popState ()
 

Private Attributes

int statestackindex_
 
PSState state_
 
PSState statestack_ [STATESTACKLENGTH]
 
std::ostream * out
 
std::fstream * mystream_
 
ColorSpace colorSpace_
 
Dimension dimension_
 
casacore::Bool portrait_
 
casacore::Bool eps_
 
LineStyle lineStyle_
 
float defaultFontSize_
 
float xscale_
 
float yscale_
 
float bbx0_
 Bounding box in points. More...
 
float bby0_
 
float bbx1_
 
float bby1_
 
casacore::Bool boxCheck0_
 
casacore::Bool haveBoundingBox_
 
casacore::Bool checkBoundingBox_
 
float xll_
 user coords. More...
 
float yll_
 
float xur_
 
float yur_
 
float clipXll_
 Clipping rectangle in points. More...
 
float clipXur_
 
float clipYll_
 
float clipYur_
 
unsigned int pageNum_
 
int finished_
 
PSInfoinfo_
 

Detailed Description

Low level interface between PSPixelCanvas{ColorTable} and PostScript.

Intended use:

Internal

Synopsis

PSDriver takes graphics requests from PSPixelCanvas and PSPixelCanvasColorTable and generates PostScript code. It might be thought of as playing an analogous role to what Xlib does for the X11PixelCanvas{ColorTable}. It could be used separately, but mostly programers will just create a PSDriver object to pass to PSPixelCanvas{ColorTable}.

While there are many constructors, PSDrivers will probably most frequently be created using something like:

PSdriver *ps = new PSDriver("filename", PSDriver::LETTER,

If it were desired to use RGB colormode rather than INDEXED, the following could be added.

ps->setColorSpace(PSDriver::RGB);

PSDriver is logically split into two sections. The 'upper' level contains public functions, such as drawLine(). These do various amounts of bookkeeping, such as bounding box calculations, then call the 'lower' level routines, typically with names starting with emit. (eg. emitLine() in this example).

There are many public routines that will rarely be called from outside of PSDriver. Typical of these are the various xxxToAscii85 routines that are used internally to generate image data.

Thrown Exceptions

does not currently explicitly throw any exceptions.

To Do

  1. EPS support is preliminary.
  2. Vertical text justification doesn't look correct, presumably because the character's bounding box includes interline space.
  3. No display list support.
  4. Clipping support is disabled since it is currently possible to only reduce the size of the clipping path, not replace it.
  5. Points are drawn as filled circles of fixed size.

Notes:

  1. It is possible to switch between Index, RGB and HSV modes at will.
  2. The length of the color table is 4096 entries.
  3. PostScript doesn't deal with pixels.
  4. The transform matrix affects virtually everything.
  5. Font names must be known by the PostScript interpreter.

Definition at line 109 of file PSDriver.h.

Member Typedef Documentation

The PageInfo struct is used internally to supply descriptions of the various page types.

Member Enumeration Documentation

anonymous enum

Constants describing the the length of the indexed color table and the number of bits per color component.

Enumerator
NUMCOLORS 
BITSPERCOMPONENT 

Definition at line 116 of file PSDriver.h.

anonymous enum
private

Length of internal state(transform) stack.

Enumerator
STATESTACKLENGTH 

Definition at line 764 of file PSDriver.h.

The various color spaces PSDriver knows about.

Enumerator
UNKNOWNSPACE 
INDEXED 
GRAY 
RGB 
HSV 
HSB 

Definition at line 112 of file PSDriver.h.

Enumerator
POINTS 
INCHES 
MM 

Definition at line 117 of file PSDriver.h.

Options for drawImage.
SMOOTH Pixels are interpolated. Not supported by all
interpreters. Old versions of ghostscript may core
dump if this is selected.
Enumerator
NOIMGOPTS 
SMOOTH 

Definition at line 128 of file PSDriver.h.

Enumerator
PORTRAIT 
LANDSCAPE 
EPS 
EPS_PORTRAIT 
EPS_LANDSCAPE 

Definition at line 118 of file PSDriver.h.

Different line types that can be drawn.

Enumerator
UNKNOWNSTYPE 
SOLID 
DASHED 
DASHDASH 

Definition at line 114 of file PSDriver.h.

Enumerator
USERPAGE 

USERPAGE is used internally.

It is not a valid media type.

LETTER 

The following lists the known media types (paper sizes).

NA_LETTER 
LEGAL 
NA_LEGAL 
NA_10X13_ENVELOPE 
NA_9X12_ENVELOPE 
NA_NUMBER_10_ENVELOPE 
NA_7X9_ENVELOPE 
NA_9X11_ENVELOPE 
NA_10X14_ENVELOPE 
NA_6X9_ENVELOPE 
NA_10X15_ENVELOPE 
A 
B 
C 
D 
E 
ISO_A0 
ISO_A1 
ISO_A2 
ISO_A3 
ISO_A4 
A4 
ISO_A5 
ISO_A6 
ISO_A7 
ISO_A8 
ISO_A9 
ISO_A10 
ISO_B0 
ISO_B1 
ISO_B2 
ISO_B3 
ISO_B4 
ISO_B5 
ISO_B6 
ISO_B7 
ISO_B8 
ISO_B9 
ISO_B10 
ISO_C0 
ISO_C1 
ISO_C2 
ISO_C3 
ISO_C4 
ISO_C5 
ISO_C6 
ISO_C7 
ISO_C8 
ISO_DESIGNATED 
JIS_B0 
JIS_B1 
JIS_B2 
JIS_B3 
JIS_B4 
JIS_B5 
JIS_B6 
JIS_B7 
JIS_B8 
JIS_B9 
JIS_B10 

Definition at line 130 of file PSDriver.h.

Enumerator
AlignCenter 
AlignLeft 
AlignTop 
AlignRight 
AlignBottom 
AlignTopLeft 
AlignTopRight 
AlignBottomLeft 
AlignBottomRight 

Definition at line 148 of file PSDriver.h.

Constructor & Destructor Documentation

casa::PSDriver::PSDriver ( )

Generic PostScript.

Arguments to the various constructors:

  • out is an ostream that the PostScript code is written to.
  • fname it the name of the output file to be written to.
  • MediaSize is the paper size. Each paper size has default margins.
  • Dimension is POINTS, INCHES or MM. Describes values of x0,y0,x1,y1.
  • x0,y0,x1,y1 are used instead of MediaSize to explicitly give the lower left and upper right corners of the drawing surface.
  • Layout is PORTRAIT or LANDSCAPE.
  • PSInfo supplies optional header comments or margins. Optional argument.

INDEXED, PORTRAIT to a default file.

casa::PSDriver::PSDriver ( std::ostream &  out)
casa::PSDriver::PSDriver ( const char *  filename)
casa::PSDriver::PSDriver ( std::ostream &  out,
const MediaSize  ,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( const casacore::String fname,
const MediaSize  ,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( const char *  fname,
const MediaSize  ,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( std::ostream &  out,
const Dimension  dim,
const float  x0,
const float  y0,
const float  x1,
const float  y1,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( const casacore::String outname,
const Dimension  dim,
const float  x0,
const float  y0,
const float  x1,
const float  y1,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( const casacore::String outname,
const MediaSize  ,
const Dimension  dim,
const float  x0,
const float  y0,
const float  x1,
const float  y1,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( const char *  outname,
const Dimension  dim,
const float  x0,
const float  y0,
const float  x1,
const float  y1,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::~PSDriver ( )

Member Function Documentation

void casa::PSDriver::bbCheck ( const float  x,
const float  y,
const casacore::Bool  userCoords = true 
)
private

Compare x/y to current bounding box.

x and y are in current user coordinates unless userCoords is false in which case they have already been transformed.

void casa::PSDriver::bbCheck ( )
private
static int casa::PSDriver::bytesToAscii85 ( const char *  in,
const int  inlength,
char *  out 
)
static
The following, while public, will almost will almost
never be called from outside of PSDriver.

Routines to encode non negative binary numbers in ASCII85 format. There will be upto 5/4 as many output characters as input bytes. Returns the number of bytes written to out.

void casa::PSDriver::clipRect ( const float  x0,
const float  y0,
const float  width,
const float  height 
)

Set clipping rectangle.

Subsequent calls can only make the clipping rectangle smaller.

void casa::PSDriver::closePath ( )
private
ColorSpace casa::PSDriver::colorSpace ( ) const
inline

Definition at line 256 of file PSDriver.h.

References colorSpace_.

void casa::PSDriver::comment ( const char *  )

Put a comment in the output file.

The comment may include newlines.

void casa::PSDriver::comment ( const casacore::String )
Dimension casa::PSDriver::dimension ( ) const
inline

Definition at line 538 of file PSDriver.h.

References dimension_.

static const char* casa::PSDriver::dimensionToString ( const PSDriver::Dimension  dim)
static

Return a string representation of a dimension.

const char* casa::PSDriver::dimensionToString ( ) const
inline

Definition at line 535 of file PSDriver.h.

References dimension_.

void casa::PSDriver::drawColoredPoints ( const int  len,
const float *  x,
const float *  y,
const float *  colors,
const float  radius = 1.0 
)
void casa::PSDriver::drawFilledRectangle ( const float  x0,
const float  y0,
const float  x1,
const float  y1 
)
void casa::PSDriver::drawImage ( const float  x0,
const float  y0,
const int  width,
const int  height,
const float  xsize,
const float  ysize,
const casacore::uShort data,
const int  bpc = 0,
const ColorSpace  = INDEXED,
const int  imageopts = 0 
)
Draw an Image
x0,y0 Image is drawn with lower left corner at x0, y0.
(In current user coordinates).
width,height Size of source image in elements.
xsize,ysize Size of output image. (Eg. If current user
coordinates were in inches, a size of 2 would create
a two inch output square regardless of the size of the
input image).
data casacore::Data for an image that is width pixels wide by
height pixels high. The actual length of the array
depends on the ColorSpace argument:
INDEXED: The array contains width*height
indexes in the range 0.. 2^bpc -1.
(0..255 or 0..4095).
RGB or HSV: The array contains width*height
RGB (HSV) triples in the range
0..255 for bpc=8 or 0..1023 otherwise.
The length of the array is
width*height*3.
bpc Used to determing how data is encoded.
If (0 < bpc <= 8) 8 bit encoding is used.
If bpc > 8, 12 bit encoding is used.
If bpc <= 0, the array is scanned to determine the
encoding method.
ColorSpace Whether image is INDEXED, RGB or HSV.
imageopts Bitwise OR of IMAGEOPTS.
Currently only whether to smooth image.
void casa::PSDriver::drawLine ( const float  x0,
const float  y0,
const float  x1,
const float  y1 
)
void casa::PSDriver::drawLines ( const int  len,
const float *  x1,
const float *  y1,
const float *  x2,
const float *  y2 
)
void casa::PSDriver::drawPoint ( const float  x,
const float  y,
const float  radius = 1.0 
)
void casa::PSDriver::drawPoints ( const int  len,
const float *  x,
const float *  y,
const float  radius = 1.0 
)
void casa::PSDriver::drawPolygon ( const int  len,
const float *  x,
const float *  y,
const int  fill = 0 
)
void casa::PSDriver::drawPolyline ( const int  len,
const float *  x,
const float *  y,
const int  close = 0,
const int  fill = 0 
)
void casa::PSDriver::drawRectangle ( const float  x0,
const float  y0,
const float  x1,
const float  y1,
const int  fill = 0 
)
void casa::PSDriver::drawText ( const float  x,
const float  y,
const char *  str,
const TextAlign  algn = AlignBottomLeft,
const float  angle = 0 
)

br><strong>Caution:</strong><em>  PSDriver just passes the name to the output file;

It can't know whether the font really exists on the output device;
Set font using current font scaling.

Text

Display a line of text. Tabs, newlines, etc. are not handled.

void casa::PSDriver::emitBackgroundColor ( const float  a,
const float  b,
const float  c,
const ColorSpace  cs 
)
private
void casa::PSDriver::emitBoundingBox ( )
private

Write value of bounding box to output.

void casa::PSDriver::emitClipRect ( const float  x0,
const float  y0,
const float  width,
const float  height 
)
private
void casa::PSDriver::emitColorSpace ( const ColorSpace  )
private
void casa::PSDriver::emitDashLength ( const float  length)
private
void casa::PSDriver::emitFindFont ( const char *  fn,
const float  scale 
)
private
void casa::PSDriver::emitGRestore ( )
private
void casa::PSDriver::emitGSave ( )
private
void casa::PSDriver::emitHeader ( )
private

Code writers.

void casa::PSDriver::emitImage ( const float  matrix[6],
const int  width,
const int  height,
const int  bpc,
const int  smooth,
const char *  ascii85,
const int  len,
const ColorSpace  = INDEXED 
)
private

Draw a width x height PS image.

matrix casacore::Matrix to convert between user & image space. width, height size of input image in pixels. bpc bits per color component. (8 or 12) smooth 0 - no smoothing, 1 - smooth pixels. ghostscript may core dump if not 0. ascii85 data encoded as ASCII85 chars. len length of data array.

void casa::PSDriver::emitLine ( const float  x0,
const float  y0,
const float  x1,
const float  y1 
)
private
void casa::PSDriver::emitLines ( const int  len,
const float *  x1,
const float *  y1,
const float *  x2,
const float *  y2 
)
private
void casa::PSDriver::emitLineStyle ( const LineStyle  )
private
void casa::PSDriver::emitLineTo ( const float  x,
const float  y,
const int  stroke = 1 
)
private
void casa::PSDriver::emitLineWidth ( const float  w)
private
void casa::PSDriver::emitMoveTo ( const float  x,
const float  y 
)
private
void casa::PSDriver::emitPageNum ( )
private
void casa::PSDriver::emitPoint ( const float  x,
const float  y,
const float  radius = 1.0 
)
private
void casa::PSDriver::emitPoints ( const int  len,
const float *  x,
const float *  y,
const float  radius = 1.0 
)
private
void casa::PSDriver::emitPolygon ( const int  len,
const float *  x,
const float *  y,
const int  fill 
)
private
void casa::PSDriver::emitPolyline ( const int  len,
const float *  x,
const float *  y,
const int  close,
const int  fill 
)
private
void casa::PSDriver::emitPopMatrix ( )
private
void casa::PSDriver::emitProlog ( )
private
void casa::PSDriver::emitPushMatrix ( )
private
void casa::PSDriver::emitRectangle ( const float  x,
const float  y,
const float  width,
const float  height,
const int  fill 
)
private
void casa::PSDriver::emitRotate ( const float  degrees)
private

Rotate by degrees.

void casa::PSDriver::emitScale ( const float  x,
const float  y 
)
private

Scale.

(new scale = <old scale>="">*<new scale>="">.

void casa::PSDriver::emitSetColor ( const ColorSpace  cs,
const int  index 
)
private

Set curren`t color.

void casa::PSDriver::emitSetColor ( const ColorSpace  cs,
const float  a,
const float  b,
const float  c 
)
private
void casa::PSDriver::emitSetLinearRamps ( const int  ncolors)
private

Load color first ncolors entries in the tables with linear ramps scaled 0..1.

void casa::PSDriver::emitSetup ( )
private
void casa::PSDriver::emitShowPage ( const int  force = 0)
private
void casa::PSDriver::emitStoreColor ( const int  index,
const float  r,
const float  g,
const float  b 
)
private

Load one value into color table.

void casa::PSDriver::emitStoreColors ( const int  start,
const int  len,
const float *  a,
const float *  b,
const float *  c 
)
private

Load color tables with contents of a, b & c.

Typically, a holds red, b holds green & c holds blue. Values should be in the range (0..1).

void casa::PSDriver::emitStoreColors ( const int  color,
const int  start,
const int  len,
const float *  ary 
)
private

Internal helper function.

void casa::PSDriver::emitStoreColorValues ( const int  len,
const int *  indexes,
const float *  a,
const float *  b,
const float *  c 
)
private

Load color tables given an array of colors and their corresponding indexes.

Much more effecient if indexes are consecutive.

void casa::PSDriver::emitString ( const char *  str)
private

Just throw a string on the stack and leave it there.

void casa::PSDriver::emitText ( const float  x,
const float  y,
const char *  str,
const TextAlign  = AlignBottomLeft,
const float  angle = 0 
)
private

Draw text starting at point x, y.

Newlines, tabs, etc. are not handled.

void casa::PSDriver::emitTrailer ( )
private
void casa::PSDriver::emitTranslate ( const float  x,
const float  y 
)
private

Change origin.

static char* casa::PSDriver::encodeUShorts ( const int  width,
const int  height,
int &  bpc,
const casacore::uShort data,
int &  outlen 
)
static

Encode data as ASCII85 chars.

casacore::Function return is an array of chars. (use delete [] to free). outlen is set to the number of bytes in the array. On input, if bpc is 8, data is treated as containing 1 byte per element. If bpc is 12, data is assumed to contain 12 bits/element. If bpc is 0, the array is scanned. On return, bpc is set the the value actually used.

void casa::PSDriver::findFont ( const char *  fn,
const float  scale 
)

Use font with supplied scaling.

void casa::PSDriver::finish ( )

Done.

Called by the destructor.

void casa::PSDriver::flush ( )

Flush the output.

static float casa::PSDriver::fromPoints ( const float  in,
const Dimension  indem 
)
static
void casa::PSDriver::fromPoints ( const float  xin,
const float  yin,
float &  xout,
float &  yout,
const casacore::Bool  absolute = true 
) const
inline

Definition at line 526 of file PSDriver.h.

References casa::PSDriver::PSState::fromPoints(), and state_.

casacore::Bool casa::PSDriver::getBoundingBox ( float &  x0,
float &  y0,
float &  x1,
float &  y1,
const casacore::Bool  userCoords = true 
) const

Return bounding box.

Return is true if a bounding box was declared initially. Otherwise, false and the current value of the bounding box will be returned. If userCoords is true, values are in current user coordinates. Otherwise, transformed coords.

void casa::PSDriver::getCurrXY ( float &  x,
float &  y,
const casacore::Bool  userCoords = true 
)
inlineprivate

Definition at line 619 of file PSDriver.h.

References casa::PSDriver::PSState::getXY(), and state_.

float casa::PSDriver::getDefaultFontScale ( ) const
inline

Definition at line 414 of file PSDriver.h.

References defaultFontSize_.

static const PSDriver::PageInfo* casa::PSDriver::getPageInfo ( const int  indx)
static

Return page description for index indx.

void casa::PSDriver::grestore ( )
void casa::PSDriver::gsave ( )

Save/restore graphics state.

casacore::Bool casa::PSDriver::haveBoundingBox ( ) const
inline

Returns true if bounding box size was given to the constructor.

Definition at line 438 of file PSDriver.h.

References haveBoundingBox_.

static float casa::PSDriver::inchesToPoints ( const float  in)
inlinestatic

Definition at line 507 of file PSDriver.h.

void casa::PSDriver::init ( std::ostream &  output,
const ColorSpace  cs,
const PageInfo ,
const Layout  ,
PSInfo  
)
private
void casa::PSDriver::initname ( const casacore::String name,
const ColorSpace  cs,
const PageInfo ,
const Layout  ,
PSInfo  
)
private
casacore::Bool casa::PSDriver::isEPS ( ) const
inline

Is the output EPS? Portrait?

Definition at line 544 of file PSDriver.h.

References eps_.

casacore::Bool casa::PSDriver::isPortrait ( ) const
inline

Definition at line 547 of file PSDriver.h.

References portrait_.

void casa::PSDriver::lineTo ( const float  x,
const float  y,
const int  stroke = 1 
)
void casa::PSDriver::lineWidth ( const float  w)

w = 1.0 means 0.005".

static const PSDriver::PageInfo* casa::PSDriver::lookupPageInfo ( const char *  name)
static

Lookup for a page description using the name field.

static float casa::PSDriver::mmToPoints ( const float  in)
inlinestatic

Definition at line 510 of file PSDriver.h.

void casa::PSDriver::moveTo ( const float  x,
const float  y 
)
void casa::PSDriver::newPage ( )
void casa::PSDriver::newPath ( )
private
Similar to the public drawImage but uses a transform matrix instead of
position and scaling.
imagematrix 6 element array that defines transformation
from user space to image space:
m = [ a b c d tx ty ]
x' = ax + cy + tx
y' = bx + dy + ty
The transformation is such that [ width 0 0 height 0 0] will
map the image into a unit square which would then be scaled
by the current scale() values.
To invert the image, use: [ width 0 0 -height 0 height].
If imagematrix is NULL, the image will be mapped into the
unit square.
bpc is as above.
If smooth is 0, no smoothing is done. Otherwise, pixels are
interpolated.
Caution: This routine bypasses boundary box checks! If
BB checks are not important, then this routine could be public.
static int casa::PSDriver::numPageTypes ( )
static
static const PSDriver::PageInfo* casa::PSDriver::pageInfo ( const PSDriver::MediaSize  )
static

Given a paper type, return a pointer to its description.

void casa::PSDriver::pageSize ( float &  width,
float &  height,
const casacore::Bool  userCoords = true 
)
Misc.

Return page size (drawable area - margins). If userCoords is true, values are in current user coordinates. Otherwise, they are in transformed coordinates (points).

static float casa::PSDriver::pointsToInches ( const float  in)
inlinestatic

Miscellaneous functions to convert between typical scalings.

Definition at line 501 of file PSDriver.h.

static float casa::PSDriver::pointsToMM ( const float  in)
inlinestatic

Definition at line 504 of file PSDriver.h.

void casa::PSDriver::popMatrix ( )
void casa::PSDriver::popState ( )
private
void casa::PSDriver::pushMatrix ( )

Push/pop transform matrix.

void casa::PSDriver::pushState ( )
private
void casa::PSDriver::rotate ( const float  degrees)

Rotate by # degrees.

void casa::PSDriver::scale ( const float  x,
const float  y 
)

Change scale by x/y.

void casa::PSDriver::setBackgroundColor ( const float  rh,
const float  gs,
const float  bv,
const ColorSpace  = RGB 
)

Color to be used for dashes.

void casa::PSDriver::setBackgroundColor ( const float  color,
const ColorSpace  = INDEXED 
)

Set color value for indexed and gray scale modes.

void casa::PSDriver::setColor ( const float  rh,
const float  gs,
const float  bv 
)

Set current color used for text and vectors.

Only the first argument is used for indexed & gray. For Indexed mode, color should be in the range (0..ncolors-1) where ncolors is the number of colors in the table. color is truncated to an integer. For the others, color should be in the range (0..1).

void casa::PSDriver::setColor ( const float  color)

Set color value for indexed and gray scale modes.

If called when not in indexed or gray modes, the same value is used for all three components.

void casa::PSDriver::setColorSpace ( const ColorSpace  )

Set/get desired color space.

(Default is INDEXED).

void casa::PSDriver::setCurrXY ( const float  x,
const float  y,
const casacore::Bool  userCoords = true 
)
inlineprivate

Definition at line 615 of file PSDriver.h.

References casa::PSDriver::PSState::setXY(), and state_.

void casa::PSDriver::setDashLength ( const float  length)

Set the length of dashes.

void casa::PSDriver::setDefaultFontScale ( const float  scl)

Set/Get font scaling used with setFont.

void casa::PSDriver::setFont ( const char *  fn)
void casa::PSDriver::setHSBColor ( const float  h,
const float  s,
const float  b 
)

Referenced by setHSVColor().

void casa::PSDriver::setHSVColor ( const float  h,
const float  s,
const float  v 
)
inline

Definition at line 280 of file PSDriver.h.

References setHSBColor().

void casa::PSDriver::setIndexColor ( const float  indx)

Change color space then set color.

void casa::PSDriver::setLinearRamps ( const int  ncolors)

Load linear ramps (0..1.0) into the first ncolors entries.

void casa::PSDriver::setLineStyle ( const LineStyle  )
Graphics
void casa::PSDriver::setRGBColor ( const float  r,
const float  g,
const float  b 
)
void casa::PSDriver::startDocument ( )
private
void casa::PSDriver::storeColor ( const int  index,
const float  r,
const float  g,
const float  b 
)

Store 1 color.

void casa::PSDriver::storeColors ( const int  start,
const int  len,
const float *  r,
const float *  g,
const float *  b 
)

Load color tables with contents of a, b & c.

Typically, a holds red, b holds green & c holds blue. Values should be in the range (0..1). May be called anytime, but values are only used in INDEXED mode. Start is starting index in the color table. Len is the number of entries to set.

void casa::PSDriver::storeColorValues ( const int  len,
const int *  indexes,
const float *  a,
const float *  b,
const float *  c 
)

Scatter load the colortable.

Much more effecient if indexes are consecutive.

void casa::PSDriver::stroke ( )
private
static float casa::PSDriver::toPoints ( const float  in,
const Dimension  indem 
)
static
void casa::PSDriver::toPoints ( const float  xin,
const float  yin,
float &  xout,
float &  yout,
const casacore::Bool  absolute = true 
) const
inline

Do forward or reverse transformation on a point.

If absolute is false, the translations aren't done.

Definition at line 520 of file PSDriver.h.

References state_, and casa::PSDriver::PSState::toPoints().

void casa::PSDriver::translate ( const float  x,
const float  y 
)

Current transform matrix is changed by the given values, not replaced.

Change origin to x/y.

static int casa::PSDriver::uShorts12ToAscii85 ( const casacore::uShort in,
const int  width,
const int  height,
char *  out 
)
static

Converts in to ASCII85 bytes using only lower 12 bits of each integer.

Out must be at least 1.75*inlength rounded up to a multiple of 5 bytes long. (<1.5bytes/entry>*<inlength entries>="">*<1.25 expansion>). If inlength is odd, a 0 valued entry will be implicitly added.

static int casa::PSDriver::uShorts8ToAscii85 ( const casacore::uShort in,
const int  inlength,
char *  out 
)
static

Member Data Documentation

float casa::PSDriver::bbx0_
private

Bounding box in points.

Definition at line 778 of file PSDriver.h.

float casa::PSDriver::bbx1_
private

Definition at line 779 of file PSDriver.h.

float casa::PSDriver::bby0_
private

Definition at line 778 of file PSDriver.h.

float casa::PSDriver::bby1_
private

Definition at line 779 of file PSDriver.h.

casacore::Bool casa::PSDriver::boxCheck0_
private

Definition at line 780 of file PSDriver.h.

casacore::Bool casa::PSDriver::checkBoundingBox_
private

Definition at line 782 of file PSDriver.h.

float casa::PSDriver::clipXll_
private

Clipping rectangle in points.

Definition at line 789 of file PSDriver.h.

float casa::PSDriver::clipXur_
private

Definition at line 789 of file PSDriver.h.

float casa::PSDriver::clipYll_
private

Definition at line 790 of file PSDriver.h.

float casa::PSDriver::clipYur_
private

Definition at line 790 of file PSDriver.h.

ColorSpace casa::PSDriver::colorSpace_
private

Definition at line 770 of file PSDriver.h.

Referenced by colorSpace().

float casa::PSDriver::defaultFontSize_
private

Definition at line 775 of file PSDriver.h.

Referenced by getDefaultFontScale().

Dimension casa::PSDriver::dimension_
private

Definition at line 771 of file PSDriver.h.

Referenced by dimension(), and dimensionToString().

casacore::Bool casa::PSDriver::eps_
private

Definition at line 773 of file PSDriver.h.

Referenced by isEPS().

int casa::PSDriver::finished_
private

Definition at line 793 of file PSDriver.h.

casacore::Bool casa::PSDriver::haveBoundingBox_
private

Definition at line 781 of file PSDriver.h.

Referenced by haveBoundingBox().

PSInfo* casa::PSDriver::info_
private

Definition at line 794 of file PSDriver.h.

LineStyle casa::PSDriver::lineStyle_
private

Definition at line 774 of file PSDriver.h.

std::fstream* casa::PSDriver::mystream_
private

Definition at line 769 of file PSDriver.h.

std::ostream* casa::PSDriver::out
private

Definition at line 768 of file PSDriver.h.

unsigned int casa::PSDriver::pageNum_
private

Definition at line 792 of file PSDriver.h.

casacore::Bool casa::PSDriver::portrait_
private

Definition at line 772 of file PSDriver.h.

Referenced by isPortrait().

PSState casa::PSDriver::state_
private

Definition at line 766 of file PSDriver.h.

Referenced by fromPoints(), getCurrXY(), setCurrXY(), and toPoints().

PSState casa::PSDriver::statestack_[STATESTACKLENGTH]
private

Definition at line 767 of file PSDriver.h.

int casa::PSDriver::statestackindex_
private

Definition at line 765 of file PSDriver.h.

float casa::PSDriver::xll_
private

user coords.

Page boundaries in points;

Definition at line 785 of file PSDriver.h.

float casa::PSDriver::xscale_
private

Definition at line 776 of file PSDriver.h.

float casa::PSDriver::xur_
private

Definition at line 786 of file PSDriver.h.

float casa::PSDriver::yll_
private

Definition at line 785 of file PSDriver.h.

float casa::PSDriver::yscale_
private

Definition at line 776 of file PSDriver.h.

float casa::PSDriver::yur_
private

Definition at line 786 of file PSDriver.h.


The documentation for this class was generated from the following file: