~ubuntu-branches/ubuntu/maverick/ploticus/maverick

« back to all changes in this revision

Viewing changes to src/stub.c

  • Committer: Bazaar Package Importer
  • Author(s): James W. Penny
  • Date: 2002-04-10 23:02:04 UTC
  • Revision ID: james.westby@ubuntu.com-20020410230204-64em4ns2f57c5u3l
Tags: 2.0.3-1
* The "That Tears it, Now You Have to Update Docs Package" Release.
* New upstream release (well, not so new :-( )   closes: Bug#137578
* Correct missing libpng2-dev in build-depends.  closes: Bug#142205
* Use correct syntax to:
* close URL type.                                closes: Bug#137577
* fix Architecture                               closes: Bug#141657
* close ITP                                      closes: Bug#132878

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. */
 
4
 
 
5
 
 
6
#include "graphcore.h"
 
7
#include <ctype.h>
 
8
/* Low level elib drawing stubs.. */
 
9
/* These issue driver requests only when a parameter actually changes */
 
10
 
 
11
/* ======================================== */
 
12
Eclr()
 
13
{
 
14
double atof();
 
15
Epcode( 'z', 0.0, 0.0, Ecurbkcolor );
 
16
}
 
17
/* ======================================== */
 
18
/* move to x, y absolute */
 
19
Emov( x , y )
 
20
double x, y;
 
21
{
 
22
if( Eflip ) Epcode( 'M', (double)y , (double)x, "" );
 
23
else Epcode( 'M', (double)x , (double)y, "" );
 
24
}
 
25
/* ======================================== */
 
26
/* line to x, y absolute */
 
27
Elin( x , y )
 
28
double x, y;
 
29
{
 
30
if( Eflip ) Epcode( 'L', (double)y , (double)x, "" );
 
31
else Epcode( 'L', (double)x , (double)y, "" );
 
32
}
 
33
/* ======================================== */
 
34
/* path to x, y absolute (form a polygon to be shaded later) */
 
35
Epath( x, y )
 
36
double x, y;
 
37
{
 
38
if( Eflip ) Epcode( 'P', (double)y , (double)x, "" );
 
39
else Epcode( 'P', (double)x , (double)y, "" );
 
40
}
 
41
 
 
42
 
 
43
#ifdef CUT
 
44
/* ======================================== */
 
45
/* move to x, y data */
 
46
Emovu( x , y )
 
47
double x, y;
 
48
{
 
49
if( Eflip ) Epcode( 'M', Eax((double) y ) , Eay((double) x ), "" );
 
50
else Epcode( 'M', Eax((double) x ) , Eay((double) y ), "" );
 
51
}
 
52
/* ======================================== */
 
53
/* line to x, y data */
 
54
Elinu( x , y ) 
 
55
double x, y;
 
56
{
 
57
if( Eflip ) Epcode( 'L', Eax((double) y ) , Eay((double) x ), "" );
 
58
else Epcode( 'L', Eax((double) x ) , Eay((double) y ), "" );
 
59
}
 
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 ), "" )
 
62
#endif
 
63
 
 
64
/* ======================================== */
 
65
/* handle multi-line text. */
 
66
Edotext( s, op )
 
67
char *s;
 
68
char op;
 
69
{
 
70
int i, slen;
 
71
char chunk[256];
 
72
double x, y;
 
73
x = Ex1; y = Ey1;
 
74
/* convert op */
 
75
if( tolower(op) == 'l' ) op = 'T';
 
76
else if( tolower(op) == 'c' ) op = 'C';
 
77
else if( tolower(op) == 'r' ) op = 'J';
 
78
slen = strlen( s );
 
79
for( i = 0; ;  ) {
 
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 );
 
87
        else Emov( x, y );
 
88
        }
 
89
}
 
90
 
 
91
/* ======================================== */
 
92
/* EFONT - Set font to s.  If s is "" use standard font. */
 
93
Efont( s )      
 
94
char s[];
 
95
 
96
if( strlen( s ) < 1 ) {
 
97
        Epcode( 'F', 0.0, 0.0, Estandard_font ); 
 
98
        strcpy( Ecurfont, Estandard_font ); 
 
99
        }
 
100
else if( strcmp( s, Ecurfont )!= 0 ) {
 
101
        Epcode( 'F', 0.0, 0.0, s ); 
 
102
        strcpy( Ecurfont, s ); 
 
103
        } 
 
104
}
 
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. */
 
