1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
19
Corresponding concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
29
* HEADER : hpgldrv.c - Vers 3.6.002 - Jul 1992 - L. Fini, OAA
36
/*****************************************************************************/
38
/* AGL 3.6 driver for HP-GL plotters */
40
/* L.Fini - Oct 1991 */
42
/* Note: This driver is based on a VAX/VMS FORTRAN version for AGL 2.xx */
43
/* contributed by Benacchio and Franceschini (Oss. di Padova) */
45
/* This driver can control the output size and orientation, as directed in */
46
/* the HP-GL manual. The settings are controlled by appending the mode spec */
47
/* to the device identification string in the AG_VDEF call. E.g.: if the */
48
/* device identification name is defined as hpg in your system the following */
49
/* selections can be made: */
51
/* AG_VDEF("hpg",...) (def) : use paper size A/A4 orientation Landscape */
52
/* AG_VDEF("hpg.a",...) : use paper size A/A4 orientation Landscape */
53
/* AG_VDEF("hpg.b",...) : use paper size A/A4 orientation Portrait */
54
/* AG_VDEF("hpg.c",...) : use paper size B/A3 orientation Landscape */
55
/* AG_VDEF("hpg.d",...) : use paper size B/A3 orientation Portrait */
57
/* In the example it is shown how to use device specification to get the */
58
/* allowed paper settings (the plotter must support the given size) */
68
/* The following entry points have been defined: */
70
/* Function Entry point */
72
/* Initialize AGLINHPG */
73
/* Cursor en. AGLCUHPG */
76
/* Polyline AGLPLHPG */
78
/* Flush buff. AGLSEHPG */
82
#define VERSCODE 36 /* Declare driver as version 3.6 */
84
#define HPFLAGS SEPALPHA | EXECOMMND
85
#define HPPLANES 6 /* Set to number of pens */
89
/* No one can ensure color correspondance */
90
/* Unless pens are installed on the plot in */
91
/* the following order: */
99
/* Support is provided for 6 per plotters */
100
/* CYAN is set equal to blue, white is a */
101
/* "draw nothing" color */
103
#define HPGWHITE (-1)
110
/* A4L. A4P. A3L. A3P. */
112
static int xpix[4] = {10800, 7600, 15200, 10800 };
113
static int ypix[4] = {7600, 10800, 10800, 15200 };
115
static float xlen[4] = {27.0, 19.0, 38.0, 27.0 };
116
static float ylen[4] = {19.0, 27.0, 27.0, 38.0 };
118
static int pencode[6] = { 1, 2, 4, 3, 5, 6 };
121
static double xactlng,yactlng;
122
static double xfact,yfact;
124
static char *init0 = "IN;PS4;DF;SC;SP;";
125
static char *init1 = "IN;PS4;DF;SC;RO90;IP;IW;SP;";
126
static char *init2 = "IN;PS0;DF;SC;SP;";
127
static char *init3 = "IN;PS0;DF;SC;RO90;IP;IW;SP;";
129
static FILE *filpt; /* Internal file handler */
130
static char *filnam = "hpglplot";
133
static int untouched;
136
void AGLINHPG (AGLDVCOM)
137
struct bufcom *AGLDVCOM;
139
extern void AG_DMSG();
144
init = init0; /* to initialize ... */
148
switch((int)IBUFFR(0)) { /* Select function */
149
char auxbuf[15]; /* File name buffer */
152
case 0: /* Hardware initialization */
153
strcpy(auxbuf,filnam);
156
if(*auxbuf == '\0') {
161
filpt=fopen(auxbuf,"w"); /* Open output file */
164
AG_DMSG("Open error:",auxbuf);
169
CHANNEL=fileno(filpt);
171
AG_DMSG("Out to:",auxbuf);
173
pt=CHARBUF; /* Get USRAUX string */
174
while(*pt++); /* Skip device name */
175
while(*pt++); /* Skip SYSAUX info */
180
id = TOUPPER(*pt) - 'A';
183
case 0: init = init0; break;
184
case 1: init = init1; break;
185
case 2: init = init2; break;
186
case 3: init = init3; break;
189
strcpy(CHARBUF,auxbuf); /* Copy filename to buffer */
191
untouched=TRUE; /* Compute scaling factors */
194
xactlng = (xactlng<=xlen[id])?xactlng:xlen[id];
195
xactlng = (xactlng<=0.0) ? xlen[id] : xactlng;
197
yactlng = (yactlng<=ylen[id])?yactlng:ylen[id];
198
yactlng = (yactlng<=0.0) ? ylen[id] : yactlng;
200
xfact = (xpix[id]-1)*(xactlng/xlen[id]);
201
yfact = (ypix[id]-1)*(yactlng/ylen[id]);
203
fputs(init,filpt); /* Send init commands */
207
case 1: /* Pass back device characteristics */
212
IBUFFR(2) = HPPLANES;
213
IBUFFR(3) = xpix[id];
214
IBUFFR(4) = ypix[id];
215
IBUFFR(5) = VERSCODE;
216
IBUFFR(6) = HPMAXLWIDTH;
218
IBUFFR(7) = HPGWHITE; /* Default Background */
219
IBUFFR(8) = HPGBLACK; /* Default foreground */
220
IBUFFR(9) = HPGBLACK;
222
IBUFFR(11) = HPGGREEN;
223
IBUFFR(12) = HPGBLUE;
224
IBUFFR(13) = HPGYELLOW;
225
IBUFFR(14) = HPGMAGENTA;
226
IBUFFR(15) = HPGCYAN;
227
IBUFFR(16) = HPGWHITE;
229
RBUFFR(2) = CHARMULT;
230
RBUFFR(6) = xlen[id];
231
RBUFFR(7) = ylen[id];
232
RBUFFR(8) = xlen[id];
233
RBUFFR(9) = ylen[id];
236
case 2: /* set color */
239
fprintf(filpt,"SP%d;\n",pencode[curpen]);
243
case 3: /* set line style */
247
case 4: /* set line width */
248
ERRCODE=UNSFEATINF; /* Unsupported */
251
case 6: /* Coordinate roundoff */
252
break; /* Unnecessary for high resol. devices */
257
void AGLCUHPG(AGLDVCOM)
258
struct bufcom *AGLDVCOM;
263
void AGLERHPG(AGLDVCOM)
264
struct bufcom *AGLDVCOM;
269
void AGLESHPG(AGLDVCOM)
270
struct bufcom *AGLDVCOM;
277
void AGLSEHPG(AGLDVCOM)
278
struct bufcom *AGLDVCOM;
284
void AGLTEHPG(AGLDVCOM)
285
struct bufcom *AGLDVCOM;
287
extern void AG_DMSG();
288
fprintf(filpt,"SP0;\n");
290
AG_DMSG("Out file","closed");
296
void AGLPLHPG(AGLDVCOM)
297
struct bufcom *AGLDVCOM;
300
float *vectx, *vecty;
317
fprintf(filpt,"PU%d,%d;\n", /* Move to first point */
318
(int)((*vectx++)*xfact+0.5),
319
(int)((*vecty++)*yfact+0.5));
322
fprintf(filpt,"PD%d,%d;\n",
323
(int)((*vectx++)*xfact+0.5),
324
(int)((*vecty++)*yfact+0.5));