home *** CD-ROM | disk | FTP | other *** search
- Making a new driver is pretty easy. If you can write a C program that
- can draw a line on the given device, you can probably write a plplot
- driver for it.
-
- Overview
- The best way to create a new driver is to start with one of the old ones.
- At the minimum you will need to supply routines to (1) open/initialize the
- device, (2) draw a line between two points on the device, and (3) close
- the device. These three routines are discussed further below.
- After writing the routines you will need to update the dispatch table
- (dispatch.c) in the drivers directory.
-
- The initialization routine.
- This routine is of type void and takes no arguments. This routine
- sets up the resolution and page size for plplot. It accomplishes this
- by calling the following routines:
-
- (1) setpxl(float x, float y)
- Set the resolution in dots per mm in the x and y directions.
- example -- setpxl(40.,40.) 40 dots/mm or 1016 dpi
-
- (2) setphy(int minx, int maxx, int miny, int maxy)
- Set the min and max page coordinates for the device. The values
- passed to your line drawing routine will be within this range.
- example -- setphy(0,10299,0,7649)
-
- (3) scol(int color)
- Set default pen color.
- example -- scol(1)
-
- (4) swid(int width)
- Set default pen width.
- example -- swid(1)
-
- (5) smod(int mode)
- Set/clear interactive device flag. If mode == 1 device is interactive
- i.e. a terminal (plplot will wait for user input before clearing
- the screen). If mode == 0 device is not interactive.
- example -- smod(0)
-
- Portrait/landscape mode of plotting is set by the driver. See the
- supplied drivers for one method of doing this. If you are writing
- a new dirver you might want to ignore this for now (add it in later).
-
- The line drawing routine
- This should be of type void. It should draw a line between two points
- It takes the following integer arguments
- x1 - x coord of first point
- y1 - y coord of first point
- x2 - x coord of second point
- y2 - y coord of second point
- These will all be within the range specified by setphy() in the
- initialization routine.
-
- The close/tidy routine
- This is of type void. It takes no arguments. Use it to cleanup
- and recover any allocated resources.
-
-
- Updating the dispatch table
- You'll need to update the dispatch table in dispatch.c.
- Add the function declarations for your 3 driver routines to the
- others near the top of the file. Update the dispatch table.
- The first entry is a character string that is printed out in
- the device selection menu. The 4th entry should be the name
- of your initialization routine. The 5th your line routine and the
- 8th your close/tidy routine. All the others can be set to NULL
- (You'll probably want to add these later).
-
-
- Note: I've noticed that the pattern fill routines mess up on low
- resolution devices. I got around this by faking plplot into thinking
- that the device has high resolution by using setpxl() and setphy()
- to make a high resolution virtual page. I then scale down the values
- I receive in the line drawing routine before passing them on to the
- device. An example of this is in the iff driver.
-
- Tony
- resolution
-