108
Etextsize( x )          
 
109
int x;
 
110
 
111
double p;
 
112
 
 
113
/* scale text */
 
114
if( x == 0 ) p = Estandard_textsize;
 
115
else p = (double)x * (double)(Estandard_textsize/10.0);
 
116
 
 
117
 
 
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; }
 
133
                }
 
134
        else if( Edev != 'x' ) Ecurtextwidth = Ecurtextheight * 0.4; 
 
135
                        /* note: x11 driver supplies Ecurtextwidth in 
 
136
                                pcode() when text size is set */
 
137
        }
 
138
}
 
139
/* ======================================== */
 
140
Etextdir( x )
 
141
int x;
 
142
 
143
if( x != Ecurtextdirection ) {
 
144
        Epcode( 'D', (double)x , 0.0, "" ); 
 
145
        Ecurtextdirection = x ; 
 
146
        }
 
147
}
 
148
/* ======================================== */
 
149
Epaper( x )
 
150
int x;
 
151
{
 
152
/* if( Ecurpaper != x ) { deleted scg 2/29/00 trying to get multi-page landscape to work...*/
 
153
        Epcode( 'O', (double)x , 0.0, "" ); 
 
154
        Ecurpaper = x; 
 
155
/*      } */
 
156
}
 
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 )    
 
161
int pattern;
 
162
double linewidth, pat_dens;
 
163
 
164
char buf[12];
 
165
 
 
166
/* scale linewidth  */
 
167
if( linewidth == 0.0 ) linewidth = Estandard_lwscale;
 
168
else linewidth = linewidth * Estandard_lwscale;
 
169
 
 
170
if( pat_dens == 0.0 ) pat_dens = Estandard_lwscale;
 
171
 
 
172
if( linewidth != Ecurlinewidth || 
 
173
        pattern != Ecurlinetype || 
 
174
        pat_dens != Ecurpatternfactor ) {
 
175
 
 
176
        sprintf( buf, "%d", pattern );
 
177
        Epcode( 'Y', linewidth, pat_dens, buf );
 
178
        Ecurlinewidth = linewidth; 
 
179
        Ecurlinetype = pattern; 
 
180
        Ecurpatternfactor = pat_dens;
 
181
        }
 
182
}
 
183
 
 
184
/* ======================================== */
 
185
Enormline()             
 
186
 
187
Epcode( 'Y', Estandard_lwscale, 1.0, "0" ); 
 
188
Ecurlinewidth = Estandard_lwscale;
 
189
Ecurlinetype = 0; 
 
190
Ecurpatternfactor = 1; 
 
191
}
 
192
 
 
193
/* ======================================== */
 
194
/* set current color for lines and text to s.  If s is "", use
 
195
   standard color.  */
 
196
Ecolor( s )
 
197
char *s;
 
198
{
 
199
/* char color[40], fillpat[40]; */
 
200
/* strip off fillpat spec and set flag? */
 
201
 
 
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 */
 
204
 
 
205
/* else {
 
206
 *      sscanf( s, "%s %s", 
 
207
 */
 
208
 
 
209
else strcpy( Ecurcolor, s );
 
210
        
 
211
Epcode( 'r', 0.0, 0.0, Ecurcolor );
 
212
}
 
213
 
 
214
/* ======================================== */
 
215
/* set background color.
 
216
   If background color is "" use standard background color. */
 
217
Ebackcolor( color )
 
218
char *color;
 
219
{
 
220
if( color[0] != '\0' )strcpy( Ecurbkcolor, color );
 
221
else strcpy( Ecurbkcolor, Estandard_bkcolor );
 
222
}
 
223
 
 
224
/* ======================================== */
 
225
/* fill currently defined rectangle/polygon with color c */
 
226
Ecolorfill( c )
 
227
char *c;
 
228
{
 
229
char oldcolor[30];
 
230
if( strcmp( c, Ecurcolor )==0 ) { Efill(); return(0); }
 
231
strcpy( oldcolor, Ecurcolor );
 
232
Ecolor( c );
 
233
Efill();
 
234
Ecolor( oldcolor ); /* go back to color as it existed before.. */
 
235
}
 
236
/* ======================================== */
 
237
/* (Old) do shading, within the previously defined polygon path.. the shade can be 0 to 1 */
 
238
Eshade( s )
 
239
double s;
 
240
{
 
241
char str[20];
 
242
sprintf( str, "%g", s );
 
243
Ecolorfill( str );
 
244
}