1
/* ploticus data display engine. Software, documentation, and examples.
2
* Copyright 1998-2002 Stephen C. Grubb (scg@jax.org).
3
* Covered by GPL; see the file ./Copyright for details. */
8
/* Low level elib drawing stubs.. */
9
/* These issue driver requests only when a parameter actually changes */
11
/* ======================================== */
15
Epcode( 'z', 0.0, 0.0, Ecurbkcolor );
17
/* ======================================== */
18
/* move to x, y absolute */
22
if( Eflip ) Epcode( 'M', (double)y , (double)x, "" );
23
else Epcode( 'M', (double)x , (double)y, "" );
25
/* ======================================== */
26
/* line to x, y absolute */
30
if( Eflip ) Epcode( 'L', (double)y , (double)x, "" );
31
else Epcode( 'L', (double)x , (double)y, "" );
33
/* ======================================== */
34
/* path to x, y absolute (form a polygon to be shaded later) */
38
if( Eflip ) Epcode( 'P', (double)y , (double)x, "" );
39
else Epcode( 'P', (double)x , (double)y, "" );
44
/* ======================================== */
45
/* move to x, y data */
49
if( Eflip ) Epcode( 'M', Eax((double) y ) , Eay((double) x ), "" );
50
else Epcode( 'M', Eax((double) x ) , Eay((double) y ), "" );
52
/* ======================================== */
53
/* line to x, y data */
57
if( Eflip ) Epcode( 'L', Eax((double) y ) , Eay((double) x ), "" );
58
else Epcode( 'L', Eax((double) x ) , Eay((double) y ), "" );
60
/* path to x, y data (form a polygon to be shaded later) */
61
#define Epathu( x , y ) Epcode( 'P', Eax((double) x ) , Eay((double) y ), "" )
64
/* ======================================== */
65
/* handle multi-line text. */
75
if( tolower(op) == 'l' ) op = 'T';
76
else if( tolower(op) == 'c' ) op = 'C';
77
else if( tolower(op) == 'r' ) op = 'J';
80
GL_getseg( chunk, s, &i, "\n" );
81
Epcode( op, 0.0, 0.0, chunk );
82
if( i >= slen ) break;
83
if( Ecurtextdirection == 0 ) y -= Ecurtextheight;
84
else if( Ecurtextdirection == 90 ) x += Ecurtextheight;
85
else if( Ecurtextdirection == 270 ) x -= Ecurtextheight;
86
if( Eflip ) Emov( y, x );
91
/* ======================================== */
92
/* EFONT - Set font to s. If s is "" use standard font. */
96
if( strlen( s ) < 1 ) {
97
Epcode( 'F', 0.0, 0.0, Estandard_font );
98
strcpy( Ecurfont, Estandard_font );
100
else if( strcmp( s, Ecurfont )!= 0 ) {
101
Epcode( 'F', 0.0, 0.0, s );
102
strcpy( Ecurfont, s );
105
/* ======================================== */
106
/* ETEXTSIZE - Set textsize to x. If x is 0 use standard textsize.
107
In any case, the size is scaled by the standard text scaling factor. */
114
if( x == 0 ) p = Estandard_textsize;
115
else p = (double)x * (double)(Estandard_textsize/10.0);
118
if( (int)p != Ecurtextsize ) {
119
Epcode( 'I', p, 0.0, "" );
120
Ecurtextsize = (int)p;
121
Ecurtextheight = (p+2.0)/72.0;
122
if( p >= 14 ) Ecurtextheight = p / 72.0;
123
if( Edev == 'g' && Ecurfont[0] == '\0' ) { /* "ascii" does not use preset sizes */
124
/* get exact dimensions of one of the 5 gif text sizes available .. */
125
if( p <= 6 ) { Ecurtextwidth = 0.05; Ecurtextheight = 9 / 72.0; } /* 7 */
126
else if( p >= 7 && p <= 9 )
127
{ Ecurtextwidth = 0.0615384; Ecurtextheight = 12 / 72.0; } /* 10 */
128
else if( p >= 10 && p <= 12 )
129
{ Ecurtextwidth = 0.0727272; Ecurtextheight = 14 / 72.0; } /* 12 */
130
else if( p >= 13 && p <= 15 )
131
{ Ecurtextwidth = 0.08; Ecurtextheight = 17 / 72.0; } /* 15 */
132
else if( p >= 15 ) { Ecurtextwidth = 0.0930232; Ecurtextheight = 20 / 72.0; }
134
else if( Edev != 'x' ) Ecurtextwidth = Ecurtextheight * 0.4;
135
/* note: x11 driver supplies Ecurtextwidth in
136
pcode() when text size is set */
139
/* ======================================== */
143
if( x != Ecurtextdirection ) {
144
Epcode( 'D', (double)x , 0.0, "" );
145
Ecurtextdirection = x ;
148
/* ======================================== */
152
/* if( Ecurpaper != x ) { deleted scg 2/29/00 trying to get multi-page landscape to work...*/
153
Epcode( 'O', (double)x , 0.0, "" );
157
/* ======================================== */
158
/* ELINETYPE - Set line parameters. If linewidth is 0 use standard linescale.
159
If pattern density is 0 use standard linescale. */
160
Elinetype( pattern, linewidth, pat_dens )
162
double linewidth, pat_dens;
166
/* scale linewidth */
167
if( linewidth == 0.0 ) linewidth = Estandard_lwscale;
168
else linewidth = linewidth * Estandard_lwscale;
170
if( pat_dens == 0.0 ) pat_dens = Estandard_lwscale;
172
if( linewidth != Ecurlinewidth ||
173
pattern != Ecurlinetype ||
174
pat_dens != Ecurpatternfactor ) {
176
sprintf( buf, "%d", pattern );
177
Epcode( 'Y', linewidth, pat_dens, buf );
178
Ecurlinewidth = linewidth;
179
Ecurlinetype = pattern;
180
Ecurpatternfactor = pat_dens;
184
/* ======================================== */
187
Epcode( 'Y', Estandard_lwscale, 1.0, "0" );
188
Ecurlinewidth = Estandard_lwscale;
190
Ecurpatternfactor = 1;
193
/* ======================================== */
194
/* set current color for lines and text to s. If s is "", use
199
/* char color[40], fillpat[40]; */
200
/* strip off fillpat spec and set flag? */
202
if( s[0] == '\0' ) strcpy( Ecurcolor, Estandard_color );
203
/* else if( strcmp( Ecurcolor, s )==0 ) return( 0 ); */ /* tried but screws up w/gif driver */
206
* sscanf( s, "%s %s",
209
else strcpy( Ecurcolor, s );
211
Epcode( 'r', 0.0, 0.0, Ecurcolor );
214
/* ======================================== */
215
/* set background color.
216
If background color is "" use standard background color. */
220
if( color[0] != '\0' )strcpy( Ecurbkcolor, color );
221
else strcpy( Ecurbkcolor, Estandard_bkcolor );
224
/* ======================================== */
225
/* fill currently defined rectangle/polygon with color c */
230
if( strcmp( c, Ecurcolor )==0 ) { Efill(); return(0); }
231
strcpy( oldcolor, Ecurcolor );
234
Ecolor( oldcolor ); /* go back to color as it existed before.. */
236
/* ======================================== */
237
/* (Old) do shading, within the previously defined polygon path.. the shade can be 0 to 1 */
242
sprintf( str, "%g", s );