casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
casa::PSDriver Class Reference

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

#include <PSDriver.h>

List of all members.

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.

Public Member Functions

 PSDriver ()
 Generic PostScript.
 PSDriver (ostream &out)
 PSDriver (const char *filename)
 PSDriver (ostream &out, const MediaSize, const Layout=PORTRAIT, PSInfo *info=NULL)
 PSDriver (const String &fname, const MediaSize, const Layout=PORTRAIT, PSInfo *info=NULL)
 PSDriver (const char *fname, const MediaSize, const Layout=PORTRAIT, PSInfo *info=NULL)
 PSDriver (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 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 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.
ColorSpace colorSpace () const
void setColor (const float rh, const float gs, const float bv)
 Set current color used for text and vectors.
void setColor (const float color)
 Set color value for indexed and gray scale modes.
void setBackgroundColor (const float rh, const float gs, const float bv, const ColorSpace=RGB)
 Color to be used for dashes.
void setBackgroundColor (const float color, const ColorSpace=INDEXED)
 Set color value for indexed and gray scale modes.
void setIndexColor (const float indx)
 Change color space then set color.
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.
void storeColorValues (const int len, const int *indexes, const float *a, const float *b, const float *c)
 Scatter load the colortable.
void storeColor (const int index, const float r, const float g, const float b)
 Store 1 color.
void setLinearRamps (const int ncolors)
 Load linear ramps (0..1.0) into the first ncolors entries.
void translate (const float x, const float y)
 Current transform matrix is changed by the given values, not replaced.
void scale (const float x, const float y)
 Change scale by x/y.
void rotate (const float degrees)
 Rotate by # degrees.
void setDashLength (const float length)
 Set the length of dashes.
void drawImage (const float x0, const float y0, const int width, const int height, const float xsize, const float ysize, const uShort *data, const int bpc=0, const ColorSpace=INDEXED, const int imageopts=0)
void gsave ()
 Save/restore graphics state.
void grestore ()
void setLineStyle (const LineStyle)
void lineWidth (const float w)
 w = 1.0 means 0.005".
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>Caution: 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.
void setFont (const char *fn)
void findFont (const char *fn, const float scale)
 Use font with supplied scaling.
void setDefaultFontScale (const float scl)
 Set/Get font scaling used with setFont.
float getDefaultFontScale () const
void pageSize (float &width, float &height, const Bool userCoords=True)
Bool getBoundingBox (float &x0, float &y0, float &x1, float &y1, const Bool userCoords=True) const
 Return bounding box.
Bool haveBoundingBox () const
 Returns True if bounding box size was given to the constructor.
void comment (const char *)
 Put a comment in the output file.
void comment (const String &)
void pushMatrix ()
 Push/pop transform matrix.
void popMatrix ()
void newPage ()
void flush ()
 Flush the output.
void finish ()
 Done.
void clipRect (const float x0, const float y0, const float width, const float height)
 Set clipping rectangle.
void toPoints (const float xin, const float yin, float &xout, float &yout, const Bool absolute=True) const
 Do forward or reverse transformation on a point.
void fromPoints (const float xin, const float yin, float &xout, float &yout, const Bool absolute=True) const
const char * dimensionToString () const
Dimension dimension () const
Bool isEPS () const
 Is the output EPS? Portrait?
Bool isPortrait () const

Static Public Member Functions

static int bytesToAscii85 (const char *in, const int inlength, char *out)
static int uShorts8ToAscii85 (const uShort *in, const int inlength, char *out)
static int uShorts12ToAscii85 (const uShort *in, const int width, const int height, char *out)
 Converts in to ASCII85 bytes using only lower 12 bits of each integer.
static char * encodeUShorts (const int width, const int height, int &bpc, const uShort *data, int &outlen)
 Encode data as ASCII85 chars.
static float pointsToInches (const float in)
 Miscellaneous functions to convert between typical scalings.
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.
static const PSDriver::PageInfopageInfo (const PSDriver::MediaSize)
 Given a paper type, return a pointer to its description.
static const PSDriver::PageInfogetPageInfo (const int indx)
 Return page description for index indx.
static const PSDriver::PageInfolookupPageInfo (const char *name)
 Lookup for a page description using the name field.
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 (ostream &output, const ColorSpace cs, const PageInfo *, const Layout, PSInfo *)
void initname (const String &name, const ColorSpace cs, const PageInfo *, const Layout, PSInfo *)
void bbCheck (const float x, const float y, const Bool userCoords=True)
 Compare x/y to current bounding box.
void bbCheck ()
void setCurrXY (const float x, const float y, const Bool userCoords=True)
void getCurrXY (float &x, float &y, const Bool userCoords=True)
void startDocument ()
void emitHeader ()
 Code writers.
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.
void emitScale (const float x, const float y)
 Scale.
void emitTranslate (const float x, const float y)
 Change origin.
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.
void emitString (const char *str)
 Just throw a string on the stack and leave it there.
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.
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.
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.
void emitStoreColors (const int color, const int start, const int len, const float *ary)
 Internal helper function.
void emitStoreColor (const int index, const float r, const float g, const float b)
 Load one value into color table.
void emitSetColor (const ColorSpace cs, const int index)
 Set curren`t color.
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.
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.
void pushState ()
void popState ()

Private Attributes

int statestackindex_
PSState state_
PSState statestack_ [STATESTACKLENGTH]
ostream * out
std::fstream * mystream_
ColorSpace colorSpace_
Dimension dimension_
Bool portrait_
Bool eps_
LineStyle lineStyle_
float defaultFontSize_
float xscale_
float yscale_
float bbx0_
 Bounding box in points.
float bby0_
float bbx1_
float bby1_
Bool boxCheck0_
Bool haveBoundingBox_
Bool checkBoundingBox_
float xll_
 user coords.
float yll_
float xur_
float yur_
float clipXll_
 Clipping rectangle in points.
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,
                                    PSDriver::PORTRAIT);

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 728 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 127 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 129 of file PSDriver.h.

Enumerator:
AlignCenter 
AlignLeft 
AlignTop 
AlignRight 
AlignBottom 
AlignTopLeft 
AlignTopRight 
AlignBottomLeft 
AlignBottomRight 

Definition at line 146 of file PSDriver.h.


Constructor & Destructor Documentation

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 ( ostream &  out)
casa::PSDriver::PSDriver ( const char *  filename)
casa::PSDriver::PSDriver ( ostream &  out,
const MediaSize  ,
const Layout  = PORTRAIT,
PSInfo info = NULL 
)
casa::PSDriver::PSDriver ( const 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 ( 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 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 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 
)

Member Function Documentation

void casa::PSDriver::bbCheck ( const float  x,
const float  y,
const 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]

Definition at line 246 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 String )

Definition at line 510 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 508 of file PSDriver.h.

References dimension_, and dimensionToString().

Referenced by dimensionToString().

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 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                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>Caution: 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 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 uShort data,
int &  outlen 
) [static]

Encode data as ASCII85 chars.

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.

Done.

Called by the destructor.

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 Bool  absolute = True 
) const [inline]

Definition at line 500 of file PSDriver.h.

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

Bool casa::PSDriver::getBoundingBox ( float &  x0,
float &  y0,
float &  x1,
float &  y1,
const 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 Bool  userCoords = True 
) [inline, private]

Definition at line 584 of file PSDriver.h.

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

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

Definition at line 401 of file PSDriver.h.

References defaultFontSize_.

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

Return page description for index indx.

Save/restore graphics state.

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

Definition at line 423 of file PSDriver.h.

References haveBoundingBox_.

static float casa::PSDriver::inchesToPoints ( const float  in) [inline, static]

Definition at line 486 of file PSDriver.h.

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

Is the output EPS? Portrait?

Definition at line 514 of file PSDriver.h.

References eps_.

Bool casa::PSDriver::isPortrait ( ) const [inline]

Definition at line 515 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) [inline, static]

Definition at line 487 of file PSDriver.h.

void casa::PSDriver::moveTo ( const float  x,
const float  y 
)
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]

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

void casa::PSDriver::pageSize ( float &  width,
float &  height,
const 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) [inline, static]

Miscellaneous functions to convert between typical scalings.

Definition at line 484 of file PSDriver.h.

static float casa::PSDriver::pointsToMM ( const float  in) [inline, static]

Definition at line 485 of file PSDriver.h.

void casa::PSDriver::popState ( ) [private]

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.

Set/get desired color space.

(Default is INDEXED).

void casa::PSDriver::setCurrXY ( const float  x,
const float  y,
const Bool  userCoords = True 
) [inline, private]

Definition at line 581 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 268 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.

                                 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 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 495 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 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 uShort in,
const int  inlength,
char *  out 
) [static]

Member Data Documentation

float casa::PSDriver::bbx0_ [private]

Bounding box in points.

Definition at line 742 of file PSDriver.h.

float casa::PSDriver::bbx1_ [private]

Definition at line 743 of file PSDriver.h.

float casa::PSDriver::bby0_ [private]

Definition at line 742 of file PSDriver.h.

float casa::PSDriver::bby1_ [private]

Definition at line 743 of file PSDriver.h.

Definition at line 744 of file PSDriver.h.

Definition at line 746 of file PSDriver.h.

float casa::PSDriver::clipXll_ [private]

Clipping rectangle in points.

Definition at line 753 of file PSDriver.h.

float casa::PSDriver::clipXur_ [private]

Definition at line 753 of file PSDriver.h.

float casa::PSDriver::clipYll_ [private]

Definition at line 754 of file PSDriver.h.

float casa::PSDriver::clipYur_ [private]

Definition at line 754 of file PSDriver.h.

Definition at line 734 of file PSDriver.h.

Referenced by colorSpace().

Definition at line 739 of file PSDriver.h.

Referenced by getDefaultFontScale().

Definition at line 735 of file PSDriver.h.

Referenced by dimension(), and dimensionToString().

Definition at line 737 of file PSDriver.h.

Referenced by isEPS().

Definition at line 757 of file PSDriver.h.

Definition at line 745 of file PSDriver.h.

Referenced by haveBoundingBox().

Definition at line 758 of file PSDriver.h.

Definition at line 738 of file PSDriver.h.

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

Definition at line 733 of file PSDriver.h.

ostream* casa::PSDriver::out [private]

Definition at line 732 of file PSDriver.h.

unsigned int casa::PSDriver::pageNum_ [private]

Definition at line 756 of file PSDriver.h.

Definition at line 736 of file PSDriver.h.

Referenced by isPortrait().

Definition at line 730 of file PSDriver.h.

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

Definition at line 731 of file PSDriver.h.

Definition at line 729 of file PSDriver.h.

float casa::PSDriver::xll_ [private]

user coords.

Page boundaries in points;

Definition at line 749 of file PSDriver.h.

float casa::PSDriver::xscale_ [private]

Definition at line 740 of file PSDriver.h.

float casa::PSDriver::xur_ [private]

Definition at line 750 of file PSDriver.h.

float casa::PSDriver::yll_ [private]

Definition at line 749 of file PSDriver.h.

float casa::PSDriver::yscale_ [private]

Definition at line 740 of file PSDriver.h.

float casa::PSDriver::yur_ [private]

Definition at line 750 of file PSDriver.h.


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