File: hpljii.trm

package info (click to toggle)
gnuplot 3.7.1p1-4
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,808 kB
  • ctags: 4,418
  • sloc: ansic: 43,279; lisp: 661; makefile: 647; asm: 539; sh: 416; objc: 379; csh: 297; pascal: 194; perl: 138
file content (430 lines) | stat: -rw-r--r-- 11,700 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
 * $Id: hpljii.trm,v 1.9 1998/12/15 20:22:41 lhecking Exp $
 *
 */

/* GNUPLOT - hpljii.trm */

/*[
 * Copyright 1990 - 1993, 1998   Thomas Williams, Colin Kelley
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  hpljii, hpdj
 *
 * AUTHORS
 *  John Engels
 *  Russell Lang
 *  Maurice Castro
 *
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 * 
 */

/* The following HP laserjet series II driver uses generic bit mapped graphics
   routines from bitmap.c to build up a bit map in memory.  The driver
   interchanges colomns and lines in order to access entire lines
   easily and returns the lines to get bits in the right order :
   (x,y) -> (y,XMAX-1-x). */
/* This interchange is done by calling b_makebitmap() with reversed 
   xmax and ymax, and then setting b_rastermode to TRUE.  b_setpixel()
   will then perform the interchange before each pixel is plotted */
/* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
   of Jyrki Yli-Nokari */

/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#include "driver.h"

#ifdef TERM_REGISTER
register_term(hpljii)
register_term(hpdj)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void HPLJIIoptions __PROTO((void));
TERM_PUBLIC void HPLJIIinit __PROTO((void));
TERM_PUBLIC void HPLJIIgraphics __PROTO((void));
TERM_PUBLIC void HPLJIItext __PROTO((void));
TERM_PUBLIC void HPLJIIlinetype __PROTO((int linetype));
TERM_PUBLIC void HPLJIIput_text __PROTO((unsigned int x, unsigned int y, char *str));
TERM_PUBLIC void HPLJIIreset __PROTO((void));
#define HPLJIImove b_move
#define HPLJIIvector b_vector
#define HPLJIItext_angle b_text_angle
TERM_PUBLIC void HPDJgraphics __PROTO((void));
TERM_PUBLIC void HPDJtext __PROTO((void));
#define HPDJtext_angle b_text_angle
#define HPDJput_text b_put_text
/* default values for term_tbl */
#define HPLJII_75PPI_XMAX (1920/4)
#define HPLJII_75PPI_YMAX (1920/4)
#define HPLJII_75PPI_HCHAR (1920/4/6)
#define HPLJII_75PPI_VCHAR (1920/4/10)
#define HPLJII_75PPI_VTIC 5
#define HPLJII_75PPI_HTIC 5
#endif

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

/* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
   75ppi.  (Pixel size = 1, 2, 3, 4 dots) */

#define HPLJII_DPP (hplj_dpp)	/* dots per pixel */
#define HPLJII_PPI (300/HPLJII_DPP)	/* pixel per inch */
/* make XMAX and YMAX a multiple of 8 */
#define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9))
#define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9))

/* Courier font with 6 lines per inch */
#define HPLJII_VCHAR (HPLJII_PPI/6)
/* Courier font with 10 caracters per inch */
#define HPLJII_HCHAR (HPLJII_PPI/10)
/* Save current cursor position */
#define HPLJII_PUSH_CURSOR fputs("\033&f0S",gpoutfile)
/* Restore cursor position */
#define HPLJII_POP_CURSOR fputs("\033&f1S",gpoutfile)
/* be sure to use courier font with 6lpi and 10cpi */
#define HPLJII_COURIER fputs("\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D",gpoutfile)


void HPLJIIputc __PROTO((unsigned int x, unsigned int y, char c, int ang));
static int hplj_dpp = 4;
/* bm_pattern not appropriate for 300ppi graphics */
#ifndef GOT_300_PATTERN
# define GOT_300_PATTERN
static unsigned int b_300ppi_pattern[] =
{
    0xffff, 0x1111, 0xffff, 0x3333,
    0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff
};
#endif

