1 #include <../../nrnconf.h> 8 #define IGNORE(arg) {if(arg);} 10 #define IGNORE(arg) arg 19 #if defined(useNeXTstep) || defined(__TURBOC__) || defined(__linux__) 37 static void hplot(
int,
double,
double);
42 static void Fig_plt(
int,
double,
double);
47 static void tplot(
int,
double,
double);
53 #if defined(__MINGW32__) 54 extern char** _environ;
59 #if !defined(__APPLE__) 60 extern char** environ;
62 #include <crt_externs.h> 81 #define text hoc_plttext 103 static char ssun[] =
"TERM=sun";
105 static char ncsa[] =
"NEURON=ncsa";
110 extern void x11_put_text(
const char*), x11_close_window(
void), x11_setcolor(
int);
111 extern void x11_coord(
double,
double), x11_vector(), x11_point(), x11_move(), x11flush();
112 extern void x11_clear(), x11_cleararea(), x11_open_window(), x11_fast(
int);
113 static void hoc_x11plot(
int,
double,
double);
117 extern void NeXT_put_text(), NeXT_close_window(), NeXT_setcolor();
118 extern void NeXT_coord(), NeXT_vector(), NeXT_point(), NeXT_move(), NeXTflush();
119 extern void NeXT_clear(), NeXT_cleararea(), NeXT_open_window(), NeXT_fast();
124 #if defined(__TURBOC__) 127 static int graphmode = 0;
128 static double xres=640., yres=350.;
131 void *_graphgetmem(
unsigned size) {
137 static void Initplot(
void) {
138 #if !defined(__GO32__) 139 registerfarbgidriver(EGAVGA_driver_far);
140 registerfarbgidriver(CGA_driver_far);
141 registerfarbgidriver(Herc_driver_far);
142 registerfarbgifont(triplex_font_far);
146 initgraph(&
graphdev, &graphmode,
"c:\\bc\\bgi");
151 hoc_execerror(
"Error in initializing graphics adaptor\n", (
char *)0);
153 xres = (double)(getmaxx()+1);
154 yres = (double)(getmaxy()+1);
159 xres = (double)(getmaxx()+1);
160 yres = (double)(getmaxy()+1);
163 hoc_execerror(
"Error in initializing graphics adaptor\n", (
char *)0);
176 if (
text && s[strlen(s) - 1] ==
'\n') {
179 buf[strlen(s)-1] =
'\0';
186 settextstyle(text_style,text_orient,text_size);
231 if (
text && s == buf) {
239 static GrTextRegion* gtr;
242 void grx_move(
int r,
int c){
245 trcur = c + r*GRXCOL;
247 void grx_rel_move(
int new){
248 trcur = ((
int)(trcur/GRXCOL))*GRXCOL +
new;
250 void grx_output_some_chars(
const char*
string,
int count) {
251 if (
string[count] ==
'\0') {
254 hoc_outtext(
"non-terminated string\n");
257 void grx_delete_chars(
int count) {
260 for (i=0; i < count; ++
i) {
261 gtr->txr_buffer[j++] =
' ';
263 GrDumpTextRegion(gtr);
265 grx_insert_some_chars(
string, count)
char* string;
int count; {
270 gtr->txr_buffer[j--] = gtr->txr_buffer[i--];
273 grx_output_some_chars(
string, count);
276 grx_backspace(count)
int count; {
284 gtr->txr_buffer[
j] =
' ';
285 }
while ((++j)%GRXCOL);
286 GrDumpTextRegion(gtr);
291 for (i=0; i < GRXCOL*GRXROW; ++
i) {
292 gtr->txr_backup[
i] =
'\0';
294 GrDumpTextRegion(gtr);
300 gtr = (GrTextRegion*)
emalloc(
sizeof(GrTextRegion));
301 gtr->txr_font = (GrFont*)0;
302 gtr->txr_buffer =
ecalloc(GRXCOL*GRXROW,
sizeof(
char));
303 gtr->txr_backup =
ecalloc(GRXCOL*GRXROW,
sizeof(
char));
306 gtr->txr_width = GRXCOL;
307 gtr->txr_height = GRXROW;
308 gtr->txr_lineoffset = GRXCOL;
309 gtr->txr_fgcolor.v = 7;
310 gtr->txr_bgcolor.v = 0;
311 gtr->txr_chrtype = GR_BYTE_TEXT;
313 for (i=0; i < GRXCOL*GRXROW; ++
i) {
314 gtr->txr_buffer[
i] =
' ';
317 GrDumpTextRegion(gtr);
320 hoc_outtext(
s)
char*
s; {
331 for (cp = s; *cp; ++cp) {
333 if (*cp ==
'\n' || trcur >= GRXROW*GRXCOL) {
336 for (i=1; i < GRXROW; ++
i) {
337 c1 = gtr->txr_buffer + (i-1)*GRXCOL;
338 c2 = gtr->txr_buffer + (
i)*GRXCOL;
339 for (j =0; j < GRXCOL; ++
j) {
343 for (i=0; i < GRXCOL; ++
i) {
346 trcur = (GRXROW-1)*GRXCOL;
352 gtr->txr_buffer[trcur++] = ch;
354 GrDumpTextRegion(gtr);
360 #if !defined(__MINGW32__) 362 #if defined (__APPLE__) 363 char** environ=(*_NSGetEnviron());
365 #if defined(__TURBOC__) 372 for (i = 0; environ[
i] !=
NULL; i++)
374 if (strcmp(environ[i],
vt100) == 0)
376 if (strcmp(environ[i],
ssun) == 0)
378 if (strcmp(environ[i],
adm3a) == 0)
380 if (strcmp(environ[i],
tek4014) == 0)
382 if (strcmp(environ[i],
ncsa) == 0)
391 hoc_open_sunplot(environ);
436 void plt(
int mode,
double x,
double y) {
438 if (x > 1000.) x = 1000.;
440 if (y > 780.) y = 780.;
446 #if defined(__TURBOC__) 457 hoc_sunplot(&
text, mode, x, y);
461 hoc_x11plot(mode,x,y);
467 hoc_NeXTplot(mode,x,y);
514 static void tplot(
int mode,
double x,
double y) {
534 hy = (((
YHOME & 01777) >> 5) + 32);
535 ly = ((
YHOME & 037) + 96);
536 hx = (((
XHOME & 01777) >> 5) + 32);
537 lx = ((
XHOME & 037) + 64);
579 hy = (((iy & 01777) >> 5) + 32);
580 ly = ((iy & 037) + 96);
581 hx = (((ix & 01777) >> 5) + 32);
582 lx = ((ix & 037) + 64);
592 #if FIG || HP || CODRAW 607 strncpy(hardplot_filename, s, 99);
611 IGNORE(
fprintf(stderr,
"Can't open %s for hardplot output\n", s));
614 hardplot_filename[0] =
'\0';
642 fig_text_preamble[0] =
'\0';
649 static char fig_preamble[] =
"#FIG 1.4\n80 2\n";
658 #define SCX(x) ((int)(x*.8)) 659 #define SCY(y) (600-(int)(y*.8)) 661 #define SCXD(x) ((x*.8)) 662 #define SCYD(y) (7.5*80.-(y*.8)) 668 static short state = 0;
669 static double oldx, oldy;
671 text_preamble[] =
"4 0 0 16 0 0 0 0.000 1 16 40 ",
672 text_postamble[] =
"\1\n",
674 line_preamble[] =
"7 1 0 1 0 0 0 0 0.000 0 0\n",
676 line_preamble[]=
"2 1 0 1 0 0 0 0 0.000 0 0\n",
678 line_postamble[] =
" 9999 9999\n";
684 if (!fig_text_preamble[0]) {
692 if (state ==
LINE2) {
699 text_preamble,
SCX(oldx),
SCY(oldy)));
717 if (state ==
LINE2) {
723 if (state ==
LINE1) {
749 void hplot(
int mode,
double x,
double y) {
751 static short txt = 0;
803 void vtplot(
int mode,
double x,
double y)
805 static short vtgrph = 0;
851 vtx = (
int) ((767./1023.)*x);
852 vty = (
int) (479. - (479/779.)*y);
866 if (c >= 0 || c < 128) {
869 #if defined(__TURBOC__) 890 #if defined(__TURBOC__) 891 #define UN unsigned int 893 static void tplt(
int mode,
double x,
double y)
902 setgraphmode(graphmode);
945 ix = ((xres -1.)/1023.)*x;
946 iy = (yres-1.) - ((yres-1.)/779.)*y;
963 void cursor(
int r,
int c) {
964 #if !defined(__GO32__) 967 dx = (r&255)*256 + c&255;
978 #define CODRAW_MAXPOINT 200 985 static char codraw_preamble[] =
"SW(1,0,8,0,8);\nST(1);\nSG(0.1);\n\ 986 SF(1,'HELVET-L');\nSF(2,'HELVET');\nSF(3,'CENTURY');\nSF(4,'SCRIPT');\n\ 987 SF(5,'GREEK');\nSP(1);\nLT(1);LW(1);LC(15);LD(50);\nTF(1);TW(1);TS(0);TC(15);\ 988 TL(1);TV(4);TA(0);TH(0.2);\n";
993 if (!codraw_pointy) {
1003 #define SCXD(x) ((x*.008)) 1004 #define SCYD(y) ((y*.008)) 1011 static short state = 0;
1012 static double oldx, oldy;
1016 if (state ==
TEXT) {
1023 if (state ==
LINE2) {
1044 if (state ==
LINE2) {
1050 if (state ==
LINE1) {
1052 codraw_pointx[0] = oldx;
1053 codraw_pointy[0] = oldy;
1071 if (codraw_npoint < 2) {
1077 if (((i + 1) % 8) == 0) {
1081 SCYD(codraw_pointy[i])));
1097 static void hoc_x11plot(
int mode,
double x,
double y)
1099 extern int x11_init_done;
1101 if (!x11_init_done) {
1145 hoc_NeXTplot(mode, x, y)
1149 extern int NeXT_init_done;
1151 if (!NeXT_init_done) {
void hoc_close_plot(void)
void plt(int mode, double x, double y)
void * ecalloc(size_t n, size_t size)
static void codraw_line()
static char fig_text_preamble[100]
static void Fig_plt(int, double, double)
static void Fig_preamble(void)
int nrnpy_pr(const char *fmt,...)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
static void hard_text_preamble()
static float * codraw_pointx
void hoc_execerror(const char *, const char *)
void Fig_file(const char *, int)
char * getenv(const char *s)
fprintf(stderr, "Don't know the location of params at %p\, pp)
static char hardplot_filename[100]
char * emalloc(unsigned n)
static void hplot(int, double, double)
void hardplot_file(const char *s)
static void Codraw_plt(int, double, double)
static void Codraw_preamble(void)
void plprint(const char *s)
static void tplot(int, double, double)
static float * codraw_pointy
void * hoc_Emalloc(size_t size)