1 #include <../../nrnconf.h>
14 #define IGNORE(arg) arg
23 #if defined(useNeXTstep) || defined(__TURBOC__) || defined(__linux__)
41 static void hplot(
int,
double,
double);
46 static void Fig_plt(
int,
double,
double);
51 static void tplot(
int,
double,
double);
57 #if defined(__MINGW32__)
58 extern char** _environ;
63 #if !defined(__APPLE__)
64 extern char** environ;
66 #include <crt_externs.h>
85 #define text hoc_plttext
107 static char ssun[] =
"TERM=sun";
109 static char ncsa[] =
"NEURON=ncsa";
114 extern void x11_put_text(
const char*), x11_close_window(
void), x11_setcolor(
int);
115 extern void x11_coord(
double,
double), x11_vector(), x11_point(), x11_move(), x11flush();
116 extern void x11_clear(), x11_cleararea(), x11_open_window(), x11_fast(
int);
117 static void hoc_x11plot(
int,
double,
double);
121 extern void NeXT_put_text(), NeXT_close_window(), NeXT_setcolor();
122 extern void NeXT_coord(), NeXT_vector(), NeXT_point(), NeXT_move(), NeXTflush();
123 extern void NeXT_clear(), NeXT_cleararea(), NeXT_open_window(), NeXT_fast();
128 #if defined(__TURBOC__)
131 static int graphmode = 0;
132 static double xres = 640., yres = 350.;
135 void* _graphgetmem(
unsigned size) {
141 static void Initplot(
void) {
142 #if !defined(__GO32__)
143 registerfarbgidriver(EGAVGA_driver_far);
144 registerfarbgidriver(CGA_driver_far);
145 registerfarbgidriver(Herc_driver_far);
146 registerfarbgifont(triplex_font_far);
150 initgraph(&
graphdev, &graphmode,
"c:\\bc\\bgi");
156 hoc_execerror(
"Error in initializing graphics adaptor\n", (
char*) 0);
158 xres = (double) (getmaxx() + 1);
159 yres = (double) (getmaxy() + 1);
164 xres = (double) (getmaxx() + 1);
165 yres = (double) (getmaxy() + 1);
168 hoc_execerror(
"Error in initializing graphics adaptor\n", (
char*) 0);
180 if (
text && s[strlen(s) - 1] ==
'\n') {
183 buf[strlen(s) - 1] =
'\0';
243 static GrTextRegion* gtr;
246 void grx_move(
int r,
int c) {
249 trcur =
c + r * GRXCOL;
251 void grx_rel_move(
int new) {
252 trcur = ((int) (trcur / GRXCOL)) * GRXCOL +
new;
254 void grx_output_some_chars(
const char*
string,
int count) {
255 if (
string[count] ==
'\0') {
258 hoc_outtext(
"non-terminated string\n");
261 void grx_delete_chars(
int count) {
264 for (
i = 0;
i < count; ++
i) {
265 gtr->txr_buffer[
j++] =
' ';
267 GrDumpTextRegion(gtr);
269 grx_insert_some_chars(
string, count)
char* string;
276 gtr->txr_buffer[
j--] = gtr->txr_buffer[
i--];
279 grx_output_some_chars(
string, count);
282 grx_backspace(count)
int count;
291 gtr->txr_buffer[
j] =
' ';
292 }
while ((++
j) % GRXCOL);
293 GrDumpTextRegion(gtr);
298 for (
i = 0;
i < GRXCOL * GRXROW; ++
i) {
299 gtr->txr_backup[
i] =
'\0';
301 GrDumpTextRegion(gtr);
307 gtr = (GrTextRegion*)
emalloc(
sizeof(GrTextRegion));
308 gtr->txr_font = (GrFont*) 0;
309 gtr->txr_buffer =
ecalloc(GRXCOL * GRXROW,
sizeof(
char));
310 gtr->txr_backup =
ecalloc(GRXCOL * GRXROW,
sizeof(
char));
313 gtr->txr_width = GRXCOL;
314 gtr->txr_height = GRXROW;
315 gtr->txr_lineoffset = GRXCOL;
316 gtr->txr_fgcolor.v = 7;
317 gtr->txr_bgcolor.v = 0;
318 gtr->txr_chrtype = GR_BYTE_TEXT;
320 for (
i = 0;
i < GRXCOL * GRXROW; ++
i) {
321 gtr->txr_buffer[
i] =
' ';
324 GrDumpTextRegion(gtr);
327 hoc_outtext(s)
char* s;
339 for (cp = s; *cp; ++cp) {
341 if (*cp ==
'\n' || trcur >= GRXROW * GRXCOL) {
344 for (
i = 1;
i < GRXROW; ++
i) {
345 c1 = gtr->txr_buffer + (
i - 1) * GRXCOL;
346 c2 = gtr->txr_buffer + (
i) *GRXCOL;
347 for (
j = 0;
j < GRXCOL; ++
j) {
351 for (
i = 0;
i < GRXCOL; ++
i) {
354 trcur = (GRXROW - 1) * GRXCOL;
360 gtr->txr_buffer[trcur++] = ch;
362 GrDumpTextRegion(gtr);
367 #if !defined(__MINGW32__)
369 #if defined(__APPLE__)
370 char** environ = (*_NSGetEnviron());
372 #if defined(__TURBOC__)
379 for (
i = 0; environ[
i] !=
NULL;
i++) {
380 if (strcmp(environ[
i],
vt100) == 0)
382 if (strcmp(environ[
i],
ssun) == 0)
384 if (strcmp(environ[
i],
adm3a) == 0)
386 if (strcmp(environ[
i],
tek4014) == 0)
388 if (strcmp(environ[
i],
ncsa) == 0)
397 hoc_open_sunplot(environ);
443 void plt(
int mode,
double x,
double y) {
457 #if defined(__TURBOC__)
468 hoc_sunplot(&
text, mode, x, y);
472 hoc_x11plot(mode, x, y);
478 hoc_NeXTplot(mode, x, y);
525 static void tplot(
int mode,
double x,
double y) {
545 hy = (((
YHOME & 01777) >> 5) + 32);
546 ly = ((
YHOME & 037) + 96);
547 hx = (((
XHOME & 01777) >> 5) + 32);
590 hy = (((iy & 01777) >> 5) + 32);
591 ly = ((iy & 037) + 96);
592 hx = (((ix & 01777) >> 5) + 32);
593 lx = ((ix & 037) + 64);
603 #if FIG || HP || CODRAW
622 IGNORE(
fprintf(stderr,
"Can't open %s for hardplot output\n", s));
661 static char fig_preamble[] =
"#FIG 1.4\n80 2\n";
671 #define SCX(x) ((int) (x * .8))
672 #define SCY(y) (600 - (int) (y * .8))
674 #define SCXD(x) ((x * .8))
675 #define SCYD(y) (7.5 * 80. - (y * .8))
681 static short state = 0;
682 static double oldx, oldy;
683 static char text_preamble[] =
"4 0 0 16 0 0 0 0.000 1 16 40 ", text_postamble[] =
"\1\n",
685 line_preamble[] =
"7 1 0 1 0 0 0 0 0.000 0 0\n",
687 line_preamble[] =
"2 1 0 1 0 0 0 0 0.000 0 0\n",
689 line_postamble[] =
" 9999 9999\n";
704 if (state ==
LINE2) {
728 if (state ==
LINE2) {
734 if (state ==
LINE1) {
758 void hplot(
int mode,
double x,
double y) {
760 static short txt = 0;
812 void vtplot(
int mode,
double x,
double y) {
813 static short vtgrph = 0;
855 vtx = (int) ((767. / 1023.) * x);
856 vty = (int) (479. - (479 / 779.) * y);
869 if (
c >= 0 ||
c < 128) {
872 #if defined(__TURBOC__)
893 #if defined(__TURBOC__)
894 #define UN unsigned int
896 static void tplt(
int mode,
double x,
double y) {
903 setgraphmode(graphmode);
944 ix = ((xres - 1.) / 1023.) * x;
945 iy = (yres - 1.) - ((yres - 1.) / 779.) * y;
960 void cursor(
int r,
int c) {
961 #if !defined(__GO32__)
964 dx = (r & 255) * 256 +
c & 255;
975 #define CODRAW_MAXPOINT 200
982 static char codraw_preamble[] =
983 "SW(1,0,8,0,8);\nST(1);\nSG(0.1);\n\
984 SF(1,'HELVET-L');\nSF(2,'HELVET');\nSF(3,'CENTURY');\nSF(4,'SCRIPT');\n\
985 SF(5,'GREEK');\nSP(1);\nLT(1);LW(1);LC(15);LD(50);\nTF(1);TW(1);TS(0);TC(15);\
986 TL(1);TV(4);TA(0);TH(0.2);\n";
1002 #define SCXD(x) ((x * .008))
1003 #define SCYD(y) ((y * .008))
1010 static short state = 0;
1011 static double oldx, oldy;
1016 if (state ==
TEXT) {
1023 if (state ==
LINE2) {
1043 if (state ==
LINE2) {
1049 if (state ==
LINE1) {
1076 if (((
i + 1) % 8) == 0) {
1095 static void hoc_x11plot(
int mode,
double x,
double y) {
1096 extern int x11_init_done;
1098 if (!x11_init_done) {
1141 static hoc_NeXTplot(mode, x, y)
int mode;
1144 extern int NeXT_init_done;
1146 if (!NeXT_init_done) {
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
void hoc_execerror(const char *, const char *)
void hoc_close_plot(void)
int nrnpy_pr(const char *fmt,...)
void * ecalloc(size_t n, size_t size)
char * getenv(const char *s)
char * emalloc(unsigned n)
void * hoc_Emalloc(size_t size)
static char hardplot_filename[100]
static void Fig_preamble(void)
static void hard_text_preamble()
void Fig_file(const char *, int)
void hardplot_file(const char *s)
static void Fig_plt(int, double, double)
static void hplot(int, double, double)
void plprint(const char *s)
static void Codraw_preamble(void)
static void codraw_line()
static char fig_text_preamble[100]
static float * codraw_pointx
static void Codraw_plt(int, double, double)
static void tplot(int, double, double)
static float * codraw_pointy
void plt(int mode, double x, double y)