PLplot
5.10.0
|
00001 // PLplot dg300 device driver. 00002 // 00003 #include "plDevs.h" 00004 00005 #ifdef PLD_dg300 00006 00007 #include "plplotP.h" 00008 #include "drivers.h" 00009 00010 // Device info 00011 PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_dg300 = "dg300:DG300 Terminal:0:dg300:25:dg300\n"; 00012 00013 void plD_dispatch_init_dg( PLDispatchTable *pdt ); 00014 00015 void plD_init_dg( PLStream * ); 00016 void plD_line_dg( PLStream *, short, short, short, short ); 00017 void plD_polyline_dg( PLStream *, short *, short *, PLINT ); 00018 void plD_eop_dg( PLStream * ); 00019 void plD_bop_dg( PLStream * ); 00020 void plD_tidy_dg( PLStream * ); 00021 void plD_state_dg( PLStream *, PLINT ); 00022 void plD_esc_dg( PLStream *, PLINT, void * ); 00023 00024 // top level declarations 00025 00026 #define DGX 639 00027 #define DGY 239 00028 00029 struct termattr 00030 { 00031 unsigned char com[4]; 00032 unsigned char rom[4]; 00033 unsigned char ram[4]; 00034 unsigned char con[5]; 00035 unsigned char eor; 00036 } termattr; 00037 00038 void plD_dispatch_init_dg( PLDispatchTable *pdt ) 00039 { 00040 #ifndef ENABLE_DYNDRIVERS 00041 pdt->pl_MenuStr = "DG300 Terminal"; 00042 pdt->pl_DevName = "dg300"; 00043 #endif 00044 pdt->pl_type = plDevType_Interactive; 00045 pdt->pl_seq = 25; 00046 pdt->pl_init = (plD_init_fp) plD_init_dg; 00047 pdt->pl_line = (plD_line_fp) plD_line_dg; 00048 pdt->pl_polyline = (plD_polyline_fp) plD_polyline_dg; 00049 pdt->pl_eop = (plD_eop_fp) plD_eop_dg; 00050 pdt->pl_bop = (plD_bop_fp) plD_bop_dg; 00051 pdt->pl_tidy = (plD_tidy_fp) plD_tidy_dg; 00052 pdt->pl_state = (plD_state_fp) plD_state_dg; 00053 pdt->pl_esc = (plD_esc_fp) plD_esc_dg; 00054 } 00055 00056 //-------------------------------------------------------------------------- 00057 // plD_init_dg() 00058 // 00059 // Initialize device. 00060 //-------------------------------------------------------------------------- 00061 00062 void 00063 plD_init_dg( PLStream *pls ) 00064 { 00065 // Request terminal configuration report 00066 00067 printf( "\n\036\107\051\n" ); 00068 scanf( "%s", (char *) &termattr ); 00069 while ( getchar() != '\n' ) 00070 ; 00071 if ( !strncmp( (char *) &termattr.ram[0], "0000", 4 ) ) 00072 { 00073 printf( "Please wait while graphics interpreter is downloaded.\n" ); 00074 00075 // Need to download graphics interpreter. 00076 00077 system( "cat /usr/local/src/g300/g300gci110.tx" ); 00078 } 00079 00080 // Clear screen, Set pen color to green, Absolute positioning 00081 00082 printf( "\036\107\063\060\n\036\107\155\061\n\036\107\151\060\n" ); 00083 printf( "\036\107\042\061\n" ); 00084 00085 pls->termin = 1; // Is an interactive device 00086 00087 plP_setpxl( (PLFLT) ( 3.316 * 16 ), (PLFLT) ( 1.655 * 16 ) ); 00088 plP_setphy( 0, DGX * 16, 0, DGY * 16 ); 00089 } 00090 00091 //-------------------------------------------------------------------------- 00092 // plD_line_dg() 00093 // 00094 // Draw a line in the current color from (x1,y1) to (x2,y2). 00095 //-------------------------------------------------------------------------- 00096 00097 void 00098 plD_line_dg( PLStream *pls, short x1a, short y1a, short x2a, short y2a ) 00099 { 00100 int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a; 00101 00102 printf( "LINE %d %d %d %d\n", x1 >> 4, y1 >> 3, x2 >> 4, y2 >> 3 ); 00103 } 00104 00105 //-------------------------------------------------------------------------- 00106 // plD_polyline_dg() 00107 // 00108 // Draw a polyline in the current color. 00109 //-------------------------------------------------------------------------- 00110 00111 void 00112 plD_polyline_dg( PLStream *pls, short *xa, short *ya, PLINT npts ) 00113 { 00114 PLINT i; 00115 00116 for ( i = 0; i < npts - 1; i++ ) 00117 plD_line_dg( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] ); 00118 } 00119 00120 //-------------------------------------------------------------------------- 00121 // plD_eop_dg() 00122 // 00123 // End of page. User must hit a <CR> to continue. 00124 //-------------------------------------------------------------------------- 00125 00126 void 00127 plD_eop_dg( PLStream *pls ) 00128 { 00129 putchar( '\007' ); 00130 fflush( stdout ); 00131 while ( getchar() != '\n' ) 00132 ; 00133 printf( "ERASE\n" ); 00134 } 00135 00136 //-------------------------------------------------------------------------- 00137 // plD_bop_dg() 00138 // 00139 // Set up for the next page. 00140 //-------------------------------------------------------------------------- 00141 00142 void 00143 plD_bop_dg( PLStream *pls ) 00144 { 00145 pls->page++; 00146 } 00147 00148 //-------------------------------------------------------------------------- 00149 // plD_tidy_dg() 00150 // 00151 // Close graphics file 00152 //-------------------------------------------------------------------------- 00153 00154 void 00155 plD_tidy_dg( PLStream *pls ) 00156 { 00157 printf( "\036\107\042\060\n" ); 00158 fflush( stdout ); 00159 } 00160 00161 //-------------------------------------------------------------------------- 00162 // plD_state_dg() 00163 // 00164 // Handle change in PLStream state (color, pen width, fill attribute, etc). 00165 //-------------------------------------------------------------------------- 00166 00167 void 00168 plD_state_dg( PLStream *pls, PLINT op ) 00169 { 00170 } 00171 00172 //-------------------------------------------------------------------------- 00173 // plD_esc_dg() 00174 // 00175 // Escape function. 00176 //-------------------------------------------------------------------------- 00177 00178 void 00179 plD_esc_dg( PLStream *pls, PLINT op, void *ptr ) 00180 { 00181 } 00182 00183 #else 00184 int 00185 pldummy_dg300() 00186 { 00187 return 0; 00188 } 00189 00190 #endif // PLD_dg300