File: hpgltops.h

package info (click to toggle)
cups 1.4.4-7+squeeze10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 25,548 kB
  • ctags: 9,583
  • sloc: ansic: 138,214; sh: 37,926; cpp: 25,469; makefile: 3,285; perl: 190; python: 127; php: 28
file content (240 lines) | stat: -rw-r--r-- 8,351 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
/*
 * "$Id: hpgltops.h 8040 2008-10-09 20:13:21Z mike $"
 *
 *   HP-GL/2 to PostScript filter for the Common UNIX Printing System (CUPS).
 *
 *   Copyright 2007 by Apple Inc.
 *   Copyright 1993-2005 by Easy Software Products.
 *
 *   These coded instructions, statements, and computer programs are the
 *   property of Apple Inc. and are protected by Federal copyright
 *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
 *   which should have been included with this file.  If this file is
 *   file is missing or damaged, see the license at "http://www.cups.org/".
 *
 *   This file is subject to the Apple OS-Developed Software exception.
 */

/*
 * Include necessary headers...
 */

#include "common.h"
#include <math.h>

#ifndef M_PI
#  define M_PI	3.14159265358979323846
#endif /* M_PI */


/*
 * Maximum number of pens we emulate...
 */

#define MAX_PENS	1024


/*
 * Parameter value structure...
 */

typedef struct
{
  int	type;
  union
  {
    float	number;
    char	*string;
  }	value;
} param_t;

#define PARAM_ABSOLUTE	0
#define PARAM_RELATIVE	1
#define PARAM_STRING	2


/*
 * Font information...
 */

typedef struct
{
  int	symbol_set,	/* Symbol set */
	spacing,	/* Spacing (0 = fixed, 1 = proportional) */
	posture,	/* Posture number */
	weight,		/* Weight number */
	typeface;	/* Typeface number */
  float	pitch,		/* Characters per inch */
	height,		/* Height/size of font */
	xpitch;		/* X pitch scaling value */
  float	x, y;		/* X and Y direction/scaling */
} font_t;


/*
 * Pen information...
 */

typedef struct
{
  float	rgb[3];		/* Pen color */
  float	width;		/* Pen width */
} pen_t;


/*
 * Globals...
 */

#ifdef _HPGL_MAIN_C_
#  define VAR
#  define VALUE(x) =x
#  define VALUE2(x,y) ={x,y}
#else
#  define VAR extern
#  define VALUE(x)
#  define VALUE2(x,y)
#endif /* _HPGL_MAIN_C_ */

VAR ppd_file_t	*PPD VALUE(NULL);		/* PPD file */

VAR float	P1[2],				/* Lower-lefthand physical limit */
		P2[2],				/* Upper-righthand physical limit */
		IW1[2],				/* Window lower-lefthand limit */
		IW2[2];				/* Window upper-righthand limit */
VAR int		Rotation	VALUE(0);	/* Page rotation */
VAR int		ScalingType	VALUE(-1);	/* Type of scaling (-1 for none) */
VAR float	Scaling1[2],			/* Lower-lefthand user limit */
		Scaling2[2];			/* Upper-righthand user limit */
VAR float	Transform[2][3];		/* Transform matrix */
VAR int		PageRotation	VALUE(0);	/* Page/plot rotation */

VAR char	StringTerminator VALUE('\003');	/* Terminator for labels */
VAR font_t	StandardFont,			/* Standard font */
		AlternateFont;			/* Alternate font */
VAR float	PenPosition[2]	VALUE2(0.0f, 0.0f),
						/* Current pen position */
		PenScaling	VALUE(1.0f),	/* Pen width scaling factor */
		PenWidth	VALUE(1.0f);	/* Default pen width */
VAR pen_t	Pens[MAX_PENS];			/* State of each pen */
VAR int		PenMotion	VALUE(0), 	/* 0 = absolute, 1 = relative */
		PenValid	VALUE(0),	/* 1 = valid position, 0 = undefined */
		PenNumber	VALUE(0),	/* Current pen number */
		PenCount	VALUE(8),	/* Number of pens */
		PenDown		VALUE(0),	/* 0 = pen up, 1 = pen down */
		PolygonMode	VALUE(0),	/* Drawing polygons? */
		PageCount	VALUE(0),	/* Number of pages in plot */
		PageDirty	VALUE(0),	/* Current page written on? */
		WidthUnits	VALUE(0);	/* 0 = mm, 1 = proportionate */
VAR float	PlotSize[2]	VALUE2(2592.0f, 3456.0f);
						/* Plot size */
VAR int		PlotSizeSet	VALUE(0);	/* Plot size set? */
VAR int		CharFillMode	VALUE(0),	/* Where to draw labels */
		CharPen		VALUE(0),	/* Pen to use for labels */
		CharFont	VALUE(0);	/* Font to use for labels */
VAR float	CharHeight[2]	VALUE2(11.5f,11.5f);
						/* Size of font for labels */
