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