TERM_PUBLIC void HPLJIIoptions()
{
    char opt[4];
    int parse_error = 0;

    if (END_OF_COMMAND) {
	term_options[0] = NUL;
    } else {
	if (token[c_token].length > 3) {
	    parse_error = 1;	/* see below */
	} else {
	    /* almost_equals() won't accept numbers - use strcmp() instead */
	    capture(opt, c_token, c_token, 4);
	    if (!strcmp(opt, "75")) {
		hplj_dpp = 4;
	    } else if (!strcmp(opt, "100")) {
		hplj_dpp = 3;
	    } else if (!strcmp(opt, "150")) {
		hplj_dpp = 2;
	    } else if (!strcmp(opt, "300")) {
		hplj_dpp = 1;
	    } else {
		/* error, but set dpi anyway, since term it already set */
		parse_error = 1;
	    }
	    c_token++;
	}
    }

    term->xmax = HPLJII_XMAX;
    term->ymax = HPLJII_YMAX;
    switch (hplj_dpp) {
    case 1:
	strcpy(term_options, "300");
	term->v_tic = 15;
	term->h_tic = 15;
	break;
    case 2:
	strcpy(term_options, "150");
	term->v_tic = 8;
	term->h_tic = 8;
	break;
    case 3:
	strcpy(term_options, "100");
	term->v_tic = 6;
	term->h_tic = 6;
	break;
    case 4:
	strcpy(term_options, "75");
	term->v_tic = 5;
	term->h_tic = 5;
	break;
    }

    if (parse_error)
	int_error("expecting dots per inch size 75, 100, 150 or 300",
		  c_token);
}


TERM_PUBLIC void HPLJIIinit()
{
    term->v_char = HPLJII_VCHAR;
    term->h_char = HPLJII_HCHAR;
}


TERM_PUBLIC void HPLJIIgraphics()
{
    HPLJII_COURIER;
    HPLJII_PUSH_CURSOR;
    /* rotate plot -90 degrees by reversing XMAX and YMAX and by 
       setting b_rastermode to TRUE */
    b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1);
    b_rastermode = TRUE;
}


/* HPLJIItext by rjl - no compression */
TERM_PUBLIC void HPLJIItext()
{
    register int x, j, row;

    fprintf(gpoutfile, "\033*t%dR", HPLJII_PPI);
    HPLJII_POP_CURSOR;
    fputs("\033*r1A", gpoutfile);

    /* dump bitmap in raster mode */
    for (x = b_xsize - 1; x >= 0; x--) {
	row = (b_ysize / 8) - 1;
	fprintf(gpoutfile, "\033*b0m%dW", b_ysize / 8);
	for (j = row; j >= 0; j--) {
	    (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
	}
    }
    fputs("\033*rB", gpoutfile);

    b_freebitmap();

#ifndef VMS
    /* most vms spoolers add a formfeed character */
    putc('\f', gpoutfile);
#endif /* !VMS */
}



TERM_PUBLIC void HPLJIIlinetype(linetype)
int linetype;
{

    if (hplj_dpp == 1) {
	if (linetype >= 7)
	    linetype %= 7;
	/* b_pattern not appropriate for 300ppi graphics */
	b_linemask = b_300ppi_pattern[linetype + 2];
	b_maskcount = 0;
    } else {
	b_setlinetype(linetype);
    }
}

TERM_PUBLIC void HPLJIIput_text(x, y, str)
unsigned int x, y;
char *str;
{
    switch (b_angle) {
    case 0:
	y -= HPLJII_VCHAR / 5;
	HPLJII_POP_CURSOR;
	HPLJII_PUSH_CURSOR;
	/* (0,0) is the upper left point of the paper */
	fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP
		,(HPLJII_YMAX - y - 1) * HPLJII_DPP);
	fputs(str, gpoutfile);
/*       for (; *str; ++str, x += HPLJII_HCHAR)
            HPLJIIputc (x, y, *str, b_angle);*/
	break;
    case 1:
	y += (HPLJII_HCHAR - 2 * HPLJII_VCHAR) / 2;
	y += (HPLJII_VCHAR + HPLJII_HCHAR) * strlen(str) / 2;
	for (; *str; ++str, y -= HPLJII_VCHAR)
	    HPLJIIputc(x, y, *str, b_angle);
	break;
    }
}

