PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
dg300.c
Go to the documentation of this file.
1 // PLplot dg300 device driver.
2 //
3 #include "plDevs.h"
4 
5 #ifdef PLD_dg300
6 
7 #include "plplotP.h"
8 #include "drivers.h"
9 
10 // Device info
11 PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_dg300 = "dg300:DG300 Terminal:0:dg300:25:dg300\n";
12 
14 
15 void plD_init_dg( PLStream * );
16 void plD_line_dg( PLStream *, short, short, short, short );
17 void plD_polyline_dg( PLStream *, short *, short *, PLINT );
18 void plD_eop_dg( PLStream * );
19 void plD_bop_dg( PLStream * );
20 void plD_tidy_dg( PLStream * );
21 void plD_state_dg( PLStream *, PLINT );
22 void plD_esc_dg( PLStream *, PLINT, void * );
23 
24 // top level declarations
25 
26 #define DGX 639
27 #define DGY 239
28 
29 struct termattr
30 {
31  unsigned char com[4];
32  unsigned char rom[4];
33  unsigned char ram[4];
34  unsigned char con[5];
35  unsigned char eor;
36 } termattr;
37 
39 {
40 #ifndef ENABLE_DYNDRIVERS
41  pdt->pl_MenuStr = "DG300 Terminal";
42  pdt->pl_DevName = "dg300";
43 #endif
45  pdt->pl_seq = 25;
46  pdt->pl_init = (plD_init_fp) plD_init_dg;
47  pdt->pl_line = (plD_line_fp) plD_line_dg;
48  pdt->pl_polyline = (plD_polyline_fp) plD_polyline_dg;
49  pdt->pl_eop = (plD_eop_fp) plD_eop_dg;
50  pdt->pl_bop = (plD_bop_fp) plD_bop_dg;
51  pdt->pl_tidy = (plD_tidy_fp) plD_tidy_dg;
52  pdt->pl_state = (plD_state_fp) plD_state_dg;
53  pdt->pl_esc = (plD_esc_fp) plD_esc_dg;
54 }
55 
56 //--------------------------------------------------------------------------
57 // plD_init_dg()
58 //
59 // Initialize device.
60 //--------------------------------------------------------------------------
61 
62 void
63 plD_init_dg( PLStream *pls )
64 {
65 // Request terminal configuration report
66 
67  printf( "\n\036\107\051\n" );
68  scanf( "%s", (char *) &termattr );
69  while ( getchar() != '\n' )
70  ;
71  if ( !strncmp( (char *) &termattr.ram[0], "0000", 4 ) )
72  {
73  printf( "Please wait while graphics interpreter is downloaded.\n" );
74 
75  // Need to download graphics interpreter.
76 
77  system( "cat /usr/local/src/g300/g300gci110.tx" );
78  }
79 
80 // Clear screen, Set pen color to green, Absolute positioning
81 
82  printf( "\036\107\063\060\n\036\107\155\061\n\036\107\151\060\n" );
83  printf( "\036\107\042\061\n" );
84 
85  pls->termin = 1; // Is an interactive device
86 
87  plP_setpxl( (PLFLT) ( 3.316 * 16 ), (PLFLT) ( 1.655 * 16 ) );
88  plP_setphy( 0, DGX * 16, 0, DGY * 16 );
89 }
90 
91 //--------------------------------------------------------------------------
92 // plD_line_dg()
93 //
94 // Draw a line in the current color from (x1,y1) to (x2,y2).
95 //--------------------------------------------------------------------------
96 
97 void
98 plD_line_dg( PLStream *pls, short x1a, short y1a, short x2a, short y2a )
99 {
100  int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
101 
102  printf( "LINE %d %d %d %d\n", x1 >> 4, y1 >> 3, x2 >> 4, y2 >> 3 );
103 }
104 
105 //--------------------------------------------------------------------------
106 // plD_polyline_dg()
107 //
108 // Draw a polyline in the current color.
109 //--------------------------------------------------------------------------
110 
111 void
112 plD_polyline_dg( PLStream *pls, short *xa, short *ya, PLINT npts )
113 {
114  PLINT i;
115 
116  for ( i = 0; i < npts - 1; i++ )
117  plD_line_dg( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
118 }
119 
120 //--------------------------------------------------------------------------
121 // plD_eop_dg()
122 //
123 // End of page. User must hit a <CR> to continue.
124 //--------------------------------------------------------------------------
125 
126 void
127 plD_eop_dg( PLStream *pls )
128 {
129  putchar( '\007' );
130  fflush( stdout );
131  while ( getchar() != '\n' )
132  ;
133  printf( "ERASE\n" );
134 }
135 
136 //--------------------------------------------------------------------------
137 // plD_bop_dg()
138 //
139 // Set up for the next page.
140 //--------------------------------------------------------------------------
141 
142 void
143 plD_bop_dg( PLStream *pls )
144 {
145  pls->page++;
146 }
147 
148 //--------------------------------------------------------------------------
149 // plD_tidy_dg()
150 //
151 // Close graphics file
152 //--------------------------------------------------------------------------
153 
154 void
155 plD_tidy_dg( PLStream *pls )
156 {
157  printf( "\036\107\042\060\n" );
158  fflush( stdout );
159 }
160 
161 //--------------------------------------------------------------------------
162 // plD_state_dg()
163 //
164 // Handle change in PLStream state (color, pen width, fill attribute, etc).
165 //--------------------------------------------------------------------------
166 
167 void
168 plD_state_dg( PLStream *pls, PLINT op )
169 {
170 }
171 
172 //--------------------------------------------------------------------------
173 // plD_esc_dg()
174 //
175 // Escape function.
176 //--------------------------------------------------------------------------
177 
178 void
179 plD_esc_dg( PLStream *pls, PLINT op, void *ptr )
180 {
181 }
182 
183 #else
184 int
186 {
187  return 0;
188 }
189 
190 #endif // PLD_dg300