Re: XForms: Printing of xyplots?

Dr. Dikoma C. Shungu (shungu@ultranmr.cpmc.columbia.edu)
Thu, 14 Aug 1997 12:09:23 -0400 (EDT)

To subscribers of the xforms list from "Dr. Dikoma C. Shungu" <shungu@ultranmr.cpmc.columbia.edu> :

|> To subscribers of the xforms list from Ivan Powis
|> <pczip@chemistry.nottingham.ac.uk> :
|>
|>[snip]
|> My own objection to tacking on one's own ps output driver (from one of
|> sources mentioned along this thread) is that the application then has
|> to duplicate the programming required to generate the xyplot (scaling,
|> annotation, plotting data, interpolating lines) and the results may be
|> far from WYSIWYG. It kind of takes away the convenience of using
|> xyplot doesn't it?

It is actually easier than you think. The device drivers, which have
already been written for you, ensure proper scaling, plot orientation
etc..., based upon the selected device . You therefore write your
drawing/plotting routine *once*, and only pass it pointers to functions
which handle the drawing for the device you selected. These pointer
functions, which may look like those given blow...,

/* These are declared "global" */

int (*devsetcolor) (); /* device set color */
void (*devsetfont) (); /* device set font */
int (*devsetline) (); /* device set line style */
int (*devsetlinew) (); /* device set line width */
int (*devsetpat) (); /* device set fill pattern */
void (*devdrawarc) (); /* device arc routine */
void (*devfillarc) (); /* device fill arc routine */
void (*devdrawellipse) (); /* device ellipse routine */
void (*devfillellipse) (); /* device ellipse arc routine */
void (*devfillellipsecolour) ();/* device ellipse arc routine */
void (*devfill) (); /* device fill polygon with a pattern */
void (*devfillcolor) (); /* device fill polygon with color */
int (*devconvx) (); /* viewport to device mapping for x */
int (*devconvy) (); /* viewport to device mapping for y */
void (*vector) (); /* device draw line */
void (*devwritestr) (); /* device write string */
void (*devdrawtic) (); /* device draw tic */
void (*devleavegraphics) (); /* device exit */

....are initialized when you select the device. For instance when
you select to output to a PS device, the following initialization
occurs, using parameters and routines defined in, e.g., a "ps.c" driver.

devconvx = xconvps;
devconvy = yconvps;
vector = drawps;
devwritestr = dispstrps;
devsetcolor = pssetcolor;
devsetfont = pssetfont;
devsetline = pssetlinestyle;
devsetlinew = pssetlinewidth;
devdrawtic = psdrawtic;
devsetpat = pssetpat;
devdrawarc = psdrawarc;
devfillarc = psfillarc;
devfill = psfill;
devfillcolor = psfillcolor;
devdrawellipse = psdrawellipse;
devfillellipse = psfillellipse;
devfillellipsecolour = psfillellipsecolour;
devleavegraphics = psleavegraphics;
devcharsize = pscharsize;
devsymsize = 20;
devxticl = 20;
devyticl = 20;
devarrowlength = 20;

...so that if you want to draw a string on a PS printer (or any
device for which you have a driver) you can write a generic
routine as shown below.

/*
* writestr - user interface to the current device text drawing routine
*/
void writestr(double x, double y, int dir, int just, char *s)
{
if (s == NULL) {
return;
}
if (strlen(s) == 0) {
return;
}

/*
Below, we call the string drawing and coordinate conversion routines
for the selected device [*which ever it may be*, just as long as we
have a driver for it], to ensure consistent WYSIWYG output.
*/

(*devwritestr) ((*devconvx) (x), (*devconvy) (y), dir, s, just, devtype);
}

What is the point of all this? It is that writing DVI applications can be
quite easy if you have access to drivers for devices you're interested in.
XVGR or XMGR has nice drivers for PS, X11, RASTER (versatec) and HP PEN
PLOTTERS. If you had to do it from scratch, then it would definitely be the
ultimate in self-flagellation, as practiced by Dr. Masoch.

DCS

----------------------------------------------------------------------------*
Dikoma C. Shungu, Ph.D. | Assistant Professor of Radiology / Medical Physics|
The Hatch NMR Research Center | The Neurological Institute of New York |
College of Physicians & Surgeons | Columbia University | 710 W 168th Street |
New York, New York 10032 | http://www.hatch-ultra.cpmc.columbia.edu |
Phone: 212-305-6986 | FAX: 212-305-7351 | Pager: 917-424-5511 |
----------------------------------------------------------------------------*
# # |
# # # ##### ##### ## # # # # ##### |
# # # # # # # # ## # ## ## # # |
# # # # # # # # # # # # ## # # # is |
# # # # ##### ###### # # # # # ##### UltraSparc-driven |
# # # # # # # # # ## # # # # |
##### ###### # # # # # # # # # # # Solaris-2.5.1 |
----------------------------------------------------------------------------*

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/