VAR int		FitPlot		VALUE(0);	/* 1 = fit to page */
VAR float	ColorRange[3][2]		/* Range of color values */
#ifdef _HPGL_MAIN_C_
		= {
		  { 0.0, 255.0 },
		  { 0.0, 255.0 },
		  { 0.0, 255.0 }
		}
#endif /* _HPGL_MAIN_C_ */
;

VAR int		LineCap		VALUE(0);	/* Line capping */
VAR int		LineJoin	VALUE(0);	/* Line joining */
VAR float	MiterLimit	VALUE(3.0f);	/* Miter limit at joints */


/*
 * Prototypes...
 */

/* hpgl-input.c */
extern int	ParseCommand(FILE *fp, char *name, param_t **params);
extern void	FreeParameters(int num_params, param_t *params);

/* hpgl-config.c */
extern void	update_transform(void);
extern void	BP_begin_plot(int num_params, param_t *params);
extern void	DF_default_values(int num_params, param_t *params);
extern void	IN_initialize(int num_params, param_t *params);
extern void	IP_input_absolute(int num_params, param_t *params);
extern void	IR_input_relative(int num_params, param_t *params);
extern void	IW_input_window(int num_params, param_t *params);
extern void	PG_advance_page(int num_params, param_t *params);
extern void	PS_plot_size(int num_params, param_t *params);
extern void	RO_rotate(int num_params, param_t *params);
extern void	RP_replot(int num_params, param_t *params);
extern void	SC_scale(int num_params, param_t *params);

/* hpgl-vector.c */
extern void	AA_arc_absolute(int num_params, param_t *params);
extern void	AR_arc_relative(int num_params, param_t *params);
extern void	AT_arc_absolute3(int num_params, param_t *params);
extern void	CI_circle(int num_params, param_t *params);
extern void	PA_plot_absolute(int num_params, param_t *params);
extern void	PD_pen_down(int num_params, param_t *params);
extern void	PE_polyline_encoded(int num_params, param_t *params);
extern void	PR_plot_relative(int num_params, param_t *params);
extern void	PU_pen_up(int num_params, param_t *params);
extern void	RT_arc_relative3(int num_params, param_t *params);

/* hpgl-polygon.c */
extern void	EA_edge_rect_absolute(int num_params, param_t *params);
extern void	EP_edge_polygon(int num_params, param_t *params);
extern void	ER_edge_rect_relative(int num_params, param_t *params);
extern void	EW_edge_wedge(int num_params, param_t *params);
extern void	FP_fill_polygon(int num_params, param_t *params);
extern void	PM_polygon_mode(int num_params, param_t *params);
extern void	RA_fill_rect_absolute(int num_params, param_t *params);
extern void	RR_fill_rect_relative(int num_params, param_t *params);
extern void	WG_fill_wedge(int num_params, param_t *params);

/* hpgl-char.c */
extern void	define_font(int f);
extern void	AD_define_alternate(int num_params, param_t *params);
extern void	CF_character_fill(int num_params, param_t *params);
extern void	CP_character_plot(int num_params, param_t *params);
extern void	DI_absolute_direction(int num_params, param_t *params);
extern void	DR_relative_direction(int num_params, param_t *params);
extern void	DT_define_label_term(int num_params, param_t *params);
extern void	DV_define_variable_path(int num_params, param_t *params);
extern void	ES_extra_space(int num_params, param_t *params);
extern void	LB_label(int num_params, param_t *params);
extern void	LO_label_origin(int num_params, param_t *params);
extern void	SA_select_alternate(int num_params, param_t *params);
extern void	SD_define_standard(int num_params, param_t *params);
extern void	SI_absolute_size(int num_params, param_t *params);
extern void	SL_character_slant(int num_params, param_t *params);
extern void	SR_relative_size(int num_params, param_t *params);
extern void	SS_select_standard(int num_params, param_t *params);
extern void	TD_transparent_data(int num_params, param_t *params);

/* hpgl-attr.c */
extern void	AC_anchor_corner(int num_params, param_t *params);
extern void	CR_color_range(int num_params, param_t *params);
extern void	FT_fill_type(int num_params, param_t *params);
extern void	LA_line_attributes(int num_params, param_t *params);
extern void	LT_line_type(int num_params, param_t *params);
extern void	NP_number_pens(int num_params, param_t *params);
extern void	PC_pen_color(int num_params, param_t *params);
extern void	PW_pen_width(int num_params, param_t *params);
extern void	RF_raster_fill(int num_params, param_t *params);
extern void	SM_symbol_mode(int num_params, param_t *params);
extern void	SP_select_pen(int num_params, param_t *params);
extern void	UL_user_line_type(int num_params, param_t *params);
extern void	WU_width_units(int num_params, param_t *params);

/* hpgl-prolog.c */
extern void	OutputProlog(char *title, char *user, int shading);
extern void	OutputTrailer(void);
extern int	Outputf(const char *format, ...);

/*
 * End of "$Id: hpgltops.h 8040 2008-10-09 20:13:21Z mike $".
 */