#ifdef PROTOTYPES
void HPLJIIputc(unsigned int x, unsigned int y, char c, int ang)
#else
void HPLJIIputc(x, y, c, ang)
unsigned int x, y;
int ang;
char c;
#endif
{
    HPLJII_POP_CURSOR;
    HPLJII_PUSH_CURSOR;
    /* (0,0) is the upper left point of the paper */
    fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP
	    ,(HPLJII_YMAX - y - 1) * HPLJII_DPP);
    fputc(c, gpoutfile);
}


TERM_PUBLIC void HPLJIIreset()
{
#ifdef VMS
    fflush_binary();
#endif /* VMS */
}


/* HP DeskJet routines */
TERM_PUBLIC void HPDJgraphics()
{
    switch (hplj_dpp) {
    case 1:
	b_charsize(FNT13X25);
	term->v_char = FNT13X25_VCHAR;
	term->h_char = FNT13X25_HCHAR;
	break;
    case 2:
	b_charsize(FNT13X25);
	term->v_char = FNT13X25_VCHAR;
	term->h_char = FNT13X25_HCHAR;
	break;
    case 3:
	b_charsize(FNT9X17);
	term->v_char = FNT9X17_VCHAR;
	term->h_char = FNT9X17_HCHAR;
	break;
    case 4:
	b_charsize(FNT5X9);
	term->v_char = FNT5X9_VCHAR;
	term->h_char = FNT5X9_HCHAR;
	break;
    }
    /* rotate plot -90 degrees by reversing XMAX and YMAX and by 
       setting b_rastermode to TRUE */
    b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1);
    b_rastermode = TRUE;
}


/* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
   hopefully compatible with other HP Deskjet printers */
TERM_PUBLIC void HPDJtext()
{
    register int x, j, row;

    fprintf(gpoutfile, "\
\033*b0M\
\033*t%dR\
\033*r1A",
	    HPLJII_PPI);

    /* dump bitmap in raster mode */
    for (x = b_xsize - 1; x >= 0; x--) {
	row = (b_ysize / 8) - 1;
	fprintf(gpoutfile, "\033*b%dW", b_ysize / 8);
	for (j = row; j >= 0; j--) {
	    (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
	}
    }
    fputs("\033*rbC", gpoutfile);

    b_freebitmap();

#ifndef VMS			/* most vms spoolers add a formfeed character */
    putc('\f', gpoutfile);
#endif /* !VMS */
}

#endif

#ifdef TERM_TABLE

TERM_TABLE_START(hpljii_driver)
    "hpljii", "HP Laserjet series II, [75 100 150 300]",
    HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
    HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
    HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
    HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
    HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
    do_arrow, set_font_null, 0, TERM_BINARY
TERM_TABLE_END(hpljii_driver)

#undef LAST_TERM
#define LAST_TERM hpljii_driver

TERM_TABLE_START(hpdj_driver)
    "hpdj", "HP DeskJet 500, [75 100 150 300]",
    HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
    HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
    HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
    HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
    HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
    do_arrow, set_font_null, 0, TERM_BINARY
TERM_TABLE_END(hpdj_driver)

#undef LAST_TERM
#define LAST_TERM hpdj_driver

#endif
#endif

#ifdef TERM_HELP
START_HELP(hpljii)
"1 hpljii",
"?commands set terminal hpljii",
"?set terminal hpljii",
"?set term hpljii",
"?terminal hpljii",
"?term hpljii",
"?hpljii",
"?commands set terminal hpdj",
"?set terminal hpdj",
"?set term hpdj",
"?terminal hpdj",
"?term hpdj",
"?hpdj",
" The `hpljii` terminal driver supports the HP Laserjet Series II printer.  The",
" `hpdj` driver supports the HP DeskJet 500 printer.  These drivers allow a",
" choice of resolutions.",
"",
" Syntax:",
"       set terminal hpljii | hpdj {<res>}",
"",
" where `res` may be 75, 100, 150 or 300 dots per inch; the default is 75.",
" Rasterization at the higher resolutions may require a large amount of memory.",
"",
" The `hp500c` terminal is similar to `hpdj`; `hp500c` additionally supports",
" color and compression."
END_HELP(hpljii)
#endif /* TERM_HELP */