/* * $Id: aed.trm,v 1.13 1998/04/14 00:17:27 drd Exp $ * */ /* GNUPLOT - aed.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * AED terminals * * AUTHORS * Colin Kelley, Thomas Williams, Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dez. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(aed512) register_term(aed767) #endif #ifdef TERM_PROTO TERM_PUBLIC void AED_init __PROTO((void)); TERM_PUBLIC void AED_graphics __PROTO((void)); TERM_PUBLIC void AED_text __PROTO((void)); TERM_PUBLIC void AED_linetype __PROTO((int linetype)); TERM_PUBLIC void AED_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void AED_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void AED_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void AED_reset __PROTO((void)); #define AED_XMAX 768 #define AED_YMAX 575 #define AED_VCHAR 13 #define AED_HCHAR 8 #define AED_VTIC 8 #define AED_HTIC 7 /* slightly different for AED 512 */ #define AED5_XMAX 512 #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #define AED_XLAST (AED_XMAX - 1) #define AED_YLAST (AED_YMAX - 1) #define AED5_XLAST (AED5_XMAX - 1) TERM_PUBLIC void AED_init() { fputs("\033SEN3DDDN.SEC.7.SCT.0.1.80.80.90.SBC.0.AAV2.MOV.0.9.CHR.0.FFD", gpoutfile); /* 2 3 4 5 7 6 1 1. Clear Screen 2. Set Encoding 3. Set Default Color 4. Set Backround Color Table Entry 5. Set Backround Color 6. Move to Bottom Lefthand Corner 7. Anti-Alias Vectors */ } TERM_PUBLIC void AED_graphics() { fputs("\033FFD\033", gpoutfile); } TERM_PUBLIC void AED_text() { fputs("\033MOV.0.9.SEC.7.XXX", gpoutfile); } TERM_PUBLIC void AED_linetype(linetype) int linetype; { static int color[2 + 9] = { 7, 1, 6, 2, 3, 5, 1, 6, 2, 3, 5 }; static int type[2 + 9] = { 85, 85, 255, 255, 255, 255, 255, 85, 85, 85, 85 }; if (linetype >= 10) linetype %= 10; fprintf(gpoutfile, "\ \033SLS%d.255.\ \033SEC%d.", type[linetype + 2], color[linetype + 2]); } TERM_PUBLIC void AED_move(x, y) unsigned int x, y; { fprintf(gpoutfile, "\033MOV%d.%d.", x, y); } TERM_PUBLIC void AED_vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "\033DVA%d.%d.", x, y); } TERM_PUBLIC void AED_put_text(x, y, str) unsigned int x, y; char str[]; { AED_move(x, y - AED_VCHAR / 2 + 2); fprintf(gpoutfile, "\033XXX%s\033", str); } #define hxt (AED_HTIC/2) #define hyt (AED_VTIC/2) TERM_PUBLIC void AED_reset() { fputs("\033SCT0.1.0.0.0.SBC.0.FFD", gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(aed512_driver) "aed512", "AED 512 Terminal", AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR, AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, AED_text, null_scale, AED_graphics, AED_move, AED_vector, AED_linetype, AED_put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(aed512_driver) #undef LAST_TERM #define LAST_TERM aed512_driver TERM_TABLE_START(aed767_driver) "aed767", "AED 767 Terminal", AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR, AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, AED_text, null_scale, AED_graphics, AED_move, AED_vector, AED_linetype, AED_put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(aed767_driver) #undef LAST_TERM #define LAST_TERM aed767_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(aed767) "1 aed767", "?commands set terminal aed767", "?set terminal aed767", "?set term aed767", "?terminal aed767", "?term aed767", "?aed767", "?commands set terminal aed512", "?set terminal aed512", "?set term aed512", "?terminal aed512", "?term aed512", "?aed512", " The `aed512` and `aed767` terminal drivers support AED graphics terminals.", " The two drivers differ only in their horizontal ranges, which are 512 and", " 768 pixels, respectively. Their vertical range is 575 pixels. There are", " no options for these drivers." END_HELP(aed767) #endif /* * $Id: ai.trm,v 1.18 1998/04/14 00:17:28 drd Exp $ * */ /* GNUPLOT - ai.trm */ /*[ * Copyright 1991, 1992, 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * aifm * * AUTHORS * Ray Ghanbari * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * * The 'aifm' driver produces files editable by Adobe Illustrator 3.0 * To change font to Courier and font size to 20pts use * 'set term aifm "Courier" 20'. * To switch to color output use * 'set term aifm color'. */ /* AIFM driver by Ray Ghanbari, ray@mtl.mit.edu, * based on PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */ /* Changed to 3.6 terminal format, David C. Schooley, 9/29/95 */ /* Improved multiple plot support, David C. Schooley, 6/5/95 */ /* Compatiblity with Illustrator 7.0, David C. Schooley, 6/5/95 */ /* Font and size support for labels, David C. Schooley, 6/5/95 */ #include "driver.h" #ifdef TERM_REGISTER register_term(aifm) #endif #ifdef TERM_PROTO TERM_PUBLIC void AI_init __PROTO((void)); TERM_PUBLIC void AI_graphics __PROTO((void)); TERM_PUBLIC void AI_text __PROTO((void)); TERM_PUBLIC void AI_linetype __PROTO((int linetype)); TERM_PUBLIC void AI_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void AI_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void AI_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int AI_text_angle __PROTO((int ang)); TERM_PUBLIC void AI_reset __PROTO((void)); TERM_PUBLIC void AI_options __PROTO((void)); TERM_PUBLIC int AI_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void AI_suspend __PROTO(()); TERM_PUBLIC void AI_resume __PROTO(()); TERM_PUBLIC int AI_set_font __PROTO((char *font)); #define AI_XOFF 50 /* page offset in pts */ #define AI_YOFF 50 #define AI_XMAX 5000 #define AI_YMAX 3500 #define AI_XLAST (AI_XMAX - 1) #define AI_YLAST (AI_YMAX - 1) #define AI_VTIC (AI_YMAX/80) #define AI_HTIC (AI_YMAX/80) #define AI_SC (10.0) /* scale is 1pt = 10 units */ #define AI_LW (0.5*AI_SC) /* linewidth = 0.5 pts */ #define AI_VCHAR (14*AI_SC) /* default is 14 point characters */ #define AI_HCHAR (14*AI_SC*6/10) #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* From version.c */ extern char version[]; extern char patchlevel[]; char ai_font[MAX_ID_LEN + 1] = "Times-Roman"; /* name of font */ int ai_fontsize = 14; /* size of font in pts */ char ai_oldfont[MAX_ID_LEN + 1] = "Times-Roman"; /* name of font */ int ai_oldfontsize = 14; /* size of font in pts */ TBOOLEAN ai_color = FALSE; TBOOLEAN ai_stroke = FALSE; int ai_page = 0; /* page count */ int ai_path_count = 0; /* count of lines in path */ int ai_ang = 0; /* text angle */ int ai_subgroup_level = 0; /* depth of sub-groups */ int ai_multiplot_group = 0; /* group for multiplot */ enum JUSTIFY ai_justify = LEFT; /* text is flush left */ TERM_PUBLIC void AI_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "d$efault")) { ai_color = FALSE; strcpy(ai_font, "Times-Roman"); ai_fontsize = 14; strcpy(ai_oldfont, "Times-Roman"); ai_oldfontsize = 14; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "m$onochrome")) { ai_color = FALSE; c_token++; } else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { ai_color = TRUE; c_token++; } } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(ai_font, c_token, MAX_ID_LEN); strcpy(ai_oldfont, ai_font); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; ai_fontsize = (int) real(const_express(&a)); ai_oldfontsize = ai_fontsize; c_token++; term->v_char = (unsigned int) (ai_fontsize * AI_SC); term->h_char = (unsigned int) (ai_fontsize * AI_SC * 6 / 10); } sprintf(term_options, "%s \"%s\" %d", ai_color ? "color" : "monochrome", ai_font, ai_fontsize); } TERM_PUBLIC void AI_init() { ai_page = 0; fprintf(gpoutfile, "%%!PS-Adobe-2.0 EPSF-1.2\n\ %%%%Creator: Adobe Illustrator(TM) 3.2\n\ %%%%TrueCreator: gnuplot %s patchlevel %s ai terminal\n\ %%%%BoundingBox: %d %d %d %d\n\ %%%%Template:\n\ %%%%EndComments\n\ %%%%EndProlog\n", version, patchlevel, AI_XOFF, AI_YOFF, (int) ((AI_XMAX) / AI_SC + 0.5 + AI_XOFF), (int) ((AI_YMAX) / AI_SC + 0.5 + AI_YOFF)); } TERM_PUBLIC void AI_graphics() { ai_page++; /* fprintf(gpoutfile,"%%%%Page: %d %d\n",ai_page,ai_page);*/ fputs("\ 0 G\n\ 1 j\n\ 1 J\n\ u\n", gpoutfile); ai_path_count = 0; ai_stroke = FALSE; } TERM_PUBLIC void AI_text() { if (ai_stroke) { fputs("S\n", gpoutfile); ai_stroke = FALSE; } while (ai_subgroup_level) { fputs("U\n", gpoutfile); ai_subgroup_level--; } fputs("U\n", gpoutfile); ai_path_count = 0; ai_multiplot_group = 0; } TERM_PUBLIC void AI_reset() { fputs("%%%%Trailer\n", gpoutfile); /* fprintf(gpoutfile,"%%%%Pages: %d\n",ai_page);*/ } TERM_PUBLIC void AI_linetype(linetype) int linetype; { if (ai_stroke) { fputs("S\n", gpoutfile); ai_stroke = FALSE; } if (ai_subgroup_level) { fputs("U\n", gpoutfile); ai_subgroup_level--; } if (linetype == -2 && multiplot) { /* for each new plot, line_type gets called twice with a value of -2. It gets called once for the border and again for the tics. This code will need to be changed if gnuplot's behavior changes. */ switch (ai_multiplot_group) { case 0: fputs("u\n", gpoutfile); ai_subgroup_level++; ai_multiplot_group = 1; break; case 1: ai_multiplot_group = 2; break; case 2: ai_multiplot_group = 1; fputs("U\nu\n", gpoutfile); break; } } if (linetype == -2 && !multiplot) { if (ai_multiplot_group) { fputs("U\n", gpoutfile); ai_subgroup_level--; ai_multiplot_group = 0; } } fputs("u\n", gpoutfile); ai_subgroup_level++; switch (linetype) { case -2: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC * 2.0); if (ai_color) { fputs("0 0 0 1 K\n", gpoutfile); } else { fputs("[] 0 d\n", gpoutfile); } break; case -1: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC / 2.0); if (ai_color) { fputs("0 0 0 1 K\n", gpoutfile); } else { fputs("[1 2] 0 d\n", gpoutfile); } break; case 0: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("1 0 1 0 K\n", gpoutfile); } else { fputs("[] 0 d\n", gpoutfile); } break; case 1: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("1 1 0 0 K\n", gpoutfile); } else { fputs("[4 2] 0 d\n", gpoutfile); } break; case 2: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("0 1 1 0 K\n", gpoutfile); } else { fputs("[2 3] 0 d\n", gpoutfile); } break; case 3: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("0 1 0 0 K\n", gpoutfile); } else { fputs("[1 1.5] 0 d\n", gpoutfile); } break; case 4: fprintf(gpoutfile, "%f w\n", AI_LW / AI_SC); if (ai_color) { fputs("1 0 0 0 K\n", gpoutfile); } else { fputs("[5 2 1 2] 0 d\n", gpoutfile); } break; case 5: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("0 0 1 0 K\n", gpoutfile); } else { fputs("[4 3 1 3] 0 d\n", gpoutfile); } break; case 6: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("0 0 0 1 K\n", gpoutfile); } else { fputs("[2 2 2 4] 0 d\n", gpoutfile); } break; case 7: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("0 0.7 1 0 K\n", gpoutfile); } else { fputs("[2 2 2 2 2 4] 0 d\n", gpoutfile); } break; case 8: fprintf(gpoutfile, "%.2f w\n", AI_LW / AI_SC); if (ai_color) { fputs("0.5 0.5 0.5 0 K\n", gpoutfile); } else { fputs("[2 2 2 2 2 2 2 4] 0 d\n", gpoutfile); } break; } ai_path_count = 0; } TERM_PUBLIC void AI_move(x, y) unsigned int x, y; { if (ai_stroke) fputs("S\n", gpoutfile); fprintf(gpoutfile, "%.2f %.2f m\n", x / AI_SC, y / AI_SC); ai_path_count += 1; ai_stroke = TRUE; } TERM_PUBLIC void AI_vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "%.2f %.2f l\n", x / AI_SC, y / AI_SC); ai_path_count += 1; ai_stroke = TRUE; if (ai_path_count >= 400) { fprintf(gpoutfile, "S\n%.2f %.2f m\n", x / AI_SC, y / AI_SC); ai_path_count = 0; } } TERM_PUBLIC void AI_put_text(x, y, str) unsigned int x, y; char *str; { char ch; if (ai_stroke) { fputs("S\n", gpoutfile); ai_stroke = FALSE; } switch (ai_justify) { case LEFT: fprintf(gpoutfile, "/_%s %d 0 0 0 z\n", ai_font, ai_fontsize); break; case CENTRE: fprintf(gpoutfile, "/_%s %d 0 0 1 z\n", ai_font, ai_fontsize); break; case RIGHT: fprintf(gpoutfile, "/_%s %d 0 0 2 z\n", ai_font, ai_fontsize); break; } if (ai_ang == 0) { fprintf(gpoutfile, "[ 1 0 0 1 %.2f %.2f] e\n", x / AI_SC, y / AI_SC - ai_fontsize / 3.0); } else { fprintf(gpoutfile, "[ 0 1 -1 0 %.2f %.2f] e\n", x / AI_SC - ai_fontsize / 3.0, y / AI_SC); } putc('(', gpoutfile); ch = *str++; while (ch != '\0') { if ((ch == '(') || (ch == ')') || (ch == '\\')) putc('\\', gpoutfile); putc(ch, gpoutfile); ch = *str++; } fputs(") t\nT\n", gpoutfile); ai_path_count = 0; } TERM_PUBLIC int AI_text_angle(ang) int ang; { ai_ang = ang; return TRUE; } TERM_PUBLIC int AI_justify_text(mode) enum JUSTIFY mode; { ai_justify = mode; return TRUE; } TERM_PUBLIC int AI_set_font(font) /* Entry font added by DJL */ char *font; { char name[32]; int size, sep; if (font && *font) { sep = strcspn(font, ","); strncpy(name, font, sep); name[sep] = '\0'; size = ai_fontsize; sscanf(&(font[sep + 1]), "%d", &size); if (*name) strcpy(ai_font, name); if (size) ai_fontsize = size; } else { ai_fontsize = ai_oldfontsize; strcpy(ai_font, ai_oldfont); } return TRUE; } TERM_PUBLIC void AI_suspend() { } TERM_PUBLIC void AI_resume() { } #endif #ifdef TERM_TABLE TERM_TABLE_START(aifm_driver) "aifm", "Adobe Illustrator 3.0 Format", AI_XMAX, AI_YMAX, AI_VCHAR, AI_HCHAR, AI_VTIC, AI_HTIC, AI_options, AI_init, AI_reset, AI_text, null_scale, AI_graphics, AI_move, AI_vector, AI_linetype, AI_put_text, AI_text_angle, AI_justify_text, do_point, do_arrow, AI_set_font, NULL, 0, AI_suspend, AI_resume TERM_TABLE_END(aifm_driver) #undef LAST_TERM #define LAST_TERM aifm_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(aifm) "1 aifm", "?commands set terminal aifm", "?set terminal aifm", "?set term aifm", "?terminal aifm", "?term aifm", "?aifm", " Several options may be set in `aifm`---the Adobe Illustrator 3.0+ driver.", "", " Syntax:", " set terminal aifm {} {\"\"} {}", "", " is either `color` or `monochrome`; \"\" is the name of a", " valid PostScript font; is the size of the font in PostScript", " points, before scaling by the `set size` command. Selecting `default` sets", " all options to their default values: `monochrome`, \"Helvetica\", and 14pt.", "", " Since AI does not really support multiple pages, multiple graphs will be", " drawn directly on top of one another. However, each graph will be grouped", " individually, making it easy to separate them inside AI (just pick them up", " and move them).", "", " Examples:", " set term aifm", " set term aifm 22", " set size 0.7,1.4; set term aifm color \"Times-Roman\" 14" END_HELP(ai) #endif /* TERM_HELP */ /* * $Id: amiga.trm,v 1.18 1998/04/14 00:17:29 drd Exp $ * */ /* GNUPLOT - amiga.trm */ /*[ * Copyright 1991, 1992, 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Amiga Custom Screen * * AUTHORS * Carsten Steger * * Pat R. Empleo Slightly modified for Aztec C v5.2a (beta); sort of * 08/27/91 supports overscan; for large WB 2.0 virtual screens, * we limit the plot size so we don't have to scroll * around (not fun). * * Carsten Steger Modified to support Kickstart 2.0. * 09/11/91 Opens a text overscan screen when used with WB 2.0. * Discerns between NTSC and PAL Amigas when used with * WB 1.3 and lower. * * Pat R. Empleo Defined some 2.0 stuff in order to get Aztec C to * 09/20/91 work with Carsten's new code (see above). When * KS/WB 2.0 support gets implemented in Aztec C, this * kludge will get deleted! * (Aztec C release 5.2 beta) * * Carsten Steger Converted to new terminal layout. * 10/01/95 * * Lars Hecking Add code from George Coulouris to * 06/20/97 implement window option, requires AmigaOS 3.0+. * General cleanup, better readability. * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ #include "driver.h" #ifdef TERM_REGISTER register_term(amiga) #endif #ifdef TERM_PROTO #define AMIGA_XMAX 640 #define AMIGA_YMAX 512 #define AMIGA_VCHAR 12 #define AMIGA_HCHAR 8 #define AMIGA_VTIC 5 #define AMIGA_HTIC 5 TERM_PUBLIC void AMIGA_reset __PROTO((void)); TERM_PUBLIC void AMIGA_init __PROTO((void)); TERM_PUBLIC void AMIGA_options __PROTO((void)); TERM_PUBLIC void AMIGA_text __PROTO((void)); TERM_PUBLIC void AMIGA_graphics __PROTO((void)); TERM_PUBLIC void AMIGA_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void AMIGA_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void AMIGA_linetype __PROTO((int linetype)); TERM_PUBLIC void AMIGA_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int AMIGA_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int AMIGA_set_font __PROTO((char *font)); TERM_PUBLIC void AMIGA_suspend __PROTO((void)); TERM_PUBLIC void AMIGA_resume __PROTO((void)); #define GOT_AMIGA_PROTO #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #ifdef AMIGA_AC_5 #include #include #include #include #else /* You will have to use the Kickstart 2.0 header files for this to compile */ #include #include #include #include #include #include #include #include #endif /* !AMIGA_AC_5 */ #ifndef NO_ATEXIT void AMIGA_exit(void); # define ATEXIT(x) (atexit(x) != 0) # ifdef AMIGA_SC_6_1 /* # define ATEXIT(x) (onexit(x) == 0) */ # define RAWCON(x) rawcon(x) # else # define RAWCON(x) /* nought */ # endif /* SAS */ #else # define ATEXIT(x) 0 #endif /* NO_ATEXIT */ #ifndef RETURN_FAIL # define RETURN_FAIL 20 #endif #define LIB_VERSION(LibBase) ((LibBase)->LibNode.lib_Version) #define AMIGA_ERROR(string,rc) {fprintf (stderr,"%s\n",string);\ AMIGA_reset (); exit (rc);} /* from plot.c */ extern TBOOLEAN interactive; /* The origin is in the upper left hand corner, so we have to translate */ /* and flip the coordinates: */ #define AMIGA_VTF(y) (AMIGA_ymax-1-(y)) /* Libraries */ struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct Library *DiskfontBase; /* Name of font, size in pts */ static char AMIGA_FontName[MAX_ID_LEN+1] = ""; static int AMIGA_FontSize; /* Font stuff */ static struct TextAttr AMIGA_Font = { "topaz.font", TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT }; static struct TextFont *AMIGA_TextFont; /* Screen stuff */ static struct NewScreen AMIGA_NewScreen = { 0, 0, AMIGA_XMAX, AMIGA_YMAX, 4, 15, 0, HIRES | LACE, CUSTOMSCREEN | SCREENBEHIND | SCREENQUIET, NULL, NULL, NULL, NULL }; static struct Screen *AMIGA_Screen; static struct TagItem AMIGA_ScrTagList[] = { { SA_Overscan, OSCAN_TEXT }, { TAG_DONE, 0 } }; /* Window stuff */ /* FALSE: plot to screen; TRUE: plot to window */ static TBOOLEAN AMIGA_window_mode = FALSE; #define AMIGA_WIN_XMAX 512 #define AMIGA_WIN_YMAX 320 static struct Window *AMIGA_Window; static struct TagItem AMIGA_WinTagList[] = { { WA_InnerWidth, AMIGA_WIN_XMAX }, { WA_InnerHeight, AMIGA_WIN_YMAX }, { WA_Title, (ULONG) "gnuplot" }, { WA_DragBar, TRUE }, { WA_DepthGadget, TRUE }, { WA_WBenchWindow, TRUE }, { WA_SmartRefresh, TRUE }, { WA_GimmeZeroZero, TRUE }, { WA_AutoAdjust, TRUE }, { TAG_DONE, 0 } }; /* * This is the palette. Values are stored as 0xrrggbb, where rr, gg, and, bb * are big-endian 8-bit intensities for red, green, and blue, respectively. */ static unsigned int palette[] = { 0xffffff, /* white */ 0x000000, /* black */ 0xff0000, /* red */ 0x00ff00, /* green */ 0x0000ff, /* blue */ 0x00ffff, /* cyan */ 0xff00ff, /* magenta */ 0xffff00, /* yellow */ 0x7f007f, /* purple */ 0xff7f00, /* orange */ }; #define PALETTE_SIZE (sizeof (palette) / sizeof (unsigned int)) /* This is the color look-up table, indexed in the same order as * the above palette. The values stored in this table are pen numbers; * e.g clut[2] is the pen which represents the color "red". */ static unsigned int clut[PALETTE_SIZE]; /* Colors */ static UWORD AMIGA_Colors[] = { 0x000, 0xfff, 0xbbb, 0x0f0, 0xf00, 0x00f, 0x3ca, 0xf0f, 0x94d, 0x0ff, 0x82f, 0xff0, 0x0af, 0xc5e, 0xfa2, 0xf44 }; /* Misc */ static int AMIGA_slinetype; static enum JUSTIFY AMIGA_justify = LEFT; static unsigned int AMIGA_ymax, AMIGA_xmax; static WORD AMIGA_cwd, AMIGA_cht, AMIGA_bsl, AMIGA_vadj; /* Common RastPort */ static struct RastPort *AMIGA_RastPort; /* * Close open font, screen and libraries. */ TERM_PUBLIC void AMIGA_reset() { if (AMIGA_window_mode == TRUE) { int i = 0; /* Free the pens */ while (i < PALETTE_SIZE) { if (clut[i] != -1) ReleasePen(AMIGA_Window->WScreen->ViewPort.ColorMap, clut[i]); i++; } /* Close the window */ if (AMIGA_Window != NULL) CloseWindow(AMIGA_Window); AMIGA_Window = NULL; AMIGA_window_mode = FALSE; } if (AMIGA_TextFont != NULL) CloseFont(AMIGA_TextFont); if (DiskfontBase != NULL) CloseLibrary(DiskfontBase); if (AMIGA_Screen != NULL) CloseScreen(AMIGA_Screen); if (IntuitionBase != NULL) CloseLibrary((struct Library *) IntuitionBase); if (GfxBase != NULL) CloseLibrary((struct Library *) GfxBase); AMIGA_TextFont = NULL; DiskfontBase = NULL; AMIGA_Screen = NULL; IntuitionBase = NULL; GfxBase = NULL; AMIGA_RastPort = NULL; } /* * Init terminal. */ TERM_PUBLIC void AMIGA_init() { char name[MAX_ID_LEN + 1]; /* Install exit trap in case of abnormal termination (see below). */ if (ATEXIT(AMIGA_exit)) AMIGA_ERROR("Couldn't set exit trap", RETURN_FAIL); /* Open needed libraries */ GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0); if (GfxBase == NULL) AMIGA_ERROR("No Graphics-Library", RETURN_FAIL); IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0); if (IntuitionBase == NULL) AMIGA_ERROR("No Intuition-Library", RETURN_FAIL); if (AMIGA_window_mode == TRUE) { int i = 0; /* Initialize the clut */ while (i < PALETTE_SIZE) clut[i++] = -1; } if (LIB_VERSION(IntuitionBase) <= 34) { /* We compute the vertical resolution for those poor NTSC-souls :-) */ if (GfxBase->DisplayFlags & PAL) AMIGA_ymax = 512; else AMIGA_ymax = 400; AMIGA_xmax = 640; AMIGA_NewScreen.Width = AMIGA_xmax; AMIGA_NewScreen.Height = AMIGA_ymax; AMIGA_Screen = OpenScreen(&AMIGA_NewScreen); if (AMIGA_Screen == NULL) AMIGA_ERROR("No Screen", RETURN_FAIL); AMIGA_RastPort = &AMIGA_Screen->RastPort; } else { /* Intuition version > 34 */ /* Kickstart 2.0 support */ AMIGA_NewScreen.Width = STDSCREENWIDTH; AMIGA_NewScreen.Height = STDSCREENHEIGHT; if (AMIGA_window_mode != TRUE) { AMIGA_Screen = OpenScreenTagList(&AMIGA_NewScreen, AMIGA_ScrTagList); if (AMIGA_Screen == NULL) AMIGA_ERROR("No Screen", RETURN_FAIL); AMIGA_RastPort = &AMIGA_Screen->RastPort; AMIGA_xmax = AMIGA_Screen->Width; AMIGA_ymax = AMIGA_Screen->Height; } else if (LIB_VERSION(GfxBase) >= 39) { /* AMIGA_window_mode == TRUE */ /* Open the plot window */ AMIGA_Window = (struct Window *)OpenWindowTagList(NULL, AMIGA_WinTagList); /* Don't do this: fall back to screen */ if (AMIGA_Window == NULL) AMIGA_ERROR("Could not open plot window", RETURN_FAIL); AMIGA_RastPort = AMIGA_Window->RPort; AMIGA_xmax = AMIGA_WIN_XMAX; AMIGA_ymax = AMIGA_WIN_YMAX; } /* Gfx version >= 39 */ } /* Intuition version <= 34 */ term->xmax = AMIGA_xmax; term->ymax = AMIGA_ymax; if (AMIGA_window_mode != TRUE) { sprintf(name, "%s,%d", AMIGA_FontName, AMIGA_FontSize); AMIGA_set_font(name); LoadRGB4(&AMIGA_Screen->ViewPort, AMIGA_Colors, 16); RemakeDisplay(); AMIGA_slinetype = 1; SetAPen(&AMIGA_Screen->RastPort, AMIGA_slinetype); } else { int i, r, g, b; AMIGA_bsl = AMIGA_Window->RPort->TxBaseline; /* Reference line */ AMIGA_cht = AMIGA_Window->RPort->TxHeight; /* Height of characters */ /* Allocate pens */ for (i = 0; i < PALETTE_SIZE; i++) { r = (palette[i] << 8) & 0xFF000000; g = (palette[i] << 16) & 0xFF000000; b = (palette[i] << 24) & 0xFF000000; clut[i] = ObtainBestPenA(AMIGA_Window->WScreen->ViewPort.ColorMap, r, g, b, NULL); } } SetDrMd(AMIGA_RastPort, JAM1); } /* * Scan terminal options */ TERM_PUBLIC void AMIGA_options() { /* Screen/Window mode */ if (!END_OF_COMMAND) { if (almost_equals(c_token, "scr$een")) { AMIGA_window_mode = FALSE; c_token++; } else if (almost_equals(c_token, "win$dow")) { AMIGA_window_mode = TRUE; c_token++; } } /* Font name */ if (!END_OF_COMMAND && isstring(c_token)) { quote_str(AMIGA_FontName, c_token, MAX_ID_LEN); c_token++; } /* Font size */ if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; AMIGA_FontSize = (int) real(const_express(&a)); } if (strcmp(AMIGA_FontName, "") == 0 && AMIGA_FontSize != 0) strcpy(AMIGA_FontName, "topaz"); if (strcmp(AMIGA_FontName, "") != 0 && AMIGA_FontSize == 0) AMIGA_FontSize = 8; if (strcmp(AMIGA_FontName, "") != 0 && AMIGA_FontSize != 0) { sprintf(default_font, "%s,%d", AMIGA_FontName, AMIGA_FontSize); sprintf(term_options, "%s \"%s\" %d", \ (AMIGA_window_mode != TRUE ? "screen" : "window"), \ AMIGA_FontName, AMIGA_FontSize); } else sprintf(term_options, "%s", (AMIGA_window_mode != TRUE ? "screen" : "window")); } /* * */ TERM_PUBLIC void AMIGA_text() { if (AMIGA_window_mode != TRUE) { if (interactive == TRUE) { FILE *fp; if ((fp = fopen("*", "r")) != NULL) { int c = getc(fp); ungetc(c, stdin); fclose(fp); } ScreenToBack(AMIGA_Screen); } } } /* * */ TERM_PUBLIC void AMIGA_graphics() { SetRast(AMIGA_RastPort, 0); if (AMIGA_window_mode == TRUE) { /* clear the window */ SetAPen(AMIGA_Window->RPort, clut[0]); RectFill(AMIGA_Window->RPort, 0, 0, 640, 400); AMIGA_slinetype = clut[1]; } SetAPen(AMIGA_RastPort, AMIGA_slinetype); AMIGA_resume(); } /* * */ TERM_PUBLIC void AMIGA_move(x, y) unsigned int x, y; { if ((x >= AMIGA_xmax) || (y >= AMIGA_ymax)) return; Move(AMIGA_RastPort, x, AMIGA_VTF(y)); } /* * */ TERM_PUBLIC void AMIGA_vector(x, y) unsigned int x, y; { if ((x >= AMIGA_xmax) || (y >= AMIGA_ymax)) return; Draw(AMIGA_RastPort, x, AMIGA_VTF(y)); } /* * */ TERM_PUBLIC void AMIGA_linetype(linetype) int linetype; { if (AMIGA_window_mode != TRUE) { if (linetype >= 13) linetype %= 13; if (linetype < -2) linetype = -2; AMIGA_slinetype = linetype + 3; } else { if (linetype >= 0) linetype = (linetype % 9) + 1; if (linetype < 0) linetype = 1; AMIGA_slinetype = clut[linetype]; } SetAPen(AMIGA_RastPort, AMIGA_slinetype); } /* * */ TERM_PUBLIC void AMIGA_put_text(x, y, str) unsigned int x, y; char *str; { LONG len, tx_len; WORD x_min, x_max, y_min, y_max; len = strlen(str); tx_len = TextLength(AMIGA_RastPort, str, len); switch (AMIGA_justify) { case LEFT: x_min = x; x_max = x + tx_len; break; case CENTRE: x_min = x - tx_len / 2; x_max = x + tx_len - tx_len / 2; /* avoid roundoff errors ! */ break; default: /* does this make sense ?? */ case RIGHT: x_min = x - tx_len; x_max = x; break; } y_min = AMIGA_VTF(y) - AMIGA_vadj; y_max = y_min + AMIGA_cht; /* Check if character-string lies completely within the screen: */ /* What about clipping? */ if ((x_max >= AMIGA_xmax) || (y_min < 0) || (y_max >= AMIGA_ymax)) return; Move(AMIGA_RastPort, x_min, y_min + AMIGA_bsl); Text(AMIGA_RastPort, str, len); } /* * */ TERM_PUBLIC int AMIGA_justify_text(mode) enum JUSTIFY mode; { AMIGA_justify = mode; return TRUE; } /* * */ TERM_PUBLIC int AMIGA_set_font(font) char *font; { static char test_str[] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; static WORD test_len, test_pxl; char name[MAX_ID_LEN+1]; int size, sep; /* Disable for window mode */ if (AMIGA_window_mode != TRUE) { sep = strcspn(font, ","); strncpy(name, font, sep); name[sep] = NUL; size = AMIGA_FontSize; sscanf(&(font[sep + 1]), "%d", &size); if (strcmp(name, "") != 0) { strncat(name, ".font", MAX_ID_LEN+1); /* Avoid opening "diskfont.library" if a built-in font is desired */ if ((strcmp("topaz.font", name) == 0) && ((size == TOPAZ_EIGHTY) || (size == TOPAZ_SIXTY))) { AMIGA_Font.ta_Name = name; AMIGA_Font.ta_YSize = size; AMIGA_Font.ta_Style = FS_NORMAL; AMIGA_Font.ta_Flags = FPF_ROMFONT; AMIGA_TextFont = OpenFont(&AMIGA_Font); if (AMIGA_TextFont != NULL) SetFont(&AMIGA_Screen->RastPort, AMIGA_TextFont); } else { DiskfontBase = OpenLibrary("diskfont.library", 0); if (DiskfontBase != NULL) { AMIGA_Font.ta_Name = name; AMIGA_Font.ta_YSize = size; AMIGA_Font.ta_Style = FS_NORMAL; AMIGA_Font.ta_Flags = FPF_ROMFONT | FPF_DISKFONT; AMIGA_TextFont = OpenDiskFont(&AMIGA_Font); if (AMIGA_TextFont != NULL) SetFont(&AMIGA_Screen->RastPort, AMIGA_TextFont); } } } /* Width of characters: This works better for proportional fonts than */ /* AMIGA_Screen->RastPort.TxWidth + AMIGA_Screen->RastPort.TxSpacing */ test_len = strlen(test_str); test_pxl = TextLength(&AMIGA_Screen->RastPort, test_str, test_len); AMIGA_cwd = test_pxl / test_len; AMIGA_cht = AMIGA_Screen->RastPort.TxHeight; /* Height of characters */ AMIGA_bsl = AMIGA_Screen->RastPort.TxBaseline; /* Reference line */ /* Amount by which characters have to be shifted upwards to be */ /* vertically justified: */ AMIGA_vadj = AMIGA_bsl / 2; term->v_char = AMIGA_cht + 4; /* So lines won't be too close */ term->h_char = AMIGA_cwd; } /* !window_mode */ return TRUE; } /* * */ TERM_PUBLIC void AMIGA_suspend() { if (AMIGA_window_mode != TRUE) { if (interactive == TRUE) { FILE *fp; if ((fp = fopen("*", "r")) != NULL) { int c = getc(fp); ungetc(c, stdin); fclose(fp); } ScreenToBack(AMIGA_Screen); } } } /* * */ TERM_PUBLIC void AMIGA_resume() { if (AMIGA_window_mode != TRUE) ScreenToFront(AMIGA_Screen); else WindowToFront(AMIGA_Window); } #ifndef NO_ATEXIT /* This function is mainly included if the program terminates abnormally * and the screen and libraries are still open. It closes down all opened * libraries and screens. This happens e.g. when loading "bivariat.demo" * and the stack is smaller than 120000 bytes. */ void AMIGA_exit(void) { AMIGA_reset(); RAWCON(0); } #endif /* NO_ATEXIT */ #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(amiga_driver) "amiga", "Amiga Custom Screen/Window [screen window]", AMIGA_XMAX, AMIGA_YMAX, AMIGA_VCHAR, AMIGA_HCHAR, AMIGA_VTIC, AMIGA_HTIC, AMIGA_options, AMIGA_init, AMIGA_reset, AMIGA_text, null_scale, AMIGA_graphics, AMIGA_move, AMIGA_vector, AMIGA_linetype, AMIGA_put_text, null_text_angle, AMIGA_justify_text, do_point, do_arrow, AMIGA_set_font, 0, /* pointsize */ TERM_CAN_MULTIPLOT, AMIGA_suspend, AMIGA_resume TERM_TABLE_END(amiga_driver) #undef LAST_TERM #define LAST_TERM amiga_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(amiga) "1 amiga", "?commands set terminal amiga", "?set terminal amiga", "?set term amiga", "?terminal amiga", "?term amiga", "?amiga", " The `amiga` terminal, for Commodore Amiga computers, allows the user to", " plot either to a screen (default), or, if Kickstart 3.0 or higher is", " installed, to a window on the current public screen. The font and its size", " can also be selected.", "", " Syntax:", " set terminal amiga {screen | window} {\"\"} {}", "", " The default font is 8-point \"topaz\".", "", " The screen option uses a virtual screen, so it is possible that the graph", " will be larger than the screen." END_HELP(amiga) #endif /* TERM_HELP */ /* * $Id: apollo.trm,v 1.13 1998/04/14 00:17:30 drd Exp $ * */ /* GNUPLOT - apollo.trm */ /* Apollo terminal driver for gnuplot. Open a pad for the graphics, and use GPR routines. For additional speed, we do the graphics to a separate bitmap, and the blt the entire bitmap to the display. When the user specifies an output file name, however, we draw directly to the screen, so the graphics are written to the file correctly. Thus, the user can save the graphics in a file, to be viewed later. If we try the bitmap trick, it looks funny. Ray Lischner (uunet!mntgfx!lisch) 4 October 1989 file created for gnuplot 1.1 26 March 1990 updated for gnuplot 2.0 30 October 1991 fixed minor problem in apollo_tic_sizes As of 13 January 1999, this file has been placed in the public domain by Ray Lischner. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(apollo) #endif #ifdef TERM_PROTO TERM_PUBLIC void APOLLO_init __PROTO((void)); TERM_PUBLIC void APOLLO_graphics __PROTO((void)); TERM_PUBLIC void APOLLO_linetype __PROTO((int ltype)); TERM_PUBLIC void APOLLO_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void APOLLO_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void APOLLO_text __PROTO((void)); TERM_PUBLIC int APOLLO_text_angle __PROTO((int ang)); TERM_PUBLIC int APOLLO_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void APOLLO_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void APOLLO_reset __PROTO((void)); /* default tick sizes for small windows */ #define APOLLO_VTIC 6 #define APOLLO_HTIC 6 #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #include #include #include #include int apollo_isa_pad __PROTO((void)); static void apollo_font_info __PROTO((struct termentry * tbl, char *fname)); static void apollo_gpr_init __PROTO((struct termentry * tbl, pad_$window_desc_t * window)); static void apollo_tic_sizes __PROTO((struct termentry * tbl)); static void apollo_gpr_terminate __PROTO((void)); static void apollo_redo_window __PROTO((pad_$window_desc_t * window)); static void apollo_xy_error __PROTO((char *s, int x, int y, status_$t status)); /* issue an error message, using additional text "s" */ #define apollo_error(s) error_$print_name(status, (s), strlen(s)) /* if "status" indicates an error, then issue an error message */ #define apollo_check(s) if (status.all != status_$ok) apollo_error(s) static ios_$id_t stream = -1; /* the stream for the pad */ static gpr_$bitmap_desc_t screen_desc; /* the screen's bitmap */ static gpr_$bitmap_desc_t bitmap_desc; /* the graphics bitmap */ static gpr_$attribute_desc_t attr; /* attribute block for saved bitmap */ static int APOLLO_XMAX, APOLLO_YMAX; /* window size */ static short draw_width; /* default GPR draw width */ static name_$long_pname_t font_name; /* font path name */ static boolean use_bitmap; /* use a separate bitmap? */ /* return whether stdout is a DM pad */ apollo_isa_pad() { status_$t status; pad_$isa(1, &status); return (status.all == status_$ok); } /* Find out what the default font is for the pad, and save the character height and width information. Note that we must save the font file name because we need to reload the font file everytime the window changes size. */ static void apollo_font_info(struct termentry *tbl, char *fname) { short fwidth, fheight, flen; status_$t status; /* get the font size & update the termentry table */ pad_$inq_font(stream, &fwidth, &fheight, fname, name_$long_pnamlen_max, &flen, &status); apollo_check("inq_font"); fname[flen] = NUL; tbl->v_char = fheight; tbl->h_char = fwidth; } /* Initialize all the GPR stuff. To save time, we draw into a separate bitmap, and then blt it onto the screen all at once. This results in 5-10 times speed-up in the graphics, with only a little complication. Most of the complication is right here, making sure we allocate the right bitmaps, etc., in the right order. The rest is in APOLLO_text(), where we actually BLT the bitmap onto the screen. Everything else is the same. The bitmaps have the same size as the window. If the window changes size, then the bitmaps retain the same size, so the user sees part of the plot or a lot of space around the plot. Drawing a new plot, or replotting the previous one causes APOLLO_graphics() to see if the window has changed size, in which case the GPR is terminated, and this routine is called again. Thus, make sure any changes preserve this ability. Anything that should only be done once to the pad should be handled by APOLLO_init(). By the way, we save the current draw width, to be used later for drawing extra wide lines. This way we don't need to know anything about the current output device characteristics; we can just draw the default width, or twice the default width, etc. */ static void apollo_gpr_init(struct termentry *tbl, pad_$window_desc_t * window) { gpr_$offset_t size; short fontid; status_$t status; size.x_size = APOLLO_XMAX = tbl->xmax = window->width; size.y_size = APOLLO_YMAX = tbl->ymax = window->height; /* now initialize GPR */ gpr_$init(gpr_$frame, stream, size, 1, &screen_desc, &status); apollo_check("gpr_$init"); if (use_bitmap) { /* allocate the bitmap and its attribute block */ gpr_$allocate_attribute_block(&attr, &status); apollo_check("allocate_attribute_block"); gpr_$allocate_bitmap(size, 1, attr, &bitmap_desc, &status); apollo_check("allocate_bitmap"); gpr_$set_bitmap(bitmap_desc, &status); apollo_check("set_bitmap"); } /* set the font file */ gpr_$load_font_file(font_name, strlen(font_name), &fontid, &status); apollo_check(font_name); gpr_$set_text_font(fontid, &status); apollo_check("set_text_font"); gpr_$inq_draw_width(&draw_width, &status); apollo_check("inq_draw_width"); } /* Determine the tick sizes to be used for labelling borders. By default, we use 1/50 of the window size, which looks nice to me. If this makes the ticks too small, however, we use a minimum size, to make sure they are visible. The minimum size was also determined experimentally. Feel free to changes the sizes to something you feel looks better. This routine must be called after apollo_gpr_init(), because we need to know the window size, as stored in the termentry table. */ static void apollo_tic_sizes(struct termentry *tbl) { /* base the tick size on the window size */ tbl->v_tic = tbl->ymax / 50; if (tbl->v_tic < APOLLO_VTIC) tbl->v_tic = APOLLO_VTIC; tbl->h_tic = tbl->xmax / 50; if (tbl->h_tic < APOLLO_HTIC) tbl->h_tic = APOLLO_HTIC; } /* Terminate the GPR. This is called whenever the window size changes, and we need to reinitialize the GPR. I assume that calling gpr_$terminate() also deallocates the bitmaps and attribute blocks because deallocating the screen's bitmap causes terminate() to think GPR has already been terminated. Since this can be called many times, make sure nothing drastic is done here, like closing the stream to the pad. The only actions should be those that will be reinitialized by apollo_gpr_init(). */ static void apollo_gpr_terminate() { status_$t status; gpr_$terminate(false, &status); apollo_check("terminate"); } /* Initialize the graphics. This is called once, so we do things here that should be done exactly once, such as opening the window. I like to give windows names, so it is obvious what the window's contents are, but this causes a transcript to be kept in a file whose name is the window's name. This might be nice in some circumstances, but to me it is a nuisance, so the file is deleted immediately. The name is unlikely to appear normally, so there should be little interference with users' normal files. If the user has explicitly set the output file, however, then we use that name, and do not delete the file. Thus, the user can get a metafile of the plot. We can tell if the output file has been set because outstr is NULL. Otherwise, outstr is the filename, in alloc-ed store. The DM defaults are used for window sizes and positions. If the user doesn't like it, he or she can change is and issue a replot command (assuming a plot has already been generated). Note, also, that we must call pad_$set_scale() or else pad_$inq_windows() returns scaled values, which is not what we want. Setting the scale to one (1) turns off the scaling, so we get real pixel sizes. Finally, we get the name and size of the default font. The name is kept, as explained earlier. Then we can initialize the GPR stuff. Note that there is a way that APOLLO_init() gets called more than once. If the user issues the "set terminal apollo" command more than once, then this is called, so we need to make sure that we do not keep creating windows. An alternative strategy would be to interpret multiple "set term apollo"s to mean create multiple windows. The user could only access the most recent window because gnuplot has no concept of multiple terminals. The user would, in fact, have no way of removing old windows because they are still active. We could try catching keyboard events to see if the user presses EXIT, but I do not want to start getting into that mess. If the user really wants this kind of functionality, then he or she can run gnuplot multiple times. I think that is a lot cleaner, don't you? */ TERM_PUBLIC void APOLLO_init() { /* only initialize once */ if (stream == -1) { struct termentry *tbl; pad_$window_desc_t window; name_$long_name_t wname; short wnum; /* junk needed by pad_$inq_windows() */ boolean unlink_wname; status_$t status; tbl = term; /* make the window name unique, with "gnuplot" in the label */ if (outstr == NULL) { sprintf(wname, "gnuplot-%d", getpid()); unlink_wname = true; } else { strcpy(wname, outstr); unlink_wname = false; } use_bitmap = unlink_wname; /* use the default window position and size */ window.top = window.left = window.width = window.height = 0; pad_$create_window(wname, strlen(wname), pad_$transcript, 1, window, &stream, &status); apollo_check("create_window"); /* if this is not the user's name, then delete the file */ if (unlink_wname) unlink(wname); /* remove all scaling, to revert to pixel units, not char. units */ pad_$set_scale(stream, 1, 1, &status); apollo_check("set_scale"); /* get rid of the window when the program exits */ pad_$set_auto_close(stream, 1, true, &status); apollo_check("set_auto_close"); /* now determine the window size & update the termentry table */ pad_$inq_windows(stream, &window, 1, &wnum, &status); apollo_check("inq_windows"); /* the order of the next three calls is important */ apollo_font_info(tbl, font_name); apollo_gpr_init(tbl, &window); apollo_tic_sizes(tbl); } } /* Prepare for graphics output. Since this is what the user wants to do when preparing a new plot, this is a meaningful time to see if the window has changed size. Thus, we avoid mucking about with asynchronous traps, and we avoid the bigger problem of dealing with a half-finished plot when the window changes size. Simply put, get the current window size, and if it has changed, then get rid of the old bitmaps, etc., and allocate new ones at the new size. We also need to update the termentry table. If the window stays the same size, then just clear it. */ static void apollo_redo_window(pad_$window_desc_t * window) { struct termentry *tbl = term; status_$t status; /* the order of the following calls is important */ apollo_gpr_terminate(); apollo_gpr_init(tbl, window); apollo_tic_sizes(tbl); } TERM_PUBLIC void APOLLO_graphics() { pad_$window_desc_t window; short wnum; status_$t status; pad_$inq_windows(stream, &window, 1, &wnum, &status); apollo_check("inq_windows"); if (window.width != APOLLO_XMAX || window.height != APOLLO_YMAX) apollo_redo_window(&window); else { gpr_$clear(0, &status); apollo_check("clear"); } } /* set a line type: -2 heavy, solid (border) -1 heavy, dotted (axis) 0 solid (normal) 1 dots (other curves) 2 short dash 3 long dash 4 dash dot Apparently, GPUplot draws a lot of short line segments, and each one starts a new pattern. This makes the patterns somewhat useless, but one can still tell the difference between solid, dotted, and dashed lines. The utility of fancier styles is limited, however. On a color workstation, we should use different colors, but I don't have one. */ /* To draw different line styles on an Apollo, we use two different parameters. One is a line thickness, which is just an integral multiple of the default line thickness. The second is a 16-bit pattern that is repeated. We could use fancier patterns, since GPR supports up to 64-bits, but, as I explained earlier, this really does not buy us anything. I used patterns that do not start with all bits on because gnuplot seems to use lots of short line segments to draw a curve, and this might make a very curvey plot seem like a solid line, regardless of pattern. I don't want to start with too many zeros, however, or else the curve might not appear at all! All the patterns, therefore, start with one bit on. The rest of the bits determine the true pattern. By examining graphics.c, we see that linetype -2 is used exclusively for the border, -1 for the axes, and the non-negative integers for the curves. We use heavy lines for the border and axes, and normal width lines for the curves. Since C arrays start at zero, make sure all the offsets are correct, so that it is easy to access the array with -2...n linetypes. */ typedef struct { short width; short pattern; } APOLLO_LINE; static APOLLO_LINE apollo_lines[] = { {2, ~0}, /* heavy, solid */ {2, 0x6666}, /* heavy, dotted */ {1, ~0}, /* normal */ {1, 0xAAAA}, /* dotted */ {1, 0xC3C3}, /* short dash */ {1, 0xE01F}, /* long dash */ {1, 0x87F8}, /* dash dot */ {1, 0x6666}, /* big dots */ }; #define BITS_PER_LINETYPE 16 /* apollo_line(-2) is the border style, etc. */ #define apollo_line(x) apollo_lines[(x)+2] #define apollo_pattern(x) &apollo_line(x).pattern #define apollo_width(x) apollo_line(x).width #define APOLLO_MIN_LINE (-2) #define APOLLO_MAX_LINE (sizeof(apollo_lines)/sizeof(*apollo_lines)-2) /* set the line style */ TERM_PUBLIC void APOLLO_linetype(ltype) int ltype; { status_$t status; if (ltype < APOLLO_MIN_LINE) ltype = APOLLO_MIN_LINE; if (ltype >= APOLLO_MAX_LINE) ltype %= APOLLO_MAX_LINE; gpr_$set_line_pattern(1, apollo_pattern(ltype), BITS_PER_LINETYPE, &status); apollo_check("set_line_pattern"); gpr_$set_draw_width(draw_width * apollo_width(ltype), &status); apollo_check("set_draw_width"); } /* issue an error message that includes an (x, y) coordinate */ static void apollo_xy_error(char *s, int x, int y, status_$t status) { char buffer[128]; sprintf(buffer, "%s(%d, %d)", s, x, y); apollo_error(buffer); } #define apollo_xy_check(s) \ if (status.all != status_$ok) apollo_xy_error((s), x, y, status) /* Note that gnuplot and GPR have reversed ideas of where the Y origin is. This means subtracting the Y coordinate from Y max. */ #define plot_to_gpr(y) (APOLLO_YMAX - (y)) /* move to a new position */ TERM_PUBLIC void APOLLO_move(unsigned int x, unsigned int y) { status_$t status; gpr_$move((gpr_$coordinate_t) x, plot_to_gpr(y), &status); apollo_xy_check("move"); } /* draw a line to a new position */ TERM_PUBLIC void APOLLO_vector(unsigned int x, unsigned int y) { status_$t status; gpr_$line((gpr_$coordinate_t) x, plot_to_gpr(y), &status); apollo_xy_check("line"); } /* On terminals, this switches to text mode. The real meaning, however, is that the graphics are finished. This means we can now display the saved bitmap. */ TERM_PUBLIC void APOLLO_text() { if (use_bitmap) { static gpr_$position_t pos; /* always zero */ gpr_$window_t window; status_$t status; /* bitblt the entire bitmap to the entire window */ window.window_base.x_coord = 0; window.window_base.y_coord = 0; window.window_size.x_size = APOLLO_XMAX; window.window_size.y_size = APOLLO_YMAX; gpr_$set_bitmap(screen_desc, &status); apollo_check("set_bitmap(screen_desc)"); gpr_$pixel_blt(bitmap_desc, window, pos, &status); apollo_check("bitblt"); gpr_$set_bitmap(bitmap_desc, &status); apollo_check("set_bitmap(bitmap_desc)"); } } TERM_PUBLIC int APOLLO_text_angle(ang) int ang; { status_$t status; gpr_$set_text_path(ang ? gpr_$up : gpr_$right, &status); apollo_check("set_text_path"); return TRUE; } static enum JUSTIFY apollo_text_mode; TERM_PUBLIC int APOLLO_justify_text(mode) enum JUSTIFY mode; { apollo_text_mode = mode; return TRUE; } /* Write "str" right justified on row "row". A row is assumed to have whatever height the current text has. Make sure the text does not cover the tick marks. */ TERM_PUBLIC void APOLLO_put_text(x, y, str) unsigned int x, y; char str[]; { gpr_$offset_t size; status_$t status; gpr_$inq_text_extent(str, strlen(str), &size, &status); apollo_check("inq_text_extent"); y -= size.y_size / 2; /* center around "y" */ switch (apollo_text_mode) { case LEFT: break; case CENTRE: x -= size.x_size / 2; break; case RIGHT: x -= size.x_size; break; } APOLLO_move(x, y); gpr_$text(str, strlen(str), &status); apollo_check("put_text"); } /* reset the graphics state and terminate */ TERM_PUBLIC void APOLLO_reset() { if (stream != -1) { apollo_gpr_terminate(); stream = -1; } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(apollo_driver) "apollo", "Apollo Graphics Primitive Resource, rescaling of subsequent plots after window resizing", 0, 0, 0, 0, /* APOLLO_XMAX, APOLLO_YMAX, APOLLO_VCHAR, APOLLO_HCHAR, are filled in at run-time */ APOLLO_VTIC, APOLLO_HTIC, options_null, APOLLO_init, APOLLO_reset, APOLLO_text, null_scale, APOLLO_graphics, APOLLO_move, APOLLO_vector, APOLLO_linetype, APOLLO_put_text, APOLLO_text_angle, APOLLO_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(apollo_driver) #undef LAST_TERM #define LAST_TERM apollo_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(apollo) "1 apollo", "?commands set terminal apollo", "?set terminal apollo", "?set term apollo", "?terminal apollo", "?term apollo", "?apollo", " The `apollo` terminal driver supports the Apollo Graphics Primitive Resource", " with rescaling after window resizing. It has no options.", "", " If a fixed-size window is desired, the `gpr` terminal may be used instead." END_HELP(apollo) #endif /* TERM_HELP */ /* * $Id: atariaes.trm,v 1.9 1998/06/18 14:59:17 ddenholm Exp $ * */ /* GNUPLOT - atari.trm */ /*[ * Copyright 1992, 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Atari Screens working with the normal VDI * (this should include TT and big screens) * * AUTHORS * Alexander Lehmann * HE Koechling * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * * ATARI-related comments please to alexlehm@iti.informatik.th-darmstadt.de * */ #include "driver.h" #ifdef TERM_REGISTER register_term(atari) #endif #ifdef TERM_PROTO /* function-prototypes */ TERM_PUBLIC void ATARI_options __PROTO((void)); TERM_PUBLIC void ATARI_init __PROTO((void)); TERM_PUBLIC void ATARI_reset __PROTO((void)); TERM_PUBLIC void ATARI_graphics __PROTO((void)); TERM_PUBLIC void ATARI_text __PROTO((void)); TERM_PUBLIC void ATARI_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void ATARI_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void ATARI_linetype __PROTO((int lt)); TERM_PUBLIC void ATARI_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int ATARI_text_angle __PROTO((int ang)); TERM_PUBLIC int ATARI_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void ATARI_point __PROTO((unsigned int x, unsigned int y, int number)); /* default to hi-res */ #define ATARI_XMAX 640 #define ATARI_YMAX 400 #define ATARI_VCHAR 16 #define ATARI_HCHAR 8 #define ATARI_HTIC (ATARI_XMAX/100) #define ATARI_VTIC ATARI_HTIC #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #ifdef __PUREC__ /* why did they have to change these names ??? */ # include # include # include #else /* !__PUREC__ i.e. __GNUC__, maybe others */ # include # include # include extern short _global[]; #endif #include static void open_window __PROTO((void)); static void close_window __PROTO((void)); static void text_mode __PROTO((void)); static void mouse_mode __PROTO((void)); static void application_exit __PROTO((void)); void application_init __PROTO((void)); static int intersect __PROTO((int *x1, int *y1, int *w1, int *h1, int x2, int y2, int w2, int h2)); static void walk_rects __PROTO((void (*draw) (int, int, int, int), int x1, int y1, int w1, int h1)); static void clear __PROTO((int x, int y, int w, int h)); static void process_message __PROTO((int *msg)); long poll_events __PROTO((int waitkey)); static void f_line __PROTO((int x, int y, int w, int h)); static void flush_line __PROTO((void)); static void put_text __PROTO((int x, int y, int w, int h)); static int multi_aes; static int window_id = -1; static int vdi_handle = -1; static int win_xpos, win_ypos; static int win_xsize, win_ysize; #define ATARI_yc(y) (ATARI_maxycoord-(y)) static int ATARI_linetypes[] = { 0xffff, 0x1111, 0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f, 0xe4e4, 0x55f5 }; #define ATARI_LINETYPES_MAX (sizeof(ATARI_linetypes)/sizeof(int)) static int ATARI_lt; static int ATARI_maxycoord; static int ATARI_rotation; static int ATARI_numcolors; static int pxy[128]; /* Maximum of 64 pixels per v_pline */ static int pxy_index; static int ATARI_colors[16]; static int ATARI_savecolors[16][3]; static int ATARI_numpalette; #define ATARI_c_height_default 6 /* well, well ... */ static int ATARI_c_height = ATARI_c_height_default; static int cursor_is_on = FALSE; static int put_text_x; static int put_text_y; static char *put_text_str; /* don't change this without changing process_message() below */ #define WINTYPE (NAME|CLOSER|FULLER|MOVER|SIZER) static void open_window(void) { int x, y, w, h; if (window_id == -1) { wind_calc(WC_BORDER, WINTYPE, win_xpos, win_ypos, win_xsize, win_ysize, &x, &y, &w, &h); window_id = wind_create(WINTYPE, x, y, w, h); if (window_id < 0) { window_id = -1; int_error("Can't create window", NO_CARET); } wind_set(window_id, WF_NAME, "gnuplot output"); wind_open(window_id, x, y, w, h); } } static void close_window(void) { if (window_id != -1) { wind_close(window_id); wind_delete(window_id); window_id = -1; } } static void text_mode(void) { if (!multi_aes) { if (!cursor_is_on) { cursor_is_on = TRUE; graf_mouse(M_OFF, NULL); fputs("\033e", stderr); } fputs("\033E", stderr); } } static void mouse_mode(void) { if (!multi_aes) { if (cursor_is_on) { cursor_is_on = FALSE; graf_mouse(M_ON, NULL); fputs("\033f", stderr); } } } static void application_exit(void) { close_window(); if (vdi_handle != -1) { v_clsvwk(vdi_handle); } mouse_mode(); } void application_init(void) { if (aesid < 0) { if ((aesid = appl_init()) < 0) int_error("APPL_INIT failed !", NO_CARET); } #ifdef __PUREC__ multi_aes = _GemParBlk.global[1] == -1; #else /* tested with gcc only */ multi_aes = _global[1] == -1; #endif if (!multi_aes) graf_mouse(ARROW, NULL); else menu_register(aesid, " Terminal: atari"); text_mode(); atexit(application_exit); } static int intersect(int *x1, int *y1, int *w1, int *h1, int x2, int y2, int w2, int h2) { if (*x1 > x2) { w2 -= *x1 - x2; x2 = *x1; } else { (*w1) -= x2 - *x1; *x1 = x2; } if (*y1 > y2) { h2 -= *y1 - y2; y2 = *y1; } else { (*h1) -= y2 - *y1; *y1 = y2; } if (*w1 > w2) { *w1 = w2; } else { w2 = *w1; } if (*h1 > h2) { *h1 = h2; } else { h2 = *h1; } return (*w1) > 0 && (*h1) > 0; } static void walk_rects(void (*draw) (int, int, int, int), int x1, int y1, int w1, int h1) { int x, y, w, h; int pxy[4]; wind_update(BEG_UPDATE); graf_mouse(M_OFF, NULL); wind_get(window_id, WF_FIRSTXYWH, &x, &y, &w, &h); while (w > 0 && h > 0) { if (intersect(&x, &y, &w, &h, x1, y1, w1, h1)) { pxy[0] = x; pxy[1] = y; pxy[2] = x + w - 1; pxy[3] = y + h - 1; vs_clip(vdi_handle, 1, pxy); (*draw) (x, y, w, h); } wind_get(window_id, WF_NEXTXYWH, &x, &y, &w, &h); } vs_clip(vdi_handle, 0, pxy); graf_mouse(M_ON, NULL); wind_update(END_UPDATE); } static void clear(int x, int y, int w, int h) { static MFDB mfdb = {NULL}; int pxy[8]; pxy[0] = pxy[4] = x; pxy[1] = pxy[5] = y; pxy[2] = pxy[6] = x + w - 1; pxy[3] = pxy[7] = y + h - 1; vro_cpyfm(vdi_handle, ALL_WHITE /*0 */ , pxy, &mfdb, &mfdb); } static void process_message(int *msg) { static int is_fulled = FALSE; static int small_xpos, small_ypos, small_xsize, small_ysize; int x, y, w, h; if (window_id == -1 || msg[3] != window_id) return; switch (msg[0]) { case WM_REDRAW: walk_rects(clear, msg[4], msg[5], msg[6], msg[7]); break; case WM_CLOSED: close_window(); break; case WM_TOPPED: wind_set(window_id, WF_TOP, window_id); break; case WM_MOVED: case WM_SIZED: is_fulled = 0; wind_calc(WC_WORK, WINTYPE, msg[4], msg[5], msg[6], msg[7], &win_xpos, &win_ypos, &win_xsize, &win_ysize); wind_set(window_id, WF_CURRXYWH, msg[4], msg[5], msg[6], msg[7]); break; case WM_FULLED: if (!is_fulled) { is_fulled = TRUE; small_xpos = win_xpos; small_ypos = win_ypos; small_xsize = win_xsize; small_ysize = win_ysize; wind_get(0, WF_WORKXYWH, &x, &y, &w, &h); wind_calc(WC_WORK, WINTYPE, x, y, w, h, &win_xpos, &win_ypos, &win_xsize, &win_ysize); } else { is_fulled = FALSE; win_xpos = small_xpos; win_ypos = small_ypos; win_xsize = small_xsize; win_ysize = small_ysize; } wind_calc(WC_BORDER, WINTYPE, win_xpos, win_ypos, win_xsize, win_ysize, &x, &y, &w, &h); wind_set(window_id, WF_CURRXYWH, x, y, w, h); break; } } long poll_events(int waitkey) { int msg[8]; int dummy; int which; int key = 0; /* 1/10th second when waiting for key, poll otherwise */ unsigned long time = (waitkey ? 100L : 1L); do { which = evnt_multi( (waitkey ? (MU_MESAG | MU_KEYBD | MU_TIMER) : (MU_MESAG | MU_TIMER)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, msg, #ifdef __PUREC__ time, 0, #else time, #endif &dummy, &dummy, &dummy, &dummy, &key, &dummy); if (which & MU_MESAG) { process_message(msg); } } while (which & MU_MESAG); if (which & MU_KEYBD) { return ((Kbshift(-1) & 7) << 24) | ((long) (key & 0xff00) << 8) | (key & 0xff); } else { return 0; } } static void f_line(int x, int y, int w, int h) { v_pline(vdi_handle, pxy_index, pxy); } static void flush_line() { int line_type; int color_index; int i; if (pxy_index >= 2) { if (ATARI_numcolors == 2) { /* Monochrome */ color_index = 1; line_type = ATARI_lt; if (line_type >= 0) line_type %= (ATARI_LINETYPES_MAX - 2); } else { /* Color */ if (ATARI_lt < 0) { color_index = 1; line_type = ATARI_lt; } else { color_index = 2 + ATARI_lt % (ATARI_numcolors - 2); line_type = (ATARI_lt / (ATARI_numcolors - 2)) % (ATARI_LINETYPES_MAX - 2); } } vswr_mode(vdi_handle, MD_TRANS); vsl_color(vdi_handle, color_index); vsl_type(vdi_handle, 7); vsl_udsty(vdi_handle, ATARI_linetypes[line_type + 2]); walk_rects(f_line, win_xpos, win_ypos, win_xsize, win_ysize); } if (pxy_index >= 1) { pxy[0] = pxy[2 * (pxy_index - 1)]; pxy[1] = pxy[2 * (pxy_index - 1) + 1]; pxy_index = 1; } } static void put_text(int x, int y, int w, int h) { v_gtext(vdi_handle, put_text_x, put_text_y, put_text_str); } TERM_PUBLIC void ATARI_options() { #define ATARIHEXERROR "palette values 3 hex digits, please" #define ATARIHEIGHTERROR "expecting a character height" char opt[6]; /* maximum: 'fff'\0 */ int i; char *tok_end; term_options[0] = NUL; ATARI_c_height = ATARI_c_height_default; for (i = 0; i < 17; i++) { if (END_OF_COMMAND) break; if (token[c_token].length > 5) { ATARI_numpalette = 0; ATARI_c_height = ATARI_c_height_default; term_options[0] = NUL; int_error(ATARIHEXERROR, c_token); } capture(opt, c_token, c_token, 6); if (!i) { ATARI_c_height = strtoul(opt, &tok_end, 10); if (*tok_end != NUL) { ATARI_numpalette = 0; ATARI_c_height = ATARI_c_height_default; term_options[0] = NUL; int_error(ATARIHEIGHTERROR, c_token); } if (ATARI_c_height > 999) ATARI_c_height = 999; /* avoid opt length overflow */ sprintf(opt, "%d ", ATARI_c_height); } else { if (*opt == '"' || *opt == '\'') { opt[strlen(opt) - 1] = NUL; strcpy(opt, opt + 1); } ATARI_colors[i - 1] = strtoul(opt, &tok_end, 16); if (*tok_end != NUL) { ATARI_numpalette = 0; ATARI_c_height = ATARI_c_height_default; term_options[0] = NUL; int_error(ATARIHEXERROR, c_token); } sprintf(opt, "%X ", ATARI_colors[i - 1]); /* do we need to quote? */ if (isdigit(*opt) && strpbrk(opt, "ABCDEF")) { sprintf(opt, "\"%X\" ", ATARI_colors[i - 1]); } } strcat(term_options, opt); c_token++; } ATARI_numpalette = (i == 0 ? 0 : i - 1); /* printf("Number of linetypes:%d\n", ATARI_LINETYPES_MAX); */ } TERM_PUBLIC void ATARI_init() { int work_in[11]; int work_out[57]; int i; int hchar, wchar, dummy; int rgb[3]; int num_save; char *colors, *tok_end; int x, y, w, h; static int have_win_size = 0; application_init(); if (ATARI_numpalette == 0 && (colors = getenv("GNUCOLORS")) && *colors) { for (i = 0; i < 17; i++) { if (!i) { ATARI_c_height = strtoul(colors, &tok_end, 10); if (colors == tok_end) { i = 0; ATARI_c_height = ATARI_c_height_default; break; } } else { if (*colors == '\0') break; ATARI_colors[i] = strtoul(colors, &tok_end, 16); if (colors == tok_end || (unsigned) ATARI_colors[i] > 0xfff) { i = 0; break; } } colors = tok_end; while (*colors == ' ') colors++; } ATARI_numpalette = (i == 0 ? 0 : i - 1); } vdi_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); if (!vdi_handle) int_error("Fatal error opening virtual workstation", NO_CARET); for (i = 0; i < 10; work_in[i++] = 1); work_in[10] = 2; /* use raster coordinates */ v_opnvwk(work_in, &vdi_handle, work_out); if (!vdi_handle) int_error("Fatal error opening virtual workstation", NO_CARET); if (!have_win_size) { wind_get(0, WF_WORKXYWH, &x, &y, &w, &h); wind_calc(WC_WORK, WINTYPE, x, y, w, h, &win_xpos, &win_ypos, &win_xsize, &win_ysize); have_win_size = 1; } term->xmax = win_xsize; term->ymax = win_ysize; vst_height(vdi_handle, ATARI_c_height, &dummy, &dummy, &wchar, &hchar); term->h_char = wchar; term->v_char = hchar; /* hchar stands for height this time */ term->h_tic = win_xsize / 100; term->v_tic = term->h_tic; ATARI_maxycoord = win_ysize - 1; ATARI_numcolors = work_out[13]; for (i = 0; i < ATARI_numpalette; i++) { vq_color(vdi_handle, i, 1, ATARI_savecolors[i]); rgb[0] = 1000 * (ATARI_colors[i] >> 8); rgb[0] /= 15; rgb[1] = 1000 * ((ATARI_colors[i] >> 4) & 15); rgb[1] /= 15; rgb[2] = 1000 * (ATARI_colors[i] & 15); rgb[2] /= 15; vs_color(vdi_handle, i, rgb); } pxy_index = 0; } TERM_PUBLIC void ATARI_reset() { int i; close_window(); if (vdi_handle != -1) { for (i = 0; i < ATARI_numpalette; i++) { vs_color(vdi_handle, i, ATARI_savecolors[i]); } v_clsvwk(vdi_handle); vdi_handle = -1; } } TERM_PUBLIC void ATARI_graphics() { ATARI_maxycoord = win_ysize - 1; term->xmax = win_xsize; term->ymax = win_ysize; mouse_mode(); open_window(); poll_events(0); walk_rects(clear, win_xpos, win_ypos, win_xsize, win_ysize); pxy_index = 0; } TERM_PUBLIC void ATARI_text() { flush_line(); if (!multi_aes) { while (window_id != -1 && !poll_events(1)); close_window(); } text_mode(); } TERM_PUBLIC void ATARI_move(unsigned int x, unsigned int y) { flush_line(); pxy[0] = x + win_xpos; pxy[1] = ATARI_yc(y) + win_ypos; pxy_index = 1; } TERM_PUBLIC void ATARI_vector(unsigned int x, unsigned int y) { pxy[2 * pxy_index] = x + win_xpos; pxy[2 * pxy_index + 1] = ATARI_yc(y) + win_ypos; pxy_index++; if (pxy_index == 64) { /* we're all full */ flush_line(); } } TERM_PUBLIC void ATARI_linetype(int lt) { flush_line(); ATARI_lt = lt; } TERM_PUBLIC void ATARI_put_text(unsigned int x, unsigned int y, char *str) { int vchar = term->v_char; int dummy; if (!strlen(str)) return; if (x < 0) x = 0; if (y < 0) y = 0; /* align text left and to middle of char height */ vst_alignment(vdi_handle, 0, 5, &dummy, &dummy); vst_rotation(vdi_handle, (ATARI_rotation ? 900 : 0)); if (ATARI_rotation) { put_text_x = x - vchar / 2 + 1 + win_xpos; put_text_y = ATARI_yc(y) - 1 + win_ypos; put_text_str = str; } else { put_text_x = x + 1 + win_xpos; put_text_y = ATARI_yc(y) - vchar / 2 + 1 + win_ypos; put_text_str = str; } walk_rects(put_text, win_xpos, win_ypos, win_xsize, win_ysize); } TERM_PUBLIC int ATARI_text_angle(int ang) { ATARI_rotation = ang; return TRUE; } TERM_PUBLIC int ATARI_justify_text(enum JUSTIFY mode) { return FALSE; } TERM_PUBLIC void ATARI_point(unsigned int x, unsigned int y, int number) { int old_linetype; if (ATARI_numcolors == 2) { line_and_point(x, y, number); /* monochrome */ } else { /* we map colors that exceed our limit to dotted lines, but we can't do that with the markers (sortof a generalized line_and_point) */ old_linetype = ATARI_lt; if (ATARI_lt > ATARI_numcolors - 2) ATARI_linetype(ATARI_lt % (ATARI_numcolors - 2)); /* same color, but no dots */ do_point(x, y, number); ATARI_linetype(old_linetype); } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(atari_driver) "atari", "Atari AES-Terminal", ATARI_XMAX, ATARI_YMAX, ATARI_VCHAR, ATARI_HCHAR, ATARI_VTIC, ATARI_HTIC, ATARI_options, ATARI_init, ATARI_reset, ATARI_text, null_scale, ATARI_graphics, ATARI_move, ATARI_vector, ATARI_linetype, ATARI_put_text, ATARI_text_angle, ATARI_justify_text, ATARI_point, do_arrow, set_font_null, 0, TERM_CAN_MULTIPLOT, 0, 0 TERM_TABLE_END(atari_driver) #undef LAST_TERM #define LAST_TERM atari_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(atari) "1 atari ST (via AES)", "?commands set terminal atari", "?set terminal atari", "?set term atari", "?terminal atari", "?term atari", "?atari", " The `atari` terminal has options to set the character size and the screen", " colors.", "", " Syntax:", " set terminal atari {} { ... # include # include #else /* !__PUREC__ i.e. __GNUC__, maybe others */ # include # include # include #endif #define VDI_yc(y) (VDI_maxycoord-(y)) #define VDI_LINETYPES_MAX 11 static int VDI_linetypes[VDI_LINETYPES_MAX] = { 0xffff, 0x1111, 0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f, 0xe4e4, 0x55f5 }; static int VDI_lt; static int vdi_vdi_handle = -1; static int VDI_maxycoord; static int VDI_rotation; static int VDI_numcolors; static int pxy[128]; /* Maximum of 64 pixels per v_pline */ static int pxy_index; static int VDI_colors[16]; static int VDI_savecolors[16][3]; static int VDI_numpalette; #define VDI_c_height_default 6 /* well, well ... */ static int VDI_c_height = VDI_c_height_default; static void vdi_flush_line(void); TERM_PUBLIC void VDI_options() { #define VDIHEXERROR "palette values 3 hex digits, please" #define VDIHEIGHTERROR "expecting a character height" char opt[4]; int i; char *tok_end; term_options[0] = NUL; VDI_c_height = VDI_c_height_default; for (i = 0; i < 17; i++) { if (END_OF_COMMAND) break; if (token[c_token].length > 3) { VDI_numpalette = 0; VDI_c_height = VDI_c_height_default; term_options[0] = NUL; int_error(VDIHEXERROR, c_token); } capture(opt, c_token, c_token, 6); if (!i) { VDI_c_height = strtoul(opt, &tok_end, 10); if (*tok_end != NUL) { VDI_numpalette = 0; VDI_c_height = VDI_c_height_default; term_options[0] = NUL; int_error(VDIHEIGHTERROR, c_token); } if (VDI_c_height > 999) VDI_c_height = 999; /* avoid opt length overflow */ sprintf(opt, "%d ", VDI_c_height); } else { VDI_colors[i - 1] = strtoul(opt, &tok_end, 16); if (*tok_end != NUL) { VDI_numpalette = 0; VDI_c_height = VDI_c_height_default; term_options[0] = NUL; int_error(VDIHEXERROR, c_token); } sprintf(opt, "%03X ", VDI_colors[i - 1]); } strcat(term_options, opt); c_token++; } VDI_numpalette = (i == 0 ? 0 : i - 1); } TERM_PUBLIC void VDI_init() { int work_in[11]; int work_out[57]; int i; int hchar, wchar, dummy; int rgb[3]; int num_save; char *colors, *tok_end; if (VDI_numpalette == 0 && (colors = getenv("GNUCOLORS")) && *colors) { for (i = 0; i < 17; i++) { if (!i) { VDI_c_height = strtoul(colors, &tok_end, 10); if (colors == tok_end) { i = 0; VDI_c_height = VDI_c_height_default; break; } } else { if (*colors == NUL) break; VDI_colors[i] = strtoul(colors, &tok_end, 16); if (colors == tok_end || (unsigned) VDI_colors[i] > 0xfff) { i = 0; break; } } colors = tok_end; while (*colors == ' ') colors++; } VDI_numpalette = (i == 0 ? 0 : i - 1); } vdi_vdi_handle = graf_handle(&wchar, &hchar, &dummy, &dummy); if (!vdi_vdi_handle) int_error("Fatal error opening virtual workstation", NO_CARET); for (i = 0; i < 10; work_in[i++] = 1); work_in[10] = 2; /* use raster coordinates */ v_opnvwk(work_in, &vdi_vdi_handle, work_out); if (!vdi_vdi_handle) int_error("Fatal error opening virtual workstation", NO_CARET); vst_height(vdi_vdi_handle, VDI_c_height, &dummy, &dummy, &wchar, &hchar); vs_clip(vdi_vdi_handle, 0, work_in); /* turn clipping off */ term->xmax = work_out[0] + 1; term->ymax = work_out[1] + 1; term->h_char = wchar; term->v_char = hchar; /* hchar stands for height this time */ term->h_tic = (work_out[0] + 1) / 100; term->v_tic = term->h_tic; VDI_maxycoord = work_out[1]; VDI_numcolors = work_out[13]; pxy_index = 0; for (i = 0; i < VDI_numpalette; i++) { vq_color(vdi_vdi_handle, i, 1, VDI_savecolors[i]); rgb[0] = 1000 * (VDI_colors[i] >> 8); rgb[0] /= 15; rgb[1] = 1000 * ((VDI_colors[i] >> 4) & 15); rgb[1] /= 15; rgb[2] = 1000 * (VDI_colors[i] & 15); rgb[2] /= 15; vs_color(vdi_vdi_handle, i, rgb); } #ifdef __PUREC__ /* currently the PureC version runs as .prg and the GCC version runs as .ttp. Let's hope that we soon figure out which way is the best */ v_hide_c(vdi_vdi_handle); #endif } TERM_PUBLIC void VDI_reset() { int i; if (vdi_vdi_handle != -1) { for (i = 0; i < VDI_numpalette; i++) { vs_color(vdi_vdi_handle, i, VDI_savecolors[i]); } #ifdef __PUREC__ /* see above */ v_show_c(vdi_vdi_handle, 0); #endif v_clsvwk(vdi_vdi_handle); vdi_vdi_handle = -1; } } TERM_PUBLIC void VDI_graphics() { int pxy[8]; MFDB mfdb; fflush(stdout); fflush(stderr); Cconws("\033f"); /* turn cursor off */ /* apparently v_clrwk doesn't work with overscan. We'll blit the screen clear. v_clrwk( vdi_vdi_handle ); */ mfdb.fd_addr = NULL; /* NULL means actual screen. So we don't need size etc. */ pxy[0] = pxy[4] = 0; pxy[1] = pxy[5] = 0; pxy[2] = pxy[6] = term->xmax - 1; pxy[3] = pxy[7] = term->ymax - 1; vro_cpyfm(vdi_vdi_handle, ALL_WHITE /*0 */ , pxy, &mfdb, &mfdb); pxy_index = 0; } TERM_PUBLIC void VDI_text() { vdi_flush_line(); Cnecin(); /* wait for any char --> enable screen dump */ Cconws("\033e"); /* turn cursor on again */ } TERM_PUBLIC void VDI_move(unsigned int x, unsigned int y) { vdi_flush_line(); pxy_index = 1; pxy[0] = x; pxy[1] = VDI_yc(y); } TERM_PUBLIC void VDI_vector(unsigned int x, unsigned int y) { pxy[2 * pxy_index] = x; pxy[2 * pxy_index + 1] = VDI_yc(y); pxy_index++; if (pxy_index == 64) { /* we're all full */ vdi_flush_line(); } } TERM_PUBLIC void VDI_linetype(int lt) { vdi_flush_line(); VDI_lt = lt; } TERM_PUBLIC void VDI_put_text(unsigned int x, unsigned int y, char *str) { int vchar = term->v_char; int dummy; if (!strlen(str)) return; if (x < 0) x = 0; if (y < 0) y = 0; /* align text left and to middle of char height */ vst_alignment(vdi_vdi_handle, 0, 5, &dummy, &dummy); vst_rotation(vdi_vdi_handle, (VDI_rotation ? 900 : 0)); if (VDI_rotation) v_gtext(vdi_vdi_handle, x - vchar / 2 + 1, VDI_yc(y) - 1, str); else v_gtext(vdi_vdi_handle, x + 1, VDI_yc(y) - vchar / 2 + 1, str); } TERM_PUBLIC int VDI_text_angle(int ang) { VDI_rotation = ang; return TRUE; } TERM_PUBLIC int VDI_justify_text(enum JUSTIFY mode) { return FALSE; } TERM_PUBLIC void VDI_point(unsigned int x, unsigned int y, int number) { int old_linetype; if (VDI_numcolors == 2) { line_and_point(x, y, number); /* monochrome */ } else { /* we map colors that exceed our limit to dotted lines, but we can't do that with the markers (sortof a generalized line_and_point) */ old_linetype = VDI_lt; if (VDI_lt > VDI_numcolors - 2) { /* same color, but no dots */ VDI_linetype(VDI_lt % (VDI_numcolors - 2)); } do_point(x, y, number); VDI_linetype(old_linetype); } } static void vdi_flush_line() { int line_type; int color_index; int i; if (pxy_index >= 2) { if (VDI_numcolors == 2) { /* Monochrome */ color_index = 1; line_type = VDI_lt; if (line_type >= 0) line_type %= (VDI_LINETYPES_MAX - 2); } else { /* Color */ if (VDI_lt < 0) { color_index = 1; line_type = VDI_lt; } else { color_index = 2 + VDI_lt % (VDI_numcolors - 2); line_type = (VDI_lt / (VDI_numcolors - 2)) % (VDI_LINETYPES_MAX - 2); } } vswr_mode(vdi_vdi_handle, MD_TRANS); vsl_color(vdi_vdi_handle, color_index); vsl_type(vdi_vdi_handle, 7); vsl_udsty(vdi_vdi_handle, VDI_linetypes[line_type + 2]); v_pline(vdi_vdi_handle, pxy_index, pxy); } if (pxy_index >= 1) { pxy[0] = pxy[2 * (pxy_index - 1)]; pxy[1] = pxy[2 * (pxy_index - 1) + 1]; pxy_index = 1; } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(vdi_driver) "vdi", "Atari VDI-Terminal", VDI_XMAX, VDI_YMAX, VDI_VCHAR, VDI_HCHAR, VDI_VTIC, VDI_HTIC, VDI_options, VDI_init, VDI_reset, VDI_text, null_scale, VDI_graphics, VDI_move, VDI_vector, VDI_linetype, VDI_put_text, VDI_text_angle, VDI_justify_text, VDI_point, do_arrow, set_font_null, 0, TERM_CAN_MULTIPLOT, 0, 0 TERM_TABLE_END(vdi_driver) #undef LAST_TERM #define LAST_TERM vdi_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(vdi) "1 atari ST (via VDI)", "?commands set terminal vdi", "?set terminal vdi", "?set term vdi", "?terminal vdi", "?term vdi", "?vdi", " The `vdi` terminal is the same as the `atari` terminal, except that it sends", " output to the screen via the VDI and not into AES-Windows.", "", " The `vdi` terminal has options to set the character size and the screen", " colors.", "", " Syntax:", " set terminal vdi {} { ... */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(cgi) register_term(hcgi) #endif #ifdef TERM_PROTO TERM_PUBLIC void CGI_init __PROTO((void)); TERM_PUBLIC void HCGI_init __PROTO((void)); TERM_PUBLIC void CGI_graphics __PROTO((void)); TERM_PUBLIC void CGI_text __PROTO((void)); TERM_PUBLIC void CGI_reset __PROTO((void)); TERM_PUBLIC void CGI_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void CGI_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void CGI_linetype __PROTO((int linetype)); TERM_PUBLIC void CGI_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int CGI_text_angle __PROTO((int ang)); TERM_PUBLIC int CGI_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void CGI_point __PROTO((unsigned int x, unsigned int y, int num)); #define CGI_XMAX 32767 #define CGI_YMAX 32767 #define CGI_VTIC (CGI_YMAX / 75) #define CGI_HTIC term->h_tic #define CGI_VCHAR term->v_char #define CGI_HCHAR term->h_char #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #ifdef VGA_MONO static short rgb[16][3] = { 0, 0, 0, /* Black */ 1000, 1000, 1000, /* White */ 800, 800, 0, /* Red */ 0, 600, 0, /* Green */ 0, 800, 800, /* Blue */ 1000, 1000, 400, /* Yellow */ 0, 600, 600, /* Cyan */ 600, 600, 600, /* Magenta */ 800, 800, 0, /* Brown */ 600, 600, 600, /* Lt. Grey */ 400, 600, 400, /* Dark Grey */ 400, 600, 1000, /* Lt. Blue */ 400, 1000, 400, /* Lt Green */ 400, 1000, 1000, /* Lt Cyan */ 1000, 600, 400, /* Lt Red */ 600, 600, 1000 /* Lt Magenta */ }; #endif #define CRT (gout[45] == 0) #define CGICOLORS gout[13] #define CGILINES gout[6] #define CGIROTATES gout[36] #define CGITEXTALIGN gout[48] static short gout[66]; static short cgidev; static short vect[4]; static short gin[19] = { 0, /* default aspect ratio */ 1, /* solid line */ 1, /* line color */ 1, /* marker type . */ 1, /* marker color */ 1, /* graphics text font */ 1, /* graphics text color */ 0, /* fill interior style */ 0, /* fill style index */ 1, /* fill color index */ 1 /* prompt for paper changes */ }; char *cgidriver, *getenv(); TERM_PUBLIC void CGI_init() { if (getenv(cgidriver = "CGIDISP") == NULL) HCGI_init(); } TERM_PUBLIC void HCGI_init() { if (getenv(cgidriver = "CGIPRNT") == NULL) int_error("no CGI driver", NO_CARET); } TERM_PUBLIC void CGI_graphics() { int i, aspect; char *s; short font_cap[9]; char err_str[80]; if ((s = getenv("ASPECT")) != NULL && (aspect = atoi(s)) >= 0 && aspect <= 3) gin[0] = aspect; for (i = 0; cgidriver[i]; i++) gin[11 + i] = cgidriver[i]; gin[18] = ' '; if (v_opnwk(gin, &cgidev, gout) < 0) { sprintf(err_str, "CGI error %d opening %s", -vq_error(), cgidriver); int_error(err_str, NO_CARET); } vqt_representation(cgidev, 9, font_cap); CGI_VCHAR = font_cap[8] * 3 / 2; CGI_HCHAR = font_cap[7]; CGI_HTIC = CGI_VTIC * ((double) gout[1] / (double) gout[4]) / ((double) gout[0] / (double) gout[3]); #ifdef VGA_MONO if (CGICOLORS > 2) vsc_table(cgidev, 0, CGICOLORS, rgb); #endif } TERM_PUBLIC void CGI_text() { if (CRT) { short ptin[2]; char strin[2]; ptin[0] = 0; ptin[1] = 0; vrq_string(cgidev, 1, 0, ptin, strin); } v_clswk(cgidev); } TERM_PUBLIC void CGI_reset() { } TERM_PUBLIC void CGI_move(x, y) unsigned int x, y; { vect[0] = x; vect[1] = y; } TERM_PUBLIC void CGI_vector(x, y) unsigned int x, y; { vect[2] = x; vect[3] = y; v_pline(cgidev, 2, vect); vect[0] = x; vect[1] = y; } TERM_PUBLIC void CGI_linetype(linetype) int linetype; { short lcolor; if (CGICOLORS > 2) { lcolor = (linetype + 2) % CGICOLORS + 1; vsl_color(cgidev, lcolor); vsm_color(cgidev, lcolor); } vsl_type(cgidev, (linetype < 1) ? 1 : (linetype % CGILINES) + 1); } TERM_PUBLIC void CGI_put_text(x, y, str) unsigned int x, y; char *str; { v_gtext(cgidev, (short) x, (short) y, str); } TERM_PUBLIC CGI_text_angle(ang) int ang; { if (!CGIROTATES) return FALSE; /* angles are 1/10 degree ccw */ vst_rotation(cgidev, (ang) ? 900 : 0); return TRUE; } TERM_PUBLIC CGI_justify_text(mode) enum JUSTIFY mode; { short hor_in, hor_out, vert_out; if (!CGITEXTALIGN) return FALSE; switch (mode) { case LEFT: hor_in = 0; break; case CENTRE: hor_in = 1; break; case RIGHT: hor_in = 2; break; } vst_alignment(cgidev, hor_in, 1, &hor_out, &vert_out); return TRUE; } #define POINT_TYPES 6 TERM_PUBLIC void CGI_point(x, y, num) unsigned int x, y; int num; { short point[2]; static short cgimarker[POINT_TYPES] = { 1, 2, 6, 4, 5, 3 }; /* . + <> [] X * */ if (num < 0) { CGI_move(x, y); CGI_vector(x, y); } else { vsm_type(cgidev, cgimarker[num % POINT_TYPES]); point[0] = x; point[1] = y; v_pmarker(cgidev, 1, point); } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(cgi_driver) "cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)", CGI_XMAX, CGI_YMAX, 0, 0, CGI_VTIC, 0, options_null, CGI_init, CGI_reset, CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, CGI_linetype, CGI_put_text, CGI_text_angle, CGI_justify_text, CGI_point, do_arrow, set_font_null TERM_TABLE_END(cgi_driver) #undef LAST_TERM #define LAST_TERM cgi_driver TERM_TABLE_START(hcgi_driver) "hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)", CGI_XMAX, CGI_YMAX, 0, 0, CGI_VTIC, 0, options_null, HCGI_init, CGI_reset, CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, CGI_linetype, CGI_put_text, CGI_text_angle, CGI_justify_text, CGI_point, do_arrow, set_font_null TERM_TABLE_END(hcgi_driver) #undef LAST_TERM #define LAST_TERM hcgi_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(cgi) "1 cgi", "?commands set terminal cgi", "?set terminal cgi", "?set term cgi", "?terminal cgi", "?term cgi", "?cgi", "?commands set terminal hcgi", "?set terminal hcgi", "?set term hcgi", "?terminal hcgi", "?term hcgi", "?hcgi", " The `cgi` and `hcgi` terminal drivers support SCO CGI drivers. `hcgi` is for", " printers; the environment variable CGIPRNT must be set. `cgi` may be used", " for either a display or hardcopy; if the environment variable CGIDISP is set,", " then that display is used. Otherwise CGIPRNT is used.", "", " These terminals have no options." END_HELP(cgi) #endif /* Hey Emacs this is -*- C -*- * $Id: cgm.trm,v 1.16 1998/06/18 14:59:18 ddenholm Exp $ */ /* GNUPLOT - cgm.trm */ /*[ * Copyright 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c and ../docs/termdoc.c. * * This terminal driver supports: * Computer Graphics Metafile * * TODO * better control over plot size (never cutting off labels, correct font * sizes) * Fix font sizes for portrait orientation * * AUTHOR * Jim Van Zandt * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). */ #include "driver.h" #ifdef TERM_REGISTER register_term(cgm) #endif #ifdef TERM_PROTO TERM_PUBLIC void CGM_options __PROTO((void)); TERM_PUBLIC void CGM_init __PROTO((void)); TERM_PUBLIC void CGM_reset __PROTO((void)); TERM_PUBLIC void CGM_text __PROTO((void)); TERM_PUBLIC void CGM_graphics __PROTO((void)); TERM_PUBLIC void CGM_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void CGM_dashed_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void CGM_solid_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void CGM_linetype __PROTO((int linetype)); TERM_PUBLIC void CGM_linecolor __PROTO((int color)); TERM_PUBLIC void CGM_dashtype __PROTO((int dashtype)); TERM_PUBLIC void CGM_linewidth __PROTO((double width)); TERM_PUBLIC void CGM_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int CGM_text_angle __PROTO((int ang)); TERM_PUBLIC int CGM_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void CGM_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC int CGM_find_font __PROTO((char *font, int numchar)); TERM_PUBLIC int CGM_set_font __PROTO((char *font)); TERM_PUBLIC void CGM_set_pointsize __PROTO((double size)); #define CGM_LARGE 32767 #define CGM_SMALL 32767/18*13 /* aspect ratio 1:.7222 */ #define CGM_MARGIN (CGM_LARGE/180) /* convert from plot units to pt */ #define CGM_PT ((term->xmax + CGM_MARGIN)/cgm_plotwidth) #define CGM_LINE_TYPES 9 /* number of line types we support */ #define CGM_COLORS 7 /* number of colors we support */ #define CGM_POINTS 8 /* number of markers we support */ #define CGM_MAX_SEGMENTS 104 /* maximum # polyline coordinates */ #define CGM_VCHAR (CGM_SMALL/360*12) #define CGM_HCHAR (CGM_SMALL/360*12*5/9) #define CGM_VTIC (CGM_LARGE/80) #define CGM_HTIC (CGM_LARGE/80) #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* * on NeXTstep, id is an identifier (in ObjC) and causes a parse error * since some asserts below are mistaken as casts. datum is a type * defined in ndbm.h which also causes a parse error (ndbm.h is * included as part of appkit.h, I think). Strangely enough, both * errors only happen with cpp-precomp -smart, not with the regular * cpp. (AL) */ #ifdef NEXT #define id id_ #define datum datum_ #endif #include /* for isspace() */ #ifndef assert #define assert(x) 0 /* defeat assertions */ #endif /* uncomment the following to enable assertions for this module only, regardless of compiler switches */ #ifdef NDEBUG #define DEFEAT_ASSERTIONS #endif #undef NDEBUG #include #define CGM_ADJ (sizeof(int)/sizeof(short)) static unsigned int cgm_posx; static unsigned int cgm_posy; static unsigned int cgm_linetype = 1; static unsigned int cgm_dashtype = 0; static unsigned int cgm_color = 0; static int cgm_polyline[CGM_MAX_SEGMENTS]; /* stored polyline coordinates */ static int cgm_coords = 0; /* # polyline coordinates saved */ enum JUSTIFY cgm_justify = LEFT; static int cgm_vert_text = 0; /* text orientation -- nonzero for vertical */ static int cgm_vert_text_requested = 0; static int cgm_step_sizes[8]; /* array of currently used dash lengths in plot units */ static int cgm_step_index = 0; /* index into cgm_step_sizes[] */ static int cgm_step = 0; /* amount of current dash not yet drawn, in plot units */ static int cgm_tic, cgm_tic707, cgm_tic866, cgm_tic500, cgm_tic1241, cgm_tic1077, cgm_tic621; /* marker dimensions */ /* Each font string is preceded by a byte with its length */ static char GPFAR cgm_font_data[] = {"\ \005Arial\ \014Arial Italic\ \012Arial Bold\ \021Arial Bold Italic\ \013Times Roman\ \022Times Roman Italic\ \020Times Roman Bold\ \027Times Roman Bold Italic\ \011Helvetica\ \005Roman\ "}; /* variables to record the options */ static char cgm_font[32] = "Arial Bold"; static unsigned int cgm_fontsize = 10; static unsigned cgm_linewidth; /* line width in plot units */ static unsigned cgm_linewidth_pt = 1; /* line width in pt */ static TBOOLEAN cgm_monochrome = FALSE; /* colors enabled? */ static int cgm_plotwidth = 432; /* assumed width of plot in pt. */ static TBOOLEAN cgm_portrait = FALSE; /* portrait orientation? */ static TBOOLEAN cgm_rotate = TRUE; /* text rotation enabled? */ static TBOOLEAN cgm_dashed = TRUE; /* dashed linestyles enabled? */ static TBOOLEAN cgm_winword6_mode = FALSE; /* workaround for WinWord bug? */ /* prototypes for static functions */ static void CGM_flush_polyline __PROTO((void)); static void CGM_flush_polygon __PROTO((void)); static void CGM_write_char_record __PROTO((int class, int cgm_id, int length, char *data)); static void CGM_write_code __PROTO((int class, int cgm_id, int length)); static void CGM_write_int __PROTO((int value)); static void CGM_write_int_record __PROTO((int class, int cgm_id, int length, int *data)); static void CGM_write_mixed_record __PROTO((int class, int cgm_id, int numint, int *int_data, int numchar, char *char_data)); TERM_PUBLIC void CGM_init() { cgm_posx = cgm_posy = 0; cgm_linetype = 0; cgm_vert_text = 0; } TERM_PUBLIC void CGM_graphics() { register struct termentry *t = term; static int version_data[] = { 1 }; static char GPFAR description_data[] = "Computer Graphics Metafile version of Gnuplot"; static int vdc_type_data[] = { 0 }; static int integer_precision_data[] = { 16 }; static int real_precision_data[] = { 1, 16, 16 }; static int index_precision_data[] = { 16 }; static int color_precision_data[] = { 16 }; static int color_index_precision_data[] = { 16 }; static int maximum_color_index_data_data[] = { CGM_COLORS }; static int scaling_mode_data[] = { 0, 0, 0 }; static int color_value_extent_data[] = { 0, 0, 0, 255, 255, 255 }; static int GPFAR color_table_data[] = /* for testing { 8, 0,0,0, 64,64,64, 128,128,128, 196,196,196, 0,255,255, 255,0,255, 255,255,0, 255,255,255 }; */ { CGM_COLORS, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255 /* black red green blue yellow magenta cyan */ }; static int color_selection_mode_data[] = { 0 }; static int linewidth_specification_mode_data[] = { 0 }; static int marker_size_specification_mode_data[] = { 0 }; static int vdc_extent_data[] = { 0, 0, 0, 0 }; static int vdc_integer_precision_data[] = { 16 }; static int transparency_data[] = { 0 }; /* text background: 1=transparent */ static int clip_indicator_data[] = { 0 }; /* static int line_color_data[] = { 1 }; */ static int line_type_data[] = { 1 }; static int interior_style_data[] = { 1 }; /* 1=filled */ static int GPFAR elements_list_data[] = { 0, /* will be set to # elements in this list */ 0, 1, /* Begin Metafile */ 0, 2, /* End Metafile */ 0, 3, /* Begin Picture */ 0, 4, /* Begin Picture Body */ 0, 5, /* End Picture */ 1, 1, /* Metafile Version */ 1, 2, /* Metafile Description */ 1, 3, /* VDC Type */ 1, 4, /* Integer Precision */ 1, 5, /* Real Precision */ 1, 6, /* Index Precision */ 1, 7, /* Color Precision */ 1, 8, /* Color Index Precision */ 1, 9, /* Maximum Color Index */ 2, 1, /* Scaling Mode */ 2, 2, /* Color Selection Mode */ 2, 3, /* Line Width Specification Mode */ 2, 4, /* Marker Size Specification Mode */ 2, 6, /* VDC Extent */ 3, 1, /* VDC Integer Precision */ 3, 4, /* Transparency */ 3, 6, /* Clip Indicator */ 4, 1, /* Polyline */ 4, 3, /* Polymarker */ 4, 4, /* Text */ 4, 7, /* Polygon */ 4, 11, /* Rectangle */ 4, 12, /* Circle */ 4, 15, /* Circular Arc Center */ 4, 16, /* Circular Arc Center Close */ 4, 17, /* Ellipse */ 4, 18, /* Elliptical Arc */ 4, 19, /* Elliptical Arc Close */ 5, 2, /* Line Type */ 5, 3, /* Line Width */ 5, 4, /* Line Color */ 5, 6, /* Marker Type */ 5, 7, /* Marker Size */ 5, 8, /* Marker Color */ 5, 10, /* Text Font Index */ 5, 14, /* Text Color */ 5, 15, /* Character Height */ 5, 16, /* Character Orientation */ 5, 18, /* Text Alignment */ 5, 22, /* Interior Style */ 5, 23, /* Fill Color */ 5, 24, /* Hatch Index */ 6, 1, /* Escape */ 7, 2 /* Application Data */ }; /* metafile description (class 1) */ if (!outstr) CGM_write_char_record(0, 1, 1, outstr); else CGM_write_char_record(0, 1, strlen(outstr) + 1, outstr); CGM_write_int_record(1, 1, 2, version_data); CGM_write_char_record(1, 2, sizeof(description_data), description_data); CGM_write_int_record(1, 3, 2, vdc_type_data); CGM_write_int_record(1, 4, 2, integer_precision_data); CGM_write_int_record(1, 5, 6, real_precision_data); CGM_write_int_record(1, 6, 2, index_precision_data); CGM_write_int_record(1, 7, 2, color_precision_data); CGM_write_int_record(1, 8, 2, color_index_precision_data); CGM_write_int_record(1, 9, 2, maximum_color_index_data_data); CGM_write_int_record(1, 10, sizeof(color_value_extent_data) / CGM_ADJ, color_value_extent_data); elements_list_data[0] = (sizeof(elements_list_data) / CGM_ADJ - 2) / 4; CGM_write_int_record(1, 11, sizeof(elements_list_data) / CGM_ADJ, elements_list_data); if (cgm_winword6_mode == FALSE) CGM_write_char_record(1, 13, strlen(cgm_font_data), cgm_font_data); /* picture description (classes 2 and 3) */ CGM_write_char_record(0, 3, 8, "PICTURE1"); CGM_write_int_record(2, 1, 6, scaling_mode_data); CGM_write_int_record(2, 2, 2, color_selection_mode_data); CGM_write_int_record(2, 3, 2, linewidth_specification_mode_data); CGM_write_int_record(2, 4, 2, marker_size_specification_mode_data); vdc_extent_data[2] = t->xmax + CGM_MARGIN; vdc_extent_data[3] = t->ymax + CGM_MARGIN; CGM_write_int_record(2, 6, 8, vdc_extent_data); CGM_write_int_record(3, 1, 2, vdc_integer_precision_data); CGM_write_int_record(3, 4, sizeof(transparency_data) / CGM_ADJ, transparency_data); CGM_write_int_record(3, 6, sizeof(clip_indicator_data) / CGM_ADJ, clip_indicator_data); /* picture body (classes 4 and 5) */ CGM_write_int_record(0, 4, 0, NULL); /* The WinWord 6.0 and PublishIt input filters seem to mostly ignore the color table. With the table, WinWord maps color 7 to black. */ if (!cgm_winword6_mode) CGM_write_int_record(5, 34, sizeof(color_table_data) / CGM_ADJ, color_table_data); CGM_write_int_record(5, 2, sizeof(line_type_data) / CGM_ADJ, line_type_data); cgm_linewidth = cgm_linewidth_pt * CGM_PT; CGM_write_int_record(5, 3, sizeof(cgm_linewidth) / CGM_ADJ, (int *) &cgm_linewidth); CGM_linecolor(0); /* CGM_write_int_record(5, 4, sizeof(line_color_data)/CGM_ADJ, line_color_data); */ CGM_write_int_record(5, 15, 2, (int *) &t->v_char); CGM_write_int_record(5, 22, 2, interior_style_data); { char buf[45]; sprintf(buf, "%.31s,%d", cgm_font, cgm_fontsize); CGM_set_font(buf); } CGM_set_pointsize(pointsize); } TERM_PUBLIC int CGM_find_font(font, numchar) char *font; int numchar; { int font_index = 1; char *s; for (s = cgm_font_data; s < cgm_font_data + strlen(cgm_font_data); s += (int) *s + 1) { /* strnicmp is not standard, but defined by stdfn.c if not available */ if (numchar == (int) *s && strnicmp(font, s + 1, numchar - 1) == 0) return font_index; font_index++; } return 0; } TERM_PUBLIC int CGM_set_font(font) char *font; { register struct termentry *t = term; int size, font_index; char *comma; int sep; comma = strchr(font, ','); if (comma == NULL) return FALSE; /* bad format */ sep = comma - font; /* find font in font table, or use 1st font */ font_index = CGM_find_font(font, sep); if (font_index == 0) font_index = 1; CGM_write_int_record(5, 10, 2, &font_index); /* set font size */ size = cgm_fontsize; sscanf(comma + 1, "%d", &size); if (sep > 31) sep = 31; strncpy(cgm_font, font, sep); cgm_font[sep] = NUL; t->v_char = size * CGM_PT; t->h_char = (t->v_char * 5) / 9; CGM_write_int_record(5, 15, 2, (int *) &t->v_char); return TRUE; } TERM_PUBLIC void CGM_text() { CGM_flush_polyline(); CGM_write_int_record(0, 5, 0, NULL); /* end picture */ CGM_write_int_record(0, 2, 0, NULL); /* end metafile */ } TERM_PUBLIC void CGM_linetype(linetype) int linetype; { assert(linetype >= -2); if (linetype == cgm_linetype) return; cgm_linetype = linetype; CGM_linecolor(linetype); if (cgm_dashed) { CGM_dashtype(linetype); /* DBT 10-8-98 use dashes */ } else { /* dashes for gridlines, solid for everything else */ CGM_dashtype(linetype == -1 ? 2 : 0); } /* CGM_dashtype(cgm_monochrome ? linetype : 0); first fix, color->no dashes */ /* CGM_dashtype(linetype); orig distribution */ } TERM_PUBLIC void CGM_linecolor(linecolor) int linecolor; { assert(linecolor >= -2); linecolor = (linecolor < 1) ? 1 : linecolor % CGM_COLORS + 1; if (cgm_monochrome || linecolor == cgm_color) return; cgm_color = linecolor; CGM_flush_polyline(); CGM_write_int_record(5, 4, 2, (int *) &cgm_color); CGM_write_int_record(5, 23, 2, (int *) &cgm_color); } TERM_PUBLIC void CGM_linewidth(width) double width; { int new_linewidth; assert(width >= 1.); new_linewidth = width * cgm_linewidth_pt * CGM_PT; if (new_linewidth == cgm_linewidth) return; cgm_linewidth = new_linewidth; CGM_write_int_record(5, 3, sizeof(cgm_linewidth) / CGM_ADJ, (int *) &cgm_linewidth); CGM_dashtype(cgm_dashtype); /* have dash lengths recalculated */ } TERM_PUBLIC void CGM_dashtype(dashtype) int dashtype; { int i, j; /* Each group of 8 entries in dot_length[] defines a dash pattern. Entries in each group are alternately length of whitespace and length of line, in units of 2/3 of the linewidth. */ static int dot_length[CGM_LINE_TYPES * 8] = { /* 0 - solid */ 5, 8, 5, 8, 5, 8, 5, 8, /* 1 - dashes */ 5, 3, 5, 3, 5, 3, 5, 3, /* 2 - short dashes */ 4, 1, 4, 1, 4, 1, 4, 1, /* 3 - dotted */ 4, 8, 4, 1, 4, 8, 4, 1, /* 4 - dash-dot */ 4, 9, 4, 1, 4, 1, 0, 0, /* 5 - dash-dot-dot */ 4, 10, 4, 1, 4, 1, 4, 1, /* 6 - dash-dot-dot-dot */ 4, 10, 4, 10, 4, 1, 0, 0, /* 7 - dash-dash-dot */ 4, 10, 4, 10, 4, 1, 4, 1}; /* 8 - dash-dash-dot-dot */ assert(dashtype >= -2); if (dashtype == cgm_dashtype) return; cgm_dashtype = dashtype; CGM_flush_polyline(); if (dashtype >= CGM_LINE_TYPES) dashtype = dashtype % CGM_LINE_TYPES; if (dashtype < 1) { term->vector = CGM_solid_vector; return; } term->vector = CGM_dashed_vector; /* set up dash dimensions */ j = (dashtype - 1) * 8; for (i = 0; i < 8; i++, j++) { if (dot_length[j]) cgm_step_sizes[i] = (dot_length[j] * cgm_linewidth) * 2 / 3; else cgm_step_sizes[i] = 0; } /* first thing drawn will be a line */ cgm_step = cgm_step_sizes[1]; cgm_step_index = 1; } TERM_PUBLIC void CGM_move(x, y) unsigned int x, y; { assert(x < term->xmax && y < term->ymax); if (x == cgm_posx && y == cgm_posy) return; CGM_flush_polyline(); cgm_posx = x; cgm_posy = y; } static void CGM_flush_polyline() { if (cgm_coords == 0) return; CGM_write_int_record(4, 1, cgm_coords * 2, cgm_polyline); cgm_coords = 0; } static void CGM_write_char_record(class, cgm_id, numbytes, data) int class, cgm_id, numbytes; char *data; { int pad, padded_length; static unsigned char flag = 0xff; char short_len; pad = 0; padded_length = numbytes + 1; if (numbytes >= 255) padded_length += 2; /* long string */ if (padded_length & 1) padded_length += pad = 1; /* needs pad */ CGM_write_code(class, cgm_id, padded_length); short_len = numbytes; if (numbytes < 255) fwrite(&short_len, 1, 1, gpoutfile); /* write true length */ else { fwrite(&flag, 1, 1, gpoutfile); CGM_write_int(numbytes); } fwrite(data, 1, numbytes + pad, gpoutfile); /* write string */ } static void CGM_write_int_record(class, cgm_id, numbytes, data) int class, cgm_id, numbytes, *data; { int i; assert((numbytes & 1) == 0); CGM_write_code(class, cgm_id, numbytes); numbytes >>= 1; for (i = 0; i < numbytes; i++) CGM_write_int(data[i]); } static void CGM_write_mixed_record(class, cgm_id, numint, int_data, numchar, char_data) int class, cgm_id, numint, *int_data, numchar; char *char_data; { int i, pad, padded_length; static unsigned char flag = 0xff; char short_len; pad = 0; padded_length = numchar + 1; if (numchar >= 255) padded_length += 2; /* long string */ if (padded_length & 1) padded_length += pad = 1; /* needs pad */ CGM_write_code(class, cgm_id, numint * 2 + padded_length); for (i = 0; i < numint; i++) CGM_write_int(int_data[i]); /* write integers */ short_len = numchar; if (numchar < 255) fwrite(&short_len, 1, 1, gpoutfile); /* write string length */ else { fwrite(&flag, 1, 1, gpoutfile); CGM_write_int(numchar); } fwrite(char_data, 1, numchar + pad, gpoutfile); /* write string */ } /* Write the code word that starts a CGM record. bits in code word are as follows... cccciiiiiiilllll where cccc is a 4-bit class number iiiiiii is a 7-bit ID number lllll is a 5-bit length (# bytes following the code word, or 31 followed by a word with the actual number) */ static void CGM_write_code(class, cgm_id, length) int class, cgm_id, length; { unsigned code; assert((0 <= class) &&(class <16)); assert((0 <= cgm_id) && (cgm_id < 128)); assert(0 <= length); if (length < 31) { code = ((class &0x0f) <<12) | ((cgm_id & 0x7f) << 5) | ((length & 0x1f)); CGM_write_int(code); } else { code = ((class &0x0f) <<12) | ((cgm_id & 0x7f) << 5) | 0x1f; CGM_write_int(code); CGM_write_int(length); } } static void CGM_write_int(value) int value; { union { short s; char c[2]; } u; #if !defined(DOS16) && !defined(WIN16) assert(-32768 <= value && value <= 32767); #endif u.c[0] = (value >> 8) & 255; /* convert to network order */ u.c[1] = value & 255; fwrite(&u.s, 1, 2, gpoutfile); } /* Draw a dashed line to (ux,uy). CGM has linestyles, but they are not usable -- at least with the Word for Windows 6.0 filter, where lines of significant width (even 1 pt) always come out solid. Therefore, we implement dashed lines here instead. */ TERM_PUBLIC void CGM_dashed_vector(ux, uy) unsigned int ux, uy; { int xa, ya; int dx, dy, adx, ady; int dist; /* approximate distance in plot units from starting point to specified end point. */ long remain; /* approximate distance in plot units remaining to specified end point. */ assert(ux < term->xmax && uy < term->ymax); dx = (ux - cgm_posx); dy = (uy - cgm_posy); adx = abs(dx); ady = abs(dy * 10); /* using the approximation sqrt(x**2 + y**2) ~ x + (5*x*x)/(12*y) when x > y. Note ordering of calculations to avoid overflow on 16 bit architectures */ if (10 * adx < ady) dist = (ady / 2 + 25 * adx / ady * adx / 6 * 5) / 5; else { if (adx == 0) return; dist = (adx * 10 + (ady / 24) * (ady / adx)) / 10; } remain = dist; xa = cgm_posx; ya = cgm_posy; while (remain > cgm_step) { remain -= cgm_step; if (cgm_step_index & 1) CGM_solid_vector((int) (ux - (remain * dx) / dist), (int) (uy - (remain * dy) / dist)); else { xa = (int) (ux - (remain * dx) / dist); ya = (int) (uy - (remain * dy) / dist); CGM_move(xa, ya); } if (++cgm_step_index >= 8) cgm_step_index = 0; cgm_step = cgm_step_sizes[cgm_step_index]; } if (cgm_step_index & 1) CGM_solid_vector(ux, uy); else CGM_move(ux, uy); cgm_step -= (int) remain; } TERM_PUBLIC void CGM_solid_vector(ux, uy) unsigned int ux, uy; { assert(ux < term->xmax && uy < term->ymax); if (ux == cgm_posx && uy == cgm_posy) return; if (cgm_coords > CGM_MAX_SEGMENTS - 2) { CGM_flush_polyline(); cgm_polyline[cgm_coords++] = cgm_posx; cgm_polyline[cgm_coords++] = cgm_posy + CGM_MARGIN; } else if (cgm_coords == 0) { cgm_polyline[cgm_coords++] = cgm_posx; cgm_polyline[cgm_coords++] = cgm_posy + CGM_MARGIN; } cgm_polyline[cgm_coords++] = ux; cgm_polyline[cgm_coords++] = uy + CGM_MARGIN; cgm_posx = ux; cgm_posy = uy; } TERM_PUBLIC void CGM_put_text(x, y, str) unsigned int x, y; char str[]; { static int where[3] = { 0, 0, 1 }; int data[4]; char *s = str; while (*s) if (!isspace((int) *s++)) goto showit; return; showit: if (cgm_vert_text != cgm_vert_text_requested) { cgm_vert_text = cgm_vert_text_requested; if (cgm_vert_text) { data[0] = -term->v_char; data[1] = data[2] = 0; data[3] = term->v_char; } else { data[1] = data[2] = term->v_char; data[0] = data[3] = 0; } CGM_write_int_record(5, 16, 8, data); } CGM_flush_polyline(); where[0] = x; where[1] = y + CGM_MARGIN; CGM_write_mixed_record(4, 4, 3, where, strlen(str), str); cgm_posx = cgm_posy = -2000; } TERM_PUBLIC int CGM_text_angle(ang) int ang; { if (cgm_rotate) { cgm_vert_text_requested = ang; return TRUE; } return ang ? FALSE : TRUE; } TERM_PUBLIC int CGM_justify_text(mode) enum JUSTIFY mode; { static int data[6] = { 1, 3, 0, 0, 0, 0 }; switch (mode) { case LEFT: data[0] = 1; break; case CENTRE: data[0] = 2; break; case RIGHT: data[0] = 3; break; default: assert(0); } CGM_write_int_record(5, 18, 12, data); return (TRUE); } TERM_PUBLIC void CGM_reset() { cgm_posx = cgm_posy = 0; } TERM_PUBLIC void CGM_point(x, y, number) unsigned int x, y; int number; { int old_dashtype; if (number < 0) { /* draw dot */ CGM_move(x, y); CGM_solid_vector(x + 1, y); return; } number %= CGM_POINTS; CGM_flush_polyline(); old_dashtype = cgm_dashtype; CGM_dashtype(0); switch (number) { case 0: /* draw diamond */ CGM_move(x - cgm_tic, y); CGM_solid_vector(x, y - cgm_tic); CGM_solid_vector(x + cgm_tic, y); CGM_solid_vector(x, y + cgm_tic); CGM_flush_polygon(); break; case 1: /* draw plus */ CGM_move(x - cgm_tic, y); CGM_solid_vector(x + cgm_tic, y); CGM_move(x, y - cgm_tic); CGM_solid_vector(x, y + cgm_tic); break; case 2: /* draw box */ CGM_move(x - cgm_tic707, y - cgm_tic707); CGM_solid_vector(x + cgm_tic707, y - cgm_tic707); CGM_solid_vector(x + cgm_tic707, y + cgm_tic707); CGM_solid_vector(x - cgm_tic707, y + cgm_tic707); CGM_flush_polygon(); break; case 3: /* draw X */ CGM_move(x - cgm_tic707, y - cgm_tic707); CGM_solid_vector(x + cgm_tic707, y + cgm_tic707); CGM_move(x - cgm_tic707, y + cgm_tic707); CGM_solid_vector(x + cgm_tic707, y - cgm_tic707); break; case 4: /* draw triangle (point up) */ CGM_move(x, y + cgm_tic1241); CGM_solid_vector(x - cgm_tic1077, y - cgm_tic621); CGM_solid_vector(x + cgm_tic1077, y - cgm_tic621); CGM_flush_polygon(); break; case 5: /* draw star (asterisk) */ CGM_move(x, y - cgm_tic); CGM_solid_vector(x, y + cgm_tic); CGM_move(x + cgm_tic866, y - cgm_tic500); CGM_solid_vector(x - cgm_tic866, y + cgm_tic500); CGM_move(x + cgm_tic866, y + cgm_tic500); CGM_solid_vector(x - cgm_tic866, y - cgm_tic500); break; case 6: /* draw triangle (point down) */ CGM_move(x, y - cgm_tic1241); CGM_solid_vector(x - cgm_tic1077, y + cgm_tic621); CGM_solid_vector(x + cgm_tic1077, y + cgm_tic621); CGM_flush_polygon(); break; case 7: /* draw circle (actually, dodecagon) (WinWord 6 accepts the CGM "circle" element, but the resulting circle is not correctly centered!) */ CGM_move(x, y - cgm_tic); CGM_solid_vector(x + cgm_tic500, y - cgm_tic866); CGM_solid_vector(x + cgm_tic866, y - cgm_tic500); CGM_solid_vector(x + cgm_tic, y); CGM_solid_vector(x + cgm_tic866, y + cgm_tic500); CGM_solid_vector(x + cgm_tic500, y + cgm_tic866); CGM_solid_vector(x, y + cgm_tic); CGM_solid_vector(x - cgm_tic500, y + cgm_tic866); CGM_solid_vector(x - cgm_tic866, y + cgm_tic500); CGM_solid_vector(x - cgm_tic, y); CGM_solid_vector(x - cgm_tic866, y - cgm_tic500); CGM_solid_vector(x - cgm_tic500, y - cgm_tic866); CGM_flush_polygon(); break; } CGM_dashtype(old_dashtype); } TERM_PUBLIC void CGM_set_pointsize(size) double size; { /* Markers were chosen to have approximately equal areas. Dimensions are as follows, in units of cgm_tic: plus, diamond: half height = 1 square, cross: half height = sqrt(1/2) ~ 12/17 triangle: half width = sqrt(sqrt(4/3)) ~ 14/13, height = sqrt(3*sqrt(4/3)) ~ 54/29 star: half height = 1, half width = sqrt(3/4) ~ 13/15 dodecagon: coordinates of vertices are 0, sin(30) = 1/2, cos(30) = sqrt(3/4) ~ 13/15, or 1 The fractions are approximates of the equivalent continued fractions. */ cgm_tic = (size * term->h_tic / 2); cgm_tic707 = cgm_tic * 12 / 17; cgm_tic866 = cgm_tic * 13 / 15; cgm_tic500 = cgm_tic / 2; cgm_tic1241 = cgm_tic * 36 / 29; cgm_tic1077 = cgm_tic * 14 / 13; cgm_tic621 = cgm_tic * 18 / 29; } static void CGM_flush_polygon() { if (cgm_coords == 0) return; CGM_write_int_record(4, 7, cgm_coords * 2, cgm_polyline); cgm_coords = 0; } TERM_PUBLIC void CGM_options() { strcpy(cgm_font, "Arial Bold"); cgm_fontsize = 10; term->v_char = (unsigned int) (cgm_fontsize * CGM_PT); term->h_char = (unsigned int) (cgm_fontsize * CGM_PT * 5 / 9); cgm_linewidth_pt = 1; cgm_monochrome = FALSE; cgm_plotwidth = 6 * 72; cgm_portrait = FALSE; cgm_rotate = TRUE; cgm_dashed = TRUE; cgm_winword6_mode = FALSE; while (!END_OF_COMMAND) { if (almost_equals(c_token, "p$ortrait")) { cgm_portrait = TRUE; c_token++; continue; } if (almost_equals(c_token, "la$ndscape")) { cgm_portrait = FALSE; c_token++; continue; } if (almost_equals(c_token, "de$fault")) { strcpy(cgm_font, "Arial Bold"); cgm_fontsize = 10; term->v_char = (unsigned int) (cgm_fontsize * CGM_PT); term->h_char = (unsigned int) (cgm_fontsize * CGM_PT * 5 / 9); cgm_linewidth_pt = 1; cgm_monochrome = FALSE; cgm_plotwidth = 6 * 72; cgm_portrait = FALSE; cgm_rotate = TRUE; cgm_dashed = TRUE; cgm_winword6_mode = FALSE; c_token++; continue; } if (almost_equals(c_token, "w$inword6")) { cgm_winword6_mode = TRUE; c_token++; continue; } if (almost_equals(c_token, "m$onochrome")) { cgm_monochrome = TRUE; c_token++; continue; } if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { cgm_monochrome = FALSE; c_token++; continue; } if (almost_equals(c_token, "r$otate")) { cgm_rotate = TRUE; c_token++; continue; } if (almost_equals(c_token, "nor$otate")) { cgm_rotate = FALSE; c_token++; continue; } if (almost_equals(c_token, "da$shed")) { cgm_dashed = TRUE; c_token++; continue; } if (almost_equals(c_token, "s$olid")) { cgm_dashed = FALSE; c_token++; continue; } if (almost_equals(c_token, "li$newidth")) { c_token++; if (!END_OF_COMMAND) { struct value a; cgm_linewidth_pt = (unsigned int) real(const_express(&a)); if (cgm_linewidth_pt > 10000) { fputs("gnuplot(cgm.trm): linewidth out of range\n", stderr); cgm_linewidth_pt = 1; } } continue; } if (almost_equals(c_token, "wid$th")) { c_token++; if (!END_OF_COMMAND) { struct value a; cgm_plotwidth = (int) real(const_express(&a)); if (cgm_plotwidth < 0 || cgm_plotwidth > 10000) { fputs("gnuplot(cgm.trm): width out of range\n", stderr); cgm_plotwidth = 6 * 72; } } continue; } break; } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(cgm_font, c_token, MAX_ID_LEN); if (CGM_find_font(cgm_font, strlen(cgm_font)) == 0) { /* insert the font in the font table */ int n; n = strlen(cgm_font); if (n + 1 <= sizeof(cgm_font_data) && n <= 255) { cgm_font_data[0] = n; strncpy(cgm_font_data + 1, cgm_font, n); cgm_font_data[n + 1] = 0; } } c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; cgm_fontsize = (int) real(const_express(&a)); term->v_char = (unsigned int) (cgm_fontsize * CGM_PT); term->h_char = (unsigned int) (cgm_fontsize * CGM_PT * 5 / 9); } if (cgm_portrait) { term->xmax = CGM_SMALL - CGM_MARGIN; term->ymax = CGM_LARGE - CGM_MARGIN; } else { term->xmax = CGM_LARGE - CGM_MARGIN; term->ymax = CGM_SMALL - CGM_MARGIN; } sprintf(default_font, "%s,%d", cgm_font, cgm_fontsize); /* default_font holds the font and size set at 'set term' */ sprintf(term_options, "%s %s %s %s %s width %d linewidth %d \"%s\" %d", cgm_portrait ? "portrait" : "landscape", cgm_monochrome ? "monochrome" : "color", cgm_rotate ? "rotate" : "norotate", cgm_dashed ? "dashed" : "solid", cgm_winword6_mode ? "winword6" : "", cgm_plotwidth, cgm_linewidth_pt, cgm_font, cgm_fontsize); } #ifdef DEFEAT_ASSERTIONS #define NDEBUG #include #undef DEFEAT_ASSERTIONS #endif /* DEFEAT_ASSERTIONS */ #ifdef NEXT #undef id #undef datum #endif #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(cgm_driver) "cgm", "Computer Graphics Metafile", CGM_LARGE - CGM_MARGIN, CGM_SMALL - CGM_MARGIN, CGM_VCHAR, CGM_HCHAR, CGM_VTIC, CGM_HTIC, CGM_options, CGM_init, CGM_reset, CGM_text, null_scale, CGM_graphics, CGM_move, CGM_solid_vector, CGM_linetype, CGM_put_text, CGM_text_angle, CGM_justify_text, CGM_point, do_arrow, CGM_set_font, CGM_set_pointsize, TERM_BINARY, /* various flags */ NULL, /* after one plot of multiplot */ NULL, /* before subsequent plot of multiplot */ NULL, /* clear part of multiplot */ CGM_linewidth TERM_TABLE_END(cgm_driver) #undef LAST_TERM #define LAST_TERM cgm_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(cgm) "1 cgm", "?commands set terminal cgm", "?set terminal cgm", "?set term cgm", "?terminal cgm", "?term cgm", "?cgm", " The `cgm` terminal generates a Computer Graphics Metafile. This file format", " is a subset of the ANSI X3.122-1986 standard entitled \"Computer Graphics -", " Metafile for the Storage and Transfer of Picture Description Information\".", " Several options may be set in `cgm`.", "", " Syntax:", " set terminal cgm {} {} {} {solid | dashed}", " {width } {linewidth }", " {\"\"} {}", "", " where is `landscape`, `portrait`, or `default`;", " is either `color` or `monochrome`; ", " is either `rotate` or `norotate`;", " `solid` draws all curves with solid lines, overriding any dashed patterns;", " is the width of the page in points; ", " is the line width in points; ", " is the name of a font; and ", " `` is the size of the font in points.", "", " By default, `cgm` uses rotated text for the Y axis label.", "", " The first six options can be in any order. Selecting `default` sets all", " options to their default values.", "", " Examples:", " set terminal cgm landscape color rotate dashed width 432 \\", " linewidth 1 'Arial Bold' 12 # defaults", " set terminal cgm 14 linewidth 2 14 # wider lines & larger font", " set terminal cgm portrait 'Times Roman Italic' 12", " set terminal cgm color solid # no pesky dashes!", "2 font", "?commands set terminal cgm font", "?set terminal cgm font", "?set term cgm font", "?cgm font", " The first part of a Computer Graphics Metafile, the metafile description,", " includes a font table. In the picture body, a font is designated by an", " index into this table. By default, this terminal generates a table with", " the following fonts:", "@start table - first is interactive cleartext form", " Arial", " Arial Italic", " Arial Bold", " Arial Bold Italic", " Times Roman", " Times Roman Italic", " Times Roman Bold", " Times Roman Bold Italic", " Helvetica", " Roman", "#\\begin{tabular}{|ccl|} \\hline", "#\\multicolumn{2}{|c|}{CGM fonts}\\\\", "#&Arial&\\\\", "#&Arial Italic&\\\\", "#&Arial Bold&\\\\", "#&Arial Bold Italic&\\\\", "#&Times Roman&\\\\", "#&Times Roman Italic&\\\\", "#&Times Roman Bold&\\\\", "#&Times Roman Bold Italic&\\\\", "#&Helvetica&\\\\", "#&Roman&\\\\", "%c c l .", "%@@CGM fonts", "%_", "%@@Arial", "%@@Arial Italic", "%@@Arial Bold", "%@@Arial Bold Italic", "%@@Times Roman", "%@@Times Roman Italic", "%@@Times Roman Bold", "%@@Times Roman Bold Italic", "%@@Helvetica", "%@@Roman", "@end table", " Case is not distinct, but the modifiers must appear in the above order (that", " is, not 'Arial Italic Bold'). 'Arial Bold' is the default font.", "", " You may also specify a font name which does not appear in the default font", " table. In that case, a new font table is constructed with the specified", " font as its only entry. You must ensure that the spelling, capitalization,", " and spacing of the name are appropriate for the application that will read", " the CGM file.", "2 fontsize", "?commands set terminal cgm fontsize", "?set terminal cgm fontsize", "?set term cgm fontsize", "?cgm fontsize", " Fonts are scaled assuming the page is 6 inches wide. If the `size` command", " is used to change the aspect ratio of the page or the CGM file is converted", " to a different width (e.g. it is imported into a document in which the", " margins are not 6 inches apart), the resulting font sizes will be different.", " To change the assumed width, use the `width` option.", "2 linewidth", "?commands set terminal cgm linewidth", "?set terminal cgm linewidth", "?set term cgm linewidth", "?cgm linewidth", " The `linewidth` option sets the width of lines in pt. The default width is", " 1 pt. Scaling is affected by the actual width of the page, as discussed", " under the `fontsize` and `width` options", "2 rotate", "?commands set terminal cgm rotate", "?set terminal cgm rotate", "?set term cgm rotate", "?cgm rotate", " The `norotate` option may be used to disable text rotation. For example,", " the CGM input filter for Word for Windows 6.0c can accept rotated text, but", " the DRAW editor within Word cannot. If you edit a graph (for example, to", " label a curve), all rotated text is restored to horizontal. The Y axis", " label will then extend beyond the clip boundary. With `norotate`, the Y", " axis label starts in a less attractive location, but the page can be edited", " without damage. The `rotate` option confirms the default behavior.", "2 solid", "?set terminal cgm solid", "?set term cgm solid", "?cgm solid", " The `solid` option may be used to disable dashed line styles in the", " plots. This is useful when color is enabled and the dashing of the lines", " detracts from the appearance of the plot. The `dashed` option confirms the", " default behavior, which gives a different dash pattern to each curve.", "2 size", "?commands set terminal cgm size", "?set terminal cgm size", "?set term cgm size", "?scgm size", " Default size of a CGM page is 32599 units wide and 23457 units high for", " landscape, or 23457 units wide by 32599 units high for portrait.", "2 width", "?commands set terminal cgm width", "?set terminal cgm width", "?set term cgm width", "?cgm width", " All distances in the CGM file are in abstract units. The application that", " reads the file determines the size of the final page. By default, the width", " of the final page is assumed to be 6 inches (15.24 cm). This distance is", " used to calculate the correct font size, and may be changed with the `width`", " option. The keyword should be followed by the width in points. (Here, a", " point is 1/72 inch, as in PostScript. This unit is known as a \"big point\"", " in TeX.) `gnuplot` arithmetic can be used to convert from other units, as", " follows:", " set terminal cgm width 432 # default", " set terminal cgm width 6*72 # same as above", " set terminal cgm width 10/2.54*72 # 10 cm wide", "2 winword6", "?commands set terminal cgm winword6", "?set terminal cgm winword6", "?set term cgm winword6", "?cgm winword6", " The default font table was chosen to match, where possible, the default font", " assignments made by the Computer Graphics Metafile input filter for", " Microsoft Word 6.0c, although the filter makes available only 'Arial' and", " 'Times Roman' fonts and their bold and/or italic variants. Other fonts such", " as 'Helvetica' and 'Roman' are not available. If the CGM file includes a", " font table, the filter mostly ignores it. However, it changes certain font", " assignments so that they disagree with the table. As a workaround, the", " `winword6` option deletes the font table from the CGM file. In this case,", " the filter makes predictable font assignments. 'Arial Bold' is correctly", " assigned even with the font table present, which is one reason it was chosen", " as the default.", "", " `winword6` disables the color tables for a similar reason---with the color", " table included, Microsoft Word displays black for color 7.", "", " Linewidths and pointsizes may be changed with `set linestyle`." END_HELP(cgm) #endif /* TERM_HELP */ /* * $Id: corel.trm,v 1.12 1998/04/14 00:17:35 drd Exp $ */ /* corel.trm A modified ai.trm for CorelDraw import filters by Chris Parks, parks@physics.purdue.edu Import from CorelDraw with the CorelTrace filter syntax: set terminal default set terminal mode "fontname" fontsize,xsize,ysize,linewidth mode= color or monochrome (default=mono) "fontname"= postscript font name (default="SwitzerlandLight") fontsize = size of font in points (default=22pt) xsize = width of page in inches (default=8.2in) ysize = height of page in inches (default=10in) linewidth = width of lines in points (default=1.2pt) */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(corel) #endif #ifdef TERM_PROTO TERM_PUBLIC void COREL_options __PROTO((void)); TERM_PUBLIC void COREL_init __PROTO((void)); TERM_PUBLIC void COREL_graphics __PROTO((void)); TERM_PUBLIC void COREL_text __PROTO((void)); TERM_PUBLIC void COREL_reset __PROTO((void)); TERM_PUBLIC void COREL_linetype __PROTO((int linetype)); TERM_PUBLIC void COREL_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void COREL_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void COREL_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int COREL_text_angle __PROTO((int ang)); TERM_PUBLIC int COREL_justify_text __PROTO((enum JUSTIFY mode)); #define CORELD_XMAX 5960 /* 8.2 inches wide */ #define CORELD_YMAX 7200 /* 10 inches high */ #define CORELD_VTIC (CORELD_YMAX/80) #define CORELD_HTIC (CORELD_YMAX/80) #define CORELD_VCHAR (22*COREL_SC) /* default is 22 point characters */ #define CORELD_HCHAR (22*COREL_SC*6/10) #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* plots for publication should be sans-serif (don't use TimesRoman) */ char corel_font[MAX_ID_LEN + 1] = "SwitzerlandLight"; /* name of font */ int corel_fontsize = 22; /* size of font in pts */ TBOOLEAN corel_color = FALSE; TBOOLEAN corel_stroke = FALSE; int corel_path_count = 0; /* count of lines in path */ int corel_ang = 0; /* text angle */ enum JUSTIFY corel_justify = LEFT; /* text is flush left */ /* default mode constants */ #define CORELD_XOFF 0 /* page offset in pts */ #define CORELD_YOFF 0 #define COREL_SC (10.0) /* scale is 1pt = 10 units */ #define CORELD_LW (1.2*COREL_SC) /* linewidth = 1.2 pts */ unsigned int corel_xmax = CORELD_XMAX; unsigned int corel_ymax = CORELD_YMAX; float corel_lw = CORELD_LW; TERM_PUBLIC void COREL_options() { struct value a; if (!END_OF_COMMAND && almost_equals(c_token, "def$ault")) { corel_color = FALSE; strcpy(corel_font, "SwitzerlandLight"); corel_fontsize = 22; corel_lw = CORELD_LW; corel_xmax = CORELD_XMAX; corel_ymax = CORELD_YMAX; c_token++; } if (!END_OF_COMMAND && almost_equals(c_token, "mono$chrome")) { corel_color = FALSE; c_token++; } else if (!END_OF_COMMAND && (almost_equals(c_token, "color$") || almost_equals(c_token, "colour$"))) { corel_color = TRUE; c_token++; } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(corel_font, c_token, MAX_ID_LEN); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ corel_fontsize = (int) real(const_express(&a)); c_token++; term->v_char = (unsigned int) (corel_fontsize * COREL_SC); term->h_char = (unsigned int) (corel_fontsize * COREL_SC * 6 / 10); } if (!END_OF_COMMAND) { corel_xmax = (unsigned int) (real(const_express(&a)) * 720); c_token++; if (!END_OF_COMMAND) { corel_ymax = (unsigned int) (real(const_express(&a)) * 720); c_token++; } term->xmax = corel_xmax; term->ymax = corel_ymax; term->v_tic = corel_ymax / 80; term->h_tic = corel_ymax / 80; } if (!END_OF_COMMAND) { corel_lw = real(const_express(&a)) * COREL_SC; c_token++; } sprintf(term_options, "%s \"%s\" %d,%0.1f,%0.1f,%0.1f", corel_color ? "color" : "monochrome", corel_font, corel_fontsize, corel_xmax / 720.0, corel_ymax / 720.0, corel_lw / COREL_SC); } TERM_PUBLIC void COREL_init() { fprintf(gpoutfile, "\ %%!PS-Adobe-2.0 EPSF-1.2\n\ %%%%BoundingBox: %d %d %d %d\n\ %%%%TemplateBox: %d %d %d %d\n\ %%%%EndComments\n\ %%%%EndProlog\n\ %%%%BeginSetup\n%%%%EndSetup\n", CORELD_XOFF, CORELD_YOFF, (int) ((corel_xmax) / COREL_SC + 0.5 + CORELD_XOFF), (int) ((corel_ymax) / COREL_SC + 0.5 + CORELD_YOFF), CORELD_XOFF, CORELD_YOFF, (int) ((corel_xmax) / COREL_SC + 0.5 + CORELD_XOFF), (int) ((corel_ymax) / COREL_SC + 0.5 + CORELD_YOFF)); } TERM_PUBLIC void COREL_graphics() { corel_path_count = 0; corel_stroke = FALSE; } TERM_PUBLIC void COREL_text() { if (corel_stroke) { fputs("S\n", gpoutfile); corel_stroke = FALSE; } corel_path_count = 0; } TERM_PUBLIC void COREL_reset() { fputs("%%%%Trailer\n", gpoutfile); } TERM_PUBLIC void COREL_linetype(linetype) int linetype; { if (corel_stroke) { fputs("S\n", gpoutfile); corel_stroke = FALSE; } switch (linetype) { case -2: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 0 0 1 K\n", gpoutfile); } else { fputs("\ [] 0 d\n\ 0 j\n0 G\n", gpoutfile); } break; case -1: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 0 0 1 K\n", gpoutfile); } else { fputs("\ [1 2] 0 d\n\ 0 j\n0 G\n", gpoutfile); } break; case 0: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("1 0 1 0 K\n", gpoutfile); } else { fputs("\ [] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 1: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("1 1 0 0 K\n", gpoutfile); } else { fputs("\ [4 2] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 2: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 1 1 0 K\n", gpoutfile); } else { fputs("\ [2 3] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 3: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 1 0 0 K\n", gpoutfile); } else { fputs("\ [1 1.5] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 4: fprintf(gpoutfile, "%f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("1 0 0 0 K\n", gpoutfile); } else { fputs("\ [5 2 1 2] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 5: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 0 1 0 K\n", gpoutfile); } else { fputs("\ [4 3 1 3] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 6: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 0 0 1 K\n", gpoutfile); } else { fputs("\ [2 2 2 4] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 7: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0 0.7 1 0 K\n", gpoutfile); } else { fputs("\ [2 2 2 2 2 4] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; case 8: fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC); if (corel_color) { fputs("0.5 0.5 0.5 0 K\n", gpoutfile); } else { fputs("\ [2 2 2 2 2 2 2 4] 0 d\n\ 2 j\n0 G\n", gpoutfile); } break; } corel_path_count = 0; } TERM_PUBLIC void COREL_move(x, y) unsigned int x, y; { if (corel_stroke) fputs("S\n", gpoutfile); fprintf(gpoutfile, "%0.2f %0.2f m\n", x / COREL_SC, y / COREL_SC); corel_path_count += 1; corel_stroke = TRUE; } TERM_PUBLIC void COREL_vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "%.2f %.2f l\n", x / COREL_SC, y / COREL_SC); corel_path_count += 1; corel_stroke = TRUE; if (corel_path_count >= 400) { fprintf(gpoutfile, "S\n%.2f %.2f m\n", x / COREL_SC, y / COREL_SC); corel_path_count = 0; } } TERM_PUBLIC void COREL_put_text(x, y, str) unsigned int x, y; char *str; { char ch; if (corel_stroke) { fputs("S\n", gpoutfile); corel_stroke = FALSE; } switch (corel_justify) { case LEFT: fprintf(gpoutfile, "/_%s %d %d 0 0 z\n", corel_font, corel_fontsize, corel_fontsize); break; case CENTRE: fprintf(gpoutfile, "/_%s %d %d 0 1 z\n", corel_font, corel_fontsize, corel_fontsize); break; case RIGHT: fprintf(gpoutfile, "/_%s %d %d 0 2 z\n", corel_font, corel_fontsize, corel_fontsize); break; } if (corel_ang == 0) { fprintf(gpoutfile, "[1 0 0 1 %.2f %.2f]e\n0 g\n", x / COREL_SC, y / COREL_SC - corel_fontsize / 3.0); } else { fprintf(gpoutfile, "[0 1 -1 0 %.2f %.2f]e\n0 g\n", x / COREL_SC - corel_fontsize / 3.0, y / COREL_SC); } putc('(', gpoutfile); ch = *str++; while (ch != NUL) { if ((ch == '(') || (ch == ')') || (ch == '\\')) putc('\\', gpoutfile); putc(ch, gpoutfile); ch = *str++; } fputs(")t\nT\n", gpoutfile); corel_path_count = 0; } TERM_PUBLIC int COREL_text_angle(ang) int ang; { corel_ang = ang; return TRUE; } TERM_PUBLIC int COREL_justify_text(mode) enum JUSTIFY mode; { corel_justify = mode; return TRUE; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(corel_driver) "corel", "EPS format for CorelDRAW", CORELD_XMAX, CORELD_YMAX, CORELD_VCHAR, CORELD_HCHAR, CORELD_VTIC, CORELD_HTIC, COREL_options, COREL_init, COREL_reset, COREL_text, null_scale, COREL_graphics, COREL_move, COREL_vector, COREL_linetype, COREL_put_text, COREL_text_angle, COREL_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(corel_driver) #undef LAST_TERM #define LAST_TERM corel_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(corel) "1 corel", "?commands set terminal corel", "?set terminal corel", "?set term corel", "?terminal corel", "?term corel", "?corel", " The `corel` terminal driver supports CorelDraw.", "", " Syntax:", " set terminal corel { default", " | {monochrome | color", " { {\"\" ", " { { }}}}}", "", " where the fontsize and linewidth are specified in points and the sizes in", " inches. The defaults are monochrome, \"SwitzerlandLight\", 22, 8.2, 10 and 1.2." END_HELP(corel) #endif /* TERM_HELP */ /* * $Id: debug.trm,v 1.11 1998/04/14 00:17:35 drd Exp $ * */ /* GNUPLOT - debug.trm */ /*[ * Copyright 1990 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * DEBUG * * AUTHORS * luecken@udel.edu * * send your comments or suggestions to (luecken@udel.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) * generalised to have *all* defined capabilities by HBB (June 1997) */ #include "driver.h" #ifdef TERM_REGISTER register_term(debug) #endif #ifdef TERM_PROTO TERM_PUBLIC void DEBUG_init __PROTO((void)); TERM_PUBLIC void DEBUG_graphics __PROTO((void)); TERM_PUBLIC void DEBUG_text __PROTO((void)); TERM_PUBLIC void DEBUG_linetype __PROTO((int linetype)); TERM_PUBLIC void DEBUG_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DEBUG_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DEBUG_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void DEBUG_reset __PROTO((void)); TERM_PUBLIC int DEBUG_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int DEBUG_text_angle __PROTO((int ang)); TERM_PUBLIC void DEBUG_point __PROTO((unsigned int x, unsigned int y, int pointstyle)); TERM_PUBLIC void DEBUG_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head)); TERM_PUBLIC int DEBUG_set_font __PROTO((char *font)); TERM_PUBLIC void DEBUG_pointsize __PROTO((double pointsize)); TERM_PUBLIC void DEBUG_suspend __PROTO((void)); TERM_PUBLIC void DEBUG_resume __PROTO((void)); TERM_PUBLIC void DEBUG_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height)); TERM_PUBLIC void DEBUG_linewidth __PROTO((double linewidth)); #define DEBUG_XMAX 512 #define DEBUG_YMAX 390 #define DEBUG_XLAST (DEBUG_XMAX - 1) #define DEBUG_YLAST (DEBUG_XMAX - 1) /* Assume a character size of 1, or a 7 x 10 grid. */ #define DEBUG_VCHAR 10 #define DEBUG_HCHAR 7 #define DEBUG_VTIC (DEBUG_YMAX/70) #define DEBUG_HTIC (DEBUG_XMAX/75) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY int DEBUG_linetype_last; int DEBUG_xlast; int DEBUG_ylast; TERM_PUBLIC void DEBUG_init() { fputs("init\n", gpoutfile); DEBUG_linetype_last = -3; } TERM_PUBLIC void DEBUG_graphics() { DEBUG_xlast = DEBUG_ylast = 0; fputs("graphics\n", gpoutfile); } TERM_PUBLIC void DEBUG_text() { fputs("text\n", gpoutfile); } TERM_PUBLIC void DEBUG_linetype(linetype) int linetype; { /* if (linetype != DEBUG_linetype_last){ fprintf(gpoutfile,"l%d",linetype); DEBUG_linetype_last = linetype; } */ fprintf(gpoutfile, "line %d\n", linetype); } TERM_PUBLIC void DEBUG_move(x, y) unsigned int x, y; { /* if (x != DEBUG_xlast || y != DEBUG_ylast){ fprintf(gpoutfile,"mm"); DEBUG_xlast = x; DEBUG_ylast = y; } */ fprintf(gpoutfile, "move %d, %d\t(%d, %d)\n", x, y, x - DEBUG_xlast, y - DEBUG_ylast); DEBUG_xlast = x; DEBUG_ylast = y; } TERM_PUBLIC void DEBUG_vector(x, y) unsigned int x, y; { /* if (x != DEBUG_xlast || y != DEBUG_ylast){ fprintf(gpoutfile,"vv"); DEBUG_xlast = x; DEBUG_ylast = y; } */ fprintf(gpoutfile, "vect %d, %d\t(%d, %d)\n", x, y, x - DEBUG_xlast, y - DEBUG_ylast); DEBUG_xlast = x; DEBUG_ylast = y; } TERM_PUBLIC void DEBUG_put_text(x, y, str) unsigned int x, y; char *str; { /* DEBUG_move(x,y); fprintf(gpoutfile,"tx%s\r",str); */ fputs("put_text calls:", gpoutfile); DEBUG_move(x, y); fprintf(gpoutfile, "put_text '%s'\n", str); } TERM_PUBLIC void DEBUG_reset() { fputs("reset", gpoutfile); } TERM_PUBLIC int DEBUG_justify_text(mode) enum JUSTIFY mode; { fputs("justify ", gpoutfile); switch (mode) { case (CENTRE): fputs("centre", gpoutfile); break; case (RIGHT): fputs("right", gpoutfile); break; default: case (LEFT): fputs("left", gpoutfile); break; } fputs("\n", gpoutfile); return (TRUE); } TERM_PUBLIC int DEBUG_text_angle(ang) int ang; { fprintf(gpoutfile, "text_angle %d:", ang); switch (ang) { case 0: fputs(": horizontal\n", gpoutfile); break; case 1: fputs(": upwards\n", gpoutfile); break; default: fputs(": \a*undefined*\n", gpoutfile); break; } return TRUE; } TERM_PUBLIC void DEBUG_point(x, y, pointstyle) unsigned int x, y; int pointstyle; { fprintf(gpoutfile, "point at (%ud,%ud), pointstyle %d\n", x, y, pointstyle); } TERM_PUBLIC void DEBUG_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; int head; { fprintf(gpoutfile, "arrow from (%ud,%ud) to (%ud,%ud), %s head\n", sx, sy, ex, ey, head ? "with" : "without"); } TERM_PUBLIC int DEBUG_set_font(font) char *font; { fprintf(gpoutfile, "set font to \"%s\"\n", font ? (*font ? font : "\aempty string!") : "\aNULL string!"); return TRUE; } TERM_PUBLIC void DEBUG_pointsize(pointsize) double pointsize; { fprintf(gpoutfile, "set pointsize to %lf\n", pointsize); } TERM_PUBLIC void DEBUG_suspend(void) { fputs("suspended terminal driver\n", gpoutfile); } TERM_PUBLIC void DEBUG_resume(void) { fputs("resumed terminal driver\n", gpoutfile); } TERM_PUBLIC void DEBUG_fillbox(style, x1, y1, width, height) int style; unsigned int x1, y1, width, height; { fprintf(gpoutfile, "fillbox/clear at (%ud,%ud), area (%ud,%ud), style %d)\n", x1, y1, width, height, style); } TERM_PUBLIC void DEBUG_linewidth(double linewidth) { fprintf(gpoutfile, "set linewidth %lf\n", linewidth); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(debug_driver) "debug", "debugging driver", DEBUG_XMAX, DEBUG_YMAX, DEBUG_VCHAR, DEBUG_HCHAR, DEBUG_VTIC, DEBUG_HTIC, options_null, DEBUG_init, DEBUG_reset, DEBUG_text, null_scale, DEBUG_graphics, DEBUG_move, DEBUG_vector, DEBUG_linetype, DEBUG_put_text, DEBUG_text_angle, DEBUG_justify_text, DEBUG_point, DEBUG_arrow, DEBUG_set_font, DEBUG_pointsize, TERM_CAN_MULTIPLOT, DEBUG_suspend, DEBUG_resume, DEBUG_fillbox, DEBUG_linewidth TERM_TABLE_END(debug_driver) #undef LAST_TERM #define LAST_TERM debug_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(debug) "1 debug", "?commands set terminal debug", "?set terminal debug", "?set term debug", "?terminal debug", "?term debug", "?debug", " This terminal is provided to allow for the debugging of `gnuplot`. It is", " likely to be of use only for users who are modifying the source code." END_HELP(debug) #endif /* * $Id: djsvga.trm,v 1.17 1998/04/14 00:17:36 drd Exp $ */ /* GNUPLOT - djsvga.trm */ /*[ * Copyright 1992 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * svga * * AUTHORS * Russell Lang * Edzer Pebesma (gnuplot 3.6: new terminal layout, fonts, grx20) * Hans-Bernhard Broeker (several improvements) * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* HBB: A new version, called grx21a was released recently. To * tell gnuplot you have it, add '-DGRX21' to your compilation flags. * Currently, that only enables the drawing of wide lines. Maybe more * to come. */ #include "driver.h" #ifdef TERM_REGISTER register_term(djsvga) /* no ; */ #endif #ifdef TERM_PROTO #define DJSVGA_XMAX 640 #define DJSVGA_YMAX 480 #define DJSVGA_XLAST (DJSVGA_XMAX - 1) #define DJSVGA_YLAST (DJSVGA_YMAX - 1) #define DJSVGA_VCHAR 16 #define DJSVGA_HCHAR 8 #define DJSVGA_VTIC 4 #define DJSVGA_HTIC 4 TERM_PUBLIC void DJSVGA_init __PROTO((void)); TERM_PUBLIC void DJSVGA_graphics __PROTO((void)); TERM_PUBLIC void DJSVGA_text __PROTO((void)); TERM_PUBLIC void DJSVGA_reset __PROTO((void)); TERM_PUBLIC void DJSVGA_options __PROTO((void)); TERM_PUBLIC void DJSVGA_linetype __PROTO((int linetype)); TERM_PUBLIC void DJSVGA_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DJSVGA_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC int DJSVGA_angle __PROTO((int ang)); TERM_PUBLIC int DJSVGA_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void DJSVGA_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int DJSVGA_set_font __PROTO((char *fontname)); TERM_PUBLIC void DJSVGA_suspend __PROTO((void)); TERM_PUBLIC void DJSVGA_resume __PROTO((void)); /* clear part of multiplot */ TERM_PUBLIC void DJSVGA_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height)); TERM_PUBLIC void DJSVGA_linewidth __PROTO((double linewidth)); #define GOT_DJSVGA_PROTO #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* SVGA driver using DJGPP */ #if (DJGPP==2) # define GRX20 #endif #ifdef GRX20 /* use grx20.h for DJGPP V1 / GRX V2 combo as well */ # include #else # include #endif #include static int dj_startx, dj_starty; static int dj_xlast, dj_ylast; #define DJNUMCOLOR 15 /* HBB: Let's just use long for GRX1 as well */ static long dj_color; static long svga256color[DJNUMCOLOR] = {7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6}; static long dj_colors[DJNUMCOLOR]; #ifdef GRX20 /* Save, Restore: for 16 color mode! */ static void *DJSVGA_colorbuf = NULL; #endif static GrTextOption DJSVGA_TextOption; /* HBB: I think we should use GR_NAMEWIDTH (=16), instead of MAX_ID_LEN, * which has nothing to do with GRX at all */ #ifdef GRX20 char DJSVGA_fontname[MAX_ID_LEN + 1] = ""; #else char DJSVGA_fontname[MAX_ID_LEN + 1] = "@:pc8x14.fnt"; /* EGA bios font */ #endif static GrContext *DJSVGA_context = 0; /* save screen for suspend/resume */ static char *dj_textsave = 0; /* for text-screen-saving */ static int dj_cursorx, dj_cursory; static int dj_width, dj_height; #ifdef GRX21 static double dj_linewidth; /* store linewidth assignments here */ #endif TERM_PUBLIC void DJSVGA_init() { int i, on, r, g, b, medium = 170, low = 85; GrFont *font = NULL; #ifdef GRX20 font = &GrDefaultFont; #endif /* HBB: save textscreen contents and cursor-position */ dj_textsave = gp_alloc(ScreenRows() * ScreenCols() * 2, "djsvga term scrbuf"); ScreenRetrieve(dj_textsave); dj_width = ScreenCols(); dj_height = ScreenRows(); ScreenGetCursor(&dj_cursory, &dj_cursorx); GrSetMode(GR_default_graphics); GrSetRGBcolorMode(); GrResetColors(); /* Allocate colors */ for (i = 0; i < DJNUMCOLOR; i++) { on = (svga256color[i] & 8) ? 255 : medium; r = (svga256color[i] & 4) ? on : 0; g = (svga256color[i] & 2) ? on : 0; b = (svga256color[i] & 1) ? on : 0; if (svga256color[i] == 8) r = g = b = low; dj_colors[i] = GrAllocColor(r, g, b); } /* Get the screen size: */ dj_xlast = GrMaxX(); term->xmax = dj_xlast + 1; dj_ylast = GrMaxY(); term->ymax = dj_ylast + 1; /* if GRX 1.x loads an GRX 2.x save'd file: */ if (font == NULL && DJSVGA_fontname[0] == '\0') sprintf(DJSVGA_fontname, "@:pc8x14.fnt"); if (DJSVGA_fontname[0] != '\0') font = GrLoadFont(DJSVGA_fontname); if (font == NULL) font = GrLoadFont("@:pc8x14.fnt"); /* try EGA bios font */ if (font == NULL) font = GrLoadFont("@:pc8x16.fnt"); /* try VGA bios font */ /* * HBB: There are cases when we reach this point with font still NULL, * eg. when the GRXFONT env.variable points to the GRX V1 fonts, but * GRX V2 is used for this program: some fonts will *fail* to load in * that setup (e.g. cour20b)! So IMHO, there should be some error * treatment here..., like int_error("Couldn't load font!"); */ DJSVGA_TextOption.txo_font = font; DJSVGA_TextOption.txo_direct = GR_TEXT_RIGHT; DJSVGA_TextOption.txo_xalign = GR_ALIGN_LEFT; DJSVGA_TextOption.txo_yalign = GR_ALIGN_CENTER; DJSVGA_TextOption.txo_chrtype = GR_BYTE_TEXT; DJSVGA_TextOption.txo_bgcolor.v = GrNOCOLOR; #ifndef GRX20 DJSVGA_TextOption.txo_xmag = 1; DJSVGA_TextOption.txo_ymag = 1; #endif /* HBB: this version should work in all configurations */ term->v_char = font->h.height; term->h_char = font->h.width; #ifdef GRX20 if (DJSVGA_colorbuf == NULL) DJSVGA_colorbuf = (void *) gp_alloc(GrColorSaveBufferSize(), "djsvga term colorbuf"); GrSaveColors(DJSVGA_colorbuf); #endif GrSetMode(GR_default_text); ScreenUpdate(dj_textsave); ScreenSetCursor(dj_cursory, dj_cursorx); } /* * HBB: make these two inline, as they're called by other routines * inside this module, and -finline-functions (normally switched * on by 'gcc -O3') doesn't work for compiling term.c */ __inline__ TERM_PUBLIC void DJSVGA_graphics() { ScreenRetrieve(dj_textsave); /* HBB: save text screen contents */ ScreenGetCursor(&dj_cursory, &dj_cursorx); GrSetMode(GR_default_graphics); #ifdef GRX20 GrRestoreColors(DJSVGA_colorbuf); #endif } __inline__ TERM_PUBLIC void DJSVGA_text() { (void) getkey(); GrSetMode(GR_width_height_text, dj_width, dj_height); ScreenUpdate(dj_textsave); /* HBB: restore text screen */ ScreenSetCursor(dj_cursory, dj_cursorx); } TERM_PUBLIC void DJSVGA_reset() { GrResetColors(); free(dj_textsave); } TERM_PUBLIC void DJSVGA_options() { if (!END_OF_COMMAND && isstring(c_token)) { quote_str(DJSVGA_fontname, c_token, MAX_ID_LEN); c_token++; } sprintf(term_options, "\"%s\"", DJSVGA_fontname); } TERM_PUBLIC void DJSVGA_linetype(linetype) int linetype; { if (linetype >= 13) linetype %= 13; /* HBB: set the TextOption color variable right here (faster) */ DJSVGA_TextOption.txo_fgcolor.v = dj_color = dj_colors[linetype + 2]; } TERM_PUBLIC void DJSVGA_move(x, y) unsigned int x, y; { dj_startx = x; dj_starty = y; } TERM_PUBLIC void DJSVGA_vector(x, y) unsigned int x, y; { #ifdef GRX21 GrLineOption dj_lineoption = {dj_color, dj_linewidth, 0, ""}; GrCustomLine(dj_startx, dj_ylast - dj_starty, x, dj_ylast - y, &dj_lineoption); #else GrLine(dj_startx, dj_ylast - dj_starty, x, dj_ylast - y, dj_color); #endif dj_startx = x; dj_starty = y; } /* * HBB: IMHO, the previous version was seriously flawed. E.g. * in the termentry, _justify_text was pointing to the * null_justify_text dummy routine, so DJSVGA_justify wasn't * ever called at all. I copied the routines from my (now * otherwise pointless) own private driver, djgrx.trm, to * cure that. */ TERM_PUBLIC int DJSVGA_angle(ang) int ang; { if (ang) { DJSVGA_TextOption.txo_direct = GR_TEXT_UP; } else { DJSVGA_TextOption.txo_direct = GR_TEXT_RIGHT; } return TRUE; } TERM_PUBLIC int DJSVGA_justify_text(mode) enum JUSTIFY mode; { if (DJSVGA_TextOption.txo_direct == GR_TEXT_RIGHT) { DJSVGA_TextOption.txo_yalign = GR_ALIGN_CENTER; switch (mode) { case LEFT: DJSVGA_TextOption.txo_xalign = GR_ALIGN_LEFT; break; case CENTRE: DJSVGA_TextOption.txo_xalign = GR_ALIGN_CENTER; break; case RIGHT: DJSVGA_TextOption.txo_xalign = GR_ALIGN_RIGHT; break; } } else { DJSVGA_TextOption.txo_xalign = GR_ALIGN_CENTER; switch (mode) { case LEFT: DJSVGA_TextOption.txo_yalign = GR_ALIGN_BOTTOM; break; case CENTRE: DJSVGA_TextOption.txo_yalign = GR_ALIGN_CENTER; break; case RIGHT: DJSVGA_TextOption.txo_yalign = GR_ALIGN_TOP; break; } } return TRUE; } TERM_PUBLIC int DJSVGA_set_font(fontname) char *fontname; { char *cp; GrFont *font; safe_strncpy(DJSVGA_fontname, fontname, sizeof(DJSVGA_fontname)); cp = strstr(DJSVGA_fontname, ","); if (cp != NULL) *cp = NUL; font = GrLoadFont(DJSVGA_fontname); /*HBB: if no font found, do *not* report success! */ if (font != NULL) { GrUnloadFont(DJSVGA_TextOption.txo_font); DJSVGA_TextOption.txo_font = font; return TRUE; } else { graph_error("Font not found"); return FALSE; } } TERM_PUBLIC void DJSVGA_put_text(x, y, str) unsigned int x, y; char *str; { /* HBB: why isn't font!=NULL ensured elsewhere? Testing it at * this point doesn't really make much sense (we're in graphics * mode, so we can't even print out a useful error message!) */ /*if (DJSVGA_TextOption.txo_font != NULL) */ GrDrawString(str, strlen(str), x, dj_ylast - y, &DJSVGA_TextOption); } TERM_PUBLIC void DJSVGA_suspend() { DJSVGA_context = GrCreateContext(GrSizeX(), GrSizeY(), 0, 0); GrBitBltNC(DJSVGA_context, 0, 0, 0, 0, 0, GrMaxX(), GrMaxY(), GrWRITE); DJSVGA_text(); } TERM_PUBLIC void DJSVGA_resume() { DJSVGA_graphics(); GrBitBltNC(0, 0, 0, DJSVGA_context, 0, 0, GrMaxX(), GrMaxY(), GrWRITE); GrDestroyContext(DJSVGA_context); } TERM_PUBLIC void DJSVGA_fillbox(style, left, bottom, width, height) int style; unsigned int left, bottom, width, height; { if (style >= 13) style %= 13; /* HBB: prize question: should it be 'width-1' instead? */ /* HBB: fill with GRX Color '0', which *should* be black : */ GrFilledBox(left, dj_ylast - bottom, left + width, dj_ylast - bottom - height, 0); } TERM_PUBLIC void DJSVGA_linewidth(double linewidth) { #ifdef GRX21 dj_linewidth = linewidth; #endif } #endif /* TERM_BODY */ #ifdef TERM_TABLE /* HBB: I think \" is more readable than \042. BTW: why is this * option 'documented' here, but not in the Help node? */ TERM_TABLE_START(djsvga_driver) "svga", "IBM PC/Clone with Super VGA graphics board [\"fontname\"]", DJSVGA_XMAX, DJSVGA_YMAX, DJSVGA_VCHAR, DJSVGA_HCHAR, DJSVGA_VTIC, DJSVGA_HTIC, DJSVGA_options, DJSVGA_init, DJSVGA_reset, DJSVGA_text, null_scale, DJSVGA_graphics, DJSVGA_move, DJSVGA_vector, DJSVGA_linetype, DJSVGA_put_text, DJSVGA_angle, DJSVGA_justify_text, do_point, do_arrow, DJSVGA_set_font, 0, /* no pointsize() */ TERM_CAN_MULTIPLOT, DJSVGA_suspend, DJSVGA_resume, DJSVGA_fillbox, DJSVGA_linewidth TERM_TABLE_END(djsvga_driver) #undef LAST_TERM #define LAST_TERM djsvga_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ /* * HBB: I think this documentation should be at least a *bit* longer * (E.g., the "fontname" parameter is claimed to be non-existent!) */ /* RCC: Not any more... * If you have other ideas about what could be in the help section, * please let me know (rccrawford@lanl.gov) --- particularly info * about what fonts are permitted, if there is such a list. */ #ifdef TERM_HELP START_HELP(svga) "1 svga", "?commands set terminal svga", "?set terminal svga", "?set term svga", "?terminal svga", "?term svga", "?svga", " The `svga` terminal driver supports PCs with SVGA graphics. It can only be", " be used if it is compiled with DJGPP. Its only option is the font.", "", " Syntax:", " set terminal svga {\"\"}" END_HELP(svga) #endif /* TERM_HELP */ /* * $Id: dumb.trm,v 1.24 1998/04/14 00:17:37 drd Exp $ * */ /* GNUPLOT - dumb.trm */ /*[ * Copyright 1991 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * DUMB terminals * * AUTHORS * Francois Pinard, 91-04-03 * INTERNET: pinard@iro.umontreal.ca * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ #include "driver.h" #ifdef TERM_REGISTER register_term(dumb_driver) #endif #ifdef TERM_PROTO TERM_PUBLIC void DUMB_options __PROTO((void)); TERM_PUBLIC void DUMB_init __PROTO((void)); TERM_PUBLIC void DUMB_graphics __PROTO((void)); TERM_PUBLIC void DUMB_text __PROTO((void)); TERM_PUBLIC void DUMB_reset __PROTO((void)); TERM_PUBLIC void DUMB_linetype __PROTO((int linetype)); TERM_PUBLIC void DUMB_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DUMB_point __PROTO((unsigned int x, unsigned int y, int point)); TERM_PUBLIC void DUMB_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DUMB_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void DUMB_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head)); #define DUMB_XMAX 79 #define DUMB_YMAX 24 #endif /* TERM_PROTO */ #ifdef TERM_BODY #define DUMB_AXIS_CONST '\1' #define DUMB_BORDER_CONST '\2' /* matrix of characters */ static char *dumb_matrix = NULL; /* matrix of priority at each position */ static char *dumb_priority = NULL; /* current character used to draw */ static char dumb_pen; /* current X position */ static int dumb_x; /* current Y position */ static int dumb_y; static int dumb_xmax = DUMB_XMAX; static int dumb_ymax = DUMB_YMAX; static int dumb_feed = 1; #define DUMB_PIXEL(x,y) dumb_matrix[dumb_xmax*(y)+(x)] static void dumb_set_pixel __PROTO((int x, int y, int v, int p)); static void dumb_set_pixel(x, y, v, p) int x, y, v, p; { if ((unsigned) x <= dumb_xmax && /* ie x>=0 && x<=dumb_xmax */ (unsigned) y <= dumb_ymax && p > dumb_priority[dumb_xmax * y + x]) { dumb_matrix[dumb_xmax * y + x] = v; dumb_priority[dumb_xmax * y + x] = p; } } TERM_PUBLIC void DUMB_options() { int x, y; struct value a; if (almost_equals(c_token, "f$eed")) ++c_token, dumb_feed = 1; else if (almost_equals(c_token, "nof$eed")) ++c_token, dumb_feed = 0; if (!END_OF_COMMAND) { x = (int) real(const_express(&a)); if (!END_OF_COMMAND) { y = (int) real(const_express(&a)); dumb_xmax = term->xmax = x; dumb_ymax = term->ymax = y; } } sprintf(term_options, "%sfeed %d %d", dumb_feed ? "" : "no", dumb_xmax, dumb_ymax); } TERM_PUBLIC void DUMB_init() { if (dumb_matrix) free(dumb_matrix); dumb_matrix = gp_alloc((unsigned long) dumb_xmax * dumb_ymax * 2, "dumb terminal"); dumb_priority = dumb_matrix + dumb_xmax * dumb_ymax; } TERM_PUBLIC void DUMB_graphics() { int i; char *pm = dumb_matrix, *pp = dumb_priority; for (i = dumb_xmax * dumb_ymax; i > 0; i--) { *pm++ = ' '; *pp++ = 0; } } TERM_PUBLIC void DUMB_text() { int x, y, l; putc('\f', gpoutfile); for (y = dumb_ymax - 1; y >= 0; y--) { for (l = dumb_xmax; l > 0 && DUMB_PIXEL(l - 1, y) == ' '; l--); for (x = 0; x < l; x++) putc(DUMB_PIXEL(x, y), gpoutfile); if (dumb_feed || y > 0) putc('\n', gpoutfile); } fflush(gpoutfile); } TERM_PUBLIC void DUMB_reset() { free(dumb_matrix); dumb_matrix = NULL; } TERM_PUBLIC void DUMB_linetype(linetype) int linetype; { static char pen_type[7] = { '*', '#', '$', '%', '@', '&', '=' }; if (linetype == -2) dumb_pen = DUMB_BORDER_CONST; else if (linetype == -1) dumb_pen = DUMB_AXIS_CONST; else { linetype = linetype % 7; dumb_pen = pen_type[linetype]; } } TERM_PUBLIC void DUMB_move(x, y) unsigned int x, y; { dumb_x = x; dumb_y = y; } TERM_PUBLIC void DUMB_point(x, y, point) unsigned int x, y; int point; { dumb_set_pixel(x, y, point == -1 ? '.' : point % 26 + 'A', 4); } TERM_PUBLIC void DUMB_vector(_x, _y) unsigned int _x, _y; { int x = _x; /* we need signed int, since * unsigned-signed=unsigned and */ int y = _y; /* abs and cast to double wouldn't work */ char pen, pen1; int priority; int delta; if (ABS(y - dumb_y) > ABS(x - dumb_x)) { switch (dumb_pen) { case DUMB_AXIS_CONST: pen = ':'; pen1 = '+'; priority = 1; break; case DUMB_BORDER_CONST: pen = '|'; pen1 = '+'; priority = 2; break; default: pen = dumb_pen; pen1 = dumb_pen; priority = 3; break; } dumb_set_pixel(dumb_x, dumb_y, pen1, priority); for (delta = 1; delta < ABS(y - dumb_y); delta++) { dumb_set_pixel(dumb_x + (int) ((double) (x - dumb_x) * delta / ABS(y - dumb_y) + 0.5), dumb_y + delta * sign(y - dumb_y), pen, priority); } dumb_set_pixel(x, y, pen1, priority); } else if (ABS(x - dumb_x) > ABS(y - dumb_y)) { switch (dumb_pen) { case DUMB_AXIS_CONST: pen = '.'; pen1 = '+'; priority = 1; break; case DUMB_BORDER_CONST: pen = '-'; pen1 = '+'; priority = 2; break; default: pen = dumb_pen; pen1 = dumb_pen; priority = 3; break; } dumb_set_pixel(dumb_x, dumb_y, pen1, priority); for (delta = 1; delta < ABS(x - dumb_x); delta++) dumb_set_pixel(dumb_x + delta * sign(x - dumb_x), dumb_y + (int) ((double) (y - dumb_y) * delta / ABS(x - dumb_x) + 0.5), pen, priority); dumb_set_pixel(x, y, pen1, priority); } else { switch (dumb_pen) { case DUMB_AXIS_CONST: /* zero length axis */ pen = '+'; priority = 1; break; case DUMB_BORDER_CONST: /* zero length border */ pen = '+'; priority = 2; break; default: pen = dumb_pen; priority = 3; break; } for (delta = 0; delta <= ABS(x - dumb_x); delta++) dumb_set_pixel(dumb_x + delta * sign(x - dumb_x), dumb_y + delta * sign(y - dumb_y), pen, priority); } dumb_x = x; dumb_y = y; } TERM_PUBLIC void DUMB_put_text(x, y, str) unsigned int x, y; char *str; { int length; length = strlen(str); if (x + length > dumb_xmax) x = GPMAX(0, dumb_xmax - length); for (; x < dumb_xmax && *str; x++, str++) dumb_set_pixel(x, y, *str, 5); } TERM_PUBLIC void DUMB_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; int head; /* ignored */ { char saved_pen; char saved_x; char saved_y; saved_pen = dumb_pen; saved_x = dumb_x; saved_y = dumb_y; dumb_pen = '>'; dumb_x = sx; dumb_y = sy; DUMB_vector(ex, ey); dumb_pen = saved_pen; dumb_x = saved_x; dumb_y = saved_y; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(dumb_driver) "dumb", "printer or glass dumb terminal", DUMB_XMAX, DUMB_YMAX, 1, 1, 1, 1, DUMB_options, DUMB_init, DUMB_reset, DUMB_text, null_scale, DUMB_graphics, DUMB_move, DUMB_vector, DUMB_linetype, DUMB_put_text, null_text_angle, null_justify_text, DUMB_point, DUMB_arrow, set_font_null, 0, /* pointsize */ TERM_CAN_MULTIPLOT TERM_TABLE_END(dumb_driver) #undef LAST_TERM #define LAST_TERM dumb_driver #endif /* TERM_TABLE */ #ifdef TERM_HELP START_HELP(dumb) "1 dumb", "?commands set terminal dumb", "?set terminal dumb", "?set term dumb", "?terminal dumb", "?term dumb", "?dumb", " The `dumb` terminal driver has an optional size specification and trailing", " linefeed control.", "", " Syntax:", " set terminal dumb {[no]feed} { }", "", " where and set the size of the dumb terminals. Default is", " 79 by 24. The last newline is printed only if `feed` is enabled.", "", " Examples:", " set term dumb nofeed", " set term dumb 79 49 # VGA screen---why would anyone do that?" END_HELP(dumb) #endif /* TERM_HELP */ /* * $Id: dxf.trm,v 1.15 1998/04/14 00:17:37 drd Exp $ * */ /* GNUPLOT - dxf.trm */ /*[ * Copyright 1991 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * AutoCad (Release 10.x) dxf file format (import with AutoCad dxfin command) * * * AUTHOR * Florian Hiss (fhis1231@w204zrz.zrz.tu-berlin.de) * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(dxf) #endif #ifdef TERM_PROTO TERM_PUBLIC void DXF_init __PROTO((void)); TERM_PUBLIC void DXF_graphics __PROTO((void)); TERM_PUBLIC void DXF_text __PROTO((void)); TERM_PUBLIC void DXF_linetype __PROTO((int linetype)); TERM_PUBLIC void DXF_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DXF_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void DXF_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int DXF_text_angle __PROTO((int ang)); TERM_PUBLIC int DXF_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void DXF_reset __PROTO((void)); #define DXF_XMAX (120.0 * DXF_UNIT) #define DXF_YMAX (80.0 * DXF_UNIT) #define DXF_HTIC (0.01 * DXF_XMAX) /* 1.0 percent */ #define DXF_VTIC (0.01 * DXF_YMAX) /* 1.0 percent */ #define DXF_HCHAR (0.014 * DXF_XMAX) /* 1.4 percent */ #define DXF_VCHAR (0.026 * DXF_YMAX) /* 2.6 percent */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #define DXF_UNIT 60.0 #define LINEWIDTH 0.0351 /* default line width is 1 pt */ /* 120 (autocad units) wide by 80 (autocad units) high (default) * use the GNUPLOT 'set size' command to change the defaults */ /* actual text height */ #define DXF_TEXTHEIGHT (0.7 * DXF_VCHAR) /* actual text width, only a guess, we don't know the width of * a character of given height of the AutoCad STANDARD text font, * so change it if you like */ #define DXF_TEXTWIDTH (0.7 * DXF_HCHAR) /* number of line types we support. see below */ #define DXF_LINE_TYPES 7 /* number of layers used for the drawing. see below */ #define MAX_LAYER 7 /* line type scaling */ #define LT_SCALE 1 static unsigned int DXF_posx; static unsigned int DXF_posy; /* linetype is mapped to a layer. see below. */ static unsigned int dxf_linetype; enum JUSTIFY dxf_justify = LEFT; static float dxf_angle = 0.0; /* either 0 (horizontal) or 90.0 (vertical) */ /* text style used in the entire drawing */ static char *text_style = "STANDARD"; /* text always resides on layer 0 */ #define TEXT_LAYER 0 /* each linetype resides on its own layer. each layer has its own color. * this avoids difficulties that AutoCad has with proper scaling of * the linetypes. * change the colors according to your needs */ static char *layer_name[] ={ "0", "1", "2", "3", "4", "5", "6" }; /* the colours are white, red, yellow, green, cyan, blue, magenta. * change them according to your needs. * when using a black and white plotting device the colours map to different * line thicknesses. see description of AutoCad print / plot command */ static char *layer_colour[] = { "7", "1", "2", "3", "4", "5", "6" }; /* support line types AutoCad has to offer by default. */ static char *layer_lines[] = { "CONTINUOUS", "DASHED", "HIDDEN", "CENTER", "PHANTOM", "DOT", "DASHDOT" }; static TBOOLEAN vector_was_last = FALSE; TERM_PUBLIC void DXF_init() { DXF_posx = DXF_posy = 0; dxf_linetype = 0; dxf_angle = 0.0; vector_was_last = FALSE; } TERM_PUBLIC void DXF_graphics() { register struct termentry *t = term; int i; static char GPFAR dxfi1[] = "\ 999\n\ %% GNUPLOT: dxf file for AutoCad\n\ 0\nSECTION\n 2\nHEADER\n\ 9\n$EXTMIN\n\ 10\n0.000\n 20\n0.000\n\ 9\n$EXTMAX\n\ 10\n%-6.3f\n 20\n%-6.3f\n\ 9\n$LIMMIN\n\ 10\n0.000\n 20\n0.000\n\ 9\n$LIMMAX\n\ 10\n%-6.3f\n 20\n%-6.3f\n\ 9\n$TEXTSTYLE\n 7\n%s\n\ 9\n$TEXTSIZE\n 40\n%-6.3f\n\ 9\n$PLINEWID\n 40\n%-6.4f\n\ 9\n$LTSCALE\n 40\n%-6.3f\n\ 9\n$COORDS\n 70\n 1\n\ 9\n$CELTYPE\n 6\nBYLAYER\n\ 9\n$CLAYER\n 8\n0\n\ 9\n$CECOLOR\n 62\n %s\n\ 9\n$MENU\n 1\nacad\n\ 0\nENDSEC\n\ 0\nSECTION\n 2\nTABLES\n"; static char GPFAR dxfi2[] = "\ 0\nTABLE\n 2\nLTYPE\n 70\n %d\n\ 0\nLTYPE\n 2\nCONTINUOUS\n 70\n 64\n\ 3\nSolid line\n 72\n 65\n 73\n 0\n 40\n0.0\n\ 0\nLTYPE\n 2\nDASHED\n 70\n 64\n\ 3\n__ __ __ __ __ __ __ __ __ __ __ __ __ __ __\n\ 72\n 65\n 73\n 2\n 40\n0.75\n 49\n0.5\n 49\n-0.25\n\ 0\nLTYPE\n 2\nHIDDEN\n 70\n 64\n\ 3\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\ 72\n 65\n 73\n 2\n 40\n0.375\n 49\n0.25\n 49\n-0.125\n\ 0\nLTYPE\n 2\nCENTER\n 70\n 64\n\ 3\n____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____\n\ 72\n 65\n 73\n 4\n 40\n2.0\n 49\n1.25\n 49\n-0.25\n\ 49\n0.25\n 49\n-0.25\n\ 0\nLTYPE\n 2\nPHANTOM\n 70\n 64\n\ 3\n_____ _ _ _____ _ _ _____ _ _ _____ _ _ ____\n\ 72\n 65\n 73\n 6\n 40\n2.5\n 49\n1.25\n\ 49\n-0.25\n 49\n0.25\n 49\n-0.25\n 49\n0.25\n 49\n-0.25\n\ 0\nLTYPE\n 2\nDOT\n 70\n 64\n\ 3\n...............................................\n\ 72\n 65\n 73\n 2\n 40\n0.25\n 49\n0.0\n 49\n-0.25\n\ 0\nLTYPE\n 2\nDASHDOT\n 70\n 64\n\ 3\n__ . __ . __ . __ . __ . __ . __ . __ . __ . __\n\ 72\n 65\n 73\n 4\n 40\n1.0\n 49\n0.5\n 49\n-0.25\n\ 49\n0.0\n 49\n-0.25\n\ 0\nENDTAB\n"; fprintf(gpoutfile, dxfi1, t->xmax / DXF_UNIT, t->ymax / DXF_UNIT, t->xmax / DXF_UNIT, t->ymax / DXF_UNIT, text_style, DXF_TEXTHEIGHT / DXF_UNIT, LINEWIDTH, (double) LT_SCALE, layer_colour[0]); /* the linetype table */ fprintf(gpoutfile, dxfi2, DXF_LINE_TYPES); /* the layer table */ fprintf(gpoutfile, " 0\nTABLE\n 2\nLAYER\n 70\n %-d\n", MAX_LAYER); for (i = 1; i <= MAX_LAYER; i++) fprintf(gpoutfile, " 0\nLAYER\n 2\n%s\n 70\n 64\n62\n %s\n 6\n%s\n", layer_name[i - 1], layer_colour[i - 1], layer_lines[i - 1]); /* no blocks for insertion */ /* start the entity section */ fputs(" 0\nENDTAB\n0\nENDSEC\n\ 0\nSECTION\n 2\nBLOCKS\n 0\nENDSEC\n\ 0\nSECTION\n\ 2\nENTITIES\n", gpoutfile); } TERM_PUBLIC void DXF_text() { if (vector_was_last) fputs(" 0\nSEQEND\n", gpoutfile); fputs(" 0\nENDSEC\n 0\nEOF\n", gpoutfile); } TERM_PUBLIC void DXF_linetype(linetype) int linetype; { linetype = ABS(linetype); linetype = linetype % DXF_LINE_TYPES; dxf_linetype = linetype; } TERM_PUBLIC void DXF_move(x, y) unsigned int x, y; { DXF_posx = x; DXF_posy = y; if (vector_was_last) fputs(" 0\nSEQEND\n", gpoutfile); vector_was_last = FALSE; fprintf(gpoutfile, "\ 0\nPOLYLINE\n 8\n%s\n 66\n 1\n\ 6\n%s\n\ 0\nVERTEX\n 8\n%s\n\ 6\n%s\n\ 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n", layer_name[dxf_linetype], layer_lines[dxf_linetype], layer_name[dxf_linetype], layer_lines[dxf_linetype], DXF_posx / DXF_UNIT, DXF_posy / DXF_UNIT); } TERM_PUBLIC void DXF_vector(ux, uy) unsigned int ux, uy; { DXF_posx = ux; DXF_posy = uy; vector_was_last = TRUE; fprintf(gpoutfile, "\ 0\nVERTEX\n 8\n%s\n\ 6\n%s\n\ 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n", layer_name[dxf_linetype], layer_lines[dxf_linetype], DXF_posx / DXF_UNIT, DXF_posy / DXF_UNIT); } TERM_PUBLIC void DXF_put_text(x, y, str) unsigned int x, y; char str[]; { int stl; float xleftpos, yleftpos, xrightpos, yrightpos; /* shut up gcc warnings - SB */ xleftpos = yleftpos = xrightpos = yrightpos = 1.0; /* dummy */ /* ignore empty strings */ if (str[0] == NUL) return; stl = 0; while (str[stl] != NUL) ++stl; /* get string length */ if (vector_was_last) fputs(" 0\nSEQEND\n", gpoutfile); vector_was_last = FALSE; fprintf(gpoutfile, " 0\nTEXT\n 8\n%s\n", layer_name[TEXT_LAYER]); if (dxf_angle != 90.0) { switch (dxf_justify) { case LEFT: xleftpos = (float) x; yleftpos = (float) (y - DXF_VCHAR / 4.0); xrightpos = (float) (x + stl * DXF_TEXTWIDTH); yrightpos = yleftpos; break; case RIGHT: xleftpos = (float) (x - stl * DXF_TEXTWIDTH); yleftpos = (float) (y - DXF_VCHAR / 4.0); xrightpos = (float) x; yrightpos = yleftpos; break; case CENTRE: xleftpos = (float) (x - stl * DXF_TEXTWIDTH / 2.0); yleftpos = (float) (y - DXF_VCHAR / 4.0); xrightpos = (float) x; /* center point */ yrightpos = yleftpos; break; } } else { switch (dxf_justify) { case LEFT: xleftpos = (float) (x + DXF_VCHAR / 4.0); yleftpos = (float) y; xrightpos = xleftpos; yrightpos = (float) (y + stl * DXF_TEXTWIDTH); break; case RIGHT: xleftpos = (float) (x + DXF_VCHAR / 4.0); yleftpos = (float) (y - stl * DXF_HCHAR); xrightpos = xleftpos; yrightpos = (float) y; break; case CENTRE: xleftpos = (float) (x + DXF_VCHAR / 4.0); yleftpos = (float) (y - stl * DXF_TEXTWIDTH / 2.0); xrightpos = xleftpos; yrightpos = (float) y; /* center point */ break; } } fprintf(gpoutfile, "\ 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n\ 40\n%-6.3f\n 1\n%s\n 50\n%-6.3f\n\ 7\n%s\n", xleftpos / DXF_UNIT, yleftpos / DXF_UNIT, DXF_TEXTHEIGHT / DXF_UNIT, str, dxf_angle, text_style); if (dxf_justify != LEFT) { fprintf(gpoutfile, " 72\n%d\n\ 11\n%-6.3f\n 21\n%-6.3f\n 31\n0.000\n", dxf_justify, xrightpos / DXF_UNIT, yrightpos / DXF_UNIT); } } TERM_PUBLIC int DXF_text_angle(ang) int ang; { dxf_angle = 0.0; if (ang == 1) dxf_angle = 90.0; return (TRUE); } TERM_PUBLIC int DXF_justify_text(mode) enum JUSTIFY mode; { dxf_justify = mode; return (TRUE); } TERM_PUBLIC void DXF_reset() { DXF_posx = DXF_posy = 0; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(dxf_driver) "dxf", "dxf-file for AutoCad (default size 120x80)", DXF_XMAX, DXF_YMAX, DXF_VCHAR, DXF_HCHAR, DXF_VTIC, DXF_HTIC, options_null, DXF_init, DXF_reset, DXF_text, null_scale, DXF_graphics, DXF_move, DXF_vector, DXF_linetype, DXF_put_text, DXF_text_angle, DXF_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(dxf_driver) #undef LAST_TERM #define LAST_TERM dxf_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(dxf) "1 dxf", "?commands set terminal dxf", "?set terminal dxf", "?set term dxf", "?terminal dxf", "?term dxf", "?dxf", " The `dxf` terminal driver creates pictures that can be imported into AutoCad", " (Release 10.x). It has no options of its own, but some features of its plots", " may be modified by other means. The default size is 120x80 AutoCad units,", " which can be changed by `set size`. `dxf` uses seven colors (white, red,", " yellow, green, cyan, blue and magenta), which can be changed only by", " modifying the source file. If a black-and-white plotting device is used, the", " colors are mapped to differing line thicknesses. See the description of the", " AutoCad print/plot command." END_HELP(dxf) #endif /* TERM_HELP */ /* * $Id: dxy.trm,v 1.13 1998/04/14 00:17:38 drd Exp $ * */ /* GNUPLOT - dxy.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Roland DXY800A plotter * * AUTHORS * Martin Yii, eln557h@monu3.OZ * Further modified Jan 1990 by Russell Lang, rjl@monu1.cc.monash.oz * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(dxy800a) #endif #ifdef TERM_PROTO TERM_PUBLIC void DXY_init __PROTO((void)); TERM_PUBLIC void DXY_graphics __PROTO((void)); TERM_PUBLIC void DXY_text __PROTO((void)); TERM_PUBLIC void DXY_linetype __PROTO((int linetype)); TERM_PUBLIC void DXY_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DXY_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void DXY_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int DXY_text_angle __PROTO((int ang)); TERM_PUBLIC void DXY_reset __PROTO((void)); #define DXY_XMAX 2470 #define DXY_YMAX 1700 #define DXY_XLAST (DXY_XMAX - 1) #define DXY_YLAST (DXY_XMAX - 1) #define DXY_VCHAR (56) /* double actual height of characters */ #define DXY_HCHAR (28) /* actual width including spacing */ #define DXY_VTIC (28) #define DXY_HTIC (28) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY int dxy_angle = 0; TERM_PUBLIC void DXY_init() { /* No initialisation sequences for DXY 800A */ } TERM_PUBLIC void DXY_graphics() { /* HOME, Character size 3 */ fputs("H\nS3\n", gpoutfile); } TERM_PUBLIC void DXY_text() { /* No sequences needed */ } TERM_PUBLIC void DXY_linetype(linetype) int linetype; { /* select pen */ fprintf(gpoutfile, "J%d\n", (linetype + 2) % 8 + 1); switch (linetype) { case -1: /* use dotted line for axis */ fputs("L1\nB50\n", gpoutfile); break; default: /* use solid line for all others */ fputs("L0\n", gpoutfile); break; } } TERM_PUBLIC void DXY_move(x, y) unsigned int x, y; { fprintf(gpoutfile, "M%d,%d\n", x, y); } TERM_PUBLIC void DXY_vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "D%d,%d\n", x, y); } TERM_PUBLIC void DXY_put_text(x, y, str) unsigned int x, y; char *str; { if (dxy_angle == 1) { /* vertical */ DXY_move(x + DXY_VCHAR / 4, y); } else { /* horiz */ DXY_move(x, y - DXY_VCHAR / 4); } fprintf(gpoutfile, "P%s\n", str); } TERM_PUBLIC int DXY_text_angle(ang) int ang; { dxy_angle = ang; fprintf(gpoutfile, "Q%d\n", ang); return TRUE; } TERM_PUBLIC void DXY_reset() { /* Home pen */ fputs("H\n", gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(dxy_driver) "dxy800a", "Roland DXY800A plotter", DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR, DXY_VTIC, DXY_HTIC, options_null, DXY_init, DXY_reset, DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector, DXY_linetype, DXY_put_text, DXY_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(dxy_driver) #undef LAST_TERM #define LAST_TERM dxy_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(dxy800a) "1 dxy800a", "?commands set terminal dxy800a", "?set terminal dxy800a", "?set term dxy800a", "?terminal dxy800a", "?term dxy800a", "?dxy800a", " This terminal driver supports the Roland DXY800A plotter. It has no options." END_HELP(dxy800a) #endif /* * $Id: eepic.trm,v 1.18 1998/04/14 00:17:39 drd Exp $ * */ /* GNUPLOT - eepic.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * The EEPIC macros for LaTeX. * * AUTHORS * David Kotz * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * This file contains the eepic terminal driver, intended for use with the * eepic.sty macro package for LaTeX. This is an alternative to the * latex driver. You need eepic.sty, epic.sty, and a printer driver that * supports the tpic \specials. * * Although dotted and dashed lines are possible with EEPIC, and are * tempting, they do not work well for high-sample-rate curves, mushing * the dashes all together into a solid line. For now anyway, the EEPIC * driver will have only solid lines. Anyone got a solution? * * LATEX must also be defined. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(eepic) #endif #ifdef TERM_PROTO TERM_PUBLIC void EEPIC_init __PROTO((void)); TERM_PUBLIC void EEPIC_graphics __PROTO((void)); TERM_PUBLIC void EEPIC_text __PROTO((void)); TERM_PUBLIC void EEPIC_linetype __PROTO((int linetype)); TERM_PUBLIC void EEPIC_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void EEPIC_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void EEPIC_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void EEPIC_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC void EEPIC_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int EEPIC_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int EEPIC_text_angle __PROTO((int ang)); TERM_PUBLIC void EEPIC_reset __PROTO((void)); #define EEPIC_PTS_PER_INCH (72.27) /* resolution of printer we expect to use */ #define DOTS_PER_INCH (300) /* dot size in pt */ #define EEPIC_UNIT (EEPIC_PTS_PER_INCH/DOTS_PER_INCH) /* 5 inches wide by 3 inches high (default) */ /* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*5.0) */ #define EEPIC_XMAX (5*DOTS_PER_INCH) /* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*3.0) */ #define EEPIC_YMAX (3*DOTS_PER_INCH) #define EEPIC_HTIC (5*DOTS_PER_INCH/72) /* (5./EEPIC_UNIT) */ #define EEPIC_VTIC (5*DOTS_PER_INCH/72) /* (5./EEPIC_UNIT) */ #define EEPIC_HCHAR (DOTS_PER_INCH*53/10/72) /* (5.3/EEPIC_UNIT) */ #define EEPIC_VCHAR (DOTS_PER_INCH*11/72) /* (11./EEPIC_UNIT) */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static unsigned int EEPIC_posx; static unsigned int EEPIC_posy; enum JUSTIFY eepic_justify = LEFT; static int eepic_angle = 0; /* for DOTS point style */ #define EEPIC_TINY_DOT "\\rule{.1pt}{.1pt}" /* POINTS */ #define EEPIC_POINT_TYPES 12 /* we supply more point types */ static char GPFAR *GPFAR EEPIC_points[] = { "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}", "\\makebox(0,0){$+$}", "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Box$}}", "\\makebox(0,0){$\\times$}", "\\makebox(0,0){$\\triangle$}", "\\makebox(0,0){$\\star$}", "\\circle{12}", "\\circle{18}", "\\circle{24}", "\\circle*{12}", "\\circle*{18}", "\\circle*{24}" }; /* LINES */ #define EEPIC_NUMLINES 5 /* number of linetypes below */ static char GPFAR *GPFAR EEPIC_lines[] = { "\\thicklines \\path", /* -2 border */ "\\thinlines \\drawline[-50]", /* -1 axes */ "\\thinlines \\path", /* 0 solid thin */ "\\thicklines \\path", /* 1 solid thick */ "\\Thicklines \\path", /* 2 solid Thick */ }; /* These are other possibilities "\\thinlines \\dottedline{30}", "\\thinlines \\drawline[-30]", "\\thinlines \\dottedline{60}", "\\thinlines \\drawline[-60]", "\\thinlines \\dashline[-10]{20}[6]" */ static int EEPIC_type; /* current line type */ static TBOOLEAN EEPIC_inline = FALSE; /* are we in the middle of a line */ void EEPIC_endline __PROTO((void)); /* terminate any line in progress */ static int EEPIC_linecount = 0; /* number of points in line so far */ #define EEPIC_LINEMAX 50 /* max value for linecount */ /* ARROWS */ /* we use the same code as for LATEX */ /* figure out the best arrow */ void best_latex_arrow __PROTO((int sx, int sy, int ex, int ey, int who, TBOOLEAN head)); TERM_PUBLIC void EEPIC_init() { EEPIC_posx = EEPIC_posy = 0; EEPIC_linetype(-1); fprintf(gpoutfile, "%% GNUPLOT: LaTeX picture using EEPIC macros\n\ \\setlength{\\unitlength}{%fpt}\n", EEPIC_UNIT); } TERM_PUBLIC void EEPIC_graphics() { register struct termentry *t = term; fprintf(gpoutfile, "\\begin{picture}(%d,%d)(0,0)\n\ \\footnotesize\n", t->xmax, t->ymax); } TERM_PUBLIC void EEPIC_text() { EEPIC_endline(); fputs("\\end{picture}\n", gpoutfile); } TERM_PUBLIC void EEPIC_linetype(linetype) int linetype; { EEPIC_endline(); if (linetype >= EEPIC_NUMLINES - 2) linetype %= (EEPIC_NUMLINES - 2); EEPIC_type = linetype; } TERM_PUBLIC void EEPIC_move(x, y) unsigned int x, y; { EEPIC_endline(); EEPIC_posx = x; EEPIC_posy = y; } TERM_PUBLIC void EEPIC_point(x, y, number) /* version of line_and_point */ unsigned int x, y; int number; /* type of point */ { EEPIC_move(x, y); /* Print the character defined by 'number'; number < 0 means to use a dot, otherwise one of the defined points. */ fprintf(gpoutfile, "\\put(%d,%d){%s}\n", x, y, (number < 0 ? EEPIC_TINY_DOT : EEPIC_points[number % EEPIC_POINT_TYPES])); } TERM_PUBLIC void EEPIC_vector(ux, uy) unsigned int ux, uy; { if (!EEPIC_inline) { EEPIC_inline = TRUE; /* Start a new line. This depends on line type */ fprintf(gpoutfile, "%s(%u,%u)", EEPIC_lines[EEPIC_type + 2], EEPIC_posx, EEPIC_posy); EEPIC_linecount = 1; } else { /* Even though we are in middle of a path, * we may want to start a new path command. * If they are too long then latex will choke. */ if (EEPIC_linecount++ >= EEPIC_LINEMAX) { fprintf(gpoutfile, "\n%s(%u,%u)", EEPIC_lines[EEPIC_type + 2], EEPIC_posx, EEPIC_posy); EEPIC_linecount = 1; } } fprintf(gpoutfile, "(%u,%u)", ux, uy); EEPIC_posx = ux; EEPIC_posy = uy; } void EEPIC_endline() { if (EEPIC_inline) { putc('\n', gpoutfile); EEPIC_inline = FALSE; } } TERM_PUBLIC void EEPIC_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; TBOOLEAN head; { best_latex_arrow(sx, sy, ex, ey, 2, head); /* call latex routine */ EEPIC_posx = ex; EEPIC_posy = ey; } TERM_PUBLIC void EEPIC_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char str[]; /* the text */ { EEPIC_endline(); fprintf(gpoutfile, "\\put(%d,%d)", x, y); if ((str[0] == '{') || (str[0] == '[')) { fprintf(gpoutfile, "{\\makebox(0,0)%s}\n", str); } else switch (eepic_angle) { case 0:{ switch (eepic_justify) { case LEFT:{ fprintf(gpoutfile, "{\\makebox(0,0)[l]{%s}}\n", str); break; } case CENTRE:{ fprintf(gpoutfile, "{\\makebox(0,0){%s}}\n", str); break; } case RIGHT:{ fprintf(gpoutfile, "{\\makebox(0,0)[r]{%s}}\n", str); break; } } break; } case 1:{ /* put text in a short stack */ switch (eepic_justify) { case LEFT:{ fprintf(gpoutfile, "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str); break; } case CENTRE:{ fprintf(gpoutfile, "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str); break; } case RIGHT:{ fprintf(gpoutfile, "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str); break; } } break; } } } TERM_PUBLIC int EEPIC_justify_text(mode) enum JUSTIFY mode; { eepic_justify = mode; return (TRUE); } TERM_PUBLIC int EEPIC_text_angle(ang) int ang; { /* we can't really write text vertically, but this will put the ylabel centred at the left of the plot, and then we'll make a \shortstack */ eepic_angle = ang; return (TRUE); } TERM_PUBLIC void EEPIC_reset() { EEPIC_endline(); EEPIC_posx = EEPIC_posy = 0; } #endif #ifdef TERM_TABLE TERM_TABLE_START(eepic_driver) "eepic", "EEPIC -- extended LaTeX picture environment", EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR, EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset, EEPIC_text, null_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector, EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle, EEPIC_justify_text, EEPIC_point, EEPIC_arrow, set_font_null TERM_TABLE_END(eepic_driver) #undef LAST_TERM #define LAST_TERM eepic_driver #endif #endif #ifdef TERM_HELP START_HELP(eepic) "1 eepic", "?commands set terminal eepic", "?set terminal eepic", "?set term eepic", "?terminal eepic", "?term eepic", "?eepic", " The `eepic` terminal driver supports the extended LaTeX picture environment.", " It is an alternative to the `latex` driver.", "", " The output of this terminal is intended for use with the \"eepic.sty\" macro", " package for LaTeX. To use it, you need \"eepic.sty\", \"epic.sty\" and a", " printer driver that supports the \"tpic\" \\specials. If your printer driver", " doesn't support those \\specials, \"eepicemu.sty\" will enable you to use some", " of them.", "", " Although dotted and dashed lines are possible with `eepic` and are tempting,", " they do not work well for high-sample-rate curves, fusing the dashes all", " together into a solid line. For now, the `eepic` driver creates only solid", " lines. There is another gnuplot driver (`tpic`) that supports dashed lines,", " but it cannot be used if your DVI driver doesn't support \"tpic\" \\specials.", "", " All drivers for LaTeX offer a special way of controlling text positioning:", " If any text string begins with '{', you also need to include a '}' at the", " end of the text, and the whole text will be centered both horizontally", " and vertically by LaTeX. --- If the text string begins with '[', you need", " to continue it with: a position specification (up to two out of t,b,l,r),", " ']{', the text itself, and finally, '}'. The text itself may be anything", " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.", "", " The `eepic` terminal has no options.", "", " Examples:", " About label positioning:", " Use gnuplot defaults (mostly sensible, but sometimes not really best):", " set title '\\LaTeX\\ -- $ \\gamma $'", " Force centering both horizontally and vertically:", " set label '{\\LaTeX\\ -- $ \\gamma $}' at 0,0", " Specify own positioning (top here):", " set xlabel '[t]{\\LaTeX\\ -- $ \\gamma $}'", " The other label -- account for long ticlabels:", " set ylabel '[r]{\\LaTeX\\ -- $ \\gamma $\\rule{7mm}{0pt}'" END_HELP(eepic) #endif /* TERM_HELP */ /* * $Id: emxvga.trm,v 1.16 1998/04/14 00:17:40 drd Exp $ */ /* GNUPLOT - emxvga.trm */ /*[ * Copyright 1994, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * SVGA 1024x768x256 for PC's running DOS or OS/2 * * AUTHOR * David J. Liu (liudj0@minerva.cis.yale.edu) */ /* * Compile with GCC (emx) with VESA and SVGAKIT maintained by * Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE) * with additions by David J. Liu (liudj0@minerva.cis.yale.edu) * supports VESA, Trident, Cirrus, ET4000, WD and S3. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER #ifdef EMXVESA register_term(vesa) #endif /* EMXVESA */ register_term(emxvga) #endif #ifdef TERM_PROTO TERM_PUBLIC void EMXVGA_init __PROTO((void)); TERM_PUBLIC void EMXVGA_reset __PROTO((void)); TERM_PUBLIC void EMXVGA_text __PROTO((void)); TERM_PUBLIC void EMXVGA_graphics __PROTO((void)); TERM_PUBLIC void EMXVGA_linetype __PROTO((int)); TERM_PUBLIC void EMXVGA_move __PROTO((unsigned int, unsigned int)); TERM_PUBLIC void EMXVGA_vector __PROTO((unsigned int, unsigned int)); TERM_PUBLIC int EMXVGA_text_angle __PROTO((int)); TERM_PUBLIC void EMXVGA_put_text __PROTO((unsigned int, unsigned int, char *)); #define EMXVGA_VCHAR 8 #define EMXVGA_HCHAR 8 #define EMXVGA_VTIC 4 #define EMXVGA_HTIC 4 #define EMXVGA_XMAX 0 /* These two entries are just place holders. */ #define EMXVGA_YMAX 0 /* The actual values will be filled in init. */ #ifdef EMXVESA TERM_PUBLIC void EMXVESA_options __PROTO((void)); TERM_PUBLIC void EMXVESA_init __PROTO((void)); TERM_PUBLIC void EMXVESA_graphics __PROTO((void)); TERM_PUBLIC void EMXVESA_text __PROTO((void)); TERM_PUBLIC void EMXVESA_reset __PROTO((void)); #endif #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* avoid name clash with graph.h - lets hope that no following * driver needs these symbols ! */ #ifdef RIGHT #undef RIGHT #endif #ifdef DOWN #undef DOWN #endif #include #include #include /* for getch() -SB */ #include #include /* * Some versions of graph.h (e.g. jmgraph.h) define RIGHT to be 0 * colliding with enum JUSTIFY. We don't need this define anyway, * just undef it. -SB */ #ifdef RIGHT #undef RIGHT #endif #ifdef DOWN #undef DOWN #endif static int EMXVGA_vmode = G640x480x256; /* default mode */ static int vgacolor[] ={ 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 }; static int graphics_on = FALSE; int startx, starty, lasty; int EMXVGA_angle, EMXVGA_color; char *EMXVGA_buf; void emx_getch() { union REGS reg; char c; if (_osmode == OS2_MODE) VesaGetCharacter(&c); else { reg.x.ax = 0x0000; _int86(0x16, ®, ®); if (reg.h.al == 0) { reg.x.ax = 0x0000; _int86(0x16, ®, ®); } } } /* gstring.c (emx+gcc) -- Copyright (c) 1994 by David J. Liu */ unsigned char font[128][8] = { /* 8x8 font */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E}, {0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E}, {0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00}, {0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00}, {0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x92, 0x10, 0x7C}, {0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C}, {0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00}, {0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF}, {0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00}, {0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF}, {0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78}, {0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18}, {0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0}, {0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0}, {0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99}, {0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00}, {0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00}, {0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18}, {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00}, {0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00}, {0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0x86, 0xFC}, {0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00}, {0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF}, {0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00}, {0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00}, {0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00}, {0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00}, {0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00}, {0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00}, {0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00}, {0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, {0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00}, {0x18, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x18, 0x00}, {0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00}, {0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00}, {0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00}, {0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00}, {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, {0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30}, {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}, {0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00}, {0x7C, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x7C, 0x00}, {0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00}, {0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00}, {0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00}, {0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00}, {0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00}, {0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00}, {0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00}, {0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00}, {0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00}, {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00}, {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30}, {0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00}, {0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00}, {0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00}, {0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00}, {0x7C, 0xC6, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00}, {0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00}, {0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00}, {0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00}, {0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00}, {0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00}, {0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00}, {0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00}, {0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00}, {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, {0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00}, {0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00}, {0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00}, {0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00}, {0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00}, {0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00}, {0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00}, {0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0x7C, 0x0E, 0x00}, {0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00}, {0x7C, 0xC6, 0xE0, 0x78, 0x0E, 0xC6, 0x7C, 0x00}, {0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00}, {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00}, {0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00}, {0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00}, {0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00}, {0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00}, {0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00}, {0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00}, {0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00}, {0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00}, {0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00}, {0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00}, {0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00}, {0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00}, {0x38, 0x6C, 0x64, 0xF0, 0x60, 0x60, 0xF0, 0x00}, {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8}, {0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00}, {0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00}, {0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78}, {0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00}, {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, {0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xD6, 0x00}, {0x00, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00}, {0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00}, {0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0}, {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E}, {0x00, 0x00, 0xDC, 0x76, 0x62, 0x60, 0xF0, 0x00}, {0x00, 0x00, 0x7C, 0xC0, 0x70, 0x1C, 0xF8, 0x00}, {0x10, 0x30, 0xFC, 0x30, 0x30, 0x34, 0x18, 0x00}, {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00}, {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00}, {0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00}, {0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00}, {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8}, {0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00}, {0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00}, {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, {0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00}, {0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00} }; void g_set(int x, int y, int color); /* part of SVGA */ void g_string(x0, y0, color, angle, s) /* upper left corner of text, color and angle */ int x0, y0, color, angle; char *s; { int i, j, k; float sa, ca, x, y; k = 0; x = 0.5 + x0; y = 0.5 + y0; sa = sin(-Pi * angle / 180); ca = cos(Pi * angle / 180); while (s[k]) { for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) g_set(x + ca * j - sa * i, y + ca * i + sa * j, (font[(int) s[k]][i] & (1 << (7 - j))) ? color : 0); k++; x += ca * 8; y += sa * 8; } } /* end of gstring.c */ TERM_PUBLIC void EMXVGA_init() { if (!g_mode(EMXVGA_vmode)) { fputs("Unable to initiate graphics.\n", stderr); return; } term->xmax = g_xsize; term->ymax = g_ysize; lasty = g_ysize - 1; } TERM_PUBLIC void EMXVGA_reset() { g_mode(GTEXT); graphics_on = FALSE; } TERM_PUBLIC void EMXVGA_text() { if (graphics_on) { emx_getch(); g_mode(GTEXT); graphics_on = FALSE; } } TERM_PUBLIC void EMXVGA_graphics() { if (!graphics_on) { g_mode(EMXVGA_vmode); graphics_on = TRUE; } } TERM_PUBLIC void EMXVGA_linetype(linetype) int linetype; { EMXVGA_color = vgacolor[(linetype % 13) + 2]; } TERM_PUBLIC void EMXVGA_move(x, y) unsigned int x, y; { startx = x; starty = y; } TERM_PUBLIC void EMXVGA_vector(x, y) unsigned int x, y; { g_line(startx, lasty - starty, x, lasty - y, EMXVGA_color); startx = x; starty = y; } TERM_PUBLIC int EMXVGA_text_angle(ang) int ang; { EMXVGA_angle = ang * 90; return (TRUE); } TERM_PUBLIC void EMXVGA_put_text(x, y, str) unsigned int x, y; char *str; { g_string(x, lasty - y - 3, EMXVGA_color, EMXVGA_angle, str); } TERM_PUBLIC void EMXVGA_suspend() { if (EMXVGA_buf) free(EMXVGA_buf); /* do this just for safety */ EMXVGA_buf = (char *) malloc(g_memsize); g_save(EMXVGA_buf); emx_getch(); g_mode(GTEXT); } TERM_PUBLIC void EMXVGA_resume() { g_mode(EMXVGA_vmode); g_restore(EMXVGA_buf); free(EMXVGA_buf); } #ifdef EMXVESA int emx_vesamode = G640x480x256; int emx_xlast, emx_ylast; TERM_PUBLIC void EMXVESA_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "d$efault")) { emx_vesamode = G640x480x256; c_token++; } } if (!END_OF_COMMAND) { /* We have a vesa mode specified */ struct value a; emx_vesamode = (int) real(const_express(&a)); } sprintf(term_options, "%d", emx_vesamode); } TERM_PUBLIC void EMXVESA_init() { if (!g_mode(emx_vesamode)) int_error("Couldn't select graphics mode", NO_CARET); emx_xlast = g_xsize - 1; term->xmax = emx_xlast + 1; emx_ylast = g_ysize - 1; term->ymax = emx_ylast + 1; g_mode(GTEXT); } TERM_PUBLIC void EMXVESA_graphics() { g_mode(emx_vesamode); } TERM_PUBLIC void EMXVESA_text() { int ch; ch = getch(); g_mode(GTEXT); if (ch == 3) int_error("Interrupt", NO_CARET); } TERM_PUBLIC void EMXVESA_reset() { } #endif /* VESA */ #endif /* TERM_BODY */ #ifdef TERM_TABLE #ifdef EMXVESA TERM_TABLE_START(vesa_driver) "vesa", "IBM PC/Clone with VESA SVGA graphics board [vesa mode]", EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR, EMXVGA_VTIC, EMXVGA_HTIC, EMXVESA_options, EMXVESA_init, EMXVESA_reset, EMXVESA_text, null_scale, EMXVESA_graphics, EMXVGA_move, EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(vesa_driver) #undef LAST_TERM #define LAST_TERM vesa_driver #endif /* VESA */ TERM_TABLE_START(emxvga_driver) "emxvga", "PC with VGA running DOS or OS/2", EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR, EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset, EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move, EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, /* pointsize */ TERM_CAN_MULTIPLOT, EMXVGA_suspend, EMXVGA_resume TERM_TABLE_END(emxvga_driver) #undef LAST_TERM #define LAST_TERM emxvga_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(emxvga) "1 emxvga", "?commands set terminal emxvga", "?set terminal emxvga", "?set term emxvga", "?terminal emxvga", "?term emxvga", "?emxvga", "?commands set terminal emxvesa", "?set terminal emxvesa", "?set term emxvesa", "?terminal emxvesa", "?term emxvesa", "?emxvesa", "?commands set terminal vgal", "?set terminal vgal", "?set term vgal", "?terminal vgal", "?term vgal", "?vgal", " The `emxvga`, `emxvesa` and `vgal` terminal drivers support PCs with SVGA,", " vesa SVGA and VGA graphics boards, respectively. They are intended to be", " compiled with \"emx-gcc\" under either DOS or OS/2. They also need VESA and", " SVGAKIT maintained by Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE) with", " additions by David J. Liu (liu@phri.nyu.edu).", "", " Syntax:", " set terminal emxvga", " set terminal emxvesa {vesa-mode}", " set terminal vgal", "", " The only option is the vesa mode for `emxvesa`, which defaults to G640x480x256." END_HELP(emxvga) #endif /* TERM_HELP */ /* * $Id: epson.trm,v 1.19 1998/04/14 00:17:41 drd Exp $ * */ /* GNUPLOT - epson.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * epson_lx800, nec_cp6, starc, * epson_60dpi, tandy_60dpi * epson_180dpi * * AUTHORS * Russell Lang * William Wilson * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (1995) */ #include "driver.h" #ifdef TERM_REGISTER #ifdef EPS180 register_term(epson_180dpi) #endif /* EPS180 */ #ifdef EPS60 register_term(epson_60dpi) #endif /* EPS60 */ #ifdef EPSONP register_term(epson_lx800) #endif /* EPSONP */ #ifdef NEC register_term(nec_cp6) #endif /* NEC */ #ifdef OKIDATA register_term(okidata) #endif /* OKIDATA */ #ifdef STARC register_term(starc) #endif /* STARC */ #ifdef TAMDY60 register_term(tandy_60dpi) #endif /* TANDY60 */ #endif /* TERM_REGISTER */ #ifdef TERM_PROTO #if defined(EPS180) || defined(EPS60) || defined(EPSONP) || defined(TANDY60) || defined(OKIDATA) TERM_PUBLIC void EPSONinit __PROTO((void)); TERM_PUBLIC void EPSONreset __PROTO((void)); #define EPSONlinetype b_setlinetype #define EPSONmove b_move #define EPSONvector b_vector #define EPSONput_text b_put_text #define EPSON_text_angle b_text_angle #if defined(EPS60) || defined(EPSONP) || defined(TANDY60) || defined(OKIDATA) #define EPSONVCHAR FNT5X9_VCHAR #define EPSONHCHAR FNT5X9_HCHAR #define EPSONVTIC 6 #define EPSONHTIC 6 #ifdef EPSONP #define EPSONXMAX 512 #define EPSONYMAX 384 TERM_PUBLIC void EPSONgraphics __PROTO((void)); TERM_PUBLIC void EPSONtext __PROTO((void)); #endif /* EPSONP */ #endif /* four drivers */ #endif /* all five */ #ifdef EPS180 TERM_PUBLIC void EPS180graphics __PROTO((void)); TERM_PUBLIC void EPS180text __PROTO((void)); #define EPSON180VCHAR FNT13X25_VCHAR #define EPSON180HCHAR FNT13X25_HCHAR #define EPSON180VTIC 18 #define EPSON180HTIC 18 /* make the total dimensions 8 inches by 6 inches */ #define EPS180XMAX 1260 #define EPS180YMAX 1080 #endif /* EPS180 */ #if defined(EPS60) || defined(TANDY60) || defined(OKIDATA) /* make the total dimensions 8 inches by 5 inches */ #define EPS60XMAX 480 #define EPS60YMAX 360 TERM_PUBLIC void EPS60graphics __PROTO((void)); #ifdef TANDY60 TERM_PUBLIC void TANDY60text __PROTO((void)); #endif /* TANDY60 */ #ifdef OKIDATA TERM_PUBLIC void OKIDATAtext __PROTO((void)); #endif /* OKIDATA */ #ifdef EPS60 TERM_PUBLIC void EPS60text __PROTO((void)); #endif /* EPS60 */ #endif /* all three */ #ifdef NEC TERM_PUBLIC void NECoptions __PROTO((void)); TERM_PUBLIC void NECinit __PROTO((void)); TERM_PUBLIC void NECgraphics __PROTO((void)); TERM_PUBLIC void NECtext __PROTO((void)); TERM_PUBLIC void NEClinetype __PROTO((int linetype)); TERM_PUBLIC void NECreset __PROTO((void)); #define NECmove b_move #define NECvector b_vector #define NECput_text b_put_text #define NEC_text_angle b_text_angle #define NECXMAX 400 #define NECYMAX 320 #define NECVCHAR FNT5X9_VCHAR #define NECHCHAR FNT5X9_HCHAR #define NECVTIC 6 #define NECHTIC 6 #endif /* NEC */ #ifdef STARC TERM_PUBLIC void STARCinit __PROTO((void)); TERM_PUBLIC void STARCgraphics __PROTO((void)); TERM_PUBLIC void STARCtext __PROTO((void)); TERM_PUBLIC void STARClinetype __PROTO((int linetype)); TERM_PUBLIC void STARCreset __PROTO((void)); #define STARCmove b_move #define STARCvector b_vector #define STARCput_text b_put_text #define STARC_text_angle b_text_angle #define STARCXMAX 512 #define STARCYMAX 384 #define STARCVCHAR FNT5X9_VCHAR #define STARCHCHAR FNT5X9_HCHAR #define STARCVTIC 6 #define STARCHTIC 6 #endif /* STARC */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #ifdef EPSONP /* The following epson lx800 driver uses generic bit mapped graphics routines to build up a bit map in memory. */ /* by Russell Lang, rjl@monu1.cc.monash.edu.au */ /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */ /* EPSON_init changes gpoutfile to binary mode on PC's */ void epson_dump __PROTO((void)); #define EPSONXLAST (EPSONXMAX - 1) #define EPSONYLAST (EPSONYMAX - 1) TERM_PUBLIC void EPSONinit() { } TERM_PUBLIC void EPSONgraphics() { b_charsize(FNT5X9); b_makebitmap((unsigned int) (EPSONXMAX * xsize), (unsigned int) (EPSONYMAX * ysize), 1); } TERM_PUBLIC void EPSONtext() { epson_dump(); b_freebitmap(); } TERM_PUBLIC void EPSONreset() { #ifdef VMS fflush_binary(); #endif } /* output file must be binary mode for epson_dump */ void epson_dump() { register unsigned int x; int j; for (j = (b_ysize / 8) - 1; j >= 0; j--) { /* select plotter graphics mode (square pixels) */ fputs("\033J\030", gpoutfile); /* line feed 8/72" = 8 dots */ fputs("\r\033*\005", gpoutfile); (void) fputc((char) (b_xsize % 256), gpoutfile); (void) fputc((char) (b_xsize / 256), gpoutfile); for (x = 0; x < b_xsize; x++) { (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile); } } #ifdef PC fputs("Print using: COPY /B\n", stderr); #endif } #endif /* EPSONP */ /* The following NEC CP6 Pinwriter driver uses generic bit mapped graphics routines to build up a bit map in memory. */ /* by Russell Lang, rjl@monu1.cc.monash.edu.au */ /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */ /* NECinit changes gpoutfile to binary mode for PC's */ /* Add a Monochrome NEC printer (for faster speed and line types) jdc */ #ifdef NEC void nec_dump __PROTO((void)); void nec_draft_dump __PROTO((void)); #define NECXLAST (NECXMAX - 1) #define NECYLAST (NECYMAX - 1) /* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */ static unsigned int neccolor[] = { 1, 8, 4, 2, 10, 12, 6, 14 }; static unsigned int necpcolor[] = { 0, 2, 1, 4 }; static int NECmode; TERM_PUBLIC void NECoptions() { if (END_OF_COMMAND) { strcpy(term_options, "monochrome"); NECmode = 'm'; } else if (almost_equals(c_token, "m$onochrome")) { c_token++; strcpy(term_options, "monochrome"); NECmode = 'm'; } else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { c_token++; strcpy(term_options, "color"); NECmode = 'c'; } else if (almost_equals(c_token, "d$raft")) { c_token++; strcpy(term_options, "draft"); NECmode = 'd'; } else { /* error, but since the terminal is already set, default to mono */ strcpy(term_options, "monochrome"); NECmode = 'm'; int_error("modes: color, monochrome, draft", c_token); } } TERM_PUBLIC void NECinit() { } TERM_PUBLIC void NECgraphics() { b_charsize(FNT5X9); b_makebitmap((unsigned int) (NECXMAX * xsize), (unsigned int) (NECYMAX * ysize), (NECmode == 'c' ? 4 : 1)); } TERM_PUBLIC void NECtext() { if (NECmode == 'd') { nec_draft_dump(); } else { nec_dump(); } b_freebitmap(); } TERM_PUBLIC void NEClinetype(linetype) int linetype; { if (NECmode == 'c') { if (linetype >= 6) linetype %= 6; b_setvalue(neccolor[linetype + 2]); } else { b_setlinetype(linetype); } } TERM_PUBLIC void NECreset() { #ifdef VMS fflush_binary(); #endif } /* output file must be binary mode for nec_dump */ void nec_dump() { unsigned int x; unsigned int plane, offset; int j; unsigned int column8; unsigned long column24; char column3, column2, column1; fputs("\033P\033l\005", gpoutfile); /* 10cpi, left margin 5 char */ for (j = (b_ysize / 8) - 1; j >= 0; j--) { fputs("\033J\030", gpoutfile); /* 24/180" line feed */ for (plane = 0; plane < b_planes; plane++) { offset = plane * b_psize; if (b_planes > 1) { /* select colour for plane */ fputs("\033r", gpoutfile); (void) fputc((char) necpcolor[plane], gpoutfile); } /* select plotter graphics mode (square pixels) */ fputs("\r\033*\047", gpoutfile); (void) fputc((char) ((b_xsize * 3) % 256), gpoutfile); (void) fputc((char) ((b_xsize * 3) / 256), gpoutfile); for (x = 0; x < b_xsize; x++) { column8 = (unsigned int) (*((*b_p)[j + offset] + x)); column24 = 0; if (column8 & 0x01) column24 |= (long) 0x000007; if (column8 & 0x02) column24 |= (long) 0x000038; if (column8 & 0x04) column24 |= (long) 0x0001c0; if (column8 & 0x08) column24 |= (long) 0x000e00; if (column8 & 0x10) column24 |= (long) 0x007000; if (column8 & 0x20) column24 |= (long) 0x038000; if (column8 & 0x40) column24 |= (long) 0x1c0000; if (column8 & 0x80) column24 |= (long) 0xe00000; column1 = (char) (column24 & (long) 0xff); column2 = (char) ((column24 >> 8) & (long) 0xff); column3 = (char) ((column24 >> 16) & (long) 0xff); (void) fputc(column3, gpoutfile); (void) fputc(column2, gpoutfile); (void) fputc(column1, gpoutfile); (void) fputc(column3, gpoutfile); (void) fputc(column2, gpoutfile); (void) fputc(column1, gpoutfile); (void) fputc(column3, gpoutfile); (void) fputc(column2, gpoutfile); (void) fputc(column1, gpoutfile); } } } fputs("\r\033l", gpoutfile); (void) fputc('\0', gpoutfile); /* set left margin to 0 */ if (b_planes > 1) { fprintf(gpoutfile, "\033r"); (void) fputc('\0', gpoutfile); /* set color to black */ } #ifdef PC fputs("Print using: COPY /B\n", stderr); #endif #ifdef VMS fflush_binary(); #endif } /* output file must be binary mode for nec_dump */ void nec_draft_dump() { unsigned int x; unsigned int plane, offset; int j; fputs("\033P\033l\005\r", gpoutfile); /* 10cpi, left margin 5 char */ for (j = (b_ysize / 8) - 1; j >= 0; j--) { fputs("\033J\030", gpoutfile); /* 24/180" line feed */ for (plane = 0; plane < b_planes; plane++) { offset = plane * b_psize; if (b_planes > 1) { /* select colour for plane */ fputs("\033r", gpoutfile); (void) fputc((char) necpcolor[plane], gpoutfile); } /* select plotter graphics mode (square pixels) */ fputs("\r\033*", gpoutfile); (void) fputc('\0', gpoutfile); (void) fputc((char) (b_xsize % 256), gpoutfile); (void) fputc((char) (b_xsize / 256), gpoutfile); for (x = 0; x < b_xsize; x++) { (void) fputc((char) (*((*b_p)[j + offset] + x)), gpoutfile); } } } fputs("\r\033l", gpoutfile); (void) fputc('\0', gpoutfile); /* set left margin to 0 */ if (b_planes > 1) { fputs("\033r", gpoutfile); (void) fputc('\0', gpoutfile); /* set color to black */ } #ifdef PC fputs("Print using: COPY /B\n", gpoutfile); #endif } #endif /* NEC */ #ifdef STARC /* The following Star color driver uses generic bit mapped graphics routines to build up a bit map in memory. */ /* Star Color changes made by William Wilson, wew@naucse.cse.nau.edu */ /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */ /* STARC_init changes gpoutfile to binary mode on PC's */ void STARC_dump __PROTO((void)); #define STARCXLAST (STARCXMAX - 1) #define STARCYLAST (STARCYMAX - 1) /* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */ static unsigned int STARCcolor[] = { 1, 8, 4, 2, 10, 12, 6, 14 }; static unsigned int STARCpcolor[] = { 0, 2, 1, 4 }; TERM_PUBLIC void STARCinit() { } TERM_PUBLIC void STARCgraphics() { b_charsize(FNT5X9); b_makebitmap((unsigned int) (STARCXMAX * xsize), (unsigned int) (STARCYMAX * ysize), 4); } TERM_PUBLIC void STARCtext() { STARC_dump(); b_freebitmap(); } TERM_PUBLIC void STARClinetype(linetype) int linetype; { if (linetype >= 6) linetype %= 6; b_setvalue(STARCcolor[linetype + 2]); } TERM_PUBLIC void STARCreset() { #ifdef VMS fflush_binary(); #endif } /* output file must be binary mode for STARC_dump */ void STARC_dump() { unsigned int x; unsigned int plane, offset; int j; for (j = (b_ysize / 8) - 1; j >= 0; j--) { fputs("\033J\030", gpoutfile); /* line feed 8/72" = 8 dots */ for (plane = 0; plane < b_planes; plane++) { offset = plane * b_psize; if (b_planes > 1) { /* select colour for plane */ fputs("\033r", gpoutfile); (void) fputc((char) STARCpcolor[plane], gpoutfile); } /* select plotter graphics mode (square pixels) */ fputs("\r\033*\005", gpoutfile); (void) fputc((char) (b_xsize % 256), gpoutfile); (void) fputc((char) (b_xsize / 256), gpoutfile); for (x = 0; x < b_xsize; x++) { (void) fputc((char) (*((*b_p)[j + offset] + x)), gpoutfile); } } } if (b_planes > 1) { fputs("\033r", gpoutfile); (void) fputc('\0', gpoutfile); /* set color to black */ } #ifdef PC fputs("Print using: COPY /B\n", stderr); #endif } #endif /* STARC */ #ifdef EPS180 void eps180_dump __PROTO((void)); #define EPS180XLAST (EPS180XMAX - 1) #define EPS180YLAST (EPS180YMAX - 1) TERM_PUBLIC void EPS180graphics() { b_charsize(FNT13X25); b_makebitmap((unsigned int) (EPS180XMAX * xsize), (unsigned int) (EPS180YMAX * ysize), 1); } TERM_PUBLIC void EPS180text() { eps180_dump(); b_freebitmap(); } /* output file must be binary mode for eps180_dump */ void eps180_dump() { register unsigned int x; int j; /* reset, set line spacing to 24/180", and move left margin */ fputs("\033@\033+\060\033l\005", gpoutfile); for (j = (b_ysize / 8) - 1; j >= 0;) { /* select printer graphics mode '39' */ fputs("\r\n\033*'", gpoutfile); (void) fputc((char) (b_xsize % 256), gpoutfile); (void) fputc((char) (b_xsize / 256), gpoutfile); for (x = 0; x < b_xsize; x++) { (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile); (void) fputc((char) (*((*b_p)[j - 1] + x)), gpoutfile); (void) fputc((char) (*((*b_p)[j - 2] + x)), gpoutfile); } j -= 3; } fputs("\r\n\033@\r\n", gpoutfile); /* reset printer */ #ifdef PC fputs("Print using: COPY /B\n", stderr); #endif } #endif /* EPS180 */ #ifdef EPS60 void eps60_dump __PROTO((void)); #define EPS60XLAST (EPS60XMAX - 1) #define EPS60YLAST (EPS60YMAX - 1) TERM_PUBLIC void EPS60graphics() { b_charsize(FNT5X9); b_makebitmap((unsigned int) (EPS60XMAX * xsize), (unsigned int) (EPS60YMAX * ysize), 1); } TERM_PUBLIC void EPS60text() { eps60_dump(); b_freebitmap(); } /* output file must be binary mode for eps60_dump */ void eps60_dump() { register unsigned int x; int j; fprintf(gpoutfile, "\033%c\030", '3'); /* set line spacing 24/216" = 8 dots */ for (j = (b_ysize / 8) - 1; j >= 0; j--) { /* select printer graphics mode 'K' */ fputs("\r\n\033K", gpoutfile); (void) fputc((char) (b_xsize % 256), gpoutfile); (void) fputc((char) (b_xsize / 256), gpoutfile); for (x = 0; x < b_xsize; x++) { (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile); } } fprintf(gpoutfile, "\033%c\044\r\n", '3'); /* set line spacing 36/216" = 1/6" */ #ifdef PC fputs("Print using: COPY /B\n", stderr); #endif } #endif /* EPS60 */ #ifdef TANDY60 /* The only difference between TANDY60 and EPS60 is the inclusion of codes to swap the Tandy printer into IBM mode and back into Tandy mode. For a Tandy already in IBM mode, use EPS60. */ TERM_PUBLIC void TANDY60text() { #ifdef PC fputs("Inserting Tandy/IBM mode conversion codes\n", stderr); #endif /* Switch to IBM mode, and leave 3 inches above the plot so as to get rough vertical centring on the page. Perform the centring by setting 1" line feeds and issuing 3 of them. */ fprintf(gpoutfile, "\033!\033%c%c\n\n\n", '3', 216); eps60_dump(); b_freebitmap(); /* A form feed must be sent before switching back to Tandy mode, or else the form setting will be messed up. */ fputs("\f\033!", gpoutfile); } #endif /* TANDY60 */ #ifdef OKIDATA void okidata_dump __PROTO((void)); TERM_PUBLIC void OKIDATAtext() { okidata_dump(); b_freebitmap(); } int bitrev_tbl[] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; /* output file must be binary mode for okidata_dump */ void okidata_dump() { register unsigned int x; int j; char cur_char; int prev_char; prev_char = 0; fprintf(gpoutfile, "\033%c%c\020\033*eP:\003", '%', '9'); /* set line spacing 16/144" = 8 dots :Turned on single density graphics mode */ for (j = (b_ysize / 8) - 1; j >= 0; j--) { fputs("\003\016", gpoutfile); /* (void) fputc((char)(b_xsize%256),gpoutfile); */ /* (void) fputc((char)(b_xsize/256),gpoutfile); */ for (x = 0; x < b_xsize; x++) { if ((cur_char = (char) (bitrev_tbl[(int) (*((*b_p)[j] + x))])) == '\003') { fputs("\003\003", gpoutfile); } else { (void) fputc((char) cur_char, gpoutfile); } } } fprintf(gpoutfile, "\003\002\033%c%c\030\r\n", '%', '9'); /* Turned off graphics mode: set line spacing 24/144" = 1/6" */ #ifdef PC fputs("Print using: COPY /B\n", stderr); #endif } #endif /* OKIDATA */ #endif /* TERM_BODY */ #ifdef TERM_TABLE #ifdef EPS180 TERM_TABLE_START(epson180_driver) "epson_180dpi", "Epson LQ-style 180-dot per inch (24 pin) printers", EPS180XMAX, EPS180YMAX, EPSON180VCHAR, EPSON180HCHAR, EPSON180VTIC, EPSON180HTIC, options_null, EPSONinit, EPSONreset, EPS180text, null_scale, EPS180graphics, EPSONmove, EPSONvector, EPSONlinetype, EPSONput_text, EPSON_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(epson180_driver) #undef LAST_TERM #define LAST_TERM epson180_driver #endif /* EPS180 */ #ifdef EPS60 TERM_TABLE_START(epson60_driver) "epson_60dpi", "Epson-style 60-dot per inch printers", EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR, EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, EPS60text, null_scale, EPS60graphics, EPSONmove, EPSONvector, EPSONlinetype, EPSONput_text, EPSON_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(epson60_driver) #undef LAST_TERM #define LAST_TERM epson60_driver #endif /* EPS60 */ #ifdef EPSONP TERM_TABLE_START(epsonlx_driver) "epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...", EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR, EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector, EPSONlinetype, EPSONput_text, EPSON_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(epsonlx_driver) #undef LAST_TERM #define LAST_TERM epsonlx_driver #endif /* EPSONP */ #ifdef NEC TERM_TABLE_START(nec_driver) "nec_cp6", "NEC printer CP6, Epson LQ-800 [monocrome color draft]", NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, NECVTIC, NECHTIC, NECoptions, NECinit, NECreset, NECtext, null_scale, NECgraphics, NECmove, NECvector, NEClinetype, NECput_text, NEC_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(nec_driver) #undef LAST_TERM #define LAST_TERM nec_driver #endif /* NEC */ #ifdef OKIDATA TERM_TABLE_START(okidata_driver) "okidata", "OKIDATA 320/321 Standard", EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR, EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, OKIDATAtext, null_scale, EPS60graphics, EPSONmove, EPSONvector, EPSONlinetype, EPSONput_text, EPSON_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(okidata_driver) #undef LAST_TERM #define LAST_TERM okidata_driver #endif /* OKIDATA */ #ifdef STARC TERM_TABLE_START(starc_driver) "starc", "Star Color Printer", STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR, STARCVTIC, STARCHTIC, options_null, STARCinit, STARCreset, STARCtext, null_scale, STARCgraphics, STARCmove, STARCvector, STARClinetype, STARCput_text, STARC_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(starc_driver) #undef LAST_TERM #define LAST_TERM starc_driver #endif /* STARC */ #ifdef TANDY60 TERM_TABLE_START(tandy60_driver) "tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics", EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR, EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, TANDY60text, null_scale, EPS60graphics, EPSONmove, EPSONvector, EPSONlinetype, EPSONput_text, EPSON_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(tandy60_driver) #undef LAST_TERM #define LAST_TERM tandy60_driver #endif /* TANDY60 */ #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(epson_180dpi) "1 epson-180dpi", "?commands set terminal epson-180dpi", "?set terminal epson-180dpi", "?set term epson-180dpi", "?terminal epson-180dpi", "?term epson-180dpi", "?epson-180dpi", "?commands set terminal epson-60dpi", "?set terminal epson-60dpi", "?set term epson-60dpi", "?terminal epson-60dpi", "?term epson-60dpi", "?epson-60dpi", "?commands set terminal epson-lx800", "?set terminal epson-lx800", "?set term epson-lx800", "?terminal epson-lx800", "?term epson-lx800", "?epson-lx800", "?commands set terminal nec-cp6", "?set terminal nec-cp6", "?set term nec-cp6", "?terminal nec-cp6", "?term nec-cp6", "?nec-cp6", "?commands set terminal okidata", "?set terminal okidata", "?set term okidata", "?terminal okidata", "?term okidata", "?okidata", "?commands set terminal starc", "?set terminal starc", "?set term starc", "?terminal starc", "?term starc", "?starc", "?commands set terminal tandy-60dpi", "?set terminal tandy-60dpi", "?set term tandy-60dpi", "?terminal tandy-60dpi", "?term tandy-60dpi", "?tandy-60dpi", " This driver supports a family of Epson printers and derivatives.", "", " `epson-180dpi` and `epson-60dpi` are drivers for Epson LQ-style 24-pin", " printers with resolutions of 180 and 60 dots per inch, respectively.", "", " `epson-lx800` is a generic 9-pin driver appropriate for printers like the", " Epson LX-800, the Star NL-10 and NX-1000, the PROPRINTER, and so forth.", "", " `nec-cp6` is generix 24-pin driver that can be used for printers like the", " NEC CP6 and the Epson LQ-800.", "", " The `okidata` driver supports the 9-pin OKIDATA 320/321 Standard printers.", "", " The `starc` driver is for the Star Color Printer.", "", " The `tandy-60dpi` driver is for the Tandy DMP-130 series of 9-pin, 60-dpi", " printers.", "", " Only `nec-cp6` has any options.", "", " Syntax:", " set terminal nec-cp6 {monochrome | colour | draft}", "", " which defaults to monochrome.", "", " With each of these drivers, a binary copy is required on a PC to print. Do", " not use `print`---use instead `copy file /b lpt1:`." END_HELP(epson_180dpi) #endif /* TERM_HELP */ /* * $Id: excl.trm,v 1.9 1998/04/14 00:17:41 drd Exp $ * */ /* GNUPLOT - excl.trm */ /* Copyright (c) 1992, 1998 by P. Klosowski at NIST. All Rights Reserved * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. * * This file is included by ../term.c. * * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /*** NAME quic PURPOSE QUIC driver for GNUPLOT NOTES HISTORY przemek - Aug 16, 1992: Created. lars - Nov 30, 1998: Updated to new gnuplot copyright by permission from Przemek ***/ /* c ***************************************** c ***************************************** c ****** ***** c ****** EXCL command definitions ***** c ****** ***** c ***************************************** c ***************************************** */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(excl) #endif #ifdef TERM_PROTO TERM_PUBLIC void EXCL_init __PROTO((void)); TERM_PUBLIC void EXCL_graphics __PROTO((void)); TERM_PUBLIC void EXCL_text __PROTO((void)); TERM_PUBLIC void EXCL_linetype __PROTO((int linetype)); TERM_PUBLIC void EXCL_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void EXCL_vector __PROTO((unsigned int x2, unsigned int y2)); TERM_PUBLIC void EXCL_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void EXCL_reset __PROTO((void)); #define EXCL_XMAX 9000 #define EXCL_YMAX 6500 #define EXCL_XLAST (EXCL_XMAX - 1) #define EXCL_YLAST (EXCL_YMAX - 1) #define EXCL_VCHAR 120 #define EXCL_HCHAR 70 #define EXCL_VTIC 70 #define EXCL_HTIC 70 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* Define ansi command headers, NUL character */ #define ESC "\033" #define GS "\035" #define CSI "\033[" #define DCS "\033P" #define ST "\033\\" /* page numbers are given per "Talaris EXCL programmer's reference manual" M292 rev.2 NOTE: EXCL coordinate system places (0,0) at upper left corner of the page c EXCL commands for initialization c TALAMS: set ANSI (p. 162) c TALMOD: set emulation *** EXCL (p. 164) c TALPGO: set page orient *** landscape (p. 81) c TALFCTL: set paper format *** 8.5x11 (p. 85) c TALTBM: set top/bot margins ** in land mode to full pg (p. 73) c TALLRM: set left/right margins (p. 75) c PUM: set units ** units of measure set by TALPRM (p. 67) c TALASF: Absorb cr/ff/lf/vt ** ON (p. 182) c TALPOP: pop controller params (p. 168) c TALPSH: push controller params (p. 167) c TALPRM: set units of measure ** to 1/1000 inch (p. 64) c TALGLT: set line type ** solid (p. 211) c TALORG: set page absolute origin ** (0,0) UL corner (p. 78) c TALPCW: set page clip window *** for landsc/full page (p. 84) c TALGLP: line: **pen7x7mil*draw*smear*glyph112*font5279* (p. 208) c TALGLPE: ending for TALGLP command, forcing DRAW mode c TALGBB: bounding box; used only by qdrive (p. 207) c TALFPO: Force page out ** clear bitmap (p. 95) c TALGDW: graphical draw to hor,vert ** abs coords (p. 212) c TALGMV: graphical move to hor,vert ** abs coords (p. 213) */ #define TALAMS "\033[0*s" #define TALMOD "\033[1;0r" #define TALPGO "\033[1;0p" #define TALFCTL "\033[0;3x" #define TALTBM "\033[0;8500 v" #define TALLRM "\033[0;11000v" #define PUM "\033[11h" #define TALASF "\033[1 z" #define TALPOP "\033[*]" #define TALPSH "\033[*[" #define TALPRM "\033[3y" #define TALGLT "\033[%s*t" #define TALORG "\033[0;0o" #define TALCCNT "\033[1;0u" #define TALPCW "\033[0;8500;11000;0*c" #define TALGLP_init "\033[7;7;8;1;112;5279*w" #define TALGLP "\033[%d;%d;8*w" #define TALFPO "\033[0*F" #define TALGDW "\033[0;%d;%d*d" #define TALGMV "\033[0;%d;%d*m" /* TALPYL: polyline (p. 222) ** 5;0} list of 16-bit signed integers, encoded, mostly relative ** 5,1} list of ASCII absolute coords (if w/o +- signs)(e.g. 315:1222;) */ #define TALPYL "\033P5;1}" TERM_PUBLIC void EXCL_init() { fprintf(gpoutfile, "%s%s%s%s%s%s", TALPSH, TALAMS, TALMOD, TALCCNT, TALFCTL, TALASF); /* ^save state ^setEXCL ^PaperSize8.5x11 */ /* ^setANSI ^copyCount1 ^absorbCtlChar */ fprintf(gpoutfile, "%s%s%s%s%s%s", PUM, TALPRM, TALPGO, TALPCW, TALORG, TALGLP_init); fprintf(gpoutfile, TALGLT, ""); /* ^setUnits ^landscape ^OriginZero ^SolidLine */ /* ^Units1/1000" ^pageClip ^SetLine */ } TERM_PUBLIC void EXCL_graphics() { } TERM_PUBLIC void EXCL_text() { fputs(TALFPO, gpoutfile); /* ^pageout */ } TERM_PUBLIC void EXCL_linetype(linetype) int linetype; { /* excl line widths in mils: 4 is mimimum, but too thin; then 7,10,14,17,20,24,27... exclpen=MOD(NPEN,8)*7 CSI exclpen; exclpen; TALGLPE */ static char *type[2 + 9] = { "", "40;40", "", "42;42", "14;21", /* .... ---- -- -- -- . . . */ "", "49;30", "14;21", "", "49;30", "14;21" /* same pattern, but thicker.. and thicker */ }; static int width[2+9] = { 14, 7, 7, 7, 7, 10, 10, 10, 17, 17, 17 }; if (linetype >= 9) linetype %= 9; fprintf(gpoutfile, TALGLP, width[linetype + 2], width[linetype + 2]); /* ^width in dots */ fprintf(gpoutfile, TALGLT, type[linetype + 2]); /* ^line type */ } TERM_PUBLIC void EXCL_move(x, y) unsigned int x, y; { fprintf(gpoutfile, TALGMV, 1000 + x, EXCL_YLAST + 1000 - y); /* ^pen up vector */ } TERM_PUBLIC void EXCL_vector(x2, y2) unsigned int x2, y2; { fprintf(gpoutfile, TALGDW, 1000 + x2, EXCL_YLAST + 1000 - y2); /* ^pen down vector */ } TERM_PUBLIC void EXCL_put_text(x, y, str) unsigned int x, y; char str[]; { char ch; EXCL_move(x, y - EXCL_VCHAR / 3); ch = *str++; while (ch != NUL) { putc(ch, gpoutfile); ch = *str++; } } TERM_PUBLIC void EXCL_reset() { fprintf(gpoutfile, "%s%s", TALFPO, TALPOP); /* ^pageout ^pop */ } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(excl_driver) "excl", "Talaris EXCL Laser printer (also Talaris 1590 and others)", EXCL_XMAX, EXCL_YMAX, EXCL_VCHAR, EXCL_HCHAR, EXCL_VTIC, EXCL_HTIC, options_null, EXCL_init, EXCL_reset, EXCL_text, null_scale, EXCL_graphics, EXCL_move, EXCL_vector, EXCL_linetype, EXCL_put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(excl_driver) #undef LAST_TERM #define LAST_TERM excl_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(excl) "1 excl", "?commands set terminal excl", "?set terminal excl", "?set term excl", "?terminal excl", "?term excl", "?excl", " The `excl` terminal driver supports Talaris printers such as the EXCL Laser", " printer and the 1590. It has no options." END_HELP(excl) #endif /* * $Id: $ */ /* GNUPLOT - fg.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Under Zortech C * egalib, vgalib, vgamono, svga, mcga, cga, hercules, att * * AUTHORS * Gnuplot for DOS 386/flash graphics * Clifton T. Liu * * There is a mailing list for gnuplot users. Note, however, that the * newsgroup * comp.graphics.apps.gnuplot * is identical to the mailing list (they * both carry the same set of messages). We prefer that you read the * messages through that newsgroup, to subscribing to the mailing list. * (If you can read that newsgroup, and are already on the mailing list, * please send a message to majordomo@dartmouth.edu, asking to be * removed from the mailing list.) * * The address for mailing to list members is * info-gnuplot@dartmouth.edu * and for mailing administrative requests is * majordomo@dartmouth.edu * The mailing list for bug reports is * bug-gnuplot@dartmouth.edu * The list of those interested in beta-test versions is * info-gnuplot-beta@dartmouth.edu */ /* The modifications to allow Gnuplot to compile with Zortech C/C++ */ /* 3.1 /Flash Graphics were made by Clifton T. Liu */ /* (cliu@merlin.appmath.columbia.edu) 20 Feb 1993 */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(hercules) register_term(egamono) register_term(egalib) register_term(vgalib) register_term(vgamono) register_term(svgalib) register_term(ssvgalib) #endif #ifdef TERM_PROTO TERM_PUBLIC void PC_text __PROTO((void)); TERM_PUBLIC void PC_reset __PROTO((void)); TERM_PUBLIC int VGA_text_angle __PROTO((int ang)); TERM_PUBLIC int VGA_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void VGA_init __PROTO((void)); TERM_PUBLIC void HERC_graphics __PROTO((void)); TERM_PUBLIC void EGAMONO_graphics __PROTO((void)); TERM_PUBLIC void EGA_graphics __PROTO((void)); TERM_PUBLIC void VGA_graphics __PROTO((void)); TERM_PUBLIC void VGAMONO_graphics __PROTO((void)); TERM_PUBLIC void SVGA_graphics __PROTO((void)); TERM_PUBLIC void SSVGA_graphics __PROTO((void)); TERM_PUBLIC void VGA_linetype __PROTO((int linetype)); #define HERC_XMAX 720 #define HERC_YMAX 348 #define HERC_XLAST (HERC_XMAX - 1) #define HERC_YLAST (HERC_YMAX - 1) #define HERC_VCHAR 10 #define HERC_HCHAR 8 #define HERC_VTIC 5 #define HERC_HTIC 5 #define EGA_XMAX 640 #define EGA_YMAX 350 #define EGA_XLAST (EGA_XMAX - 1) #define EGA_YLAST (EGA_YMAX - 1) #define EGA_VCHAR 18 #define EGA_HCHAR 8 #define EGA_VTIC 5 #define EGA_HTIC 5 #define VGA_XMAX 640 #define VGA_YMAX 480 #define VGA_XLAST (VGA_XMAX - 1) #define VGA_YLAST (VGA_YMAX - 1) #define VGA_VCHAR 24 #define VGA_HCHAR 8 #define VGA_VTIC 5 #define VGA_HTIC 5 #define SVGA_XMAX 800 #define SVGA_YMAX 600 #define SVGA_XLAST (SVGA_XMAX - 1) #define SVGA_YLAST (SVGA_YMAX - 1) #define SVGA_VCHAR 24 #define SVGA_HCHAR 8 #define SVGA_VTIC 5 #define SVGA_HTIC 5 #define SSVGA_XMAX 1024 #define SSVGA_YMAX 768 #define SSVGA_XLAST (SSVGA_XMAX - 1) #define SSVGA_YLAST (SSVGA_YMAX - 1) #define SSVGA_VCHAR 24 #define SSVGA_HCHAR 8 #define SSVGA_VTIC 5 #define SSVGA_HTIC 5 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void pause __PROTO((void)); #include static int pattern[] ={ 0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f }; static int graphics_on = FALSE; int startx, starty; /* int pc_angle; #define PC_VCHAR FNT5X9_VCHAR #define PC_HCHAR FNT5X9_HCHAR */ void pause() { /* press any key to continue... */ (void) getch(); } TERM_PUBLIC void PC_text() { if (graphics_on) { graphics_on = FALSE; pause(); } fg_term(); } TERM_PUBLIC void PC_reset() { } /* all of the FlashGraphics C routines for the different graphics devices * go here */ static int vga256color[] ={ 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 }; static int *vgacolor = vga256color; static fg_color_t vga_color; static int text_angle; static fg_line_t line_to_draw; TERM_PUBLIC int VGA_text_angle(ang) int ang; { text_angle = ang; return TRUE; } TERM_PUBLIC int VGA_justify_text(mode) enum JUSTIFY mode; { return FALSE; } TERM_PUBLIC void VGA_init() { if (fg_init() == FG_NULL) { fputs("Graphics card not detected.\n", stderr); exit(EXIT_FAILURE); } } TERM_PUBLIC void HERC_graphics() { fg_init_herc(); graphics_on = TRUE; } TERM_PUBLIC void EGAMONO_graphics() { fg_init_egamono(); graphics_on = TRUE; } TERM_PUBLIC void EGA_graphics() { fg_init_egaecd(); graphics_on = TRUE; } TERM_PUBLIC void VGA_graphics() { fg_init_vga12(); graphics_on = TRUE; } TERM_PUBLIC void VGAMONO_graphics() { fg_init_vga11(); graphics_on = TRUE; } TERM_PUBLIC void SVGA_graphics() { fg_init_vesa6a(); graphics_on = TRUE; } TERM_PUBLIC void SSVGA_graphics() { fg_init_vesa5(); graphics_on = TRUE; } TERM_PUBLIC void VGA_linetype(linetype) { if (linetype >= 13) linetype %= 13; vga_color = fg.color[vgacolor[linetype + 2]]; } TERM_PUBLIC void VGA_put_text(x, y, str) unsigned int x, y; char *str; { fg_puts(vga_color, FG_MODE_SET, ~0, text_angle, x, y, str, fg.displaybox); } TERM_PUBLIC void VGA_move(x, y) { line_to_draw[FG_X1] = x; line_to_draw[FG_Y1] = y; } TERM_PUBLIC void VGA_vector(x, y) { line_to_draw[FG_X2] = x; line_to_draw[FG_Y2] = y; fg_drawline(vga_color, FG_MODE_SET, ~0, FG_LINE_SOLID, line_to_draw); line_to_draw[FG_X1] = x; line_to_draw[FG_Y1] = y; } TERM_PUBLIC void VGA_text() { if (graphics_on) { graphics_on = FALSE; fg_flush(); pause(); } fg_term(); } TERM_PUBLIC void VGA_reset() { fg_term(); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(hercules_driver) "hercules", "IBM PC/Clone with Hercules graphics board", HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR, HERC_VTIC, HERC_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, HERC_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(hercules_driver) #undef LAST_TERM #define LAST_TERM hercules_driver TERM_TABLE_START(egamono_driver) "egamono", "IBM PC/Clone with monochrome EGA graphics board", EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR, EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, EGAMONO_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(egamono_driver) #undef LAST_TERM #define LAST_TERM egamono_driver TERM_TABLE_START(egalib_driver) "egalib", "IBM PC/Clone with color EGA graphics board", EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR, EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, EGA_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(egalib_driver) #undef LAST_TERM #define LAST_TERM egalib_driver TERM_TABLE_START(vgalib_driver) "vgalib", "IBM PC/Clone with VGA graphics board", VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR, VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(vgalib_driver) #undef LAST_TERM #define LAST_TERM vgalib_driver TERM_TABLE_START(vgamono_driver) "vgamono", "IBM PC/Clone with monochrome VGA graphics board", VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR, VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, VGAMONO_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(vgamono_driver) #undef LAST_TERM #define LAST_TERM vgamono_driver TERM_TABLE_START(svgalib_driver) "svgalib", "IBM PC/Clone with VESA Super VGA graphics board", SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR, SVGA_VTIC, SVGA_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, SVGA_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(svgalib_driver) #undef LAST_TERM #define LAST_TERM svgalib_driver TERM_TABLE_START(ssvgalib_driver) "ssvgalib", "IBM PC/Clone with VESA 256 color 1024 by 768 super VGA", SSVGA_XMAX, SSVGA_YMAX, SSVGA_VCHAR, SSVGA_HCHAR, SSVGA_VTIC, SSVGA_HTIC, options_null, VGA_init, VGA_reset, VGA_text, null_scale, SSVGA_graphics, VGA_move, VGA_vector, VGA_linetype, VGA_put_text, VGA_text_angle, VGA_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(ssvgalib_driver) #undef LAST_TERM #define LAST_TERM ssvgalib_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(hercules) "1 hercules", "?commands set terminal hercules", "?set terminal hercules", "?set term hercules", "?terminal hercules", "?term hercules", "?hercules", "?commands set terminal egalib", "?set terminal egalib", "?set term egalib", "?terminal egalib", "?term egalib", "?egalib", "?commands set terminal egamono", "?set terminal egamono", "?set term egamono", "?terminal egamono", "?term egamono", "?egamono", "?commands set terminal vgalib", "?set terminal vgalib", "?set term vgalib", "?terminal vgalib", "?term vgalib", "?vgalib", "?commands set terminal vgamono", "?set terminal vgamono", "?set term vgamono", "?terminal vgamono", "?term vgamono", "?vgamono", "?commands set terminal svgalib", "?set terminal svgalib", "?set term svgalib", "?terminal svgalib", "?term svgalib", "?svgalib", "?commands set terminal ssvgalib", "?set terminal ssvgalib", "?set term ssvgalib", "?terminal ssvgalib", "?term ssvgalib", "?ssvgalib", " These drivers supports PC monitors with autodetected graphics boards. They", " can be used only when compiled with Zortech C/C++. None have options." END_HELP(hercules) #endif /* TERM_HELP */ /* * $Id: fig.trm,v 1.57 1998/06/18 14:59:20 ddenholm Exp $ */ /* GNUPLOT - fig.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Fig graphics language * * AUTHORS * Micah Beck, David Kotz * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * Original for Fig code output by Micah Beck, 1989 * Department of Computer Science, Cornell University * Updated by David Kotz for gnuplot 2.0 * More efficient output by Ian Dall * Updated to FIG 2.1 (with color) format by Vivek Khera * Updated to FIG 3.1 (higher resolution) format by Ian MacPhedran, Jan 1995 * Updated to conform to newterm format Ian MacPhedran, Apr 1995 * Point-count option joachim.selinger@ins.uni-stuttgart.de (JFS) Feb 9 1996 * More options (portrait/landscape, metric/inches, size, fontsize, thickness) * plus symbols and depth/thickness by bernlohr@eu1.mpi-hd.mpg.de (KB) Aug 15 1996 */ #include "driver.h" #ifdef TERM_REGISTER register_term(fig) #endif /* TERM_REGISTER */ #ifdef TERM_PROTO TERM_PUBLIC void FIG_options __PROTO((void)); TERM_PUBLIC void FIG_init __PROTO((void)); TERM_PUBLIC void FIG_graphics __PROTO((void)); TERM_PUBLIC void FIG_text __PROTO((void)); TERM_PUBLIC void FIG_linetype __PROTO((int linetype)); TERM_PUBLIC void FIG_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void FIG_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void FIG_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC void FIG_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int FIG_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int FIG_text_angle __PROTO((int ang)); TERM_PUBLIC void FIG_pointsize __PROTO((double arg_pointsize)); TERM_PUBLIC void FIG_linewidth __PROTO((double linewidth)); TERM_PUBLIC void FIG_reset __PROTO((void)); TERM_PUBLIC void FIG_lpoint __PROTO((unsigned int x, unsigned int y, int number)); #define GOT_FIG_PROTO #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #include "object.h" /* modified from the XFig distribution */ #define FIG_DEFAULT DEFAULT #define FIG_ROMAN_FONT (0) /* actually, the default font */ #ifndef FIG_RES /* This is now 1200 per inch */ #define FIG_RES (1200) #endif #define FIG_COORD_SYS 2 #define FIG_ORIENT (FIG_portrait?"Portrait":"Landscape") /* Could be "Portrait" */ #define FIG_JUST "Center" /* Could be "Flush Left" */ #define FIG_UNIT (FIG_inches?"Inches":"Metric") /* Could be "Inches" */ #define FIG_MAGIC "#FIG 3.1" #define FIG_HTIC (5*FIG_RES/80) #define FIG_VTIC (5*FIG_RES/80) #define FIG_FONT_S (10) /* size in points */ #define FIG_MAX_POINTS 99999L /* almost infinite ;-) */ #define FIG_to_pixel_v(s) ((s)*FIG_RES/72*3/4) /* height of font in pixels */ /* This is fudged to enlarge the drawing area, but gives fairly good results */ #define FIG_to_pixel_h(s) (FIG_to_pixel_v(s)*6/10) /* this is a guess at the width */ #define FIG_VCHAR FIG_to_pixel_v(FIG_FONT_S) /* just for default, */ #define FIG_HCHAR FIG_to_pixel_h(FIG_FONT_S) /* not really used */ enum FIG_poly_stat { FIG_poly_new, FIG_poly_part }; static int FIG_posx; static int FIG_posy; static long FIG_poly_vec_cnt; static int FIG_depth = 10; static int FIG_linedepth = 10; static int FIG_thickness = 1; static int FIG_default_thickness = 1; static double FIG_current_pointsize = 1.; static double FIG_current_linewidth = 1.; /* Maximum number of points per POLYLINE. Default 1000 (hardcoded in help section as well) */ static int FIG_poly_vec_max = 999; /* JFS */ static enum FIG_poly_stat FIG_polyvec_stat; /* 5 inches wide by 3 inches high */ #define FIG_XMAX (5 * FIG_RES) #define FIG_YMAX (3 * FIG_RES) #define FIG_XOFF (FIG_RES/4) #define FIG_YOFF (FIG_RES/4) #define BFIG_HTIC (7*FIG_RES/80) #define BFIG_VTIC (7*FIG_RES/80) #define BFIG_FONT_S (16) /* size in points */ #define BFIG_VCHAR FIG_to_pixel_v(BFIG_FONT_S) /* height in pixels of font */ #define BFIG_HCHAR FIG_to_pixel_h(BFIG_FONT_S) /* this is a guess at the width */ static F_point *FIG_points = NULL; /* Array for the collection of points for POLYLINE, allocated on demand. */ static F_line FIG_line; /* 8 inches wide by 5 inches high */ #define BFIG_XMAX (8 * FIG_RES) #define BFIG_YMAX (5 * FIG_RES) #define BFIG_XOFF (FIG_RES/2) #define BFIG_YOFF (FIG_RES/2) static int FIG_type; /* negative types use real lines */ static float FIG_spacing; /* length of dash or dot spacing */ static int FIG_justify; /* Fig justification T_*_JUSTIFIED */ static float FIG_angle; /* Fig text angle 0=horiz, Pi/2=vert */ static int FIG_use_color = FALSE; /* do we use color or not? */ static int FIG_is_big = FALSE; /* big plot ? */ static int FIG_color = DEFAULT; /* which color to use */ static int FIG_xoff = FIG_XOFF; static int FIG_yoff = FIG_YOFF; static int FIG_font_s = FIG_FONT_S; static int FIG_portrait = FALSE; static int FIG_inches = FALSE; static void FIG_poly_clean __PROTO((enum FIG_poly_stat fig_stat)); #define FIG_POINT_TYPES POINT_TYPES /* we use the same points */ static void FIG_poly_clean(fig_stat) enum FIG_poly_stat fig_stat; { int i, j; if (fig_stat == FIG_poly_part) { fprintf(gpoutfile, "%d %d %d %d %d %d %d %d %d %9.3f %d %d %d %d %d %ld\n\t", O_POLYLINE, FIG_line.type, FIG_line.style, FIG_line.thickness, FIG_line.pen_color, FIG_line.fill_color, FIG_line.depth, FIG_line.pen_style, FIG_line.fill_style, FIG_line.style_val, FIG_line.join_style, FIG_line.cap_style, FIG_line.radius, 0, 0, FIG_poly_vec_cnt); j = 0; for (i = 0; i < FIG_poly_vec_cnt; i++) { fprintf(gpoutfile, " %d %d", FIG_points[i].x, FIG_points[i].y); if (j++ > 4 && i != FIG_poly_vec_cnt - 1) { fputs("\n\t", gpoutfile); j = 0; /* JFS */ } } if (j != 0) { putc('\n', gpoutfile); } /* Give the memory back to the system because we are done with this * polyline. Make sure FIG_points contains NULL afterwards! */ free(FIG_points); FIG_points = NULL; } FIG_polyvec_stat = FIG_poly_new; } TERM_PUBLIC void FIG_options() { static char *options_list = /* sun cc does not concat strings */ "expecting monochrome, color, small, big, portrait, landscape,\n\ \t inches, metric, size , fontsize ,\n\ \t thickness , depth or pointsmax "; int parse_error = FALSE; long temp_max; struct value a; unsigned int tmax_t; double xsize_t, ysize_t; FIG_use_color = FALSE; /* default */ FIG_is_big = FALSE; /* default */ FIG_portrait = FALSE; FIG_font_s = 0; FIG_default_thickness = 1; xsize_t = ysize_t = 0.; #if METRIC FIG_inches = FALSE; #else FIG_inches = TRUE; #endif while (!END_OF_COMMAND) { if (almost_equals(c_token, "mo$nochrome")) { FIG_use_color = FALSE; c_token++; } else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { FIG_use_color = TRUE; c_token++; } else if (almost_equals(c_token, "sm$all")) { FIG_is_big = FALSE; c_token++; } else if (almost_equals(c_token, "b$ig")) { FIG_is_big = TRUE; c_token++; } else if (almost_equals(c_token, "in$ches")) { /* KB */ FIG_inches = TRUE; c_token++; } else if (almost_equals(c_token, "me$tric")) { /* KB */ FIG_inches = FALSE; c_token++; } else if (almost_equals(c_token, "por$trait")) { /* KB */ /* KB: Would have preferred "p$ortrait" but that would */ /* collide with "p$ointsmax" below. */ FIG_portrait = TRUE; c_token++; } else if (almost_equals(c_token, "l$andscape")) { /* KB */ FIG_portrait = FALSE; c_token++; } else if (almost_equals(c_token, "si$ze")) { /* KB */ c_token++; if (END_OF_COMMAND) { int_error("size: 2 numbers expected", c_token); } else { xsize_t = real(const_express(&a)); if (END_OF_COMMAND) { int_error("size: 2 numbers expected", c_token); xsize_t = 0.; } else { ysize_t = real(const_express(&a)); } if (xsize_t < 2. || ysize_t < 2. || xsize_t > 99. || ysize_t > 99.) { if (xsize_t != 0. || ysize_t != 0.) int_error("size: out of range", c_token); xsize_t = ysize_t = 0.; } } } else if (almost_equals(c_token, "f$ontsize")) { /* KB */ c_token++; if (END_OF_COMMAND) { int_error("fontsize: number expected", c_token); } else { FIG_font_s = (int) real(const_express(&a)); if (FIG_font_s < 5 || FIG_font_s > 36) { int_error("fontsize out of range", c_token - 1); FIG_font_s = 0; } } } else if (almost_equals(c_token, "t$hickness")) { /* KB */ c_token++; if (END_OF_COMMAND) { int_error("thickness: number expected", c_token); } else { FIG_default_thickness = (int) real(const_express(&a)); if (FIG_default_thickness < 1 || FIG_default_thickness > 10) { int_error("thickness out of range", c_token - 1); FIG_default_thickness = 1; } } } else if (almost_equals(c_token, "d$epth")) { /* KB */ c_token++; if (END_OF_COMMAND) { int_error("depth: number expected", c_token); } else { FIG_depth = (int) real(const_express(&a)); if (FIG_depth < 0 || FIG_depth > 99) { int_error("depth out of range", c_token - 1); FIG_depth = 10; } FIG_linedepth = FIG_depth; } } else if (almost_equals(c_token, "poi$ntsmax")) { /* JFS */ /* Skip the word and then expect the number ! */ c_token++; if (END_OF_COMMAND) { int_error("max. points per polyline: number expected", c_token); } else { temp_max = (long) real(const_express(&a)); /* Now check the range for the number */ if ((temp_max > 1) && (temp_max < (FIG_MAX_POINTS + 2))) { /* OK. subtract one to the right number! See other numbers... */ FIG_poly_vec_max = temp_max - 1; } else { char t[128]; sprintf(t, "pointsmax: number out of range (2,%ld)", (FIG_MAX_POINTS + 1)); int_error(t, c_token); } } } else { parse_error = TRUE; int_error(options_list, c_token); } } sprintf(term_options, "%s %s %s %d %s %s %s %d %s %d %s %d", FIG_use_color ? "color" : "monochrome", FIG_is_big ? "big" : "small", "pointsmax", FIG_poly_vec_max + 1, FIG_portrait ? "portrait" : "landscape", FIG_inches ? "inches" : "metric", "fontsize", (FIG_font_s > 0 ? FIG_font_s : (FIG_is_big ? BFIG_FONT_S : FIG_FONT_S)), "thickness", FIG_default_thickness, "depth", FIG_depth); /* JFS, KB */ if (xsize_t > 0. && ysize_t > 0.) { if (xsize_t - (int) xsize_t == 0. && ysize_t - (int) ysize_t == 0.) sprintf(term_options + strlen(term_options), " size %d %d", (int) xsize_t, (int) ysize_t); else sprintf(term_options + strlen(term_options), " size %f %f", xsize_t, ysize_t); } if (!FIG_is_big) { if (FIG_font_s == 0) /* KB */ FIG_font_s = FIG_FONT_S; term->xmax = FIG_XMAX; term->ymax = FIG_YMAX; term->v_tic = FIG_VTIC; term->h_tic = FIG_HTIC; FIG_xoff = FIG_XOFF; FIG_yoff = FIG_YOFF; } else { if (FIG_font_s == 0) /* KB */ FIG_font_s = BFIG_FONT_S; term->xmax = BFIG_XMAX; term->ymax = BFIG_YMAX; term->v_tic = BFIG_VTIC; term->h_tic = BFIG_HTIC; FIG_xoff = BFIG_XOFF; FIG_yoff = BFIG_YOFF; } if (FIG_portrait) { /* KB */ tmax_t = term->xmax; term->xmax = term->ymax; term->ymax = tmax_t; } if (xsize_t > 0. && ysize_t > 0.) { if (FIG_inches) { term->xmax = (unsigned int) (xsize_t * FIG_RES); term->ymax = (unsigned int) (ysize_t * FIG_RES); } else { term->xmax = (unsigned int) (xsize_t / 2.54 * FIG_RES); term->ymax = (unsigned int) (ysize_t / 2.54 * FIG_RES); } } term->v_char = FIG_to_pixel_v(FIG_font_s); term->h_char = FIG_to_pixel_h(FIG_font_s); FIG_thickness = FIG_default_thickness; if (parse_error) { /* JFS, KB */ int_error(options_list, c_token); } } TERM_PUBLIC void FIG_init() { FIG_posx = FIG_posy = 0; FIG_polyvec_stat = FIG_poly_new; FIG_linetype(-1); FIG_justify_text(LEFT); FIG_text_angle(0); FIG_line.tagged = FIG_DEFAULT; FIG_line.distrib = FIG_DEFAULT; FIG_line.type = T_POLYLINE; FIG_line.style = 0; FIG_line.thickness = FIG_thickness; FIG_line.fill_style = -1; FIG_line.depth = FIG_linedepth; FIG_line.pen_style = 0; FIG_line.for_arrow = NULL; FIG_line.back_arrow = NULL; FIG_line.cap_style = 0; FIG_line.join_style = 0; FIG_line.style_val = 0.0; FIG_line.radius = 0; FIG_line.pic = NULL; FIG_line.next = NULL; fprintf(gpoutfile, "\ %s\n\ %s\n%s\n%s\n%d %d\n", FIG_MAGIC, FIG_ORIENT, FIG_JUST, FIG_UNIT, FIG_RES, FIG_COORD_SYS); } TERM_PUBLIC void FIG_graphics() { FIG_posx = FIG_posy = 0; FIG_polyvec_stat = FIG_poly_new; /* there is no way to have separate pictures in a FIG file */ } TERM_PUBLIC void FIG_text() { /* there is no way to have separate pictures in a FIG file */ FIG_poly_clean(FIG_polyvec_stat); FIG_posx = FIG_posy = 0; fflush(gpoutfile); } /* Line types for FIG work like this: * for monochrome: * -2 : solid (border) * -1 : dotted 4 (axes) * 0 : solid (first curve) * 1 : dotted 3 * 2 : dashed 3 * 3 : dotted 6 * 4 : dashed 6 * ... ... * for color, cycle through colors. once colors are used up, repeat colors * but start using dashed lines of different dash length. don't use white * as a color. */ TERM_PUBLIC void FIG_linetype(linetype) int linetype; /* expect linetype >= -2 */ { int last_FIG_type = FIG_type; int last_FIG_spacing = FIG_spacing; int last_FIG_color = FIG_color; int last_FIG_depth = FIG_linedepth; int last_FIG_thickness = FIG_thickness; FIG_linedepth = FIG_depth; FIG_thickness = FIG_current_linewidth * FIG_default_thickness; if (FIG_thickness < 1) FIG_thickness = 1; FIG_color = DEFAULT; if (linetype < -2) linetype = -2; switch (linetype) { case 0: case -2:{ FIG_type = SOLID_LINE; FIG_spacing = 0.0; if (FIG_use_color) FIG_color = BLACK; break; } case -1:{ FIG_type = DOTTED_LINE; FIG_spacing = 4.0; /* gap */ if (FIG_use_color) FIG_color = BLACK; break; } default:{ /* now linetype >= 1 *//* shouldn't be negative anyway */ FIG_linedepth = FIG_depth + linetype / 1000; linetype %= 1000; /* Thickness of lines is either included in the linetype */ /* (in Fig units) or the default is scaled with the */ /* current 'linewidth'. */ if ((FIG_thickness = linetype / 100) == 0) FIG_thickness = FIG_current_linewidth * FIG_default_thickness; if (FIG_thickness < 1) /* Less than 1 would be invisible */ FIG_thickness = 1; linetype %= 100; if (FIG_use_color) { FIG_type = (linetype >= WHITE); /* dashed line */ FIG_color = linetype % WHITE; FIG_spacing = (linetype / WHITE) * 3; } else { /* monochrome */ FIG_type = linetype % 2 + 1; /* dotted, dashed, ... */ FIG_spacing = (linetype + 1) / 2 * 3; } break; } } if (FIG_type != last_FIG_type || FIG_spacing != last_FIG_spacing || FIG_color != last_FIG_color || FIG_linedepth != last_FIG_depth || FIG_thickness != last_FIG_thickness) FIG_poly_clean(FIG_polyvec_stat); } TERM_PUBLIC void FIG_move(x, y) unsigned int x, y; { int last_FIG_posx = FIG_posx; int last_FIG_posy = FIG_posy; FIG_posx = x; FIG_posy = y; if (FIG_posx != last_FIG_posx || FIG_posy != last_FIG_posy) FIG_poly_clean(FIG_polyvec_stat); } TERM_PUBLIC void FIG_vector(ux, uy) unsigned int ux, uy; { int x = ux, y = uy; if (FIG_polyvec_stat != FIG_poly_part) { FIG_line.pen_color = FIG_color; FIG_line.fill_color = FIG_color; FIG_line.style = FIG_type; FIG_line.style_val = FIG_spacing; FIG_line.depth = FIG_linedepth; FIG_line.thickness = FIG_thickness; FIG_poly_vec_cnt = 0; /* allocate memory for the first point */ FIG_points = (F_point *) gp_realloc(FIG_points, sizeof(F_point), "FIG_points"); /* JFS */ FIG_points[FIG_poly_vec_cnt].x = FIG_xoff + FIG_posx; FIG_points[FIG_poly_vec_cnt].y = term->ymax + FIG_yoff - FIG_posy; FIG_poly_vec_cnt = 1; FIG_polyvec_stat = FIG_poly_part; } /* allocate memory for the next point */ FIG_points = (F_point *) gp_realloc(FIG_points, (FIG_poly_vec_cnt + 1) * sizeof(F_point), "FIG_points"); /* JFS */ FIG_points[FIG_poly_vec_cnt].x = FIG_xoff + x; FIG_points[FIG_poly_vec_cnt].y = term->ymax + FIG_yoff - y; FIG_poly_vec_cnt++; if (FIG_poly_vec_cnt > FIG_poly_vec_max) FIG_poly_clean(FIG_polyvec_stat); FIG_posx = x; FIG_posy = y; } TERM_PUBLIC void FIG_arrow(sx, sy, ex, ey, head) unsigned int sx, sy; /* start coord */ unsigned int ex, ey; /* end coord */ TBOOLEAN head; { FIG_poly_clean(FIG_polyvec_stat); fprintf(gpoutfile, "%d %d %d %d %d %d %d %d %d %9.3f %d %d %d %d %d %d\n", O_POLYLINE, FIG_line.type, FIG_line.style, FIG_line.thickness, FIG_line.pen_color, FIG_line.fill_color, FIG_line.depth, FIG_line.pen_style, FIG_line.fill_style, FIG_line.style_val, FIG_line.join_style, FIG_line.cap_style, FIG_line.radius, head ? 1 : 0, 0, 2); /* arrow line */ if (head) fprintf(gpoutfile, "%d %d %.3f %.3f %.3f\n", 0, 0, 1.0, (double) (term->h_tic / 2 + 1), (double) term->h_tic); fprintf(gpoutfile, "%d %d %d %d\n", FIG_xoff + sx, FIG_yoff + term->ymax - sy, FIG_yoff + ex, FIG_yoff + term->ymax - ey); FIG_posx = ex; FIG_posy = ey; } TERM_PUBLIC void FIG_put_text(x, y, str) unsigned int x, y; char *str; { if (strlen(str) == 0) return; FIG_poly_clean(FIG_polyvec_stat); y -= term->v_char / 2; /* assuming vertical center justified */ fprintf(gpoutfile, "%d %d %d %d %d %d %6.3f %6.3f %d %6.3f %6.3f %d %d %s\\001\n", O_TEXT, FIG_justify, FIG_color, 0, FIG_DEFAULT, FIG_ROMAN_FONT, (float) FIG_font_s, FIG_angle, SPECIAL_TEXT, (float) term->v_char, (float) term->h_char * strlen(str), FIG_xoff + x, term->ymax + FIG_yoff - y, str); } TERM_PUBLIC int FIG_justify_text(mode) enum JUSTIFY mode; { switch (mode) { case LEFT: FIG_justify = T_LEFT_JUSTIFIED; break; case CENTRE: FIG_justify = T_CENTER_JUSTIFIED; break; case RIGHT: FIG_justify = T_RIGHT_JUSTIFIED; break; /* shouldn't happen */ default: FIG_justify = T_LEFT_JUSTIFIED; return (FALSE); break; } return (TRUE); } TERM_PUBLIC int FIG_text_angle(ang) int ang; { if (ang) FIG_angle = Pi / 2.0; /* vertical is pi/2 radians */ else FIG_angle = 0.0; /* horizontal */ return (TRUE); } TERM_PUBLIC void FIG_lpoint(x, y, number) unsigned int x, y; int number; { FIG_type = 0; /* Solid lines for marker outline */ if (number % 100 >= 49 && number % 100 < 99) { /* circles, squares, triangles */ int r, d, h, xpc, ypc; int line_color, fill_color, fill_style; int cnum, tnum, color, depth; FIG_poly_clean(FIG_polyvec_stat); depth = FIG_linedepth - 1; /* Above error bars */ if (number > 1000) depth = FIG_depth + number / 1000 - 1; number %= 1000; if (depth < 0) depth = 0; if (number < 100) color = FIG_color; else if (FIG_use_color) color = number / 100 - 1; else if (number / 100 >= WHITE) color = WHITE; else color = DEFAULT; number %= 100; cnum = (number + 1) % 10; tnum = (number - 49) / 10; if (cnum < 5) line_color = (FIG_use_color ? BLACK : DEFAULT); else line_color = FIG_color; fill_color = color; if (cnum == 0 || cnum == 5) fill_style = -1; else fill_style = (cnum % 5) * 5; xpc = FIG_xoff + x; ypc = term->ymax + FIG_yoff - y; if (tnum == 0) { /* circle */ r = FIG_current_pointsize * term->v_char / 4 + 1; fprintf(gpoutfile, "1 3 %d %d %d %d %d %d %d %6.3f 1 0.000 %d %d %d %d %d %d %d %d\n", FIG_type, FIG_thickness, line_color, fill_color, depth, 0, fill_style, FIG_spacing, xpc, ypc, r, r, xpc, ypc, xpc, ypc - r); } else { fprintf(gpoutfile, "2 3 %d %d %d %d %d %d %d %6.3f 0 0 0 0 0 ", FIG_type, FIG_thickness, line_color, fill_color, depth, 0, fill_style, FIG_spacing); if (tnum == 1) { /* square */ d = FIG_current_pointsize * term->v_char / 4 + 1; fprintf(gpoutfile, "5\n\t%d %d %d %d %d %d %d %d %d %d\n", xpc - d, ypc - d, xpc - d, ypc + d, xpc + d, ypc + d, xpc + d, ypc - d, xpc - d, ypc - d); } else if (tnum == 2) { /* diamond */ d = FIG_current_pointsize * term->v_char / 3 + 1; fprintf(gpoutfile, "5\n\t%d %d %d %d %d %d %d %d %d %d\n", xpc - d, ypc, xpc, ypc + d, xpc + d, ypc, xpc, ypc - d, xpc - d, ypc); } else if (tnum == 3) { /* triangle up */ d = FIG_current_pointsize * term->v_char / 3 + 1; h = d * 4 / 7; /* About d times one 3rd of sqrt(3) */ fprintf(gpoutfile, "4\n\t%d %d %d %d %d %d %d %d\n", xpc - d, ypc + h, xpc, ypc - 2 * h, xpc + d, ypc + h, xpc - d, ypc + h); } else if (tnum == 4) { /* triangle down */ d = FIG_current_pointsize * term->v_char / 3 + 1; h = d * 4 / 7; fprintf(gpoutfile, "4\n\t%d %d %d %d %d %d %d %d\n", xpc - d, ypc - h, xpc, ypc + 2 * h, xpc + d, ypc - h, xpc - d, ypc - h); } } } else do_point(x, y, number); } TERM_PUBLIC void FIG_pointsize(arg_pointsize) double arg_pointsize; { FIG_current_pointsize = arg_pointsize; /* Bug-fix by hkeller@gwdg.de and K.B.: set pointsize for do_point() */ do_pointsize(arg_pointsize * FIG_font_s / (double) FIG_FONT_S); } TERM_PUBLIC void FIG_linewidth(linewidth) double linewidth; { FIG_current_linewidth = linewidth; } TERM_PUBLIC void FIG_reset() { FIG_poly_clean(FIG_polyvec_stat); FIG_posx = FIG_posy = 0; fflush(gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(fig_driver) "fig", "FIG 3.1 graphics language: X graphics editor", FIG_XMAX, FIG_YMAX, FIG_VCHAR, FIG_HCHAR, FIG_VTIC, FIG_HTIC, FIG_options, FIG_init, FIG_reset, FIG_text, null_scale, FIG_graphics, FIG_move, FIG_vector, FIG_linetype, FIG_put_text, FIG_text_angle, FIG_justify_text, FIG_lpoint, FIG_arrow, set_font_null, FIG_pointsize, 0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , 0 /*fillbox */ , FIG_linewidth TERM_TABLE_END(fig_driver) #undef LAST_TERM #define LAST_TERM fig_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(fig) "1 fig", "?commands set terminal fig", "?set terminal fig", "?set term fig", "?terminal fig", "?term fig", "?fig", " The `fig` terminal device generates output in the Fig graphics language.", "", " Syntax:", " set terminal fig {monochrome | color} {small | big}", " {pointsmax }", " {landscape | portrait}", " {metric | inches}", " {fontsize }", " {size }", " {thickness }", " {depth }", "", " `monochrome` and `color` determine whether the picture is black-and-white or", " `color`. `small` and `big` produce a 5x3 or 8x5 inch graph in the default", " `landscape` mode and 3x5 or 5x8 inches in `portrait` mode. ", " sets the maximum number of points per polyline. Default units for editing", " with \"xfig\" may be `metric` or `inches`. `fontsize` sets the size of the", " text font to points. `size` sets (overrides) the size of the drawing", " area to * in units of inches or centimeters depending on the", " `inches` or `metric` setting in effect. `depth` sets the default depth layer", " for all lines and text. The default depth is 10 to leave room for adding", " material with \"xfig\" on top of the plot.", "", " `thickness` sets the default line thickness, which is 1 if not specified.", " Overriding the thickness can be achieved by adding a multiple of 100 to the", " to the `linetype` value for a `plot` command. In a similar way the `depth`", " of plot elements (with respect to the default depth) can be controlled by", " adding a multiple of 1000 to . The depth is then +", " /1000 and the thickness is (%1000)/100 or, if that is", " zero, the default line thickness.", "", " Additional point-plot symbols are also available with the `fig` driver. The", " symbols can be used through `pointtype` values % 100 above 50, with different", " fill intensities controlled by % 5 and outlines in black (for", " % 10 < 5) or in the current color. Available symbols are", " 50 - 59: circles", " 60 - 69: squares", " 70 - 79: diamonds", " 80 - 89: upwards triangles", " 90 - 99: downwards triangles", " The size of these symbols is linked to the font size. The depth of symbols", " is by default one less than the depth for lines to achieve nice error bars.", " If is above 1000, the depth is + /1000-1. If", " %1000 is above 100, the fill color is (%1000)/100-1.", "", " Available fill colors are (from 1 to 9): black, blue, green, cyan, red,", " magenta, yellow, white and dark blue (in monochrome mode: black for 1 to 6", " and white for 7 to 9).", "", " See `plot with` for details of and .", "", " The `big` option is a substitute for the `bfig` terminal in earlier versions,", " which is no longer supported.", "", " Examples:", " set terminal fig monochrome small pointsmax 1000 # defaults", "", " plot 'file.dat' with points linetype 102 pointtype 759", " would produce circles with a blue outline of width 1 and yellow fill color.", "", " plot 'file.dat' using 1:2:3 with err linetype 1 pointtype 554", " would produce errorbars with black lines and circles filled red. These", " circles are one layer above the lines (at depth 9 by default).", "", " To plot the error bars on top of the circles use", " plot 'file.dat' using 1:2:3 with err linetype 1 pointtype 2554" END_HELP(fig) #endif /* TERM_HELP */ #if 0 /* I hope this is enough to stop compilers looking in here * (I think that anything inside #if 0 is still strictly * required to be valid C, rather than just any old junk * like this.) */ /* * FIG : Facility for Interactive Generation of figures * Copyright (c) 1985 by Supoj Sutanthavibul * Parts Copyright (c) 1994 by Brian V. Smith * Parts Copyright (c) 1991 by Paul King * * The X Consortium, and any party obtaining a copy of these files from * the X Consortium, directly or indirectly, is granted, free of charge, a * full and unrestricted irrevocable, world-wide, paid up, royalty-free, * nonexclusive right and license to deal in this software and * documentation files (the "Software"), including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons who receive * copies from any such party to do so, with the only requirement being * that this copyright notice remain intact. This license includes without * limitation a license to do the foregoing actions under any patents of * the party supplying this software to the X Consortium. */ /* The only difference from version 3.0 to version 3.1 is that the position of the "magnet" has been shifted by 14 Fig units. In the 2.1 and older versions of xfig the grid was in multiples of 5 Fig units, but they were on intervals 4, 9, 14, 19, etc. When version 3.0 was created, coordinates were simply multiplied by the ratio of the resolutions (1200/80 = 15) so values like 4 became 60 instead of 74 ((4+1)*15 - 1). This means that figures converted from 2.1 and older files are offset by 14 Fig units but new objects entered with version 3.0 are correct. In version 3.1 the magnet grid is at intervals 0, 75, 150, etc instead of -1, 74, 149, etc. Figures from 2.1 and older are correctly converted now and a warning is popped up when you read in a version 3.0 file that says you may have to offset the figure when you load it, using the x and y offsets in the file panel. -------------------------------------------------------------------------------- Description of the Fig Format Follows -------------------------------------------------------------------------------- (1) The very first line is a comment line containing the name and version: #FIG 3.1 The character # at the first column of a line indicates that the line is a comment line which will be ignored. (2) The first non-comment line consists of two numbers and two strings: int fig_resolution (Fig units/inch) string orientation ("Landscape" or "Portrait") string justification ("Center" or "Flush Left") string units ("Metric" or "Inches") int coordinate_system (1: origin is the lower left corner (NOT USED) 2: upper left) Fig_resolution is the resolution of the figure in the file. Xfig will always write the file with a resolution of 1200ppi so it will scale the figure upon reading it in if its resolution is different from 1200ppi. Pixels are assumed to be square. Xfig will read the orientation string and change the canvas to match either the Landscape or Portrait mode of the figure file. The units specification is self-explanatory. The coordinate_system variable is ignored - the origin is ALWAYS the upper-left corner. ** Coordinates are given in "fig_resolution" units. ** Line thicknesses are given in 1/80 of an inch ("display units"). The minimum line thickness is 0 (no line is drawn) and the maximum is 500. ** dash-lengths/dot-gaps are given in 1/80 of an inch. (3) The rest of the file contains various objects. An object can be one of six classes (or types). 0) Color pseudo-object. 1) Arc. 2) Ellipse which is a generalization of circle. 3) Polyline which includes polygon and box. 4) Spline which includes closed/open control/interpolated spline. 5) Text. 6) Compound object which is composed of one or more objects. In the following elaboration on object formats, every value of Fig output are separated by blank characters or new line ('\n'). The value of the unused parameters will be -1. Some fields are described as "enumeration type" or "bit vector"; the values which these fields can take are defined in the header file object.h. The pen_style field is unused. These values may be defined in some future version of Fig. The two color fields (pen and fill; pen only, for texts) are defined as follows: -1 = Default 0 = Black 1 = Blue 2 = Green 3 = Cyan 4 = Red 5 = Magenta 6 = Yellow 7 = White 8-11 = four shades of blue (dark to lighter) 12-14 = three shades of green (dark to lighter) 15-17 = three shades of cyan (dark to lighter) 18-20 = three shades of red (dark to lighter) 21-23 = three shades of magenta (dark to lighter) 24-26 = three shades of brown (dark to lighter) 27-30 = four shades of pink (dark to lighter) 31 = Gold values from 32 to 543 (512 total) are user colors and are defined in color pseudo-objects (type 0) For WHITE color, the area fill field is defined as follows: -1 = not filled 0 = black ... values from 1 to 19 are shades of grey, from darker to lighter 20 = white 21-40 not used 41-56 see patterns for colors, below For BLACK or DEFAULT color, the area fill field is defined as follows: -1 = not filled 0 = white ... values from 1 to 19 are shades of grey, from lighter to darker 20 = black 21-40 not used 41-56 see patterns for colors, below For all other colors, the area fill field is defined as follows: -1 = not filled 0 = black ... values from 1 to 19 are "shades" of the color, from darker to lighter. A shade is defined as the color mixed with black 20 = full saturation of the color ... values from 21 to 39 are "tints" of the color from the color to white. A tint is defined as the color mixed with white 40 = white 41 = 30 degree left diagonal pattern 42 = 30 degree right diagonal pattern 43 = 30 degree crosshatch 44 = 45 degree left diagonal pattern 45 = 45 degree right diagonal pattern 46 = 45 degree crosshatch 47 = bricks 48 = circles 49 = horizontal lines 50 = vertical lines 51 = crosshatch 52 = fish scales 53 = small fish scales 54 = octagons 55 = horizontal "tire treads" 56 = vertical "tire treads" The depth field is defined as follows: 0 ... 999 where larger value means object is deeper than (under) objects with smaller depth The line_style field is defined as follows: -1 = Default 0 = Solid 1 = Dashed 2 = Dotted The style_val field is defined as the length, in 1/80 inches, of the on/off dashes for dashed lines, and the distance between the dots, in 1/80 inches, for dotted lines. The join_style field is defined FOR LINES only as follows: 0 = Miter (the default in xfig 2.1 and earlier) 1 = Bevel 2 = Round The cap_style field is defined FOR LINES, OPEN SPLINES and ARCS only as follows: 0 = Butt (the default in xfig 2.1 and earlier) 1 = Round 2 = Projecting The arrow_type field is defined for LINES, ARCS and OPEN SPLINES only as follows: 0 = Stick-type (the default in xfig 2.1 and earlier) 1 = Closed triangle: |\ | \ | \ | / | / |/ 2 = Closed with "indented" butt: |\ \ \ \ \ \ \ / / / / / / |/ 3 = Closed with "pointed" butt: |\ / \ / \ / \ \ / \ / \ / |/ The arrow_style field is defined for LINES, ARCS and OPEN SPLINES only as follows: 0 = Hollow (actually filled with white) 1 = Filled with pen_color (3.0) OBJECT DEFINITION: (3.1) Color Pseudo-objects (user-defined colors) This is used to define arbitrary colors beyond the 32 standard colors. The color objects must be defined before any other Fig objects. First line: type name (brief description) ---- ---- ------------------- int object_code (always 0) int color_number (color number, from 32-543 (512 total)) hex string rgb values (hexadecimal string describing red, green and blue values (e.g. #330099) ) (3.2) ARC First line: type name (brief description) ---- ---- ------------------- int object_code (always 5) int sub_type (0: pie-wedge (closed) 1: open ended arc) int line_style (enumeration type) int line_thickness (1/80 inch) int pen_color (enumeration type, pen color) int fill_color (enumeration type, fill color) int depth (enumeration type) int pen_style (pen style, not used) int area_fill (enumeration type, -1 = no fill) float style_val (1/80 inch) int cap_style (enumeration type) int direction (0: clockwise, 1: counterclockwise) int forward_arrow (0: no forward arrow, 1: on) int backward_arrow (0: no forward arrow, 1: on) float center_x, center_y (center of the arc) int x1, y1 (Fig units, the 1st point the user entered) int x2, y2 (Fig units, the 2nd point) int x3, y3 (Fig units, the last point) Forward arrow line (Optional; absent if forward_arrow is 0): type name (brief description) ---- ---- ------------------- int arrow_type (enumeration type) int arrow_style (enumeration type) float arrow_thickness (1/80 inch) float arrow_width (Fig units) float arrow_height (Fig units) Backward arrow line (Optional; absent if backward_arrow is 0): type name (brief description) ---- ---- ------------------- int arrow_type (enumeration type) int arrow_style (enumeration type) float arrow_thickness (1/80 inch) float arrow_width (Fig units) float arrow_height (Fig units) (3.3) COMPOUND A line with object code 6 signifies the start of a compound. There are four more numbers on this line which indicate the upper right corner and the lower left corner of the bounding box of this compound. A line with object code -6 signifies the end of the compound. Compound may be nested. First line: type name (brief description) ---- ---- ------------------- int object_code (always 6) int upperright_corner_x (Fig units) int upperright_corner_y (Fig units) int lowerleft_corner_x (Fig units) int lowerleft_corner_y (Fig units) Subsequent lines: objects . . Last line: -6 (3.4) ELLIPSE First line: type name (brief description) ---- ---- ------------------- int object_code (always 1) int sub_type (1: ellipse defined by radiuses 2: ellipse defined by diameters 3: circle defined by radius 4: circle defined by diameter) int line_style (enumeration type) int thickness (1/80 inch) int pen_color (enumeration type, pen color) int fill_color (enumeration type, fill color) int depth (enumeration type) int pen_style (pen style, not used) int area_fill (enumeration type, -1 = no fill) float style_val (1/80 inch) int direction (always 1) float angle (radians, the angle of the x-axis) int center_x, center_y (Fig units) int radius_x, radius_y (Fig units) int start_x, start_y (Fig units; the 1st point entered) int end_x, end_y (Fig units; the last point entered) (3.5) POLYLINE First line: type name (brief description) ---- ---- ------------------- int object_code (always 2) int sub_type (1: polyline 2: box 3: polygon 4: arc-box) 5: imported-picture bounding-box) int line_style (enumeration type) int thickness (1/80 inch) int pen_color (enumeration type, pen color) int fill_color (enumeration type, fill color) int depth (enumeration type) int pen_style (pen style, not used) int area_fill (enumeration type, -1 = no fill) float style_val (1/80 inch) int join_style (enumeration type) int cap_style (enumeration type, only used for POLYLINE) int radius (1/80 inch, radius of arc-boxes) int forward_arrow (0: off, 1: on) int backward_arrow (0: off, 1: on) int npoints (number of points in line) Forward arrow line: same as ARC object Backward arrow line: same as ARC object Points line: type name (brief description) ---- ---- ------------------- int x1, y1 (Fig units) int x2, y2 (Fig units) . . int xnpoints ynpoints (this will be the same as the 1st point for polygon and box) PIC line: type name (brief description) ---- ---- ------------------- boolean flipped orientation = normal (0) or flipped (1) char file[] name of picture file to import (3.6) SPLINE First line: type name (brief description) ---- ---- ------------------- int object_code (always 3) int sub_type (0: open spline 1: closed spline 2: open interpolated spline 3: closed interpolated spline) int line_style (See the end of this section) int thickness (1/80 inch) int pen_color (enumeration type, pen color) int fill_color (enumeration type, fill color) int depth (enumeration type) int pen_style (pen style, not used) int area_fill (enumeration type, -1 = no fill) float style_val (1/80 inch) int cap_style (enumeration type, only used for open splines) int forward_arrow (0: off, 1: on) int backward_arrow (0: off, 1: on) int npoints (number of control points in spline) Forward arrow line: same as ARC object Backward arrow line: same as ARC object Points line: same as POLYLINE object Control points line (absent if sub_type is 0 or 1): Control points of interpolated spline. There are two control points for each knots. A section i, of the spline is drawn using Bezier cubic with the following four points: (x ,y ), (rx ,ry ), (lx , ly ), (x , y ). i i i i i+1 i+1 i+1 i+1 For closed interpolated spline the last pair of control points, (lxnpoints,lynpoints) and (rxnpoints,rynpoints) (which can be ignored), are the same as (lx1,ly1) and (rx1,ry1) respectively. type name (brief description) ---- ---- ------------------- float lx1, ly1 (Fig units) float rx1, ry1 (Fig units) float lx2, ly2 (Fig units) float rx2, ry2 (Fig units) . . float lxnpoints, lynpoints (Fig units) float rxnpoints, rynpoints (Fig units) (3.7) TEXT type name (brief description) ---- ---- ------------------- int object (always 4) int sub_type (0: Left justified 1: Center justified 2: Right justified) int color (enumeration type) int depth (enumeration type) int pen_style (enumeration , not used) int font (enumeration type) float font_size (font size in points) float angle (radians, the angle of the text) int font_flags (bit vector) float height (Fig units) float length (Fig units) int x, y (Fig units, coordinate of the origin of the string. If sub_type = 0, it is the lower left corner of the string. If sub_type = 1, it is the lower center. Otherwise it is the lower right corner of the string.) char string[] (ASCII characters; starts after a blank character following the last number and ends before the sequence '\001'. This sequence is not part of the string. Characters above octal 177 are represented by \xxx where xxx is the octal value. This permits Fig files to be edited with 7-bit editors and sent by e-mail without data loss. Note that the string may contain '\n'.) The font_flags field is defined as follows: Bit Description 0 Rigid text (text doesn't scale when scaling compound objects) 1 Special text (for LaTeX) 2 PostScript font (otherwise LaTeX font is used) 3 Hidden text The font field is defined as follows: For font_flags bit 2 = 0 (LaTeX fonts): 0 Default font 1 Roman 2 Bold 3 Italic 4 Sans Serif 5 Typewriter For font_flags bit 3 = 1 (PostScript fonts): -1 Default font 0 Times Roman 1 Times Italic 2 Times Bold 3 Times Bold Italic 4 AvantGarde Book 5 AvantGarde Book Oblique 6 AvantGarde Demi 7 AvantGarde Demi Oblique 8 Bookman Light 9 Bookman Light Italic 10 Bookman Demi 11 Bookman Demi Italic 12 Courier 13 Courier Oblique 14 Courier Bold 15 Courier Bold Oblique 16 Helvetica 17 Helvetica Oblique 18 Helvetica Bold 19 Helvetica Bold Oblique 20 Helvetica Narrow 21 Helvetica Narrow Oblique 22 Helvetica Narrow Bold 23 Helvetica Narrow Bold Oblique 24 New Century Schoolbook Roman 25 New Century Schoolbook Italic 26 New Century Schoolbook Bold 27 New Century Schoolbook Bold Italic 28 Palatino Roman 29 Palatino Italic 30 Palatino Bold 31 Palatino Bold Italic 32 Symbol 33 Zapf Chancery Medium Italic 34 Zapf Dingbats */ #endif /* * $Id: $ */ /* GNUPLOT -- gif.trm */ /*[ * Copyright 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * GD GIF library 1.2 & 1.3 * * To Use: * * set terminal gif ?options ...? * * Where an option is: * * transparent - generate transparent GIFs. The first color will * be the transparent one. * * interlace - generate interlaced GIFs. * * size (in pixels) * * font (small,medium,large) * * xrrggbb - sets the next color. x is the literal character 'x', * rrggbb are the red green and blue components in hex. For example * x00ff00 is green. The background color is set first, then the * color borders, then the X & Y axis, then the plotting colors. * (The wierd color spec is in order to get around limitations * in gnuplot's scanner.) * * This driver is modeled after the PBM driver pbm.trm. * * AUTHORS * Sam Shen * Alex Woo * * CONTRIBUTORS * Alfred Reibenschuh or * * send your comments or suggestions to: * info-gnuplot@cs.dartmouth.edu * * This version outputs either color or monochrome GIFs. The default * is 640x480 pixels. * * link with -Lterm/gd -lgd if your directory structure is gnuplot/term/gd * * gd is not distributed with gnuplot, because of the UNISYS license thing. * * find out about gd from http://www.boutell.com/gd/ * * [Update: as of version 1.3, gd does not use any more UNISYS licensed * code. The gnuplot team may decide to include this version some day.] * */ #include "driver.h" #ifdef TERM_REGISTER register_term(gif) #endif #ifdef TERM_PROTO TERM_PUBLIC void GIF_options __PROTO((void)); TERM_PUBLIC void GIF_init __PROTO((void)); TERM_PUBLIC void GIF_graphics __PROTO((void)); TERM_PUBLIC void GIF_text __PROTO((void)); TERM_PUBLIC void GIF_linetype __PROTO((int linetype)); TERM_PUBLIC void GIF_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GIF_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GIF_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int GIF_text_angle __PROTO((int ang)); TERM_PUBLIC void GIF_reset __PROTO((void)); #include "gd.h" extern gdFontPtr gdFontSmall; /* 6x12 */ extern gdFontPtr gdFontLarge; /* 8x16 */ extern gdFontPtr gdFontMediumBold; /* 7x13 */ #define GREG_XMAX 640 #define GREG_YMAX 480 int GIF_XMAX = GREG_XMAX; int GIF_YMAX = GREG_YMAX; #define GIF_FONT_SMALL 1 #ifdef GIF_FONT_SMALL # define gdfont gdFontSmall # define GIF_VCHAR 12 # define GIF_HCHAR 6 #else # define gdfont gdFontMediumBold # define GIF_VCHAR 13 # define GIF_HCHAR 7 #endif static gdFontPtr GIF_font; #define GIF_VTIC (GREG_YMAX/100) #define GIF_HTIC (GREG_XMAX/150) #define GIF_MAX_COLORS 256 #define GOT_NEXT_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static struct { gdImagePtr image; gdFontPtr font; unsigned int x, y; int height; int charh, charw; int color; int n_colors; int color_table[GIF_MAX_COLORS]; int rgb_table[GIF_MAX_COLORS]; int angle; int flags; int linetype; } gif_state; #define GIF_USE_TRANSPARENT 1 #define GIF_USE_INTERLACE 2 static unsigned int gif_color_rgbs[] = { 0xffffff, /* background: white */ 0x000000, /* borders: black */ 0x404040, /* x & y axes: grey */ 0xff0000, /* color 01: red */ 0x00c000, /* color 02: dark green */ 0x0080ff, /* color 03: dark blue */ 0xc000ff, /* color 04: dark magenta */ 0xc0ff40, /* color 05: yellow */ 0xc04000, /* color 06: orange */ 0x40ff80, /* color 07: sea green */ 0x2020c0, /* color 08: royal blue */ 0x8000c0, /* color 09: dark violet */ /* please note: these colors are optimized for web216 compatibility */ 0x006080, /* DeepSkyBlue4 */ 0x008000, /* green4 */ 0x008040, /* SpringGreen4 */ 0x008080, /* dark cyan, turquoise4 */ 0x00c060, /* SpringGreen3 */ 0x00c0c0, /* cyan3, turquoise3 */ 0x00ff00, /* green */ 0x208020, /* forest green */ 0x306080, /* SteelBlue4 */ 0x404040, /* grey25-31 */ 0x408000, /* chartreuse4 */ 0x000080, /* dark blue, navy blue */ 0x806000, /* DarkGoldenrod4 */ 0x806010, /* goldenrod4 */ 0x806060, /* pink4 */ 0x806080, /* plum4 */ 0x0000c0, /* medium blue */ 0x0000ff, /* blue */ 0x006000, /* dark green */ 0x40c080, /* SeaGreen3 */ 0x60a0c0, /* SkyBlue3 */ 0x60c000, /* chartreuse3 */ 0x60c0a0, /* medium aquamarine */ 0x800000, /* dark red */ 0x800080, /* dark magenta */ 0x602080, /* DarkOrchid4 */ 0x606060, /* dim grey */ 0x00ffff, /* cyan1, turquoise1 */ 0x202020, /* grey13-18 */ 0x204040, /* dark slate grey */ 0x204080, /* RoyalBlue4 */ 0x608020, /* olive drab */ 0x608060, /* DarkSeaGreen4 */ 0x608080, /* LightBlue4, PaleTurquoise4 */ 0x808040, /* LightGoldenrod4, khaki4 */ 0x808080, /* grey51-56 */ 0xa0a0a0, /* dark grey, grey63-68 */ 0xa0d0e0, /* light blue */ 0xc02020, /* firebrick3 */ 0xc06000, /* DarkOrange3 */ 0x80c0e0, /* sky blue */ 0xc060c0, /* orchid3 */ 0xc08000, /* orange3 */ 0xc08060, /* LightSalmon3 */ 0xff4000, /* orange red */ 0xff4040, /* brown1, tomato */ 0x80c0ff, /* light sky blue */ 0xff8060, /* salmon */ 0xff8080, /* light coral */ 0xc0a000, /* gold3 */ 0xc0c0c0, /* grey76-81, honeydew3, ivory3, snow3 */ 0xc0ffc0, /* DarkSeaGreen1 */ 0xff0000, /* red */ 0xff00ff, /* magenta */ 0xff80a0, /* PaleVioletRed1 */ 0xff80ff, /* orchid1 */ 0xc0c0a0, /* LemonChiffon3 */ 0xff6060, /* IndianRed1 */ 0xff8000, /* dark orange */ 0xffa000, /* orange */ 0x80e0e0, /* CadetBlue2, DarkSlateGray2 */ 0xa0e0e0, /* pale turquoise */ 0xa0ff20, /* green yellow */ 0xc00000, /* red3 */ 0xc000c0, /* magenta3 */ 0xa02020, /* brown */ 0xa020ff, /* purple */ 0x802000, /* OrangeRed4 */ 0x802020, /* brown4 */ 0x804000, /* DarkOrange4 */ 0x804020, /* sienna4 */ 0x804080, /* orchid4 */ 0x8060c0, /* MediumPurple3 */ 0x8060ff, /* SlateBlue1 */ 0x808000, /* yellow4 */ 0xa080ff, /* MediumPurple1 */ 0xc06080, /* PaleVioletRed3 */ 0xc0c000, /* yellow3 */ 0xff8040, /* sienna1 */ 0xffa040, /* tan1 */ 0xffa060, /* sandy brown */ 0xffa070, /* light salmon */ 0xffc020, /* goldenrod1 */ 0xffc0c0, /* RosyBrown1, pink */ 0xffff00, /* yellow */ 0xffff80, /* khaki1 */ 0xffffc0 /* lemon chiffon */ }; #define GIF_N_DEFAULT_COLORS (sizeof(gif_color_rgbs)/sizeof(gif_color_rgbs[0])) /* * _options() Called when terminal type is selected. * This procedure should parse options on the command line. A list of the * currently selected options should be stored in term_options[] in a form * suitable for use with the set term command. term_options[] is used by * the save command. Use options_null() if no options are available. */ TERM_PUBLIC void GIF_options() { int gif_font, i; term_options[0] = NUL; gif_state.n_colors = 0; gif_state.flags = 0; gif_font = 1; GIF_font = gdfont; while (!END_OF_COMMAND) { if (almost_equals(c_token, "t$ransparent")) { gif_state.flags |= GIF_USE_TRANSPARENT; ++c_token; } else if (almost_equals(c_token, "i$nterlace")) { gif_state.flags |= GIF_USE_INTERLACE; ++c_token; } else if (almost_equals(c_token, "s$mall")) { GIF_font = gdFontSmall; gif_font = 1; term->v_char = (unsigned int) (12); term->h_char = (unsigned int) (6); ++c_token; } else if (almost_equals(c_token, "m$edium")) { GIF_font = gdFontMediumBold; gif_font = 2; term->v_char = (unsigned int) (13); term->h_char = (unsigned int) (7); ++c_token; } else if (almost_equals(c_token, "l$arge")) { GIF_font = gdFontLarge; gif_font = 3; term->v_char = (unsigned int) (16); term->h_char = (unsigned int) (8); ++c_token; } else if (almost_equals(c_token, "si$ze")) { struct value s; c_token++; if (END_OF_COMMAND) { GIF_XMAX = GREG_XMAX; GIF_YMAX = GREG_YMAX; term->v_tic = GIF_YMAX / 80; term->h_tic = GIF_XMAX / 80; } else { GIF_XMAX = real(const_express(&s)); if (equals(c_token, ",")) { c_token++; GIF_YMAX = real(const_express(&s)); term->v_tic = GIF_YMAX / 80; term->h_tic = GIF_XMAX / 80; term->ymax = GIF_YMAX; term->xmax = GIF_XMAX; } } } else { /* not "size" */ char *string = input_line + token[c_token].start_index; unsigned long color; if (sscanf(string, "x%lx", &color) != 1) { int_error("invalid color spec, must be xRRGGBB", c_token); } else if (gif_state.n_colors == GIF_MAX_COLORS) { int_warn("too many colors, ingoring", c_token); ++c_token; } else { gif_state.rgb_table[gif_state.n_colors++] = color; ++c_token; } } } /* now generate options string */ if (gif_state.flags & GIF_USE_TRANSPARENT) { strcat(term_options, "transparent "); } if (gif_state.flags & GIF_USE_INTERLACE) { strcat(term_options, "interlace "); } switch (gif_font) { case 1: strcat(term_options, "small "); break; case 2: strcat(term_options, "medium "); break; case 3: strcat(term_options, "large "); break; } sprintf(term_options + strlen(term_options), "size %d,%d ", GIF_XMAX, GIF_YMAX); for (i = 0; i < gif_state.n_colors; i++) { sprintf(term_options + strlen(term_options), "x%06x ", gif_state.rgb_table[i]); } } /* * _init() Called once, when the device is first selected. This procedure * should set up things that only need to be set once, like handshaking and * character sets etc... */ TERM_PUBLIC void GIF_init() { gif_state.linetype = 0; } /* * _reset() Called when gnuplot is exited, the output device changed or * the terminal type changed. This procedure should reset the device, * possibly flushing a buffer somewhere or generating a form feed. */ TERM_PUBLIC void GIF_reset() { } /* * _graphics() Called just before a plot is going to be displayed. This * procedure should set the device into graphics mode. Devices which can't * be used as terminals (like plotters) will probably be in graphics mode * always and therefore won't need this. */ TERM_PUBLIC void GIF_graphics() { int i; unsigned int rgb; gif_state.font = GIF_font; gif_state.color = 0; gif_state.image = gdImageCreate((int) (xsize * GIF_XMAX), (int) (ysize * GIF_YMAX)); gif_state.height = (int) (ysize * GIF_YMAX); gif_state.charw = term->h_char; /* gif_state.font->w; */ gif_state.charh = term->v_char; /* gif_state.font->h; */ for (i = gif_state.n_colors; i < GIF_N_DEFAULT_COLORS; i++) gif_state.rgb_table[i] = gif_color_rgbs[i]; if (gif_state.n_colors < GIF_N_DEFAULT_COLORS) gif_state.n_colors = GIF_N_DEFAULT_COLORS; for (i = 0; i < gif_state.n_colors; i++) { rgb = gif_state.rgb_table[i]; gif_state.color_table[i] = gdImageColorAllocate(gif_state.image, (rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff); } if (gif_state.flags & GIF_USE_TRANSPARENT) gdImageColorTransparent(gif_state.image, gif_state.color_table[0]); else gdImageColorTransparent(gif_state.image, -1); } /* * _text() Called immediately after a plot is displayed. This procedure * should set the device back into text mode if it is also a terminal, so * that commands can be seen as they're typed. Again, this will probably * do nothing if the device can't be used as a terminal. */ TERM_PUBLIC void GIF_text() { if (gif_state.flags & GIF_USE_INTERLACE) gdImageInterlace(gif_state.image, 1); gdImageGif(gif_state.image, gpoutfile); gdImageDestroy(gif_state.image); } /* _move(x,y) Called at the start of a line. The cursor should move to the * (x,y) position without drawing. */ TERM_PUBLIC void GIF_move(unsigned int x, unsigned int y) { gif_state.x = x; gif_state.y = y; } /* _vector(x,y) Called when a line is to be drawn. This should display a line * from the last (x,y) position given by _move() or _vector() to this new (x,y) * position. */ TERM_PUBLIC void GIF_vector(unsigned int x, unsigned int y) { int gif_linetype_dotted[5]; if (gif_state.linetype == -1) { gif_linetype_dotted[0] = gif_state.color_table[2]; gif_linetype_dotted[1] = gif_state.color_table[2]; gif_linetype_dotted[2] = gif_state.color_table[0]; gif_linetype_dotted[3] = gif_state.color_table[0]; gif_linetype_dotted[4] = gif_state.color_table[0]; gdImageSetStyle(gif_state.image, gif_linetype_dotted, 5); gdImageLine(gif_state.image, gif_state.x, gif_state.height - gif_state.y, x, gif_state.height - y, gdStyled); } else { gdImageLine(gif_state.image, gif_state.x, gif_state.height - gif_state.y, x, gif_state.height - y, gif_state.color); } gif_state.x = x; gif_state.y = y; } /* _linetype(lt) Called to set the line type before text is displayed or * line(s) plotted. This procedure should select a pen color or line * style if the device has these capabilities. * lt is an integer from -2 to 0 or greater. * An lt of -2 is used for the border of the plot. * An lt of -1 is used for the X and Y axes. * lt 0 and upwards are used for plots 0 and upwards. * If _linetype() is called with lt greater than the available line types, * it should map it to one of the available line types. * Most drivers provide 9 different linetypes (lt is 0 to 8). */ TERM_PUBLIC void GIF_linetype(int type) { if (type >= (gif_state.n_colors - 3)) type %= (gif_state.n_colors - 3); gif_state.color = gif_state.color_table[type + 3]; gif_state.linetype = type; } /* _put_text(x,y,str) Called to display text at the (x,y) position, * while in graphics mode. The text should be vertically (with respect * to the text) justified about (x,y). The text is rotated according * to _text_angle and then horizontally (with respect to the text) * justified according to _justify_text. */ TERM_PUBLIC void GIF_put_text(unsigned int x, unsigned int y, char *string) { if (gif_state.angle == 1) { x -= gif_state.charh / 2; gdImageStringUp(gif_state.image, gif_state.font, x, gif_state.height - y, string, gif_state.color); } else { y += gif_state.charh / 2; gdImageString(gif_state.image, gif_state.font, x, gif_state.height - y, string, gif_state.color); } } /* _text_angle(ang) Called to rotate the text angle when placing the y label. * If ang = 0 then text is horizontal. If ang = 1 then text is vertically * upwards. Returns TRUE if text can be rotated, FALSE otherwise. */ TERM_PUBLIC int GIF_text_angle(int ang) { gif_state.angle = ang; return TRUE; } /* * Local Variables: * mode:C * End: */ #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(gif_driver) "gif", "GIF format [mode] [fontsize] [size] [colors]", GREG_XMAX, GREG_YMAX, GIF_VCHAR, GIF_HCHAR, GIF_VTIC, GIF_HTIC, GIF_options, GIF_init, GIF_reset, GIF_text, null_scale, GIF_graphics, GIF_move, GIF_vector, GIF_linetype, GIF_put_text, GIF_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, /* pointsize */ TERM_CAN_MULTIPLOT | TERM_BINARY TERM_TABLE_END(gif_driver) #undef LAST_TERM #define LAST_TERM gif_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(gif) "1 gif", "?commands set terminal gif", "?set terminal gif", "?set term gif", "?terminal gif", "?term gif", "?gif", " The `gif` terminal driver generates output in GIF format. It uses Thomas", " Boutell's gd library, which is available from http://www.boutell.com/gd/", "", " Syntax:", " set terminal gif {transparent} {interlace}", " {small | medium | large}", " {size ,}", " { ...}", "", " `transparent` instructs the driver to generate transparent GIFs. The first", " color will be the transparent one.", "", " `interlace` instructs the driver to generate interlaced GIFs.", "", " The choice of fonts is `small` (6x12 pixels), `medium` (7x13 Bold) or `large`", " (8x16).", "", " The size is given in pixels---it defaults to 640x480. The number of", " pixels can be also modified by scaling with the `set size` command.", "", " Each color must be of the form 'xrrggbb', where x is the literal character", " 'x' and 'rrggbb' are the red, green and blue components in hex. For example,", " 'x00ff00' is green. The background color is set first, then the border", " colors, then the X & Y axis colors, then the plotting colors. The maximum", " number of colors that can be set is 256.", "", " Examples:", " set terminal gif small size 640,480 \\", " xffffff x000000 x404040 \\", " xff0000 xffa500 x66cdaa xcdb5cd \\", " xadd8e6 x0000ff xdda0dd x9500d3 # defaults", "", " which uses white for the non-transparent background, black for borders, gray", " for the axes, and red, orange, medium aquamarine, thistle 3, light blue, blue,", " plum and dark violet for eight plotting colors.", "", " set terminal gif transparent xffffff \\", " x000000 x202020 x404040 x606060 \\", " x808080 xA0A0A0 xC0C0C0 xE0E0E0 \\", " which uses white for the transparent background, black for borders, dark", " gray for axes, and a gray-scale for the six plotting colors.", "", " The page size is 640x480 pixels. The `gif` driver can create either color", " or monochromatic output, but you have no control over which is produced.", "", " The current version of the `gif` driver does not support animated GIFs." END_HELP(gif) #endif /* TERM_HELP */ /* * $Id: $ */ /* GNUPLOT -- gnugraph.trm */ /*[ * Copyright 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * GNU plot(5) graphics language * * AUTHORS * Tony Richardson from the unixplot.trm by Colin Kelley, Thomas Williams, * and Russell Lang and from post.trm by Russell Lang. * * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov). */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ /* * This version of the 'unixplot' driver produces device independent * output. I've chosen parameter values so that the PostScript output * produced by plot2ps is 5" x 3". You can use the 'set size' command * to get output up to 8.25" x 8.25", i.e. size values larger than * 1 are okay. */ /* Unixplot library writes to stdout. A fix was put in place by ..!arizona!naucse!jdc to let set term and set output redirect stdout. All other terminals write to gpoutfile. */ /* This is a device independent format, so the output should look * look "reasonable" on any output device. I set things up there so * that the output of plot2ps is 5" x 3" (standard GNUPLOT size). * You can use GNUPLOT's size command to obtain plots to almost the * 8.25" x 8.25" limit. */ #include "driver.h" #ifdef TERM_REGISTER register_term(unixplot) #endif #ifdef TERM_PROTO TERM_PUBLIC void UP_options __PROTO((void)); TERM_PUBLIC void UP_init __PROTO((void)); TERM_PUBLIC void UP_graphics __PROTO((void)); TERM_PUBLIC void UP_text __PROTO((void)); TERM_PUBLIC void UP_linetype __PROTO((int linetype)); TERM_PUBLIC void UP_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void UP_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void UP_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int UP_text_angle __PROTO((int ang)); TERM_PUBLIC int UP_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void UP_reset __PROTO((void)); #define UP_XMAX 19859 #define UP_YMAX 11565 /* UP_VCHAR = ((UP_FONTSIZE*UP_YMAX)/(UP_YINCHES*72)) = UP_FONTSIZE*UP_VFONTSC UP_HCHAR = ((UP_FONTSIZE/2)*UP_XMAX)/(UP_XINCHES*72)) = UP_FONTSIZE*UP_HFONTSC */ #define UP_VFONTSC 53.5 #define UP_VCHAR 535 /* 10 * VFONTSC */ #define UP_HFONTSC 27.6 #define UP_HCHAR 276 /* 10 * HFONTSC */ #define UP_VTIC (UP_YMAX/80) #define UP_HTIC (UP_XMAX/80) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY char up_font[MAX_ID_LEN+1] = "Courier"; /* name of font */ int up_fontsize = 10; /* plot2ps produces a 8.25" x 8.25" square. */ #define UP_SCREENX 32768 #define UP_SCREENY 32768 #define UP_SCRXINC 8.25 #define UP_SCRYINC 8.25 /* We want a 5" x 3" graph by default. */ #define UP_XINCHES 5 #define UP_YINCHES 3 /* UP_XMAX = (UP_SCREENX*UP_XINCHES)/UP_SCRXINC UP_YMAX (UP_SCREENY*UP_YINCHES)/UP_SCRYINC */ #define UP_XLAST (UP_XMAX - 1) #define UP_YLAST (UP_YMAX - 1) /* These offsets center plot2ps output in the middle of the page. The * amount of resizing that can be done is limited. */ /* * #define UP_XOFF 6454 * #define UP_YOFF 10601 */ /* These offsets give a 1" offset from the lower left corner. This * gives a greater range of permissible values in GNUPLOT's size * command. */ #define UP_XOFF 3972 #define UP_YOFF 3972 enum JUSTIFY up_justify = LEFT; #ifdef GNU_PLOTUTILS # define ROTATE(angle) textangle(90*angle) #else # define ROTATE(angle) rotate(0,0,90*angle) #endif #ifdef GNU_PLOTUTILS /* We don't include plot.h from plotutils because of * the name clash with ../plot.h. */ extern int openpl __PROTO((void)); extern int space __PROTO((int, int, int, int)); extern int fontname __PROTO((const char *)); extern int fontsize __PROTO((int)); extern int erase __PROTO((void)); extern int linemod __PROTO((const char *)); extern int move __PROTO((int, int)); extern int cont __PROTO((int, int)); extern int alabel __PROTO((int, int, const char *)); extern int textangle __PROTO((int)); extern int closepl __PROTO((void)); #endif TERM_PUBLIC void UP_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "d$efault")) { strcpy(up_font, "Courier"); up_fontsize = 10; term->v_char = (unsigned int) (up_fontsize * UP_VFONTSC); term->h_char = (unsigned int) (up_fontsize * UP_HFONTSC); c_token++; } } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(up_font, c_token, MAX_ID_LEN); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; up_fontsize = (int) real(const_express(&a)); term->v_char = (unsigned int) (up_fontsize * UP_VFONTSC); term->h_char = (unsigned int) (up_fontsize * UP_HFONTSC); } sprintf(term_options, "\"%s\" %d", up_font, up_fontsize); } TERM_PUBLIC void UP_init() { openpl(); space(0, 0, UP_SCREENX - 1, UP_SCREENY - 1); fontname(up_font); /* #ifdef GNU_PLOTUTILS fontsize((int)((up_fontsize / 72.0 * 8.0) * (UP_SCREENY-1))); #else */ fontsize(up_fontsize); /* #endif */ } TERM_PUBLIC void UP_graphics() { erase(); } TERM_PUBLIC void UP_text() { /* Flush here so that output will be complete. */ fflush(stdout); } TERM_PUBLIC void UP_linetype(linetype) int linetype; { static char *lt[2+5] = { "solid", "longdashed", "solid", "dotted", "shortdashed", "dotdashed", "longdashed"}; if (linetype >= 5) linetype %= 5; linemod(lt[linetype + 2]); } TERM_PUBLIC void UP_move(x, y) unsigned int x, y; { move(x + UP_XOFF, y + UP_YOFF); } TERM_PUBLIC void UP_vector(x, y) unsigned int x, y; { cont(x + UP_XOFF, y + UP_YOFF); } TERM_PUBLIC void UP_put_text(x, y, str) unsigned int x, y; char str[]; { UP_move(x, y); /* Don't adjust x and y! It's done in UP_move. */ switch (up_justify) { case LEFT: alabel('l', 'c', str); break; case CENTRE: alabel('c', 'c', str); break; case RIGHT: alabel('r', 'c', str); break; } } TERM_PUBLIC int UP_text_angle(ang) int ang; { ROTATE(ang); return TRUE; } TERM_PUBLIC int UP_justify_text(mode) enum JUSTIFY mode; { up_justify = mode; return TRUE; } TERM_PUBLIC void UP_reset() { closepl(); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(unixplot_driver) "unixplot", "GNU plot(1) format [\042fontname\042 font_size]", UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, UP_VTIC, UP_HTIC, UP_options, UP_init, UP_reset, UP_text, null_scale, UP_graphics, UP_move, UP_vector, UP_linetype, UP_put_text, UP_text_angle, UP_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(unixplot_driver) #undef LAST_TERM #define LAST_TERM unixplot_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(unixplot) "1 unixplot", "?commands set terminal unixplot", "?set terminal unixplot", "?set term unixplot", "?terminal unixplot", "?term unixplot", "?unixplot", " The `unixplot` driver produces device-independent output in the GNU plot", " graphics language. The default size of the PostScript results generated by", " \"plot2ps\" is 5 x 3 inches; this can be increased up to about 8.25 x 8.25 by", " `set size`.", "", " Syntax:", " set terminal unixplot {\"\"} {}", "", " which defaults to 10-point \"Courier\".", "", " There is a non-GNU version of the `unixplot` driver which cannot be compiled", " unless this version is left out." END_HELP(unixplot) #endif /* * $Id: gpic.trm,v 1.16 1998/04/14 00:17:46 drd Exp $ */ /* GNUPLOT - gpic.trm -*-C-*- */ /*[ * Copyright 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. */ /* * This terminal driver supports: * The GPIC graphics language for groff * * AUTHOR * Sigfrid Lundberg * * send your comments or suggestions to (siglun@volterra.teorekol.lu.se). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(gpic) #endif #ifdef TERM_PROTO TERM_PUBLIC void GPIC_options __PROTO((void)); TERM_PUBLIC void GPIC_init __PROTO((void)); TERM_PUBLIC void GPIC_graphics __PROTO((void)); TERM_PUBLIC void GPIC_text __PROTO((void)); TERM_PUBLIC void GPIC_linetype __PROTO((int linetype)); TERM_PUBLIC void GPIC_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GPIC_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void GPIC_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC void GPIC_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int GPIC_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int GPIC_text_angle __PROTO((int ang)); TERM_PUBLIC void GPIC_reset __PROTO((void)); #define GPIC_DOTS_PER_INCH (300) /* 5 inches wide by 3 inches high (default) */ #define GPIC_XMAX (5*GPIC_DOTS_PER_INCH) #define GPIC_YMAX (3*GPIC_DOTS_PER_INCH) #define GPIC_HTIC (5*GPIC_DOTS_PER_INCH/72) #define GPIC_VTIC (5*GPIC_DOTS_PER_INCH/72) #define GPIC_HCHAR (GPIC_DOTS_PER_INCH*53/10/72) #define GPIC_VCHAR (GPIC_DOTS_PER_INCH*11/72) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #define GPIC_PTS_PER_INCH (72.27) /* dot size in pt */ #define GPIC_UNIT (GPIC_PTS_PER_INCH/GPIC_DOTS_PER_INCH) #define GPIC_coord(x) ((float)x)/((float)GPIC_DOTS_PER_INCH) void GPIC_close_line __PROTO((void)); static float GPIC_x, GPIC_y; static unsigned int GPIC_ltype; enum JUSTIFY GPIC_justify = LEFT; /* for DOTS point style */ static char *GPIC_lines[] = { "thickness 1.0", /* -2 border */ "", /* -1 axes */ "", /* 0 solid thin */ "dotted", "dashed 0.05", /* 1 solid thick */ "dashed 0.075", /* 2 solid Thick */ }; /* number of linetypes above */ #define GPIC_NUMLINES (sizeof(GPIC_lines)/sizeof(char *)) static int GPIC_linecount = 0; /* number of points in line so far */ TERM_PUBLIC void GPIC_options() { float x, y; struct value a; GPIC_x = 0; GPIC_y = 0; if (!END_OF_COMMAND) { x = real(const_express(&a)); if (!END_OF_COMMAND) { y = real(const_express(&a)); GPIC_x = x; GPIC_y = y; } } sprintf(term_options, "Origin is at (%f,%f)", GPIC_x, GPIC_y); } TERM_PUBLIC void GPIC_init() { GPIC_linetype(-1); fputs(".\\\"GNUPLOT: GROFF picture using the gpic preprocessor\n", gpoutfile); } TERM_PUBLIC void GPIC_graphics() { register struct termentry *t = term; fprintf(gpoutfile, ".PS %f %f\n", GPIC_coord(t->xmax), GPIC_coord(t->ymax)); fprintf(gpoutfile, "x=%f; y=%f\n", GPIC_x, GPIC_y); } TERM_PUBLIC void GPIC_text() { GPIC_close_line(); fputs(".PE\n", gpoutfile); } TERM_PUBLIC void GPIC_linetype(linetype) int linetype; { if (linetype >= GPIC_NUMLINES - 2) linetype %= (GPIC_NUMLINES - 2); GPIC_ltype = linetype; } void GPIC_close_line() { if (GPIC_linecount > 0) { fputs("; reset linewid\n", gpoutfile); GPIC_linecount = 0; } } TERM_PUBLIC void GPIC_move(x, y) unsigned int x, y; { GPIC_close_line(); fprintf(gpoutfile, "move to (x+%f,y+%f)\n", GPIC_coord(x), GPIC_coord(y)); GPIC_linecount = 1; } TERM_PUBLIC void GPIC_vector(ux, uy) unsigned int ux, uy; { if (GPIC_linecount == 1) { fprintf(gpoutfile, "line %s to (x+%f,y+%f)", GPIC_lines[GPIC_ltype + 2], GPIC_coord(ux), GPIC_coord(uy)); } else { fprintf(gpoutfile, "\ \\\n\ then to (x+%f,y+%f)", GPIC_coord(ux), GPIC_coord(uy)); } GPIC_linecount++; } TERM_PUBLIC void GPIC_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; TBOOLEAN head; { GPIC_close_line(); if (head) { fprintf(gpoutfile, "arrowhead=7; arrow from x+%f,y+%f to x+%f,y+%f\n", GPIC_coord(sx), GPIC_coord(sy), GPIC_coord(ex), GPIC_coord(ey)); } else { fprintf(gpoutfile, "line from x+%f,y+%f to x+%f,y+%f\n", GPIC_coord(sx), GPIC_coord(sy), GPIC_coord(ex), GPIC_coord(ey)); } } TERM_PUBLIC void GPIC_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char str[]; /* the text */ { GPIC_close_line(); fprintf(gpoutfile, "\"%s\" ", str); switch (GPIC_justify) { case LEFT:{ fputs("ljust ", gpoutfile); break; } case CENTRE:{ fputs(" ", gpoutfile); break; } case RIGHT:{ fputs("rjust ", gpoutfile); break; } } fprintf(gpoutfile, "at x+%f,y+%f\n", GPIC_coord(x), GPIC_coord(y)); } TERM_PUBLIC int GPIC_justify_text(mode) enum JUSTIFY mode; { GPIC_justify = mode; return (TRUE); } TERM_PUBLIC int GPIC_text_angle(ang) int ang; { GPIC_close_line(); return (FALSE); } TERM_PUBLIC void GPIC_reset() { fflush(gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(gpic_driver) "gpic", "GPIC -- Produce graphs in groff using the gpic preprocessor", GPIC_XMAX, GPIC_YMAX, GPIC_VCHAR, GPIC_HCHAR, GPIC_VTIC, GPIC_HTIC, GPIC_options, GPIC_init, GPIC_reset, GPIC_text, null_scale, GPIC_graphics, GPIC_move, GPIC_vector, GPIC_linetype, GPIC_put_text, GPIC_text_angle, GPIC_justify_text, line_and_point, GPIC_arrow, set_font_null TERM_TABLE_END(gpic_driver) #undef LAST_TERM #define LAST_TERM gpic_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(gpic) "1 gpic", "?commands set terminal gpic", "?set terminal gpic", "?set term gpic", "?terminal gpic", "?term gpic", "?gpic", " The `gpic` terminal driver generates GPIC graphs in the Free Software", " Foundations's \"groff\" package. The default size is 5 x 3 inches. The only", " option is the origin, which defaults to (0,0).", "", " Syntax:", " set terminal gpic { }", "", " where `x` and `y` are in inches.", "", " A simple graph can be formatted using", "", " groff -p -mpic -Tps file.pic > file.ps.", "", " The output from pic can be pipe-lined into eqn, so it is possible to put", " complex functions in a graph with the `set label` and `set {x/y}label`", " commands. For instance,", "", " set ylab '@space 0 int from 0 to x alpha ( t ) roman d t@'", "", " will label the y axis with a nice integral if formatted with the command:", "", " gpic filename.pic | geqn -d@@ -Tps | groff -m[macro-package] -Tps", " > filename.ps", "", " Figures made this way can be scaled to fit into a document. The pic language", " is easy to understand, so the graphs can be edited by hand if need be. All", " co-ordinates in the pic-file produced by `gnuplot` are given as x+gnuplotx", " and y+gnuploty. By default x and y are given the value 0. If this line is", " removed with an editor in a number of files, one can put several graphs in", " one figure like this (default size is 5.0x3.0 inches):", "", " .PS 8.0", " x=0;y=3", " copy \"figa.pic\"", " x=5;y=3", " copy \"figb.pic\"", " x=0;y=0", " copy \"figc.pic\"", " x=5;y=0", " copy \"figd.pic\"", " .PE", "", " This will produce an 8-inch-wide figure with four graphs in two rows on top", " of each other.", "", " One can also achieve the same thing by the command", "", " set terminal gpic x y", "", " for example, using", "", " .PS 6.0", " copy \"trig.pic\"", " .PE" END_HELP(gpic) #endif /* TERM_HELP */ /* * $Id: gpr.trm,v 1.13 1998/04/14 00:17:46 drd Exp $ * */ /* GNUPLOT - gpr.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * APOLLO's GPR windowing system * * AUTHORS * Michael Aramini * Roque D Oliveira , oliveria@caen.engin.umich.edu * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(gpr) #endif #ifdef TERM_PROTO TERM_PUBLIC void GPR_init __PROTO((void)); TERM_PUBLIC void GPR_graphics __PROTO((void)); TERM_PUBLIC void GPR_text __PROTO((void)); TERM_PUBLIC void GPR_linetype __PROTO((int linetype)); TERM_PUBLIC void GPR_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GPR_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GPR_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int GPR_text_angle __PROTO((int ang)); TERM_PUBLIC int GPR_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void GPR_reset __PROTO((void)); /* landscape window */ /* #define GPR_XMAX 720 #define GPR_YMAX 450 */ /* portrait window */ #define GPR_XMAX 585 #define GPR_YMAX 735 #define GPR_VCHAR 19 #define GPR_HCHAR 10 #define GPR_VTIC (GPR_YMAX/80) #define GPR_HTIC (GPR_XMAX/80) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void GPRold_linetype __PROTO((int linetype)); static void check __PROTO((char *messagex)); int gpr_isa_pad __PROTO((void)); #include #include #include #include #define GPR_XLAST (GPR_XMAX - 1) #define GPR_YLAST (GPR_YMAX - 1) gpr_$direction_t gpr_path = gpr_$right; /* text angle, 0=horizontal, 1=vertical */ int gpr_ang = 0; /* text is flush left */ enum JUSTIFY gpr_justify = LEFT; static status_$t status; /* set it to 1 when debugging program */ unsigned int Debug = 0; static void check(messagex) char *messagex; { if (status.all = status_$ok) { error_$print(status); printf("Error occurred while %s.\n", messagex); } } /* return whether stdout is a DM pad . Called by term.c */ int gpr_isa_pad() { pad_$isa(1, &status); return (status.all == status_$ok); } TERM_PUBLIC void GPR_init() { gpr_$offset_t dm_bitmap_size; gpr_$bitmap_desc_t dm_bitmap_desc; pad_$window_desc_t window; short font_id; stream_$id_t stream_id; static gpr_$rgb_plane_t hi_plane; static gpr_$disp_char_t display_characteristics; static float screen_size_r_width, screen_size_r_height; static short int disp_len = sizeof(gpr_$disp_char_t); static short int disp_len_returned; /* open a pad to do graphics in */ window.top = 0; window.left = 0; /* 10 accounts for width of window border */ window.width = GPR_XMAX + 10; /* 35 accounts for height of window border */ window.height = GPR_YMAX + 35; pad_$create_window("", (short) 0, pad_$transcript, (short) 1, window, &stream_id, &status); check("pad_$create_window"); /* pad_$set_full_window(stream_id,(short) 1,&window, &status); */ /* pad_$set_border (stream_id,(short) 1, true, &status); */ pad_$set_scale(stream_id, (short) 1, (short) 1, &status); pad_$set_auto_close(stream_id, (short) 1, true, &status); gpr_$inq_disp_characteristics(gpr_$direct, stream_id, disp_len, &display_characteristics, &disp_len_returned, &status); check("in gpr_$inq_display_characteristics"); /*x_window_size in pixels */ screen_size_r_width = (float) display_characteristics.x_window_size; /*y_window_size in pixels */ screen_size_r_height = (float) display_characteristics.y_window_size; hi_plane = display_characteristics.n_planes - 1; if (Debug) printf("width=%f height=%f \n", screen_size_r_width, screen_size_r_height); dm_bitmap_size.x_size = 1280; dm_bitmap_size.y_size = 1024; gpr_$init(gpr_$direct, stream_id, dm_bitmap_size, hi_plane, &dm_bitmap_desc, &status); check("in gpr_$init"); /* gpr_$set_obscured_opt(gpr_$pop_if_obs, &status); check("in gpr_$set_obscured_opt"); */ gpr_$set_auto_refresh(true, &status); check("in gpr_$set_auto_refresh"); /* load a font and make it current */ gpr_$load_font_file("f7x13", 5, &font_id, &status); check("in gpr_$load_font_file"); gpr_$set_text_font(font_id, &status); check("in gpr_$set_text_font"); /* set up color values */ gpr_$set_draw_value((gpr_$pixel_value_t) 7, &status); /* white */ check("in gpr_set_draw_value"); gpr_$set_text_background_value((gpr_$pixel_value_t) (-1), &status); /* trans */ check("in gpr_$set_text_background_value"); gpr_$set_text_value((gpr_$pixel_value_t) 7, &status); /* white */ check("in gpr_$set_text_value"); } TERM_PUBLIC void GPR_graphics() { gpr_$coordinate_t locx, locy, marker_size; (void) gpr_$acquire_display(&status); check("in gpr_$acquire display"); gpr_$clear((gpr_$pixel_value_t) 0, &status); /* black */ check("in gpr_$clear"); if (Debug) { marker_size = (short) 10; locx = (short) 5; locy = (short) 5; gpr_$set_draw_value((gpr_$pixel_value_t) 2, &status); /* white */ gpr_$move((locx - marker_size / 2), locy, &status); gpr_$line((locx + marker_size / 2), locy, &status); gpr_$move(locx, (locy + marker_size / 2), &status); gpr_$line(locx, (locy - marker_size / 2), &status); locx = (short) (GPR_XMAX - 1 - 5); locy = (short) 5; gpr_$set_draw_value((gpr_$pixel_value_t) 3, &status); /* white */ gpr_$move((locx - marker_size / 2), locy, &status); gpr_$line((locx + marker_size / 2), locy, &status); gpr_$move(locx, (locy + marker_size / 2), &status); gpr_$line(locx, (locy - marker_size / 2), &status); locx = (short) 5; locy = (short) (GPR_YMAX - 1 - 5); gpr_$set_draw_value((gpr_$pixel_value_t) 4, &status); /* white */ gpr_$move((locx - marker_size / 2), locy, &status); gpr_$line((locx + marker_size / 2), locy, &status); gpr_$move(locx, (locy + marker_size / 2), &status); gpr_$line(locx, (locy - marker_size / 2), &status); locx = (short) (GPR_XMAX - 1 - 5); locy = (short) (GPR_YMAX - 1 - 5); gpr_$set_draw_value((gpr_$pixel_value_t) 5, &status); /* white */ gpr_$move((locx - marker_size / 2), locy, &status); gpr_$line((locx + marker_size / 2), locy, &status); gpr_$move(locx, (locy + marker_size / 2), &status); gpr_$line(locx, (locy - marker_size / 2), &status); gpr_$set_draw_value((gpr_$pixel_value_t) 7, &status); /* white */ check("in gpr_$set_draw_value"); } /* end if(Debug) */ } TERM_PUBLIC void GPR_text() { gpr_$release_display(&status); check("gpr_$release_display"); } void GPRold_linetype(linetype) int linetype; { static gpr_$line_pattern_t patterns[2 + 5] = { {0xFFFF}, /* solid 1111111111111111 */ {0x3FFF}, /* very long dashed 0011111111111111 */ {0xFFFF}, /* solid 1111111111111111 */ {0x5555}, /* dotted 0101010101010101 */ {0x3333}, /* short dashed 0011001100110011 */ {0xB5AD}, /* dot short-dashed 1011010110101101 */ {0x3FFF} /* very long dashed 0011111111111111 */ }; if (linetype >= 5) linetype %= 5; gpr_$set_line_pattern((short) 1, patterns[linetype + 2], (short) 16, &status); check("in gpr_$set_line_pattern"); } TERM_PUBLIC void GPR_linetype(linetype) int linetype; { static gpr_$line_pattern_t patterns[2 + 7] = { {0xFFFF}, /* solid 1111111111111111 */ {0x1111}, /* long-spaced dotted 0001000100010001 */ {0xFFFF}, /* solid 1111111111111111 */ {0x5555}, /* dotted 0101010101010101 */ {0x3333}, /* short dashed 0011001100110011 */ {0x7777}, /* medium dashed 0111011101110111 */ {0x3F3F}, /* long dashed 0011111100111111 */ {0x0F0F}, /* long-spaced dashed 0000111100001111 */ {0x5F5F} /* dot dashed 0101111101011111 */ }; if (linetype >= 7) linetype %= 7; gpr_$set_line_pattern((short) 1, patterns[linetype + 2], (short) 16, &status); check("in gpr_$set_line_pattern"); /* gpr_$set_draw_value((gpr_$pixel_value_t)(linetype + 1), &status); check("in gpr_$set_draw_value"); */ } TERM_PUBLIC void GPR_move(x, y) unsigned int x, y; { gpr_$move((short) x, (short) (GPR_YMAX - 1 - y), &status); check("in gpr_$move"); } TERM_PUBLIC void GPR_vector(x, y) unsigned int x, y; { gpr_$line((short) x, (short) (GPR_YMAX - 1 - y), &status); check("in gpr_$line"); } TERM_PUBLIC void GPR_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char str[]; /* the text */ { gpr_$coordinate_t xgpr, ygpr; gpr_$offset_t str_size_in_pixels; short int str_len; gpr_$coordinate_t locx, locy, marker_size; if (Debug) { locx = (short) x; locy = (short) (GPR_YMAX - 1 - y); marker_size = (short) 20; gpr_$set_draw_value((gpr_$pixel_value_t) 1, &status); /* white */ gpr_$move((locx - marker_size / 2), locy, &status); gpr_$line((locx + marker_size / 2), locy, &status); gpr_$move(locx, (locy + marker_size / 2), &status); gpr_$line(locx, (locy - marker_size / 2), &status); gpr_$set_draw_value((gpr_$pixel_value_t) 7, &status); /* white */ } xgpr = (short) x; ygpr = (short) (GPR_YMAX - 1 - y); gpr_$set_text_path(gpr_path, &status); check("gpr_$set_text_path"); str_len = (short) strlen(str); /* Calculate how much space (in pixels) the string requires */ gpr_$inq_text_extent(str, str_len, &str_size_in_pixels, &status); check("in gpr_$inq_text_extent"); switch (gpr_justify) { case LEFT: { switch (gpr_path) { case gpr_$up: /* vertical */ { if (Debug) printf("LEFT and up , str=%s\n", str); break; } case gpr_$right: /* horizontal */ { ygpr = ygpr + str_size_in_pixels.y_size / 2; if (Debug) printf("LEFT and right, str=%s \n", str); break; } } break; } case CENTRE: { switch (gpr_path) { case gpr_$up: /* vertical */ { xgpr = xgpr + str_size_in_pixels.x_size / 2; ygpr = ygpr + str_size_in_pixels.y_size / 2; if (Debug) printf("CENTRE and up, str=%s \n", str); break; } case gpr_$right: /* horizontal */ { xgpr = xgpr - str_size_in_pixels.x_size / 2; ygpr = ygpr + str_size_in_pixels.y_size / 2; if (Debug) printf("CENTRE and right, str=%s \n", str); break; } } break; } case RIGHT: { switch (gpr_path) { case gpr_$up: /* vertical */ { ygpr = ygpr + str_size_in_pixels.y_size; if (Debug) printf("RIGHT and up, str=%s \n", str); break; } case gpr_$right: /* horizontal */ { xgpr = xgpr - str_size_in_pixels.x_size; ygpr = ygpr + str_size_in_pixels.y_size / 2; if (Debug) printf("RIGHT and right, str=%s \n", str); break; } } break; } } gpr_$move(xgpr, ygpr, &status); check("in gpr_$move"); gpr_$text(str, str_len, &status); check("in gpr_$text"); } TERM_PUBLIC int GPR_text_angle(ang) int ang; { if (gpr_ang != ang) { gpr_ang = ang; gpr_path = (gpr_ang == 1 ? gpr_$up : gpr_$right); } return (TRUE); } TERM_PUBLIC int GPR_justify_text(mode) enum JUSTIFY mode; { gpr_justify = mode; return (TRUE); } TERM_PUBLIC void GPR_reset() { gpr_$terminate(false, &status); check("in gpr_$terminate"); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(gpr_driver) "gpr", "Apollo Graphics Primitive Resource, fixed-size window", GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR, GPR_VTIC, GPR_HTIC, options_null, GPR_init, GPR_reset, GPR_text, null_scale, GPR_graphics, GPR_move, GPR_vector, GPR_linetype, GPR_put_text, GPR_text_angle, GPR_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(gpr_driver) #undef LAST_TERM #define LAST_TERM gpr_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(gpr) "1 gpr", "?commands set terminal gpr", "?set terminal gpr", "?set term gpr", "?terminal gpr", "?term gpr", "?gpr", " The `gpr` terminal driver supports the Apollo Graphics Primitive Resource", " for a fixed-size window. It has no options.", "", " If a variable window size is desired, use the `apollo` terminal instead." END_HELP(gpr) #endif /* TERM_HELP */ /*[ * GNUPLOT - grass.trm * $Id: grass.trm,v *- * Copyright (C) 1992-1995, 1999. James Darrell McCauley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. * * This software is provided "as is" without express or implied warranty. * * This file is included by ../term.c. * * This terminal driver supports: * GRASS graphics driver * * AUTHOR * James Darrell McCauley, PhD http://soils.ecn.purdue.edu/~mccauley/ * Dept of Agricultural Engineering mccauley@ecn.purdue.edu * Purdue University tel: 317.494.1198 fax: 317.496.1115 * * 05 Apr 1995 - cleaned up code by adding explicit function declarations. * compiles clean with 'gcc -Wall' * 14 Apr 1995 - adapted for new layout, added font selection * * 13 Jan 1999 - Copyright statement changed to new gnuplot copyright * Permission given by orig author in private email (lh) * * send your comments or suggestions to (grassp-list@moon.cecer.army.mil). * ]*/ #include "driver.h" #ifdef TERM_REGISTER register_term(grass) #endif #ifdef TERM_PROTO TERM_PUBLIC void GRASS_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GRASS_options __PROTO((void)); TERM_PUBLIC void GRASS_init __PROTO((void)); TERM_PUBLIC void GRASS_reset __PROTO((void)); TERM_PUBLIC void GRASS_graphics __PROTO((void)); TERM_PUBLIC void GRASS_text __PROTO((void)); TERM_PUBLIC void GRASS_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void GRASS_linetype __PROTO((int lt)); TERM_PUBLIC void GRASS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int GRASS_text_angle __PROTO((int ang)); TERM_PUBLIC int GRASS_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void GRASS_point __PROTO((unsigned int x, unsigned int y, int point)); TERM_PUBLIC int GRASS_set_font __PROTO((char *font)); /* TERM_PUBLIC void GRASS_set_pointsize __PROTO((double size)); */ TERM_PUBLIC void GRASS_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head)); #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #include #include /* #include "gis.h" */ /* this causes conflicts with things in term.c */ #define GRASS_XMAX 1000 #define GRASS_YMAX 1000 #define GRASS_VCHAR 5 #define GRASS_HCHAR 5 #define GRASS_VTIC 3 #define GRASS_HTIC 3 #define PNT_SIZE 3 #define TYPE_DOT -1 #define TYPE_X 0 #define TYPE_PLUS 1 #define TYPE_BOX 2 #define TYPE_DIAMOND 3 /* need type 4 and 5 */ #define TYPE_TRIANGLE 4 #define TYPE_OCTO 5 #define TYPE_ITRIANGLE 6 #define TYPE_FBOX 7 #define TYPE_FTRIANGLE 8 #define TYPE_FITRIANGLE 9 #define TYPE_FOCTO 10 static void cont_abs __PROTO((int x, int y)); static void draw_points_dot __PROTO((int x, int y)); static void draw_points_diamond __PROTO((int x, int y)); static void draw_points_box __PROTO((int x, int y)); static void draw_points_fbox __PROTO((int x, int y)); static void draw_points_itriangle __PROTO((int x, int y)); static void draw_points_fitriangle __PROTO((int x, int y)); static void draw_points_triangle __PROTO((int x, int y)); static void draw_points_ftriangle __PROTO((int x, int y)); static void draw_points_plus __PROTO((int x, int y)); static void draw_points_octo __PROTO((int x, int y)); static void draw_points_focto __PROTO((int x, int y)); static void draw_points_x __PROTO((int x, int y)); static int R__curx, R__cury; static int grass_yoffset; static int grass_xoffset; static int y_max; static int points_buf_x[PNT_SIZE*PNT_SIZE]; /* for filled point types */ static int points_buf_y[PNT_SIZE*PNT_SIZE]; TERM_PUBLIC void GRASS_move (x, y) unsigned int x, y; { int R_move_abs (); /* R_move_abs (grass_xoffset+x, grass_yoffset-y + y_max); */ R_move_abs (grass_xoffset+x, grass_yoffset-y); } static void cont_abs (x, y) int x, y; { int R_cont_abs (); /* R_cont_abs (grass_xoffset+x, grass_xoffset-y + y_max); */ R_cont_abs (grass_xoffset+x, grass_yoffset-y); } TERM_PUBLIC void GRASS_options () { options_null (); /* no options to begin with */ } TERM_PUBLIC void GRASS_init () { /* char buff[128]; */ char window_name[64]; float size = 3.0; /* int backcolor; */ int dots_per_line; int top, b, l, r; /* int textcolor; */ struct termentry *t = term; int G_gisinit(); int R_open_driver(); int D_setup(); int D_get_cur_wind(); int G_fatal_error(); int D_set_cur_wind(); int D_get_screen_window(); int R_set_window(); int R_text_size(); int R_font(); int R_screen_top(); int R_screen_bot(); int D_erase_window(); G_gisinit ("g.gnuplot"); R_open_driver (); D_setup (0); if (D_get_cur_wind (window_name)) G_fatal_error ("No current window"); if (D_set_cur_wind (window_name)) G_fatal_error ("Current window not available"); /* Set up the screen, conversions, and graphics */ D_get_screen_window (&top, &b, &l, &r); /* D_set_overlay_mode (1); */ /* Figure out where to put text */ R_set_window (top, b, l, r); t->xmax = r-l; t->ymax = b-top; grass_xoffset=l; grass_yoffset=b; dots_per_line = (int) (size / 100.0 * (float) (t->ymax)); t->v_char = t->h_char = (int) (.8 * (float) dots_per_line); R_text_size (t->h_char, t->v_char); R_font("romans"); t->v_tic = t->h_tic = 4; y_max = t->ymax; /* kludge? */ R__curx = R_screen_top (); R__cury = R_screen_bot () + grass_yoffset; D_erase_window(); /* fprintf(stderr,"**********************************************\n"); fprintf(stderr,"DIAGNOSTIC TERMINAL SETUP\n"); fprintf(stderr,"top = %d\tb = %d\tl = %d\tr = %d\n", top,b,l,r); fprintf(stderr,"name = %s\n", t->name); fprintf(stderr,"description = %s\n", t->description); fprintf(stderr,"xmax = %d\t", (int)t->xmax); fprintf(stderr,"ymax = %d\n", (int)t->ymax); fprintf(stderr,"v_char = %d\t", (int)t->v_char); fprintf(stderr,"h_char = %d\n", (int)t->h_char); fprintf(stderr,"v_tic = %d\t", (int)t->v_tic); fprintf(stderr,"h_tic = %d\n", (int)t->h_tic); fprintf(stderr,"**********************************************\n\n"); */ } TERM_PUBLIC void GRASS_reset () { int R_standard_color(); int D_translate_color(); int R_flush(); int R_stabilize(); int R_close_driver(); R_standard_color (D_translate_color ("black")); /* D_erase_window(); .* don't clear after g.gnuplot is finished */ R_flush (); R_stabilize (); R_close_driver (); } TERM_PUBLIC void GRASS_graphics () { int D_erase_window(); int R_flush(); int R_stabilize(); int R_standard_color(); int D_translate_color(); R_flush (); R_stabilize (); R_standard_color (D_translate_color ("black")); D_erase_window(); return; } TERM_PUBLIC void GRASS_text () { int R_flush (); int R_stabilize (); R_flush (); R_stabilize (); return; /* device can't be used as a terminal */ } TERM_PUBLIC void GRASS_vector (x, y) unsigned int x, y; { int R_flush (); int R_stabilize (); cont_abs (x, y); R_flush (); R_stabilize (); } TERM_PUBLIC void GRASS_linetype (lt) int lt; { int R_standard_color(); int D_translate_color(); int R_flush (); int R_stabilize (); while (lt > 10) lt-=10; if (lt <= -2) R_standard_color (D_translate_color ("gray")); else if (lt == -1) R_standard_color (D_translate_color ("white")); else if (lt == 0) R_standard_color (D_translate_color ("red")); else if (lt == 1) R_standard_color (D_translate_color ("green")); else if (lt == 2) R_standard_color (D_translate_color ("magenta")); else if (lt == 3) R_standard_color (D_translate_color ("brown")); else if (lt == 4) R_standard_color (D_translate_color ("orange")); else if (lt == 5) R_standard_color (D_translate_color ("yellow")); else if (lt == 6) R_standard_color (D_translate_color ("blue")); else if (lt == 7) R_standard_color (D_translate_color ("violet")); else if (lt == 8) R_standard_color (D_translate_color ("indigo")); else if (lt == 9) R_standard_color (D_translate_color ("gray")); else /* if (lt == 10) */ R_standard_color (D_translate_color ("white")); R_flush (); R_stabilize (); return; } /* originally /usr/grass4/src/display/d.label/cmd/label.c */ TERM_PUBLIC void GRASS_put_text (x, y, str) unsigned int x, y; char *str; { int R_text(); int R_flush (); int R_stabilize (); if (strlen (str) == 0) return; GRASS_move (x, y); /* R_standard_color (D_translate_color ("white")); */ R_text (str); R_flush (); R_stabilize (); } TERM_PUBLIC int GRASS_text_angle (ang) int ang; { int R_text_rotation(); R_text_rotation((float)ang); return TRUE; /* GRASS can (?) rotate text */ } TERM_PUBLIC int GRASS_justify_text (mode) enum JUSTIFY mode; { return (FALSE); /* don't mess with this now */ } TERM_PUBLIC void GRASS_point (x, y, point) unsigned int x,y; int point; { switch (point) { case TYPE_DOT: draw_points_dot (x, y); break; case TYPE_X: draw_points_x (x, y); break; case TYPE_PLUS: draw_points_plus (x, y); break; case TYPE_BOX: draw_points_box (x, y); break; case TYPE_DIAMOND: draw_points_diamond (x, y); break; case TYPE_TRIANGLE: draw_points_triangle (x, y); break; case TYPE_OCTO: draw_points_octo (x, y); break; case TYPE_ITRIANGLE: draw_points_itriangle (x, y); break; case TYPE_FBOX: draw_points_fbox (x, y); break; case TYPE_FTRIANGLE: draw_points_ftriangle (x, y); break; case TYPE_FITRIANGLE: draw_points_fitriangle (x, y); break; case TYPE_FOCTO: draw_points_focto (x, y); break; } } /* modified from /usr/grass4/src/display/d.points/cmd/main.c */ static void draw_points_dot (x, y) int x, y; { GRASS_move (x, y); cont_abs (x, y); } static void draw_points_diamond (x, y) int x, y; { GRASS_move (x, y + PNT_SIZE); GRASS_vector (x + PNT_SIZE, y); GRASS_vector (x, y - PNT_SIZE); GRASS_vector (x - PNT_SIZE, y); GRASS_vector (x, y + PNT_SIZE); } static void draw_points_box (x, y) int x, y; { GRASS_move (x - PNT_SIZE, y - PNT_SIZE); GRASS_vector (x - PNT_SIZE, y + PNT_SIZE); GRASS_vector (x + PNT_SIZE, y + PNT_SIZE); GRASS_vector (x + PNT_SIZE, y - PNT_SIZE); GRASS_vector (x - PNT_SIZE, y - PNT_SIZE); } static void draw_points_fbox (x, y) int x, y; { int R_polygon_abs(); points_buf_x[0] = grass_xoffset + x - PNT_SIZE; points_buf_y[0]= grass_yoffset - (y + PNT_SIZE); points_buf_x[1] = grass_xoffset + x + PNT_SIZE; points_buf_y[1]= grass_yoffset - (y + PNT_SIZE); points_buf_x[2] = grass_xoffset + x + PNT_SIZE; points_buf_y[2]= grass_yoffset - (y - PNT_SIZE); points_buf_x[3] = grass_xoffset + x - PNT_SIZE; points_buf_y[3]= grass_yoffset - (y - PNT_SIZE); R_polygon_abs(points_buf_x, points_buf_y, 4 ); } static void draw_points_itriangle (x, y) int x, y; { GRASS_move (x - PNT_SIZE, y + PNT_SIZE); GRASS_vector (x + PNT_SIZE, y + PNT_SIZE); GRASS_vector (x , y - PNT_SIZE); GRASS_vector (x - PNT_SIZE, y + PNT_SIZE); } static void draw_points_fitriangle (x, y) int x, y; { int R_polygon_abs(); points_buf_x[0] = grass_xoffset + x + PNT_SIZE; points_buf_y[0] = grass_yoffset - (y + PNT_SIZE); points_buf_x[1] = grass_xoffset + x ; points_buf_y[1] = grass_yoffset - (y - PNT_SIZE); points_buf_x[2] = grass_xoffset + x - PNT_SIZE; points_buf_y[2] = grass_yoffset - (y + PNT_SIZE); R_polygon_abs(points_buf_x, points_buf_y, 3 ); } static void draw_points_triangle (x, y) int x, y; { GRASS_move (x - PNT_SIZE, y - PNT_SIZE); GRASS_vector (x , y + PNT_SIZE); GRASS_vector (x + PNT_SIZE, y - PNT_SIZE); GRASS_vector (x - PNT_SIZE, y - PNT_SIZE); } static void draw_points_ftriangle (x, y) int x, y; { int R_polygon_abs(); points_buf_x[0] = grass_xoffset + x; points_buf_y[0]= grass_yoffset - (y + PNT_SIZE); points_buf_x[1] = grass_xoffset + x + PNT_SIZE; points_buf_y[1]= grass_yoffset - (y - PNT_SIZE); points_buf_x[2] = grass_xoffset + x - PNT_SIZE; points_buf_y[2]= grass_yoffset - (y - PNT_SIZE); R_polygon_abs(points_buf_x, points_buf_y, 3 ); } static void draw_points_plus (x, y) int x, y; { GRASS_move (x - PNT_SIZE, y); GRASS_vector (x + PNT_SIZE, y); GRASS_move (x, y - PNT_SIZE); GRASS_vector (x, y + PNT_SIZE); } /* depends on PNT_SIZE */ static void draw_points_octo (x, y) int x, y; { /* CCW */ GRASS_move (x - (int) (PNT_SIZE/3), y - PNT_SIZE); /* 1 */ GRASS_vector (x + (int) (PNT_SIZE/3), y - PNT_SIZE); /* 2 */ GRASS_vector (x + PNT_SIZE, y - (int) (PNT_SIZE/3)); /* 3 */ GRASS_vector (x + PNT_SIZE, y + (int) (PNT_SIZE/3)); /* 4 */ GRASS_vector (x + (int) (PNT_SIZE/3), y + PNT_SIZE); /* 5 */ GRASS_vector (x - (int) (PNT_SIZE/3), y + PNT_SIZE); /* 6 */ GRASS_vector (x - PNT_SIZE, y + (int) (PNT_SIZE/3)); /* 7 */ GRASS_vector (x - PNT_SIZE, y - (int) (PNT_SIZE/3)); /* 8 */ GRASS_vector (x - (int) (PNT_SIZE/3), y - PNT_SIZE); /* 1 */ } /* depends on PNT_SIZE */ static void draw_points_focto (x, y) int x, y; { int R_polygon_abs(); /* CCW */ points_buf_x[0] = grass_xoffset + x + (int) (PNT_SIZE/3); points_buf_y[0] = grass_yoffset - (y - PNT_SIZE); points_buf_x[1] = grass_xoffset + x + PNT_SIZE; points_buf_y[1] = grass_yoffset - (y - (int) (PNT_SIZE/3)); points_buf_x[2] = grass_xoffset + x + PNT_SIZE; points_buf_y[2] = grass_yoffset - (y + (int) (PNT_SIZE/3)); points_buf_x[3] = grass_xoffset + x + (int) (PNT_SIZE/3); points_buf_y[3] = grass_yoffset - (y + PNT_SIZE); points_buf_x[4] = grass_xoffset + x - (int) (PNT_SIZE/3); points_buf_y[4] = grass_yoffset - (y + PNT_SIZE); points_buf_x[5] = grass_xoffset + x - PNT_SIZE; points_buf_y[5] = grass_yoffset - (y + (int) (PNT_SIZE/3)); points_buf_x[6] = grass_xoffset + x - PNT_SIZE; points_buf_y[6] = grass_yoffset - (y - (int) (PNT_SIZE/3)); points_buf_x[7] = grass_xoffset + x - (int) (PNT_SIZE/3); points_buf_y[7] = grass_yoffset - (y - PNT_SIZE); R_polygon_abs(points_buf_x, points_buf_y, 8 ); } static void draw_points_x (x, y) int x,y; { GRASS_move (x - PNT_SIZE, y - PNT_SIZE); GRASS_vector (x + PNT_SIZE, y + PNT_SIZE); GRASS_move (x + PNT_SIZE, y - PNT_SIZE); GRASS_vector (x - PNT_SIZE, y + PNT_SIZE); } TERM_PUBLIC int GRASS_set_font (font) char *font; { char name[32]; int size,sep, R_font(); struct termentry *t = term; int R_text_size (), dots_per_line; /* G_warning(font); */ sep=strcspn(font,","); strncpy(name,font,sep); name[sep]=NUL; sscanf (&(font[sep+1]),"%d",&size); if (size==0) size=3; dots_per_line = (int) (size / 100.0 * (float) (t->ymax)); t->v_char = t->h_char = (int) (.8 * (float) dots_per_line); R_text_size (t->h_char, t->v_char); /* cyrilc,gothgbt,gothgrt,gothitt,greekc,greekcs,greekp, greeks,italicc,italiccs,italict,romanc,romancs,romand, romans,romant,scriptc,scripts */ if (strlen(name) > 5 ) R_font(name); else R_font("romans"); return TRUE; } #ifdef GRASS_POINTSIZE TERM_PUBLIC void GRASS_set_pointsize (size)); double *size; { return; } #endif /* GRASS_POINTSIZE */ /* need to fix */ TERM_PUBLIC void GRASS_arrow (sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; int head; { do_arrow (sx, sy, ex, ey, 1); return; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(grass_driver) "grass", "GRASS Graphics Monitor", GRASS_XMAX, GRASS_YMAX, GRASS_VCHAR, GRASS_HCHAR, GRASS_VTIC, GRASS_HTIC, GRASS_options, GRASS_init, GRASS_reset, GRASS_text, null_scale, GRASS_graphics, GRASS_move, GRASS_vector, GRASS_linetype, GRASS_put_text, GRASS_text_angle, GRASS_justify_text, GRASS_point, GRASS_arrow, GRASS_set_font TERM_TABLE_END(grass_driver) #undef LAST_TERM #define LAST_TERM grass_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(grass) "1 grass", "?commands set terminal grass", "?set terminal grass", "?set term grass", "?terminal grass", "?term grass", "?grass", " The `grass` terminal driver gives `gnuplot` capabilities to users of the ", " GRASS geographic information system. Contact grassp-list@moon.cecer.army.mil", " for more information. Pages are written to the current frame of the GRASS", " Graphics Window. There are no options." END_HELP(grass) #endif /* * $Id: hp26.trm,v 1.14 1998/04/14 00:17:47 drd Exp $ */ /* GNUPLOT - HP26.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * HP2623A * * AUTHORS * luecken@udel.edu (Bruce Lueckenhoff) * hplvlch!ch (Chuck Heller) * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(hp2623a) #endif #ifdef TERM_PROTO TERM_PUBLIC void HP26_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HP26_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HP26_init __PROTO((void)); TERM_PUBLIC void HP26_graphics __PROTO((void)); TERM_PUBLIC void HP26_text __PROTO((void)); TERM_PUBLIC void HP26_reset __PROTO((void)); TERM_PUBLIC int HP26_text_angle __PROTO((int ang)); TERM_PUBLIC void HP26_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void HP26_linetype __PROTO((int linetype)); TERM_PUBLIC void HP26_line_and_point __PROTO((unsigned int x, unsigned int y, int number)); #define HP26_XMAX 512 #define HP26_YMAX 390 /* Use a size 1 character, or a 7 x 10 grid. */ #define HP26_VCHAR 10 #define HP26_HCHAR 7 #define HP26_VTIC 5 #define HP26_HTIC 5 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* include the stream compaction routines */ #define HP26_XLAST (HP26_XMAX - 1) #define HP26_YLAST (HP26_XMAX - 1) void HP26_do_point __PROTO((unsigned int x, unsigned int y, int number)); int compact_slope __PROTO((int xp[], int yp[], int isa_move[], int *sz, double delta)); int compact_int __PROTO((int xp[], int yp[], int isa_move[], int *size)); struct _HP26_Buffer_Node *BN_create __PROTO((int index, int size, int linetype)); void BN_delete __PROTO((struct _HP26_Buffer_Node * the_node)); int HP26_flush __PROTO((struct _HP26_Buffer_Node * the_buff)); void HP26_handle_overflow __PROTO((void)); #include "compact.c" typedef struct _HP26_Buffer_Node { int index; int size; int next; int linetype; int *x; int *y; TBOOLEAN *isa_move; } HP26_Buffer_Node; /* constructor method */ HP26_Buffer_Node *BN_create(index, size, linetype) int index, size, linetype; { HP26_Buffer_Node *the_node; the_node = (HP26_Buffer_Node *) malloc(sizeof(HP26_Buffer_Node)); the_node->index = index; the_node->linetype = linetype; the_node->size = size; the_node->next = 0; the_node->x = (int *) calloc(the_node->size, sizeof(int)); the_node->y = (int *) calloc(the_node->size, sizeof(int)); the_node->isa_move = (TBOOLEAN *) calloc(the_node->size, sizeof(TBOOLEAN)); if (the_node->x == NULL || the_node->y == NULL || the_node->isa_move == NULL) return (NULL); else return (the_node); } /* destructor method */ void BN_delete(the_node) HP26_Buffer_Node *the_node; { free(the_node->x); free(the_node->y); free(the_node->isa_move); free(the_node); } /* 2 for border and axes + 9 for plots + 1 for dots */ #define HP26_gnu_map_size 12 HP26_Buffer_Node *HP26_gnu_map[HP26_gnu_map_size]; HP26_Buffer_Node *HP26_buff; int HP26_pen_x; int HP26_pen_y; int HP26_angle; int HP26_cursor_x; int HP26_cursor_y; TBOOLEAN HP26_in_text; int HP26_linetype_current; int HP26_reduction_int; int HP26_reduction_slope; int HP26_overflows; int HP26_nop_move; int HP26_nop_vect; int HP26_nop_line; /* linetype stuff */ #define SOLID 1 #define USER 2 #define LINE3 3 #define LINE4 4 #define LINE5 5 #define LINE6 6 #define DOTS 7 #define LINE8 8 #define LINE9 9 #define LINE10 10 #define POINT 11 #define swap(a, b) a ^= b; b ^= a; a ^= b; char HP26_bin_short_table[32] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/' }; /* encodes an integer (assumed to be in range) into binary short incremental format (j)*/ #define short_encode(n) (HP26_bin_short_table[n+16]) /* tells whether a given delta_x,delta_y pair can be expressed in binary short incremental format */ #define qualified(dx,dy) ((dx>-17)&&(dy>-17)&&(dx<16)&&(dy<16)) char HP26_bin_table[32] = { ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?' }; /* returns the high byte of integer n in binary absolute format (i) */ #define bin_encode_hi(n) (HP26_bin_table[n>>5]) /* returns the low byte of integer n in binary absolute format (i) */ #define bin_encode_lo(n) (HP26_bin_table[n & 31]) /* the guts of the program -- first checks if any work need be done and, failing that, returns immediately -- tries to compress the vector stream -- goes through the buffer, using binary short incremental (2 bytes/point) as much as possible, even if must output two pairs to express one vector (it's no more expensive, and will hopefully damp any excessive switching back and forth between the two formats) if can't use binary short incremental, use binary absolute(4 bytes/point) -- finally, resets the HP26_next pointer to zero */ int HP26_flush(the_buff) HP26_Buffer_Node *the_buff; { int i, delta_x, delta_y, half_dx, half_dy; int *buff_x, *buff_y; TBOOLEAN *isa_move; TBOOLEAN bin_short; if (the_buff->next == 0) return (FALSE); /* init pointers for easy access */ buff_x = the_buff->x; buff_y = the_buff->y; isa_move = the_buff->isa_move; if (HP26_in_text) { fputs("\033*dT", gpoutfile); HP26_in_text = FALSE; } if (HP26_linetype_current != the_buff->linetype && (the_buff->next > 1 || !isa_move[0])) { fprintf(gpoutfile, "\033*m%dB", the_buff->linetype); HP26_linetype_current = the_buff->linetype; } /* try to compress the stream */ if (the_buff->next > 30 && the_buff->linetype != POINT) { /* HP26_reduction_int += compact_int(buff_x,buff_y,isa_move, &(the_buff->next)); */ HP26_reduction_slope += compact_slope(buff_x, buff_y, isa_move, &(the_buff->next), 0.1); } /* start escape sequence */ fputs("\033*p", gpoutfile); /* initialize the state: binary short incremental or binary absolute */ delta_x = buff_x[0] - HP26_pen_x; delta_y = buff_y[0] - HP26_pen_y; if (qualified(delta_x, delta_y)) { fputc('j', gpoutfile); bin_short = TRUE; } else { fputc('i', gpoutfile); bin_short = FALSE; } /* now work through the list */ for (i = 0; i < the_buff->next; i++) { if (i > 0) { delta_x = buff_x[i] - buff_x[i - 1]; delta_y = buff_y[i] - buff_y[i - 1]; } if ((delta_x == 0) && (delta_y == 0)) { if (i > 0 && !isa_move[i - 1] && !isa_move[i]) { /* allow null vectors only when drawing dots */ HP26_nop_vect++; continue; } else if (isa_move[i]) { /* a null move */ HP26_nop_move++; continue; } } else if (i > 0 && i + 1 < the_buff->next && isa_move[i] && isa_move[i + 1]) { /* consecutive moves are condensed into one */ HP26_nop_move++; continue; } else if (!qualified(delta_x, delta_y) && i > 0 && i + 2 < the_buff->next && isa_move[i] && !isa_move[i + 1] && isa_move[i + 2] && qualified(buff_x[i + 1] - buff_x[i - 1], buff_y[i + 1] - buff_y[i - 1])) { swap(buff_x[i], buff_x[i + 1]); swap(buff_y[i], buff_y[i + 1]); /* set up new delta_x & delta_y */ delta_x = buff_x[i] - buff_x[i - 1]; delta_y = buff_y[i] - buff_y[i - 1]; } if (qualified(delta_x, delta_y)) { if (!bin_short) { fputc('j', gpoutfile); bin_short = TRUE; } if (isa_move[i]) fputc('a', gpoutfile); fputc(short_encode(delta_x), gpoutfile); fputc(short_encode(delta_y), gpoutfile); } else { half_dx = (delta_x + (delta_x > 0 ? 1 : -1)) / 2; half_dy = (delta_y + (delta_y > 0 ? 1 : -1)) / 2; if (bin_short && qualified(half_dx, half_dy)) { if (isa_move[i]) fputc('a', gpoutfile); fputc(short_encode(half_dx), gpoutfile); fputc(short_encode(half_dy), gpoutfile); if (isa_move[i]) fputc('a', gpoutfile); fputc(short_encode(delta_x - half_dx), gpoutfile); fputc(short_encode(delta_y - half_dy), gpoutfile); } else { if (bin_short) { bin_short = FALSE; fputc('i', gpoutfile); } if (isa_move[i]) fputc('a', gpoutfile); fputc(bin_encode_hi(buff_x[i]), gpoutfile); fputc(bin_encode_lo(buff_x[i]), gpoutfile); fputc(bin_encode_hi(buff_y[i]), gpoutfile); fputc(bin_encode_lo(buff_y[i]), gpoutfile); } } } /* end for.. */ /* the term doesn't seem to mind leaving this out */ /* finish the escape sequence */ fputc('Z', gpoutfile); /* set these for next time */ HP26_pen_x = buff_x[the_buff->next - 1]; HP26_pen_y = buff_y[the_buff->next - 1]; the_buff->next = 0; return (TRUE); } void HP26_handle_overflow() { HP26_Buffer_Node *bigger, *old; int x, y; x = (HP26_buff->x)[HP26_buff->next - 1]; y = (HP26_buff->y)[HP26_buff->next - 1]; HP26_flush(HP26_buff); bigger = BN_create(HP26_buff->index, HP26_buff->size * 2, HP26_buff->linetype); if (bigger != NULL) { old = HP26_buff; HP26_gnu_map[bigger->index] = bigger; /* special case since DOTS entry is shared 3 ways */ if (bigger->index == 0) { HP26_gnu_map[1] = bigger; HP26_gnu_map[3] = bigger; } HP26_buff = bigger; BN_delete(old); } (HP26_buff->x)[0] = x; (HP26_buff->y)[0] = y; (HP26_buff->isa_move)[0] = TRUE; HP26_buff->next = 1; HP26_overflows++; } /* checks for NOP, overcapacity condition, and then adds vector to the list */ TERM_PUBLIC void HP26_vector(x, y) unsigned int x, y; { if (HP26_buff->next > 2 && x == (HP26_buff->x)[HP26_buff->next - 1] && y == (HP26_buff->y)[HP26_buff->next - 1] && !(HP26_buff->isa_move)[HP26_buff->next - 1]) { HP26_nop_vect++; return; } if (HP26_buff->next == HP26_buff->size) HP26_handle_overflow(); /* otherwise add to the list */ (HP26_buff->x)[HP26_buff->next] = x; (HP26_buff->y)[HP26_buff->next] = y; (HP26_buff->isa_move)[HP26_buff->next] = FALSE; HP26_buff->next++; } /* checks for NOP, checks for overcapacity, puts self on list */ TERM_PUBLIC void HP26_move(x, y) unsigned int x, y; { if (HP26_buff->next > 0) { if (((HP26_buff->x)[HP26_buff->next - 1] == x) && ((HP26_buff->y)[HP26_buff->next - 1] == y)) { /* null moves are NOP's */ HP26_nop_move++; return; } else if ((HP26_buff->isa_move)[HP26_buff->next - 1]) { /* consecutive moves are NOP's */ (HP26_buff->x)[HP26_buff->next - 1] = x; (HP26_buff->y)[HP26_buff->next - 1] = y; HP26_nop_move++; return; } } if (HP26_buff->next == HP26_buff->size) HP26_handle_overflow(); (HP26_buff->x)[HP26_buff->next] = x; (HP26_buff->y)[HP26_buff->next] = y; (HP26_buff->isa_move)[HP26_buff->next] = TRUE; HP26_buff->next++; return; } TERM_PUBLIC void HP26_init() { HP26_gnu_map[-2 + 2] = BN_create(0, 2048, DOTS); /* border */ HP26_gnu_map[-1 + 2] = HP26_gnu_map[-2 + 2]; /* axes */ HP26_gnu_map[0 + 2] = BN_create(2, 3072, SOLID); /* plot 0 */ HP26_gnu_map[1 + 2] = HP26_gnu_map[-2 + 2]; /* plot 1 */ HP26_gnu_map[2 + 2] = BN_create(4, 1024, LINE5); /* plot 2 */ HP26_gnu_map[3 + 2] = BN_create(5, 256, LINE6); /* plot 3 */ HP26_gnu_map[4 + 2] = BN_create(6, 256, LINE8); /* plot 4 */ HP26_gnu_map[5 + 2] = BN_create(7, 128, LINE9); /* plot 5 */ HP26_gnu_map[6 + 2] = BN_create(8, 128, LINE10); /* plot 6 */ HP26_gnu_map[7 + 2] = BN_create(9, 64, LINE6); /* plot 7 */ HP26_gnu_map[8 + 2] = BN_create(10, 64, LINE4); /* plot 8 */ HP26_gnu_map[9 + 2] = BN_create(11, 512, POINT); /* point plot */ HP26_buff = HP26_gnu_map[10]; /* set to an unlikely linetype */ HP26_linetype_current = 0; /* set to force a linetype change */ HP26_angle = 1; /* left to right, default */ fputs("\033*mp1m2a2Q", gpoutfile); /* 1 2 3 4 1. make text upright 2. select text size 1 3. make SET the default drawing op 4. left justify text */ fflush(gpoutfile); } TERM_PUBLIC void HP26_graphics() { fputs("\033*daflsC", gpoutfile); /* 12345 1. clear graphics display 2. shut off the alphanumeric display 3. graphics cursor off 4. into graphics text mode 5. enable graphics display */ /* set the pen & cursor positions to force an initial absolute move */ HP26_pen_x = HP26_pen_y = -200; HP26_cursor_x = HP26_cursor_y = 800; HP26_in_text = TRUE; /* initialize statistics */ HP26_reduction_int = 0; HP26_reduction_slope = 0; HP26_nop_move = 0; HP26_nop_vect = 0; HP26_nop_line = 0; HP26_overflows = 0; } TERM_PUBLIC void HP26_text() { int i, j, curr; /* always flush the current line first */ for (i = 0; i < HP26_gnu_map_size; i++) if ((HP26_gnu_map[i])->linetype == HP26_linetype_current) HP26_flush(HP26_gnu_map[i]); /* now flush the rest of the lines */ for (i = 0; i < HP26_gnu_map_size; i++) { HP26_flush(HP26_gnu_map[i]); curr = HP26_gnu_map[i]->linetype; for (j = 0; j < HP26_gnu_map_size; j++) if ((HP26_gnu_map[j])->linetype == curr) HP26_flush(HP26_gnu_map[j]); } fputs("\033*deT", gpoutfile); /* 12 1. turn on the alphanumeric display 2. back to text mode */ fflush(gpoutfile); /* informational: tells how many points compressed, how many NOP's of each type, and how many times a buffer overflowed during this plot */ /* if(HP26_reduction_int + HP26_reduction_slope + HP26_nop_move + HP26_nop_vect + HP26_overflows + HP26_nop_line > 0){ if (HP26_reduction_int>0) printf("%d int-compress",HP26_reduction_int); if (HP26_reduction_slope>0) printf("%d slope-compress",HP26_reduction_slope); if (HP26_nop_move>0) printf(" %d nop_move",HP26_nop_move); if (HP26_nop_vect>0) printf(" %d nop_vect",HP26_nop_vect); if (HP26_nop_line>0) printf(" %d nop_line",HP26_nop_line); if (HP26_overflows>0) printf(" %d buffer overflows",HP26_overflows); printf("\n"); } */ } TERM_PUBLIC void HP26_reset() { int i; for (i = 2; i < HP26_gnu_map_size; i++) BN_delete(HP26_gnu_map[i]); } TERM_PUBLIC int HP26_text_angle(ang) int ang; { HP26_angle = ang + 1; fprintf(gpoutfile, "\033*m%dN", HP26_angle); return (TRUE); } TERM_PUBLIC void HP26_put_text(x, y, str) unsigned int x, y; char *str; { char abs_str[10], rel_str[10]; if (!strlen(str)) return; else { fputs("\033*d", gpoutfile); if (!HP26_in_text) { fputc('s', gpoutfile); HP26_in_text = TRUE; } sprintf(rel_str, "%d,%dP", x - HP26_cursor_x, y - HP26_cursor_y); sprintf(abs_str, "%d,%dO", x, y); if (strlen(rel_str) < strlen(abs_str)) fputs(rel_str, gpoutfile); else fputs(abs_str, gpoutfile); fputs(str, gpoutfile); HP26_pen_x = HP26_cursor_x = x; HP26_pen_y = HP26_cursor_y = y; } /* tmp = &(HP26_all_buffers[HP26_linetype_current]); tmp->x[tmp->next] = x; tmp->y[tmp->next] = y; tmp->isa_move[tmp->next] = TRUE; tmp->next++; HP26_flush(tmp); fprintf(gpoutfile,"\033*l%s\r",str); */ return; } /* checks for NOP, sets HP26_buff to point to the right buffer */ TERM_PUBLIC void HP26_linetype(linetype) int linetype; { if (linetype > 8) linetype %= 9; linetype += 2; if (HP26_gnu_map[linetype] == HP26_buff) { HP26_nop_line++; return; /* gnuplot just sent us another NOP */ } HP26_buff = HP26_gnu_map[linetype]; } /* switches to a solid linetype and calls do_point, then switches back */ TERM_PUBLIC void HP26_line_and_point(x, y, number) unsigned int x, y; int number; { int line_save, not_solid; /* shut up warnings with dummy initializer -SB */ line_save = 0; not_solid = (HP26_buff->linetype != SOLID); if (not_solid) { line_save = HP26_buff->linetype; HP26_linetype(0); /*switch to a solid line */ } HP26_do_point(x, y, number); if (not_solid) HP26_linetype(line_save); } /* provides 9 point types so they stay in sync with the linetypes puts simpler point types first on the assumption they are more frequently used */ void HP26_do_point(x, y, number) unsigned int x, y; int number; { int htic, vtic; HP26_Buffer_Node *tmp; vtic = HP26_VTIC / 2; htic = HP26_HTIC / 2; if (number < 0) { /* do a dot -- special case */ tmp = HP26_buff; HP26_buff = HP26_gnu_map[11]; /* point plot */ HP26_vector(x, y); HP26_buff = tmp; } switch (number % 9) { case 0: /* do triangle */ HP26_move(x - htic, y - vtic); HP26_vector(x, y + vtic); HP26_vector(x + htic, y - vtic); HP26_vector(x - htic, y - vtic); break; case 1: /* do nambla */ HP26_move(x - htic, y + vtic); HP26_vector(x, y - vtic); HP26_vector(x + htic, y + vtic); HP26_vector(x - htic, y + vtic); break; case 2: /* do left triangle */ HP26_move(x - htic, y); HP26_vector(x + htic, y + vtic); HP26_vector(x + htic, y - vtic); HP26_vector(x - htic, y); break; case 3: /* do right triangle */ HP26_move(x + htic, y); HP26_vector(x - htic, y + vtic); HP26_vector(x - htic, y - vtic); HP26_vector(x + htic, y); break; case 4: /* do box */ HP26_move(x - htic, y - vtic); HP26_vector(x - htic, y + vtic); HP26_vector(x + htic, y + vtic); HP26_vector(x + htic, y - vtic); HP26_vector(x - htic, y - vtic); break; case 5: /* do plus */ HP26_move(x, y + vtic); HP26_vector(x, y - vtic); HP26_move(x - htic, y); HP26_vector(x + htic, y); break; case 6: /* do X */ HP26_move(x + htic, y + vtic); HP26_vector(x - htic, y - vtic); HP26_move(x - htic, y + vtic); HP26_vector(x + htic, y - vtic); break; default: /* do diamond */ HP26_move(x, y - vtic); HP26_vector(x - htic, y); HP26_vector(x, y + vtic); HP26_vector(x + htic, y); HP26_vector(x, y - vtic); break; } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(hp2623a_driver) "hp2623A", "HP2623A and maybe others", HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR, HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset, HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector, HP26_linetype, HP26_put_text, HP26_text_angle, null_justify_text, HP26_line_and_point, do_arrow, set_font_null TERM_TABLE_END(hp2623a_driver) #undef LAST_TERM #define LAST_TERM hp2623a_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(hp2623a) "1 hp2623a", "?commands set terminal hp2623a", "?set terminal hp2623a", "?set term hp2623a", "?terminal hp2623a", "?term hp2623a", "?hp2623a", " The `hp2623a` terminal driver supports the Hewlett Packard HP2623A. It has", " no options." END_HELP(hp2623a) #endif /* * $Id: hp2648.trm,v 1.14 1998/04/14 00:17:48 drd Exp $ * */ /* GNUPLOT - hp2648.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * HP2648 and HP2647 * * AUTHORS * Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(hp2648) #endif #ifdef TERM_PROTO TERM_PUBLIC void HP2648init __PROTO((void)); TERM_PUBLIC void HP2648graphics __PROTO((void)); TERM_PUBLIC void HP2648text __PROTO((void)); TERM_PUBLIC void HP2648linetype __PROTO((int linetype)); TERM_PUBLIC void HP2648move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HP2648vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HP2648put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int HP2648_text_angle __PROTO((int ang)); TERM_PUBLIC void HP2648reset __PROTO((void)); #define HP2648XMAX 720 #define HP2648YMAX 360 #define HP2648VCHAR 12 #define HP2648HCHAR 7 #define HP2648VTIC 8 #define HP2648HTIC 8 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #define HP2648XLAST (HP2648XMAX - 1) #define HP2648YLAST (HP2648YMAX - 1) TERM_PUBLIC void HP2648init() { fprintf(gpoutfile, "\033*m1m1n136,1cZ"); /* 1 2 3 4 1. mode 2. textsize=1 3. textangle=1 4. define line type 2 to be * * * * etc. */ } TERM_PUBLIC void HP2648graphics() { fprintf(gpoutfile, "\033*dacZ"); /* 1 23 1. mode 2. clear grahics screen 3. graphics video on */ } TERM_PUBLIC void HP2648text() { } TERM_PUBLIC void HP2648linetype(linetype) int linetype; { static int hpline[] = { 1, 7, 1, 4, 5, 6, 8, 9, 10, 7, 2 }; fprintf(gpoutfile, "\033*m%dbZ", hpline[(linetype + 2) % 11]); } TERM_PUBLIC void HP2648move(x, y) unsigned int x, y; { fprintf(gpoutfile, "\033*paf%d,%dZ", x, y); /* 1 23 4 1 plot mode 2 "pen up" 3 goto absolute x,y 4 end command */ } TERM_PUBLIC void HP2648vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "\033*pbf%d,%dZ", x, y); /* 1 1 "pen down" */ } TERM_PUBLIC void HP2648put_text(x, y, str) unsigned int x, y; char *str; { HP2648move(x, y - HP2648VCHAR / 2 + 1); fprintf(gpoutfile, "\033*l%s\n", str); } TERM_PUBLIC int HP2648_text_angle(ang) int ang; { fprintf(gpoutfile, "\033*m%dnZ\n", ang + 1); return TRUE; } TERM_PUBLIC void HP2648reset() { } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(hp2648_driver) "hp2648", "HP2648 and HP2647", HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR, HP2648VTIC, HP2648HTIC, options_null, HP2648init, HP2648reset, HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector, HP2648linetype, HP2648put_text, HP2648_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(hp2648_driver) #undef LAST_TERM #define LAST_TERM hp2648_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(hp2648) "1 hp2648", "?commands set terminal hp2648", "?set terminal hp2648", "?set term hp2648", "?terminal hp2648", "?term hp2648", "?hp2648", " The `hp2648` terminal driver supports the Hewlett Packard HP2647 and HP2648.", " It has no options." END_HELP(hp2648) #endif /* * $Id: hp500c.trm,v 1.17 1998/04/14 00:17:48 drd Exp $ * */ /* GNUPLOT - hp500c.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * hpdj 500c * * AUTHORS * John Engels -- \ * Russell Lang ----> HPLJII.trm * Maurice Castro -- / * UdoHessenauer ----> derived this version from the above one * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* The following HP Deskjet500c driver uses generic bit mapped graphics routines from bitmap.c to build up a bit map in memory. The driver interchanges colomns and lines in order to access entire lines easily and returns the lines to get bits in the right order : (x,y) -> (y,XMAX-1-x). */ /* This interchange is done by calling b_makebitmap() with reversed xmax and ymax, and then setting b_rastermode to TRUE. b_setpixel() will then perform the interchange before each pixel is plotted */ /* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver of Jyrki Yli-Nokari */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(hp500c) #endif #ifdef TERM_PROTO TERM_PUBLIC void HP500Coptions __PROTO((void)); TERM_PUBLIC void HP500Cinit __PROTO((void)); TERM_PUBLIC void HP500Creset __PROTO((void)); TERM_PUBLIC void HP500Clinetype __PROTO((int linetype)); TERM_PUBLIC void HP500Cgraphics __PROTO((void)); TERM_PUBLIC void HP500Ctext __PROTO((void)); #define HP500Ctext_angle b_text_angle #define HP500Cput_text b_put_text #define HP500Cmove b_move #define HP500Cvector b_vector /* default values for term_tbl */ #define HP500C_75PPI_XMAX (1920/4) #define HP500C_75PPI_YMAX (1920/4) #define HP500C_75PPI_HCHAR (1920/4/6) #define HP500C_75PPI_VCHAR (1920/4/10) #define HP500C_75PPI_VTIC 5 #define HP500C_75PPI_HTIC 5 #define GOT_HP500C_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and 75ppi. (Pixel size = 1, 2, 3, 4 dots) */ #define HP500C_DPP (hpdj_dpp) /* dots per pixel */ #define HP500C_PPI (300/HP500C_DPP) /* pixel per inch */ /* make XMAX and YMAX a multiple of 8 */ #define HP500C_XMAX (8*(unsigned int)(xsize*1920/HP500C_DPP/8.0+0.9)) #define HP500C_YMAX (8*(unsigned int)(ysize*1920/HP500C_DPP/8.0+0.9)) /* Courier font with 6 lines per inch */ #define HP500C_VCHAR (HP500C_PPI/6) /* Courier font with 10 caracters per inch */ #define HP500C_HCHAR (HP500C_PPI/10) /* Save current cursor position */ #define HP500C_PUSH_CURSOR fputs("\033&f0S",gpoutfile) /* Restore cursor position */ #define HP500C_POP_CURSOR fputs("\033&f1S",gpoutfile) /* be sure to use courier font with 6lpi and 10cpi */ #define HP500C_COURIER fputs("\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D",gpoutfile) static int HPcompress __PROTO((unsigned char *op, unsigned char *oe, unsigned char *cp)); static unsigned char HPcomplement __PROTO((int c)); static int HPcompress_to_TIFF __PROTO((unsigned char *op, unsigned char *oe, unsigned char *cp)); static int HPnocompress __PROTO((unsigned char *op, unsigned char *oe, unsigned char *cp)); static int hpdj_dpp = 4; static int HP_COMP_MODE = 0; /* bm_pattern not appropriate for 300ppi graphics */ #ifndef GOT_300_PATTERN #define GOT_300_PATTERN static unsigned int b_300ppi_pattern[] = { 0xffff, 0x1111, 0xffff, 0x3333, 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff }; #endif TERM_PUBLIC void HP500Coptions() { char opt[6]; #define HPDJCERROR "expecting dots per inch size 75, 100, 150 or 300 and/or compression method" while (!END_OF_COMMAND) { if (token[c_token].length > 4) int_error(HPDJCERROR, c_token); /* almost_equals() won't accept numbers - use strcmp() instead */ capture(opt, c_token, c_token, 6); if (!strcmp(opt, "75")) { hpdj_dpp = 4; HP_COMP_MODE = 0; } else if (!strcmp(opt, "100")) { hpdj_dpp = 3; HP_COMP_MODE = 0; } else if (!strcmp(opt, "150")) { hpdj_dpp = 2; HP_COMP_MODE = 0; } else if (!strcmp(opt, "300")) { hpdj_dpp = 1; HP_COMP_MODE = 0; } else if (!strcmp(opt, "rle")) { HP_COMP_MODE = 1; } else if (!strcmp(opt, "tiff")) { HP_COMP_MODE = 2; } c_token++; } term->xmax = HP500C_XMAX; term->ymax = HP500C_YMAX; switch (hpdj_dpp) { case 1: strcpy(term_options, "300"); term->v_tic = 15; term->h_tic = 15; break; case 2: strcpy(term_options, "150"); term->v_tic = 8; term->h_tic = 8; break; case 3: strcpy(term_options, "100"); term->v_tic = 6; term->h_tic = 6; break; case 4: strcpy(term_options, "75"); term->v_tic = 5; term->h_tic = 5; break; } switch (HP_COMP_MODE) { case 0: strcat(term_options, " no comp"); break; case 1: strcat(term_options, " RLE"); break; case 2: strcat(term_options, " TIFF"); break; case 3: /* not implemented yet */ strcat(term_options, " Delta Row"); break; } } TERM_PUBLIC void HP500Cinit() { /* HBB 980226: all changes to term-> fields *must* happen here, not * in graphics() !*/ switch (hpdj_dpp) { case 1: b_charsize(FNT13X25); term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; break; case 2: b_charsize(FNT13X25); term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; break; case 3: b_charsize(FNT9X17); term->v_char = FNT9X17_VCHAR; term->h_char = FNT9X17_HCHAR; break; case 4: b_charsize(FNT5X9); term->v_char = FNT5X9_VCHAR; term->h_char = FNT5X9_HCHAR; break; } } TERM_PUBLIC void HP500Creset() { #ifdef VMS fflush_binary(); #endif } /* HP DeskJet 500c routines */ TERM_PUBLIC void HP500Clinetype(linetype) int linetype; { if (linetype < 0) linetype = 7; else if (linetype >= 8) { linetype %= 8; } switch (linetype) { case 0: linetype = 6; break; case 1: linetype = 5; break; case 2: linetype = 3; break; case 3: linetype = 2; break; case 4: linetype = 1; break; case 5: linetype = 4; break; case 6: linetype = 7; } b_setvalue(linetype); } /* void HP500Cpoint(x,y,value) int x; int y; int value; { HP500Clinetype(value); do_point(x,y,value); } */ TERM_PUBLIC void HP500Cgraphics() { /* HBB 980226: moved block of code from here to init() */ /* rotate plot -90 degrees by reversing XMAX and YMAX and by setting b_rastermode to TRUE */ b_makebitmap(HP500C_YMAX, HP500C_XMAX, 3); b_rastermode = TRUE; } /* * Run-length encoding for the DeskJet. We have pairs of * , where count goes from 0 (meaning one count) to 255 * this might double the size of the image. */ static int HPcompress(op, oe, cp) unsigned char *op, *oe, *cp; { unsigned char *ce = cp; while (op < oe) { unsigned char prevchar; unsigned char count; prevchar = *op; /* remember char */ count = 1; /* its read the first time */ while (++op < oe && *op == prevchar && count < 255) { /* set op to the next char */ count++; /* and count it */ } *ce++ = --count; /* were ready, so correct the count */ *ce++ = prevchar; /* and store */ } *ce = 0; /* just to be safe */ return ce - cp; /* length of cbufs */ } static unsigned char HPcomplement(c) int c; { return (unsigned char) (256 - c); } static int HPcompress_to_TIFF(op, oe, cp) unsigned char *op; /* original pointer */ unsigned char *oe; /* end of orig string */ unsigned char *cp; /* pointer for compressed data */ { unsigned char *countposition; unsigned char *ce = cp; while (op < oe) { unsigned char prevchar; unsigned char count; prevchar = *op; /* gelesenes Zeichen aufbewaren */ count = 1; /* bisher wurde es einmal gelesen */ while (++op < oe && *op == prevchar && count < 128) { count++; } *ce = HPcomplement(count - 1); /* remember count for building blocks of literal bytes */ countposition = ce++; *ce++ = prevchar; if (count < 2) { while (op < oe && (prevchar != *op || *op != *(op + 1))) { /* only use rle for at leat 3 equal bytes */ *ce++ = *op; count++; prevchar = *op++; if (op > oe) puts("FATAL op> oe!!\n"); } if (op < oe && prevchar == *op) { op--; count--; ce--; } *countposition = count - 1; } } return ce - cp; } static int HPnocompress(op, oe, cp) unsigned char *op; unsigned char *oe; unsigned char *cp; { unsigned char *ce = cp; while (op < oe) *ce++ = *op++; return ce - cp; } /* 0 compression raster bitmap dump. Compatible with HP DeskJet 500 hopefully compatible with other HP Deskjet printers */ TERM_PUBLIC void HP500Ctext() { register int x, j, row, count = 0; unsigned char *obuf, *oe, *cbuf, *ce; if ((obuf = (unsigned char *) malloc(100 * b_psize)) == 0) puts("FATAL!-- couldn't get enough memory for obuf"); if ((cbuf = (unsigned char *) malloc(400 * b_psize)) == 0) puts("FATAL!-- couldn't get enough memory for cbuf"); oe = obuf; fprintf(gpoutfile, "\ \033*t%dR\ \033*r1A\ \033*b%1dM\ \033*r%dS\ \033*r-3U", HP500C_PPI, HP_COMP_MODE, b_ysize); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; for (j = row; j >= 0; j--) { *oe++ = (char) (*((*b_p)[j] + x)); } switch (HP_COMP_MODE) { case 2: count = HPcompress_to_TIFF(obuf, oe, cbuf); break; case 1: count = HPcompress(obuf, oe, cbuf); break; case 0: count = HPnocompress(obuf, oe, cbuf); break; } fprintf(gpoutfile, "\033*b%dV", count); ce = cbuf; while (count--) fputc(*ce++, gpoutfile); oe = obuf; for (j = row; j >= 0; j--) { *oe++ = (char) (*((*b_p)[j + b_psize] + x)); } switch (HP_COMP_MODE) { case 2: count = HPcompress_to_TIFF(obuf, oe, cbuf); break; case 1: count = HPcompress(obuf, oe, cbuf); break; case 0: count = HPnocompress(obuf, oe, cbuf); break; } fprintf(gpoutfile, "\033*b%dV", count); ce = cbuf; while (count--) fputc(*ce++, gpoutfile); oe = obuf; for (j = row; j >= 0; j--) { *oe++ = (char) (*((*b_p)[j + (2 * b_psize)] + x)); } switch (HP_COMP_MODE) { case 2: count = HPcompress_to_TIFF(obuf, oe, cbuf); break; case 1: count = HPcompress(obuf, oe, cbuf); break; case 0: count = HPnocompress(obuf, oe, cbuf); break; } fprintf(gpoutfile, "\033*b%dW", count); ce = cbuf; while (count--) fputc(*ce++, gpoutfile); oe = obuf; } fputs("\033*rbC", gpoutfile); free(cbuf); free(obuf); b_freebitmap(); #ifndef VMS /* most vms spoolers add a formfeed character */ putc('\f', gpoutfile); #endif /* !VMS */ } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(hp500c_driver) "hp500c", "HP DeskJet 500c, [75 100 150 300] [rle tiff]", HP500C_75PPI_XMAX, HP500C_75PPI_YMAX, HP500C_75PPI_VCHAR, HP500C_75PPI_HCHAR, HP500C_75PPI_VTIC, HP500C_75PPI_HTIC, HP500Coptions, HP500Cinit, HP500Creset, HP500Ctext, null_scale, HP500Cgraphics, HP500Cmove, HP500Cvector, HP500Clinetype, HP500Cput_text, HP500Ctext_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(hp500c_driver) #undef LAST_TERM #define LAST_TERM hp500c_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(hp500c) "1 hp500c", "?commands set terminal hp500c", "?set terminal hp500c", "?set term hp500c", "?terminal hp500c", "?term hp500c", "?hp500c", " The `hp500c` terminal driver supports the Hewlett Packard HP DeskJet 500c.", " It has options for resolution and compression.", "", " Syntax:", " set terminal hp500c {} {}", "", " where `res` can be 75, 100, 150 or 300 dots per inch and `comp` can be \"rle\",", " or \"tiff\". Any other inputs are replaced by the defaults, which are 75 dpi", " and no compression. Rasterization at the higher resolutions may require a", " large amount of memory." END_HELP(hp500c) #endif /* TERM_HELP */ /* * $Id: hpgl.trm,v 1.24 1998/04/14 00:17:49 drd Exp $ */ /* GNUPLOT - hpgl.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * hpgl, hp7550, hp7580b, HP Laserjet III * hp7550 has been replaced by "hpgl 8 eject" * hp7580b has been replaced by "hpgl 4" * * AUTHORS * Colin Kelley, Thomas Williams, Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * * MODIFIED for expanded HPGL/2 and PCL utilites * Tom Swiler (tom@silica.mse.ufl.edu) * Modified June 1995 Ian MacPhedran to support newterm format * Modified October 1995 Ian MacPhedran to simplify HPGL terminals * Modified January 96 by David Denholm and Emmanuel Bigler for cp850 * and iso international character sets */ #define HPGL #define PCL #include "driver.h" #ifdef TERM_REGISTER register_term(hpgl) register_term(pcl5) #endif /* TERM_REGISTER */ #ifdef TERM_PROTO TERM_PUBLIC void HPGL_options __PROTO((void)); TERM_PUBLIC void HPGL2_options __PROTO((void)); TERM_PUBLIC void PCL_options __PROTO((void)); TERM_PUBLIC void HPGL_init __PROTO((void)); /* TERM_PUBLIC void HPGL2_init __PROTO((void)); */ TERM_PUBLIC void PCL_init __PROTO((void)); TERM_PUBLIC void HPGL_graphics __PROTO((void)); TERM_PUBLIC void HPGL2_graphics __PROTO((void)); TERM_PUBLIC void PCL_graphics __PROTO((void)); TERM_PUBLIC void HPGL_text __PROTO((void)); /* TERM_PUBLIC void HPGL2_text __PROTO((void)); */ TERM_PUBLIC void PCL_text __PROTO((void)); TERM_PUBLIC void HPGL_linetype __PROTO((int linetype)); TERM_PUBLIC void HPGL2_linetype __PROTO((int linetype)); TERM_PUBLIC void HPGL_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void HPGL2_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void HPGL_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HPGL_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HPGL2_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HPGL2_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void HPGL2_encode __PROTO((int d)); TERM_PUBLIC int HPGL_text_angle __PROTO((int ang)); TERM_PUBLIC int HPGL2_text_angle __PROTO((int ang)); TERM_PUBLIC void HPGL_reset __PROTO((void)); /* TERM_PUBLIC void HPGL2_reset __PROTO((void)); */ TERM_PUBLIC void PCL_reset __PROTO((void)); TERM_PUBLIC int HPGL2_justify_text __PROTO((enum JUSTIFY just)); #define GOT_HPGL_PROTO #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* * The maximum plot size, in plotter units: */ #define HPGL_PUPI 1016 /* Plotter units per inch */ #define HPGL_XMAX_A 10000 #define HPGL_YMAX_A 7500 #define HPGL_XMAX_B 15200 #define HPGL_YMAX_B 10000 #define HPGL_XMAX HPGL_XMAX_A #define HPGL_YMAX HPGL_YMAX_A #define PCL_XMAX HPGL_XMAX_A #define PCL_YMAX (HPGL_YMAX_A-60) /* * Tic sizes */ #define HPGL_VTIC (HPGL_YMAX/70) #define HPGL_HTIC (HPGL_YMAX/70) #define PCL_VTIC (PCL_YMAX/70) #define PCL_HTIC (PCL_YMAX/70) /* * Font size for HPGL */ #define HPGL_VCHAR (HPGL_YMAX/100*32/10) /* 3.2% */ #define HPGL_HCHAR (HPGL_XMAX/100*12/10) /* 1.2% */ /* * Font size for HPGL/2 */ #define HPGL2_DEF_POINT 14 /* Height of font */ #define HPGL2_DEF_PITCH (3 * 72 / (HPGL2_DEF_POINT * 2)) #define HPGL2_VCHAR ((int) HPGL_PUPI * HPGL2_DEF_POINT / 72) #define HPGL2_HCHAR (HPGL2_VCHAR * 2 / 3) /* * Control constants */ #define DOWN 0 /* Pen is down */ #define UP 1 /* Pen is up */ #define UNKNOWN -10 /* Unknown status for lots of things */ /* * For Polyline Encoded, either use base 64 or base 32. * Save space with base 64, but get 8-bit characters. */ #ifdef NEXT /* unluckily TRUE is defined as ((boolean_t)1) in mach/boolean.h */ #define HPGL2_BASE64 1 #else #define HPGL2_BASE64 TRUE #endif #if HPGL2_BASE64 #define HPGL2_BITS 6 #define HPGL2_LOW_OFFS 63 #define HPGL2_HIGH_OFFS 191 #define HPGL2_MASK 63 #else #define HPGL2_BITS 5 #define HPGL2_LOW_OFFS 63 #define HPGL2_HIGH_OFFS 95 #define HPGL2_MASK 31 #endif /* * Data structures for options */ struct HPGL2_font_str { char *compare, *name; int symbol_set, spacing; double pitch, height; int posture, stroke_weight, typeface; }; struct PCL_mode_str { char *compare, *name, *command; int xmax, ymax; }; /* * The default font goes first. Although it is the ugliest, the * stick font is probably supported by the most devices, so it * becomes the default. */ static struct HPGL2_font_str GPFAR HPGL2_font_table[] = { {"u$nivers", "univers", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4148}, {"s$tick", "stick", 277, 0, HPGL2_DEF_PITCH, 0.0, 0, 0, 48}, {"c$g_times", "cg_times", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4101} }; #define HPGL2_FONTS (sizeof(HPGL2_font_table) / sizeof (struct HPGL2_font_str)) static struct HPGL2_font_str *HPGL2_font = &HPGL2_font_table[0]; /* * The default mode goes first. Landscape style plots are probably the * most compatable with other HPGL devices. */ static struct PCL_mode_str GPFAR PCL_mode_table[] = { {"l$andscape", "landscape", "\033&l1O", PCL_XMAX, PCL_YMAX}, {"p$ortrait", "portrait", "\033&l0O", PCL_YMAX, PCL_XMAX} }; #define PCL_MODES (sizeof(PCL_mode_table) / sizeof (struct PCL_mode_str)) static struct PCL_mode_str *PCL_mode = &PCL_mode_table[0]; /* * Various line types and widths to distinguish data sets */ static char *HPGL2_lt[] = { "", "4,2", "5,2", "6,2", "7,2", "8,2" }, *HPGL2_pw[] = { ".15", ".12", ".08" }; #define HPGL2_LINETYPES (sizeof(HPGL2_lt) / sizeof(char *)) #define HPGL2_PENWIDTHS (sizeof(HPGL2_pw) / sizeof(char *)) /* encoding vector for cp850 , characters 128 (0200) -> 255 (0377) */ static char hpgl_cp_850[128][4] = { /* 0200 */ "\0164\017", /* 0201 */ "\016O\017", /* 0202 */ "\016E\017", /* 0203 */ "\016@\017", /* 0204 */ "\016L\017", /* 0205 */ "\016H\017", /* 0206 */ "\016T\017", /* 0207 */ "\0165\017", /* 0210 */ "\016A\017", /* 0211 */ "\016M\017", /* 0212 */ "\016I\017", /* 0213 */ "\016]\017", /* 0214 */ "\016Q\017", /* 0215 */ "\016Y\017", /* 0216 */ "\016X\017", /* 0217 */ "\016P\017", /* 0220 */ "\016\134\017", /* 0221 */ "\016W\017", /* 0222 */ "\016S\017", /* 0223 */ "\016B\017", /* 0224 */ "\016N\017", /* 0225 */ "\016J\017", /* 0226 */ "\016C\017", /* 0227 */ "\016K\017", /* 0230 */ "\016o\017", /* 0231 */ "\016Z\017", /* 0232 */ "\016[\017", /* 0233 */ "\016V\017", /* 0234 */ "\016;\017", /* 0235 */ "\016R\017", /* 0236 */ "", /* 0237 */ "\016>\017", /* 0240 */ "\016D\017", /* 0241 */ "\016U\017", /* 0242 */ "\016F\017", /* 0243 */ "\016G\017", /* 0244 */ "\0167\017", /* 0245 */ "\0166\017", /* 0246 */ "\016y\017", /* 0247 */ "\016z\017", /* 0250 */ "\0169\017", /* 0251 */ "", /* 0252 */ "", /* 0253 */ "\016x\017", /* 0254 */ "\016w\017", /* 0255 */ "\0168\017", /* 0256 */ "\016{\017", /* 0257 */ "\016}\017", /* 0260 */ "", /* 0261 */ "", /* 0262 */ "", /* 0263 */ "", /* 0264 */ "", /* 0265 */ "\016`\017", /* 0266 */ "\016\042\017", /* 0267 */ "\016!\017", /* 0270 */ "", /* 0271 */ "", /* 0272 */ "", /* 0273 */ "", /* 0274 */ "", /* 0275 */ "\016?\017", /* 0276 */ "\016<\017", /* 0277 */ "", /* 0300 */ "", /* 0301 */ "", /* 0302 */ "", /* 0303 */ "", /* 0304 */ "", /* 0305 */ "", /* 0306 */ "\016b\017", /* 0307 */ "\016a\017", /* 0310 */ "", /* 0311 */ "", /* 0312 */ "", /* 0313 */ "", /* 0314 */ "", /* 0315 */ "", /* 0316 */ "", /* 0317 */ "\016:\017", /* 0320 */ "\016d\017", /* 0321 */ "\016c\017", /* 0322 */ "\016$\017", /* 0323 */ "\016%\017", /* 0324 */ "\016#\017", /* 0325 */ "", /* 0326 */ "\016e\017", /* 0327 */ "\016&\017", /* 0330 */ "\016'\017", /* 0331 */ "", /* 0332 */ "", /* 0333 */ "", /* 0334 */ "", /* 0335 */ "", /* 0336 */ "\016f\017", /* 0337 */ "", /* 0340 */ "\016g\017", /* 0341 */ "\016^\017", /* 0342 */ "\016_\017", /* 0343 */ "\016h\017", /* 0344 */ "\016j\017", /* 0345 */ "\016i\017", /* 0346 */ "", /* 0347 */ "\016q\017", /* 0350 */ "\016p\017", /* 0351 */ "\016m\017", /* 0352 */ "\016.\017", /* 0353 */ "\016-\017", /* 0354 */ "", /* 0355 */ "", /* 0356 */ "\0160\017", /* 0357 */ "\016(\017", /* 0360 */ "\016v\017", /* 0361 */ "\016~\017", /* 0362 */ "", /* 0363 */ "", /* 0364 */ "", /* 0365 */ "\016=\017", /* 0366 */ "", /* 0367 */ "", /* 0370 */ "\016z\017", /* 0371 */ "\016+\017", /* 0372 */ "", /* 0373 */ "", /* 0374 */ "", /* 0375 */ "", /* 0376 */ "", /* 0377 */ "" }; /* encoding vector for iso-8859-1 , characters 128 (0200) -> 255 (0377) */ static char hpgl_iso_8859_1[128][4] = { /* 0200 */ "", /* 0201 */ "", /* 0202 */ "", /* 0203 */ "", /* 0204 */ "", /* 0205 */ "", /* 0206 */ "", /* 0207 */ "", /* 0210 */ "", /* 0211 */ "", /* 0212 */ "", /* 0213 */ "", /* 0214 */ "", /* 0215 */ "", /* 0216 */ "", /* 0217 */ "", /* 0220 */ "", /* 0221 */ "\016\017", /* 0222 */ "\016\017", /* 0223 */ "", /* 0224 */ "", /* 0225 */ "", /* 0226 */ "", /* 0227 */ "", /* 0230 */ "", /* 0231 */ "", /* 0232 */ "", /* 0233 */ "", /* 0234 */ "", /* 0235 */ "", /* 0236 */ "", /* 0237 */ "", /* 0240 */ "", /* 0241 */ "\0168\017", /* 0242 */ "\0165\017", /* 0243 */ "\016;\017", /* 0244 */ "\016:\017", /* 0245 */ "\016<\017", /* 0246 */ "\017|\017", /* 0247 */ "\016=\017", /* 0250 */ "\016+\017", /* 0251 */ "", /* 0252 */ "\016y\017", /* 0253 */ "\016{\017", /* 0254 */ "", /* 0255 */ "", /* 0256 */ "", /* 0257 */ "\0160\017", /* 0260 */ "\016z\017", /* 0261 */ "\016~\017", /* 0262 */ "", /* 0263 */ "", /* 0264 */ "", /* 0265 */ "", /* 0266 */ "", /* 0267 */ "", /* 0270 */ "", /* 0271 */ "", /* 0272 */ "\016z\017", /* 0273 */ "\016}\017", /* 0274 */ "\016w\017", /* 0275 */ "\016x\017", /* 0276 */ "", /* 0277 */ "\0169\017", /* 0300 */ "\016!\017", /* 0301 */ "\016`\017", /* 0302 */ "\016\042\017", /* 0303 */ "\016a\017", /* 0304 */ "\016X\017", /* 0305 */ "\016P\017", /* 0306 */ "\016S\017", /* 0307 */ "\0164\017", /* 0310 */ "\016#\017", /* 0311 */ "\016\134\017", /* 0312 */ "\016$\017", /* 0313 */ "\016%\017", /* 0314 */ "\016f\017", /* 0315 */ "\016e\017", /* 0316 */ "\016\046\017", /* 0317 */ "\016'\017", /* 0320 */ "\016c\017", /* 0321 */ "\0166\017", /* 0322 */ "\016h\017", /* 0323 */ "\016g\017", /* 0324 */ "\016_\017", /* 0325 */ "\016i\017", /* 0326 */ "\016Z\017", /* 0327 */ "", /* 0330 */ "\016R\017", /* 0331 */ "\016-\017", /* 0332 */ "\016m\017", /* 0333 */ "\016.\017", /* 0334 */ "\016[\017", /* 0335 */ "", /* 0336 */ "\016p\017", /* 0337 */ "\016^\017", /* 0340 */ "\016H\017", /* 0341 */ "\016D\017", /* 0342 */ "\016@\017", /* 0343 */ "\016b\017", /* 0344 */ "\016L\017", /* 0345 */ "\016T\017", /* 0346 */ "\016W\017", /* 0347 */ "\0165\017", /* 0350 */ "\016I\017", /* 0351 */ "\016E\017", /* 0352 */ "\016A\017", /* 0353 */ "\016M\017", /* 0354 */ "\016Y\017", /* 0355 */ "\016U\017", /* 0356 */ "\016Q\017", /* 0357 */ "\016]\017", /* 0360 */ "\016d\017", /* 0361 */ "\0167\017", /* 0362 */ "\016J\017", /* 0363 */ "\016F\017", /* 0364 */ "\016B\017", /* 0365 */ "\016j\017", /* 0366 */ "\016N\017", /* 0367 */ "", /* 0370 */ "\016V\017", /* 0371 */ "\016K\017", /* 0372 */ "\016G\017", /* 0373 */ "\016C\017", /* 0374 */ "\016O\017", /* 0375 */ "", /* 0376 */ "\016q\017", /* 0377 */ "\016o\017" }; /* * Static variables to keep track of where we are, etc. */ static int HPGL_ang = 0, HPGL_x = UNKNOWN, HPGL_y = UNKNOWN, HPGL_penstate = UNKNOWN, HPGL_pentype = UNKNOWN, HPGL2_in_pe, HPGL2_lost; /* * The subroutines, grouped by function for different versions. */ static int HPGL_numpen, HPGL_eject; TERM_PUBLIC void HPGL_options() { HPGL_numpen = 6; /* default to six pens */ HPGL_eject = 0; /* default to no eject */ while (!END_OF_COMMAND) { if (almost_equals(c_token, "eje$ct")) HPGL_eject = 1; else if (isanumber(c_token)) { HPGL_numpen = (int) real(&token[c_token].l_val); if (HPGL_numpen <= 0) { HPGL_numpen = 6; int_error("Number of pens must be positive", c_token); } } else int_error("expecting \"eject\" or number of pens", c_token); c_token++; } sprintf(term_options, "%d pens %s", HPGL_numpen, HPGL_eject ? "eject" : "noeject"); } TERM_PUBLIC void HPGL2_options() { struct termentry *t = term; int i; double point_size; char tmp_options[MAX_ID_LEN]; if (!END_OF_COMMAND) { for (i = 0; i < HPGL2_FONTS && !almost_equals(c_token, HPGL2_font_table[i].compare); i++); if (i < HPGL2_FONTS) { HPGL2_font = &HPGL2_font_table[i]; } else int_error("expecting font: stick, cg_times, or univers", c_token); c_token++; if (!END_OF_COMMAND) { if ((point_size = real(&token[c_token].l_val)) > 0.0) { t->v_char = (int) HPGL_PUPI *point_size / 72; t->h_char = t->v_char * 2 / 3; if (HPGL2_font->spacing) HPGL2_font->height = point_size; else HPGL2_font->pitch = 72 * 3 / (point_size * 2); } else int_error("expecting font point size: real number", c_token); c_token++; } } sprintf(tmp_options, " %s", HPGL2_font->name); strcat(term_options, tmp_options); if (HPGL2_font->spacing) { sprintf(tmp_options, " %f", HPGL2_font->height); strcat(term_options, tmp_options); } else { sprintf(tmp_options, " %f", HPGL2_font->pitch); strcat(term_options, tmp_options); } } TERM_PUBLIC void PCL_options() { int i; if (!END_OF_COMMAND) { for (i = 0; i < PCL_MODES && !almost_equals(c_token, PCL_mode_table[i].compare); i++); if (i < PCL_MODES) PCL_mode = &PCL_mode_table[i]; else int_error("expecting mode: portrait or landscape", c_token); c_token++; } sprintf(term_options, " %s", PCL_mode->name); HPGL2_options(); } TERM_PUBLIC void HPGL_init() { } /* void HPGL2_init () { } */ TERM_PUBLIC void PCL_init() { struct termentry *t = term; /* * Reset printer, set to one copy, orientation of user's choice. * Make the change to the new orientation all at once. */ fprintf(gpoutfile, "\033E\033&l1X%s\n", PCL_mode->command); t->xmax = PCL_mode->xmax; t->ymax = PCL_mode->ymax; } TERM_PUBLIC void HPGL_graphics() { fputs("\033.Y\n\033.I81;;17:\033.N;19:\033.M500:\n", gpoutfile); /* 1 1. enable eavesdropping */ fprintf(gpoutfile, "IN;%s\nSC0,%d,0,%d;\nSR%f,%f;\n", ((encoding == ENCODING_CP_850) || (encoding == ENCODING_ISO_8859_1)) ? "CA7;" : "", HPGL_XMAX, HPGL_YMAX, ((double) (HPGL_HCHAR) * 200 / 3 / HPGL_XMAX), ((double) (HPGL_VCHAR) * 100 / 2 / HPGL_YMAX)); /* 1 2 3 1. reset to power-up defaults 2. set SCaling 3. set character size */ HPGL_ang = 0; } TERM_PUBLIC void HPGL2_graphics() { /* * IN - Initialize * SP - Select pen * SD - Set default font */ fprintf(gpoutfile, "INSP1SD1,%d,2,%d,", HPGL2_font->symbol_set, HPGL2_font->spacing); if (HPGL2_font->spacing) fprintf(gpoutfile, "4,%f,", HPGL2_font->height); else fprintf(gpoutfile, "3,%f,", HPGL2_font->pitch); fprintf(gpoutfile, "5,%d,6,%d,7,%d\n", HPGL2_font->posture, HPGL2_font->stroke_weight, HPGL2_font->typeface); /* * Control variables */ HPGL_ang = 0; /* Horizontal */ HPGL2_in_pe = FALSE; /* Not in PE command */ HPGL2_lost = TRUE; /* Pen position is unknown */ HPGL_penstate = UP; /* Pen is up */ } TERM_PUBLIC void PCL_graphics() { /* * Enter HPGL/2 graphics mode */ fputs("\033%0B", gpoutfile); HPGL2_graphics(); } TERM_PUBLIC void HPGL_text() { if (HPGL_eject == 0) { fputs("PUSP0;\033.Z\n\0", gpoutfile); /* 1 2 3 1. pen up 2. park pen 3. disable eavesdropping */ } else { fputs("PUSP0;PG;\033.Z\n\0", gpoutfile); /* 1 2 3 4 1. pen up 2. park pen 3. page eject 4. disable eavesdropping */ } HPGL_penstate = UP; } #if 0 /* not used */ void HPGL2_text() { /* * If in Polyline Encoded command, leave Polyline Encoded command */ if (HPGL2_in_pe) { fputs(";\n", gpoutfile); HPGL2_in_pe = 0; } /* * Pen up, park pen */ fputs("PUSP0;", gpoutfile); } #endif TERM_PUBLIC void PCL_text() { if (HPGL2_in_pe) { fputs(";\n", gpoutfile); HPGL2_in_pe = 0; } /* * Go into PCL mode and eject the page */ fputs("\033%1A\033&l0H\n\0", gpoutfile); } TERM_PUBLIC void HPGL_linetype(linetype) int linetype; { /* allow for set number of pens */ linetype = (linetype + 2) % HPGL_numpen + 1; /* only select pen if necessary */ if (HPGL_pentype != linetype) { fprintf(gpoutfile, "PU;\nSP%d;\n", linetype); HPGL_pentype = linetype; HPGL_penstate = UP; } } TERM_PUBLIC void HPGL2_linetype(linetype) int linetype; { /* * If in Polyline Encoded command, leave Polyline Encoded command */ if (HPGL2_in_pe) { fputs(";\n", gpoutfile); HPGL2_in_pe = 0; } /* * Allow for lots of linetypes */ if (linetype >= 0) linetype = linetype % (HPGL2_LINETYPES * HPGL2_PENWIDTHS); if (linetype != HPGL_pentype) { if (linetype >= 0) { fprintf(gpoutfile, "PW%sLT%s", HPGL2_pw[linetype / HPGL2_LINETYPES], HPGL2_lt[linetype % HPGL2_LINETYPES]); } else if (linetype == -2) /* * Borders and tics */ fprintf(gpoutfile, "PW.2LT"); else if (linetype == -1) /* * Axes and grids */ fprintf(gpoutfile, "PW.1LT1,.25"); HPGL_pentype = linetype; } } TERM_PUBLIC void HPGL_put_text(x, y, str) unsigned int x, y; char *str; { if (HPGL_ang == 1) HPGL_move(x + HPGL_VCHAR / 4, y); else HPGL_move(x, y - HPGL_VCHAR / 4); if (encoding == ENCODING_CP_850) { unsigned char *s; fputs("LB", gpoutfile); for (s = (unsigned char *) str; *s; ++s) if (*s >= 128 && hpgl_cp_850[*s - 128][0]) fputs(hpgl_cp_850[*s - 128], gpoutfile); else putc(*s, gpoutfile); fputs("\003\n", gpoutfile); } else if (encoding == ENCODING_ISO_8859_1) { unsigned char *s; fputs("LB", gpoutfile); for (s = (unsigned char *) str; *s; ++s) if (*s >= 128 && hpgl_iso_8859_1[*s - 128][0]) fputs(hpgl_iso_8859_1[*s - 128], gpoutfile); else putc(*s, gpoutfile); fputs("\003\n", gpoutfile); } else fprintf(gpoutfile, "LB%s\003\n", str); } TERM_PUBLIC void HPGL2_put_text(x, y, str) unsigned int x, y; char *str; { struct termentry *t = term; /* * Position the pen */ if (HPGL_ang == 1) HPGL2_move(x + t->v_char / 4, y); else HPGL2_move(x, y - t->v_char / 4); /* * If in Polyline Encoded command, leave Polyline Encoded command */ if (HPGL2_in_pe) { fputs(";\n", gpoutfile); HPGL2_in_pe = 0; } /* * Print the text string */ fprintf(gpoutfile, "LB%s\003\n", str); HPGL2_lost = 1; } /* * Some early HPGL plotters (e.g. HP7220C) require the * Pen Up/Down and Pen (move) Absolute commands to be separate. */ TERM_PUBLIC void HPGL_move(x, y) unsigned int x, y; { if (HPGL_x != x || HPGL_y != y) { /* only move if necessary */ fprintf(gpoutfile, "PU;PA%d,%d;\n", x, y); HPGL_penstate = UP; HPGL_x = x; HPGL_y = y; } } TERM_PUBLIC void HPGL_vector(x, y) unsigned int x, y; { if (HPGL_penstate != DOWN) { fprintf(gpoutfile, "PD;PA%d,%d;\n", x, y); HPGL_penstate = DOWN; } else fprintf(gpoutfile, "PA%d,%d;\n", x, y); HPGL_x = x; HPGL_y = y; } TERM_PUBLIC void HPGL2_move(x, y) unsigned int x, y; { register int dx, dy; if (HPGL2_in_pe) { dx = x - HPGL_x; dy = y - HPGL_y; fputs("<", gpoutfile); } else { #if HPGL2_BASE64 fputs("PE<", gpoutfile); #else fputs("PE7<", gpoutfile); #endif if (HPGL2_lost) { dx = x; dy = y; HPGL2_lost = 0; fputs("=", gpoutfile); } else { dx = x - HPGL_x; dy = y - HPGL_y; } HPGL2_in_pe = 1; } #if HPGL2_EXPLICIT_PD if (HPGL_penstate == DOWN) HPGL_penstate = UP; #endif HPGL2_encode(dx); HPGL2_encode(dy); fputs("\n", gpoutfile); HPGL_x = x; HPGL_y = y; } TERM_PUBLIC void HPGL2_vector(x, y) unsigned int x, y; { register int dx, dy; if (HPGL2_in_pe) { dx = x - HPGL_x; dy = y - HPGL_y; } else { #if HPGL2_BASE64 fputs("PE", gpoutfile); #else fputs("PE7", gpoutfile); #endif if (HPGL2_lost) { dx = x; dy = y; HPGL2_lost = 0; fputs("=", gpoutfile); } else { dx = x - HPGL_x; dy = y - HPGL_y; } HPGL2_in_pe = 1; } #if HPGL2_EXPLICIT_PD /* * Put the pen down in the current position, * relative vector of 0,0. */ if (HPGL_penstate == UP) { fputc((char) HPGL2_HIGH_OFFS, gpoutfile); fputc((char) HPGL2_HIGH_OFFS, gpoutfile); HPGL_penstate = DOWN; } #endif HPGL2_encode(dx); HPGL2_encode(dy); fputs("\n", gpoutfile); HPGL_x = x; HPGL_y = y; } /* * Routine to encode position in base 32 or base 64 characters */ TERM_PUBLIC void HPGL2_encode(d) register int d; { register int c; if ((d <<= 1) < 0) d = 1 - d; do { c = d & HPGL2_MASK; d >>= HPGL2_BITS; if (d > 0) fputc((char) (c + HPGL2_LOW_OFFS), gpoutfile); else fputc((char) (c + HPGL2_HIGH_OFFS), gpoutfile); } while (d > 0); } TERM_PUBLIC int HPGL_text_angle(ang) int ang; { HPGL_ang = ang; if (ang == 1) /* * Vertical */ fputs("DI0,1;\n", gpoutfile); else /* * Horizontal */ fputs("DI1,0;\n", gpoutfile); return TRUE; } TERM_PUBLIC int HPGL2_text_angle(ang) int ang; { /* * If in Polyline Encoded command, leave Polyline Encoded command */ if (HPGL2_in_pe) { fputs(";", gpoutfile); HPGL2_in_pe = 0; } if (ang == 1) /* * Vertical */ fputs("DI0,1", gpoutfile); else /* * Horizontal */ fputs("DI1,0", gpoutfile); HPGL_ang = ang; return TRUE; } TERM_PUBLIC void HPGL_reset() { /* * do nothing */ } #if 0 void HPGL2_reset() { /* * Park the pen * Advance a page * End with ";" */ fputs("SP0PG;\n", gpoutfile); } #endif TERM_PUBLIC void PCL_reset() { /* * Return to PCL mode * Printer reset (conditional eject) */ fputs("\033%0A\033E\n", gpoutfile); } TERM_PUBLIC int HPGL2_justify_text(just) enum JUSTIFY just; { /* * If in Polyline Encoded command, leave Polyline Encoded command */ if (HPGL2_in_pe) { fputs(";\n", gpoutfile); HPGL2_in_pe = 0; } switch (just) { case LEFT: fputs("LO1", gpoutfile); break; case CENTRE: fputs("LO4", gpoutfile); break; case RIGHT: fputs("LO7", gpoutfile); break; default: return 0; } return 1; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(hpgl_driver) "hpgl", "HP7475 and relatives [number of pens] [eject]", HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR, HPGL_VTIC, HPGL_HTIC, HPGL_options, HPGL_init, HPGL_reset, HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector, HPGL_linetype, HPGL_put_text, HPGL_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(hpgl_driver) #undef LAST_TERM #define LAST_TERM hpgl_driver TERM_TABLE_START(pcl5_driver) "pcl5", "HP LaserJet III [mode] [font] [point]", PCL_XMAX, PCL_YMAX, HPGL2_VCHAR, HPGL2_HCHAR, PCL_VTIC, PCL_HTIC, PCL_options, PCL_init, PCL_reset, PCL_text, null_scale, PCL_graphics, HPGL2_move, HPGL2_vector, HPGL2_linetype, HPGL2_put_text, HPGL2_text_angle, HPGL2_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(pcl5_driver) #undef LAST_TERM #define LAST_TERM pcl5_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(hpgl) "1 hpgl", "?commands set terminal hpgl", "?set terminal hpgl", "?set term hpgl", "?terminal hpgl", "?term hpgl", "?hpgl", "?commands set terminal pcl5", "?set terminal pcl5", "?set term pcl5", "?terminal pcl5", "?term pcl5", "?pcl5", " The `hpgl` driver produces HPGL output for devices like the HP7475A plotter.", " There are two options which can be set---the number of pens and \"eject\", which", " tells the plotter to eject a page when done. The default is to use 6 pens", " and not to eject the page when done.", "", " The international character sets ISO-8859-1 and CP850 are recognized via", " `set encoding iso_8859_1` or `set encoding cp850` (see `set encoding` for", " details).", "", " Syntax:", " set terminal hpgl {} {eject}", "", " The selection", "", " set terminal hpgl 8 eject", "", " is equivalent to the previous `hp7550` terminal, and the selection", "", " set terminal hpgl 4", "", " is equivalent to the previous `hp7580b` terminal.", "", " The `pcl5` driver supports the Hewlett-Packard Laserjet III. It actually uses", " HPGL-2, but there is a name conflict among the terminal devices. It has", " several options", "", " Syntax:", " set terminal pcl5 {} {} {}", "", " where is `landscape`, or `portrait`, is `stick`, `univers`, or", " `cg_times`, and is the size in points.", "", " With `pcl5` international characters are handled by the printer; you just put", " the appropriate 8-bit character codes into the text strings. You don't need", " to bother with `set encoding`.", "", " HPGL graphics can be imported by many software packages." END_HELP(hpgl) #endif /* TERM_HELP */ /* * $Id: hpljii.trm,v 1.20 1998/04/14 00:17:51 drd Exp $ * */ /* GNUPLOT - hpljii.trm */ /*[ * Copyright 1990 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * hpljii, hpdj * * AUTHORS * John Engels * Russell Lang * Maurice Castro * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* The following HP laserjet series II driver uses generic bit mapped graphics routines from bitmap.c to build up a bit map in memory. The driver interchanges colomns and lines in order to access entire lines easily and returns the lines to get bits in the right order : (x,y) -> (y,XMAX-1-x). */ /* This interchange is done by calling b_makebitmap() with reversed xmax and ymax, and then setting b_rastermode to TRUE. b_setpixel() will then perform the interchange before each pixel is plotted */ /* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver of Jyrki Yli-Nokari */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(hpljii) register_term(hpdj) #endif #ifdef TERM_PROTO TERM_PUBLIC void HPLJIIoptions __PROTO((void)); TERM_PUBLIC void HPLJIIinit __PROTO((void)); TERM_PUBLIC void HPLJIIgraphics __PROTO((void)); TERM_PUBLIC void HPLJIItext __PROTO((void)); TERM_PUBLIC void HPLJIIlinetype __PROTO((int linetype)); TERM_PUBLIC void HPLJIIput_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void HPLJIIreset __PROTO((void)); #define HPLJIImove b_move #define HPLJIIvector b_vector #define HPLJIItext_angle b_text_angle TERM_PUBLIC void HPDJgraphics __PROTO((void)); TERM_PUBLIC void HPDJtext __PROTO((void)); #define HPDJtext_angle b_text_angle #define HPDJput_text b_put_text /* default values for term_tbl */ #define HPLJII_75PPI_XMAX (1920/4) #define HPLJII_75PPI_YMAX (1920/4) #define HPLJII_75PPI_HCHAR (1920/4/6) #define HPLJII_75PPI_VCHAR (1920/4/10) #define HPLJII_75PPI_VTIC 5 #define HPLJII_75PPI_HTIC 5 #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and 75ppi. (Pixel size = 1, 2, 3, 4 dots) */ #define HPLJII_DPP (hplj_dpp) /* dots per pixel */ #define HPLJII_PPI (300/HPLJII_DPP) /* pixel per inch */ /* make XMAX and YMAX a multiple of 8 */ #define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9)) #define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9)) /* Courier font with 6 lines per inch */ #define HPLJII_VCHAR (HPLJII_PPI/6) /* Courier font with 10 caracters per inch */ #define HPLJII_HCHAR (HPLJII_PPI/10) /* Save current cursor position */ #define HPLJII_PUSH_CURSOR fputs("\033&f0S",gpoutfile) /* Restore cursor position */ #define HPLJII_POP_CURSOR fputs("\033&f1S",gpoutfile) /* be sure to use courier font with 6lpi and 10cpi */ #define HPLJII_COURIER fputs("\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D",gpoutfile) void HPLJIIputc __PROTO((unsigned int x, unsigned int y, char c, int ang)); static int hplj_dpp = 4; /* bm_pattern not appropriate for 300ppi graphics */ #ifndef GOT_300_PATTERN # define GOT_300_PATTERN static unsigned int b_300ppi_pattern[] = { 0xffff, 0x1111, 0xffff, 0x3333, 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff }; #endif TERM_PUBLIC void HPLJIIoptions() { char opt[4]; int parse_error = 0; if (END_OF_COMMAND) { term_options[0] = NUL; } else { if (token[c_token].length > 3) { parse_error = 1; /* see below */ } else { /* almost_equals() won't accept numbers - use strcmp() instead */ capture(opt, c_token, c_token, 4); if (!strcmp(opt, "75")) { hplj_dpp = 4; } else if (!strcmp(opt, "100")) { hplj_dpp = 3; } else if (!strcmp(opt, "150")) { hplj_dpp = 2; } else if (!strcmp(opt, "300")) { hplj_dpp = 1; } else { /* error, but set dpi anyway, since term it already set */ parse_error = 1; } c_token++; } } term->xmax = HPLJII_XMAX; term->ymax = HPLJII_YMAX; switch (hplj_dpp) { case 1: strcpy(term_options, "300"); term->v_tic = 15; term->h_tic = 15; break; case 2: strcpy(term_options, "150"); term->v_tic = 8; term->h_tic = 8; break; case 3: strcpy(term_options, "100"); term->v_tic = 6; term->h_tic = 6; break; case 4: strcpy(term_options, "75"); term->v_tic = 5; term->h_tic = 5; break; } if (parse_error) int_error("expecting dots per inch size 75, 100, 150 or 300", c_token); } TERM_PUBLIC void HPLJIIinit() { term->v_char = HPLJII_VCHAR; term->h_char = HPLJII_HCHAR; } TERM_PUBLIC void HPLJIIgraphics() { HPLJII_COURIER; HPLJII_PUSH_CURSOR; /* rotate plot -90 degrees by reversing XMAX and YMAX and by setting b_rastermode to TRUE */ b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1); b_rastermode = TRUE; } /* HPLJIItext by rjl - no compression */ TERM_PUBLIC void HPLJIItext() { register int x, j, row; fprintf(gpoutfile, "\033*t%dR", HPLJII_PPI); HPLJII_POP_CURSOR; fputs("\033*r1A", gpoutfile); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; fprintf(gpoutfile, "\033*b0m%dW", b_ysize / 8); for (j = row; j >= 0; j--) { (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile); } } fputs("\033*rB", gpoutfile); b_freebitmap(); #ifndef VMS /* most vms spoolers add a formfeed character */ putc('\f', gpoutfile); #endif /* !VMS */ } TERM_PUBLIC void HPLJIIlinetype(linetype) int linetype; { if (hplj_dpp == 1) { if (linetype >= 7) linetype %= 7; /* b_pattern not appropriate for 300ppi graphics */ b_linemask = b_300ppi_pattern[linetype + 2]; b_maskcount = 0; } else { b_setlinetype(linetype); } } TERM_PUBLIC void HPLJIIput_text(x, y, str) unsigned int x, y; char *str; { switch (b_angle) { case 0: y -= HPLJII_VCHAR / 5; HPLJII_POP_CURSOR; HPLJII_PUSH_CURSOR; /* (0,0) is the upper left point of the paper */ fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP ,(HPLJII_YMAX - y - 1) * HPLJII_DPP); fputs(str, gpoutfile); /* for (; *str; ++str, x += HPLJII_HCHAR) HPLJIIputc (x, y, *str, b_angle);*/ break; case 1: y += (HPLJII_HCHAR - 2 * HPLJII_VCHAR) / 2; y += (HPLJII_VCHAR + HPLJII_HCHAR) * strlen(str) / 2; for (; *str; ++str, y -= HPLJII_VCHAR) HPLJIIputc(x, y, *str, b_angle); break; } } #ifdef PROTOTYPES void HPLJIIputc(unsigned int x, unsigned int y, char c, int ang) #else void HPLJIIputc(x, y, c, ang) unsigned int x, y; int ang; char c; #endif { HPLJII_POP_CURSOR; HPLJII_PUSH_CURSOR; /* (0,0) is the upper left point of the paper */ fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP ,(HPLJII_YMAX - y - 1) * HPLJII_DPP); fputc(c, gpoutfile); } TERM_PUBLIC void HPLJIIreset() { #ifdef VMS fflush_binary(); #endif /* VMS */ } /* HP DeskJet routines */ TERM_PUBLIC void HPDJgraphics() { switch (hplj_dpp) { case 1: b_charsize(FNT13X25); term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; break; case 2: b_charsize(FNT13X25); term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; break; case 3: b_charsize(FNT9X17); term->v_char = FNT9X17_VCHAR; term->h_char = FNT9X17_HCHAR; break; case 4: b_charsize(FNT5X9); term->v_char = FNT5X9_VCHAR; term->h_char = FNT5X9_HCHAR; break; } /* rotate plot -90 degrees by reversing XMAX and YMAX and by setting b_rastermode to TRUE */ b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1); b_rastermode = TRUE; } /* 0 compression raster bitmap dump. Compatible with HP DeskJet 500 hopefully compatible with other HP Deskjet printers */ TERM_PUBLIC void HPDJtext() { register int x, j, row; fprintf(gpoutfile, "\ \033*b0M\ \033*t%dR\ \033*r1A", HPLJII_PPI); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; fprintf(gpoutfile, "\033*b%dW", b_ysize / 8); for (j = row; j >= 0; j--) { (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile); } } fputs("\033*rbC", gpoutfile); b_freebitmap(); #ifndef VMS /* most vms spoolers add a formfeed character */ putc('\f', gpoutfile); #endif /* !VMS */ } #endif #ifdef TERM_TABLE TERM_TABLE_START(hpljii_driver) "hpljii", "HP Laserjet series II, [75 100 150 300]", HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR, HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions, HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale, HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype, HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(hpljii_driver) #undef LAST_TERM #define LAST_TERM hpljii_driver TERM_TABLE_START(hpdj_driver) "hpdj", "HP DeskJet 500, [75 100 150 300]", HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR, HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions, HPLJIIinit, HPLJIIreset, HPDJtext, null_scale, HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype, HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(hpdj_driver) #undef LAST_TERM #define LAST_TERM hpdj_driver #endif #endif #ifdef TERM_HELP START_HELP(hpljii) "1 hpljii", "?commands set terminal hpljii", "?set terminal hpljii", "?set term hpljii", "?terminal hpljii", "?term hpljii", "?hpljii", "?commands set terminal hpdj", "?set terminal hpdj", "?set term hpdj", "?terminal hpdj", "?term hpdj", "?hpdj", " The `hpljii` terminal driver supports the HP Laserjet Series II printer. The", " `hpdj` driver supports the HP DeskJet 500 printer. These drivers allow a", " choice of resolutions.", "", " Syntax:", " set terminal hpljii | hpdj {}", "", " where `res` may be 75, 100, 150 or 300 dots per inch; the default is 75.", " Rasterization at the higher resolutions may require a large amount of memory.", "", " The `hp500c` terminal is similar to `hpdj`; `hp500c` additionally supports", " color and compression." END_HELP(hpljii) #endif /* TERM_HELP */ /* * $Id: hppj.trm,v 1.13 1998/04/14 00:17:51 drd Exp $ * */ /* GNUPLOT - hppj.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * hppj * * AUTHORS * Dan Merget (danm@sr.hp.com) * * This file was based on the hpljii file by: * John Engels * Russell Lang * Maurice Castro * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* The following HP laserjet series II driver uses generic bit mapped graphics * routines from bitmap.c to build up a bit map in memory. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(hppj) #endif #ifdef TERM_PROTO TERM_PUBLIC void HPPJoptions __PROTO((void)); TERM_PUBLIC void HPPJinit __PROTO((void)); TERM_PUBLIC void HPPJreset __PROTO((void)); TERM_PUBLIC void HPPJgraphics __PROTO((void)); TERM_PUBLIC void HPPJtext __PROTO((void)); TERM_PUBLIC void HPPJlinetype __PROTO((int linetype)); #define HPPJmove b_move #define HPPJvector b_vector #define HPPJtext_angle b_text_angle #define HPPJput_text b_put_text /* We define 3 different font sizes: 5x9, 9x17, and 13x25 */ #define HPPJ_DPI 180 /* dots per inch */ #define HPPJ_PLANES 3 /* color planes */ #define HPPJ_COLORS (1 << HPPJ_PLANES) /* make XMAX and YMAX a multiple of 8 */ #define HPPJ_XMAX (8*(unsigned int)(9.5 * HPPJ_DPI / 8.0 + 0.9)) #define HPPJ_YMAX (8 * HPPJ_DPI) /* default values for term_tbl */ #define HPPJ_9x17_VCHAR FNT9X17_VCHAR #define HPPJ_9x17_HCHAR FNT9X17_HCHAR #define HPPJ_9x17_VTIC (FNT9X17_VCHAR / 2) #define HPPJ_9x17_HTIC (FNT9X17_HCHAR / 2) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int hppj_font = FNT9X17; TERM_PUBLIC void HPPJoptions() { char opt[10]; #define HPPJERROR "expecting font size FNT5X9, FNT9X17, or FNT13X25" term_options[0] = NUL; /* default to empty string and 9x17 font */ hppj_font = FNT9X17; /* in case of error or empty options */ if (!END_OF_COMMAND) { if (token[c_token].length > 8) { int_error(HPPJERROR, c_token); } capture(opt, c_token, c_token, /*4 */ 9); /* HBB 980226 */ if (!strcmp(opt, "FNT5X9")) { hppj_font = FNT5X9; strcpy(term_options, "FNT5X9"); } else if (!strcmp(opt, "FNT9X17")) { hppj_font = FNT9X17; strcpy(term_options, "FNT9X17"); } else if (!strcmp(opt, "FNT13X25")) { hppj_font = FNT13X25; strcpy(term_options, "FNT13X25"); } else { int_error(HPPJERROR, c_token); } c_token++; } } TERM_PUBLIC void HPPJinit() { /* HBB 980226: moved this here, from graphics(): only init() may * change fields of *term ! */ switch (hppj_font) { case FNT5X9: term->v_char = FNT5X9_VCHAR; term->h_char = FNT5X9_HCHAR; term->v_tic = FNT5X9_VCHAR / 2; term->h_tic = FNT5X9_HCHAR / 2; break; case FNT9X17: term->v_char = FNT9X17_VCHAR; term->h_char = FNT9X17_HCHAR; term->v_tic = FNT9X17_VCHAR / 2; term->h_tic = FNT9X17_HCHAR / 2; break; case FNT13X25: term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; term->v_tic = FNT13X25_VCHAR / 2; term->h_tic = FNT13X25_HCHAR / 2; break; } } TERM_PUBLIC void HPPJreset() { #ifdef VMS fflush_binary(); #endif /* VMS */ } TERM_PUBLIC void HPPJgraphics() { /* HBB 980226: move a block of code from here to init() */ b_charsize(hppj_font); b_makebitmap(HPPJ_XMAX, HPPJ_YMAX, HPPJ_PLANES); } TERM_PUBLIC void HPPJtext() { int x, plane, y; /* loop indexes */ int minRow, maxRow; /* loop bounds */ int numBytes; /* Number of run-length coded bytes to output */ int numReps; /* Number of times the current byte is repeated */ fprintf(gpoutfile, "\ \033E\033*t%dR\033*r%dS\ \033*b0X\033*b0Y\033*r%dU\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*v%dA\033*v%dB\033*v%dC\033*v%dI\ \033*b1M\033*r1A", HPPJ_DPI, HPPJ_YMAX, HPPJ_PLANES, 90, 88, 85, 0, 53, 8, 14, 1, 3, 26, 22, 2, 4, 4, 29, 3, 53, 5, 25, 4, 2, 22, 64, 5, 89, 83, 13, 6, 4, 4, 6, 7); /* dump bitmap in raster mode using run-length encoding */ for (x = HPPJ_XMAX - 1; x >= 0; --x) { for (plane = 0; plane < HPPJ_PLANES; plane++) { minRow = b_psize * plane; maxRow = b_psize * plane + b_psize - 1; /* Print column header */ numBytes = 0; for (y = maxRow; y >= minRow; --y) { if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) { numBytes += 2; } } fprintf(gpoutfile, "\033*b%d", numBytes); (void) fputc((char) (plane < HPPJ_PLANES - 1 ? 'V' : 'W'), gpoutfile); /* Print remainder of column */ numReps = 0; for (y = maxRow; y >= minRow; --y) { if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) { (void) fputc((char) (numReps), gpoutfile); (void) fputc((char) (*((*b_p)[y] + x)), gpoutfile); numReps = 0; } else { numReps++; } } } } fputs("\033*r1B\033E", gpoutfile); b_freebitmap(); } TERM_PUBLIC void HPPJlinetype(linetype) int linetype; { if (linetype >= 0) { b_setlinetype(0); b_setvalue((linetype % (HPPJ_COLORS - 1)) + 1); } else { b_setlinetype(linetype + 2); b_setvalue(HPPJ_COLORS - 1); } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(hppj_driver) "hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]", HPPJ_XMAX, HPPJ_YMAX, HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC, HPPJoptions, HPPJinit, HPPJreset, HPPJtext, null_scale, HPPJgraphics, HPPJmove, HPPJvector, HPPJlinetype, HPPJput_text, HPPJtext_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY TERM_TABLE_END(hppj_driver) #undef LAST_TERM #define LAST_TERM hppj_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(hppj) "1 hppj", "?commands set terminal hppj", "?set terminal hppj", "?set term hppj", "?terminal hppj", "?term hppj", "?hppj", " The `hppj` terminal driver supports the HP PaintJet and HP3630 printers. The", " only option is the choice of font.", "", " Syntax:", " set terminal hppj {FNT5X9 | FNT9X17 | FNT13X25}", "", " with the middle-sized font (FNT9X17) being the default." END_HELP(hppj) #endif /* * $Id: imagen.trm,v 1.24 1998/04/14 00:17:51 drd Exp $ */ /* GNUPLOT - imagen.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Imagen laser printers * * AUTHORS * Paul E. McKenney, David Kotz * Rewritten/extended by: * Hans Olav Eggestad * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * Original for direct Imagen output (but retaining many of the * LaTeX extensions) by Paul E. McKenney, 1989. * Further modified by David Kotz to fit into gnuplot 2.0. * Information Science and Technology Division, SRI International, * 333 Ravenswood Ave, Menlo Park, CA 94025. * Mail to mckenney@sri.com. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(imagen) #endif #ifdef TERM_PROTO TERM_PUBLIC void IMAGEN_init __PROTO((void)); TERM_PUBLIC void IMAGEN_graphics __PROTO((void)); TERM_PUBLIC void IMAGEN_options __PROTO((void)); TERM_PUBLIC void IMAGEN_text __PROTO((void)); TERM_PUBLIC void IMAGEN_linetype __PROTO((int lt)); TERM_PUBLIC void IMAGEN_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void IMAGEN_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC int IMAGEN_text_angle __PROTO((int ang)); TERM_PUBLIC int IMAGEN_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void IMAGEN_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void IMAGEN_reset __PROTO((void)); #define IMAGEN_PTS_PER_INCH (300) #define IMAGEN_XMAX (IMAGEN_PTS_PER_INCH * 11) /* 10.0 inches */ #define IMAGEN_YMAX (IMAGEN_PTS_PER_INCH * 78 / 10) /* 7.5 inches */ #define IMAGEN_HTIC (20) #define IMAGEN_VTIC (20) #define IMAGEN_VCHAR (IMAGEN_FONTSIZE*5) #define IMAGEN_HCHAR (IMAGEN_VCHAR/2) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static void IM_page __PROTO((void)); static void IMAGEN_draw_path __PROTO((void)); static void IMAGEN_setpos __PROTO((int ux, int uy)); static unsigned char *IMAGEN_cvts __PROTO((unsigned char *str, int *width, int *height)); static void IMAGEN_putwd __PROTO((unsigned int w)); static void IMAGEN_createfamily __PROTO((char *c, int sz)); static void IMAGEN_setfont __PROTO((int sz)); void IMP_set_draw_pattern __PROTO((int pattern, int sz)); void IMAGEN_mapsinit __PROTO((void)); void IMAGEN_createmap __PROTO((int name, unsigned short *map)); /* #ifndef __malloc_h #include #endif */ #include "impcodes.h" /* default is landscape */ #define IMAGEN_A4_H (IMAGEN_PTS_PER_INCH * 83 / 10) #define IMAGEN_A4_W (IMAGEN_PTS_PER_INCH * 116 / 10) /* width in current orientation */ static int IMAGEN_Xmax = IMAGEN_XMAX; static int IMAGEN_Ymax = IMAGEN_YMAX; #define IMAGEN_FONTSIZE 12 #define IMAGEN_FONT "cour" unsigned short IMP_gmap[128]; unsigned char IMP_chmap[256]; static int IMAGEN_page_h = IMAGEN_A4_H; static int IMAGEN_page_w = IMAGEN_A4_W; static int IM_win_horiz = 1; static int IM_win_verti = 1; static int IM_plot_nr = 0; static int IMAGEN_fontsize = IMAGEN_FONTSIZE; static int IMAGEN_familytable[36]; static int IMAGEN_orgX; /* absolute-pixel-ORIgin of graph page. */ static int IMAGEN_orgY; static int IMAGEN_orgx; /* absolute-pixel-ORIgin of current graph. */ static int IMAGEN_orgy; static int IMAGEN_posx; /* current drawing position (lines). */ static int IMAGEN_posy; /* static int IMAGEN_inplot; */ static int IMAGEN_xmax = IMAGEN_XMAX; /* width of graph in pixels. */ static int IMAGEN_ymax = IMAGEN_YMAX; /* height of graph in pixels. */ static int IMAGEN_winx = IMAGEN_XMAX; /* width of window in pixels. */ static int IMAGEN_winy = IMAGEN_YMAX; /* height of window in pixels. */ static int IMAGEN_hchar; /* Height of CHAR in current font. */ static int IMAGEN_wchar; /* Width of CHAR in current font. */ static int IMAGEN_blofs; /* BaseLine OFfSet from bounding box. */ static int IMAGEN_angle = -1; /* 0 for horizontal text, 1 for vertical */ static int IMAGEN_portrait; /* 0 for landscape */ static enum JUSTIFY IMAGEN_justify = LEFT; /* left/center/right */ #define STOREPATH 100 unsigned int IM_xvector[STOREPATH]; /* draw path vector of x values */ unsigned int IM_yvector[STOREPATH]; /* draw path vector of y values */ unsigned int IM_veclen; /* length of allocated path vector */ unsigned int IM_vecpos = 0; /* current pos in vector */ /* char IMPdrpattern[10][10] = { {0}, {30,10,0}, {0}, {10,30,0}, {2,20,0}, {20,10,0}, {30,20,10,20,0}, {30,20,4,10,10,10,4,20,0}, {40,20,0}, {30,15,4,15,0} }; */ char IMPdrpattern[10][10] = { /* -2 */ {0}, /* -1 */ {1, 8, 0}, /* 0 */ {0}, /* 1 */ {16, 4, 0}, /* 2 */ {3, 8, 0}, /* 3 */ {8, 8, 0}, /* 4 */ {16, 6, 3, 6, 0}, /* 5 */ {16, 6, 8, 6, 0}, /* 6 */ {16, 4, 1, 4, 8, 4, 1, 4, 0}, /* 7 */ {16, 4, 1, 8, 1, 4, 0} }; TERM_PUBLIC void IMAGEN_init() { register struct termentry *t = term; /* char font[10]; *//* font name */ IMAGEN_posx = IMAGEN_posy = 0; IMAGEN_orgX = (IMAGEN_page_w - IMAGEN_Xmax) / 2; IMAGEN_orgY = (IMAGEN_page_h - IMAGEN_Ymax) / 2; IMAGEN_xmax = IMAGEN_winx = (int) (IMAGEN_Xmax / IM_win_horiz); IMAGEN_ymax = IMAGEN_winy = (int) (IMAGEN_Ymax / IM_win_verti); t->xmax = (unsigned int) (IMAGEN_xmax); t->ymax = (unsigned int) (IMAGEN_ymax); fputs("@document(language impress, paper a4)", gpoutfile); if (IMAGEN_portrait) { putc(imP_SET_ABS_V, gpoutfile); IMAGEN_putwd(3520); } putc(imP_SET_HV_SYSTEM, gpoutfile); putc(((IMAGEN_portrait ? 3 : 0) << 5) | (3 << 3) | (IMAGEN_portrait ? 0 : 5), gpoutfile); /* sprintf(font, "cour%02d", IMAGEN_FONTSIZE); */ IMAGEN_mapsinit(); IMAGEN_createmap(1, IMP_gmap); /* IMAGEN_createfamily(font, IMAGEN_FONTSIZE); */ IMAGEN_setfont(IMAGEN_fontsize); IMAGEN_text_angle(0); putc(imP_SET_ABS_H, gpoutfile); IMAGEN_putwd(0); putc(imP_SET_ABS_V, gpoutfile); IMAGEN_putwd(0); IMAGEN_linetype(-1); /* if ((IM_xvector = (unsigned int *) malloc(STOREPATH*sizeof(int))) == NULL) { fputs("Imagendriver: Unable to allocate memory for draw path\n", stderr); exit(1); } if ((IM_yvector = (unsigned int *) malloc(STOREPATH*sizeof(int))) == NULL) { fputs("Imagendriver: Unable to allocate memory for draw path\n", stderr); exit(1); } */ IM_veclen = STOREPATH; IM_vecpos = 0; } static void IM_page() { if (IM_vecpos) { /* fprintf(stderr,"graphics, draw path\n"); */ IMAGEN_draw_path(); } putc(imP_ENDPAGE, gpoutfile); } TERM_PUBLIC void IMAGEN_graphics() { int tmpx, tmpy; /* int xoff, yoff; */ if (IM_vecpos) { /* fprintf(stderr,"graphics, draw path\n"); */ IMAGEN_draw_path(); } if (IM_plot_nr >= (IM_win_horiz * IM_win_verti)) { IM_page(); IM_plot_nr = 0; } IM_plot_nr++; tmpx = IMAGEN_orgX + ((IM_plot_nr - 1) % IM_win_horiz) * IMAGEN_winx; tmpy = IMAGEN_orgY + ((IM_win_verti - 1) - (int) ((IM_plot_nr - 1) / IM_win_horiz)) * IMAGEN_winy; IMAGEN_orgx = tmpx + (int) ((IMAGEN_winx - IMAGEN_xmax) / 2); IMAGEN_orgy = tmpy + (int) ((IMAGEN_winy - IMAGEN_ymax) / 2); } TERM_PUBLIC void IMAGEN_options() { struct value a; while (!END_OF_COMMAND) { if (almost_equals(c_token, "p$ortrait")) { IMAGEN_portrait = TRUE; IMAGEN_page_h = IMAGEN_A4_W; IMAGEN_page_w = IMAGEN_A4_H; IMAGEN_Xmax = IMAGEN_YMAX; IMAGEN_Ymax = IMAGEN_XMAX; c_token++; } else if (almost_equals(c_token, "l$andscape")) { IMAGEN_portrait = FALSE; c_token++; } else if (equals(c_token, "[")) { /* windows spesified */ c_token++; /* if (IM_plot_nr>1) */ if (equals(c_token, "]")) { IM_page(); c_token++; continue; } if (END_OF_COMMAND) { int_error("no. windows: [horizontal,vertical] expected", c_token); } else if (!equals(c_token, ",")) { IM_win_horiz = (int) real(const_express(&a)); } if (!equals(c_token, ",")) int_error("',' expected", c_token); c_token++; if (!equals(c_token, "]")) { IM_win_verti = (int) real(const_express(&a)); } if (!equals(c_token, "]")) int_error("expecting ']'", c_token); c_token++; } else { /* We have font size specified */ IMAGEN_fontsize = (int) real(const_express(&a)); if (IMAGEN_fontsize < 8) IMAGEN_fontsize = 8; if (IMAGEN_fontsize > 15) IMAGEN_fontsize = 15; } } sprintf(term_options, "%d %s [%1d,%1d]", IMAGEN_fontsize, (IMAGEN_portrait) ? "portrait" : "landscape", IM_win_horiz, IM_win_verti); } TERM_PUBLIC void IMAGEN_text() { } #define DRAW_PATTERNS 6 TERM_PUBLIC void IMAGEN_linetype(lt) int lt; { static int lastlinetype = -10; int pen /*, pattern */ ; if (IM_vecpos) { /* fprintf(stderr,"move, draw path\n"); */ IMAGEN_draw_path(); } /* -2: axis -1: border 0: arrow 1-7: graph */ if (lt == -2) { pen = 4; } else { pen = (int) (lt / 8) * 2; if (pen <= 0) pen = 1; } lt = (lt % 8) + 2; if (lastlinetype == lt) return; lastlinetype = lt; putc(imP_SET_PEN, gpoutfile); putc(pen, gpoutfile); IMP_set_draw_pattern(lt, pen); } TERM_PUBLIC void IMAGEN_move(x, y) unsigned int x, y; { if (IM_vecpos) { /* fprintf(stderr,"move, draw path\n"); */ IMAGEN_draw_path(); } IM_xvector[0] = x + IMAGEN_orgx; IM_yvector[0] = y + IMAGEN_orgy; /* fprintf(stderr,"Ny vector: startpos: %1d %1d\n",IM_xvector[0],IM_yvector[0]); */ IM_vecpos = 1; /* IMAGEN_posx = x; IMAGEN_posy = y; */ } TERM_PUBLIC void IMAGEN_vector(ux, uy) unsigned int ux, uy; { /* void IMAGEN_draw_path(); */ /* Store path. */ IM_xvector[IM_vecpos] = ux + IMAGEN_orgx; IM_yvector[IM_vecpos] = uy + IMAGEN_orgy; /* fprintf(stderr,"Ny node: nr: %1d; %1d %1d\n",IM_vecpos,IM_xvector[IM_vecpos],IM_yvector[IM_vecpos]); */ IM_vecpos++; if (IM_vecpos >= IM_veclen) { IMAGEN_draw_path(); IM_xvector[0] = ux + IMAGEN_orgx; IM_yvector[0] = uy + IMAGEN_orgy; IM_vecpos = 1; } } static void IMAGEN_draw_path() { /* unsigned int pos; */ register int i; putc(imP_CREATE_PATH, gpoutfile); IMAGEN_putwd(IM_vecpos); for (i = 0; i < IM_vecpos; i++) { /* IMAGEN_putwd(IM_xvector[i] + IMAGEN_orgx); IMAGEN_putwd(IM_yvector[i] + IMAGEN_orgy); */ IMAGEN_putwd(IM_xvector[i]); IMAGEN_putwd(IM_yvector[i]); } IM_vecpos = 0; /* Draw path with black pen. */ putc(imP_DRAW_PATH, gpoutfile); putc(15, gpoutfile); /* Set current position to end of line. */ /* IMAGEN_move(ux, uy); */ } static void IMAGEN_setpos(ux, uy) int ux, uy; { /* Set x and y position (for text), also set beginning-of-line. */ putc(imP_SET_ABS_H, gpoutfile); IMAGEN_putwd(ux + IMAGEN_orgx); putc(imP_SET_ABS_V, gpoutfile); IMAGEN_putwd(uy + IMAGEN_orgy); putc(imP_SET_BOL, gpoutfile); if (IMAGEN_angle == 1) IMAGEN_putwd(uy + IMAGEN_orgx); /* vertical */ else IMAGEN_putwd(ux + IMAGEN_orgx); /* horizontal */ } TERM_PUBLIC int IMAGEN_text_angle(ang) int ang; { if (IM_vecpos) { /* fprintf(stderr,"text_angle, draw path\n"); */ IMAGEN_draw_path(); } if (IMAGEN_angle != ang) { IMAGEN_angle = ang; /* record for later use */ putc(imP_SET_ADV_DIRS, gpoutfile); putc(ang == 0 ? 0 : 7, gpoutfile); /* 0=>horiz : 7=>vert */ } return (TRUE); } TERM_PUBLIC int IMAGEN_justify_text(mode) enum JUSTIFY mode; { if (IM_vecpos) { /* fprintf(stderr,"justify_text, draw path\n"); */ IMAGEN_draw_path(); } IMAGEN_justify = mode; return (TRUE); } static unsigned char *IMAGEN_cvts(str, width, height) unsigned char *str; int *width; int *height; { unsigned char *cp1; unsigned char *cp2; static unsigned char *buf = NULL; int h; int maxw; int w; /* Free up old buffer, if there is one, get a new one. Since */ /* all transformations shorten the string, get a buffer that is */ /* the same size as the input string. */ if (buf != NULL) (void) free(buf); buf = (unsigned char *) gp_alloc(strlen((char *) str), "converted label string"); /* Do the transformations. */ cp1 = str; cp2 = buf; h = 1; maxw = 0; w = 0; while (strlen((char *) cp1) > 0) { switch (*cp1) { case ' ': /* Space character. */ *cp2++ = imP_SP; w++; break; case '\\': /* Escape sequence. */ if (*++cp1 == '\\') { /* Begin new line. */ h++; if (w > maxw) maxw = w; w = 0; *cp2++ = '\n'; /* *cp2++ = imP_CRLF; */ break; } /* Fall through to just copy next char out. */ default: /* *cp2++ = *cp1; */ *cp2++ = IMP_chmap[*cp1]; w++; break; } cp1++; } *cp2++ = '\n'; *cp2 = '\0'; if (w > maxw) maxw = w; if (height != NULL) *height = IMAGEN_angle ? IMAGEN_wchar * maxw : IMAGEN_hchar * h; if (width != NULL) *width = IMAGEN_angle ? IMAGEN_hchar * h : IMAGEN_wchar * maxw; return (buf); } TERM_PUBLIC void IMAGEN_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char str[]; /* the text */ { unsigned char *cvstr, *p; int height; int width; int sx, sy; if (IM_vecpos) { /* fprintf(stderr,"put_text, draw path\n"); */ IMAGEN_draw_path(); } cvstr = IMAGEN_cvts((unsigned char *) str, &width, &height); if (IMAGEN_angle) { /* vertical */ /* x += IMAGEN_hchar; */ x -= width / 2 - IMAGEN_hchar; /* y -= height/2; */ } else /* horizontal */ y += height / 2 - IMAGEN_hchar; while ((p = (unsigned char *) strchr((char *) cvstr, '\n'))) { *p = '\0'; sx = x; sy = y; if (IMAGEN_angle) sx = x - IMAGEN_blofs; else sy = y + IMAGEN_blofs; width = strlen((char *) cvstr) * IMAGEN_wchar; switch (IMAGEN_justify) { case LEFT: break; case CENTRE: if (IMAGEN_angle) { sy = y - width / 2; } else { sx = x - width / 2; } break; /*x -= width/2; break; */ case RIGHT: if (IMAGEN_angle) { sy = y - width; } else { sx = x - width; } break; /* x -= width; break; */ } IMAGEN_setpos(sx, sy); fputs((char *) cvstr, gpoutfile); cvstr = ++p; if (IMAGEN_angle) { /* vertical */ x += IMAGEN_hchar; } else { y -= IMAGEN_hchar; } } } TERM_PUBLIC void IMAGEN_reset() { if (IM_vecpos) { /* fprintf(stderr,"reset, draw path\n"); */ IMAGEN_draw_path(); } putc(imP_EOF, gpoutfile); } static void IMAGEN_putwd(w) unsigned int w; { /* fprintf(stderr,"%1u\n",w); */ putc(w >> 8, gpoutfile); putc(w, gpoutfile); } static void IMAGEN_createfamily(c, sz) char *c; int sz; { putc(imP_CREATE_FAMILY_TABLE, gpoutfile); putc(sz, gpoutfile); putc(1, gpoutfile); putc(1, gpoutfile); /* putc(0, gpoutfile); */ fputs(c, gpoutfile); putc(0, gpoutfile); } static void IMAGEN_setfont(sz) int sz; { char font[20]; if (!IMAGEN_familytable[sz]) { sprintf(font, "%s%02d", IMAGEN_FONT, sz); IMAGEN_createfamily(font, sz); IMAGEN_familytable[sz] = sz; } IMAGEN_hchar = sz * 5; IMAGEN_wchar = IMAGEN_hchar / 2; IMAGEN_blofs = IMAGEN_hchar / 3; term->v_char = IMAGEN_hchar; term->h_char = IMAGEN_wchar; putc(imP_SET_FAMILY, gpoutfile); putc(sz, gpoutfile); putc(imP_SET_SP, gpoutfile); IMAGEN_putwd(IMAGEN_wchar); putc(imP_SET_IL, gpoutfile); IMAGEN_putwd(IMAGEN_hchar); } void IMP_set_draw_pattern(pattern, sz) int pattern, sz; { int i /*,j */ ; putc(imP_SET_DRAW_PATTERN, gpoutfile); putc(0, gpoutfile); putc(imP_SET_DRAW_PATTERN, gpoutfile); /* if ( strlen(IMPdrpattern[pattern]) == 1 ) { putc(type,gpoutfile); return; } */ putc(strlen(IMPdrpattern[pattern]), gpoutfile); for (i = 0; i < strlen(IMPdrpattern[pattern]); i++) { IMAGEN_putwd(IMPdrpattern[pattern][i] * sz); } } void IMAGEN_mapsinit() { register int i /*, j */ ; for (i = 32; i < 127; i++) { IMP_gmap[i] = i; } IMP_gmap[1] = 225; IMP_gmap[2] = 233; IMP_gmap[3] = 61736; IMP_gmap[4] = 241; IMP_gmap[5] = 249; IMP_gmap[6] = 61864; IMP_gmap[7] = 162; IMP_gmap[8] = 163; IMP_gmap[9] = 164; IMP_gmap[10] = 165; IMP_gmap[11] = 167; IMP_gmap[12] = 171; IMP_gmap[13] = 182; IMP_gmap[14] = 61346; IMP_gmap[15] = 191; IMP_gmap[16] = 187; IMP_gmap[17] = 188; IMP_gmap[18] = 189; IMP_gmap[19] = 190; IMP_gmap[20] = 210; IMP_gmap[21] = 211; IMP_gmap[22] = 251; IMP_gmap[23] = 61232; IMP_gmap[24] = 212; IMP_gmap[25] = 137; IMP_gmap[26] = 176; IMP_gmap[27] = 161; IMP_gmap[28] = 139; IMP_gmap[29] = 133; IMP_gmap[30] = 140; IMP_gmap[31] = 61249; IMP_gmap[32] = 8738; IMP_gmap[34] = 186; IMP_gmap[36] = 164; IMP_gmap[39] = 185; IMP_gmap[127] = 61286; /* for (i=1;i<127;i++) fprintf(stderr,"%d -> %d\n",i,IMP_gmap[i]); */ for (i = 32; i <= 127; i++) { IMP_chmap[i] = i; } for (i = 128; i <= 255; i++) { IMP_chmap[i] = 128; /* first map all non printable chars to SPACE */ } IMP_chmap[161] = 27; IMP_chmap[162] = 7; IMP_chmap[163] = 8; IMP_chmap[164] = 120; IMP_chmap[165] = 10; IMP_chmap[166] = 124; IMP_chmap[167] = 11; IMP_chmap[168] = 25; IMP_chmap[169] = 21; IMP_chmap[170] = 45; IMP_chmap[171] = 12; IMP_chmap[172] = 83; IMP_chmap[173] = 45; IMP_chmap[174] = 20; IMP_chmap[175] = 126; IMP_chmap[176] = 26; IMP_chmap[177] = 12; IMP_chmap[178] = 1; IMP_chmap[179] = 2; IMP_chmap[180] = 29; IMP_chmap[181] = 52; IMP_chmap[182] = 13; IMP_chmap[183] = 5; IMP_chmap[184] = 28; IMP_chmap[185] = 3; IMP_chmap[186] = 45; IMP_chmap[187] = 16; IMP_chmap[188] = 17; IMP_chmap[189] = 18; IMP_chmap[190] = 19; IMP_chmap[191] = 15; IMP_chmap[192] = 65; IMP_chmap[193] = 65; IMP_chmap[194] = 65; IMP_chmap[195] = 65; IMP_chmap[196] = 65; IMP_chmap[197] = 3; IMP_chmap[198] = 1; IMP_chmap[199] = 67; IMP_chmap[200] = 69; IMP_chmap[201] = 69; IMP_chmap[202] = 69; IMP_chmap[203] = 69; IMP_chmap[204] = 73; IMP_chmap[205] = 73; IMP_chmap[206] = 73; IMP_chmap[207] = 73; IMP_chmap[208] = 68; IMP_chmap[209] = 78; IMP_chmap[210] = 79; IMP_chmap[211] = 79; IMP_chmap[212] = 79; IMP_chmap[213] = 79; IMP_chmap[214] = 79; IMP_chmap[215] = 13; IMP_chmap[216] = 2; IMP_chmap[217] = 85; IMP_chmap[218] = 85; IMP_chmap[219] = 85; IMP_chmap[220] = 85; IMP_chmap[221] = 89; IMP_chmap[222] = 32; IMP_chmap[223] = 22; IMP_chmap[224] = 97; IMP_chmap[225] = 97; IMP_chmap[226] = 97; IMP_chmap[227] = 97; IMP_chmap[228] = 97; IMP_chmap[229] = 6; IMP_chmap[230] = 4; IMP_chmap[231] = 99; IMP_chmap[232] = 101; IMP_chmap[233] = 101; IMP_chmap[234] = 101; IMP_chmap[235] = 101; IMP_chmap[236] = 105; IMP_chmap[237] = 105; IMP_chmap[238] = 105; IMP_chmap[239] = 105; IMP_chmap[240] = 100; IMP_chmap[241] = 110; IMP_chmap[242] = 111; IMP_chmap[243] = 111; IMP_chmap[244] = 111; IMP_chmap[245] = 111; IMP_chmap[246] = 111; IMP_chmap[247] = 10; IMP_chmap[248] = 5; IMP_chmap[249] = 117; IMP_chmap[250] = 117; IMP_chmap[251] = 117; IMP_chmap[252] = 117; IMP_chmap[253] = 121; IMP_chmap[254] = 32; IMP_chmap[255] = 121; } void IMAGEN_createmap(name, map) unsigned short *map; int name; { register int i, j; unsigned char s[4], *p; p = s; *p++ = imP_CREATE_MAP; *p++ = name; j = 0; for (i = 0; i < 127; i++) { if (map[i]) j++; } *p = j; for (i = 0; i < 3; i++) putc(s[i], gpoutfile); s[3] = 1; for (j = 0; j < 127; j++) { if (map[j]) { p = s; *p++ = j; *p++ = map[j] >> 8; *p = map[j] & 255; for (i = 0; i < 4; i++) putc(s[i], gpoutfile); } } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(imagen_driver) "imagen", "Imagen laser printer", IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR, IMAGEN_VTIC, IMAGEN_HTIC, IMAGEN_options, IMAGEN_init, IMAGEN_reset, IMAGEN_text, null_scale, IMAGEN_graphics, IMAGEN_move, IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle, IMAGEN_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(imagen_driver) #undef LAST_TERM #define LAST_TERM imagen_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(imagen) "1 imagen", "?commands set terminal imagen", "?set terminal imagen", "?set term imagen", "?terminal imagen", "?term imagen", "?imagen", " The `imagen` terminal driver supports Imagen laser printers. It is capable", " of placing multiple graphs on a single page.", "", " Syntax:", " set terminal imagen {} {portrait | landscape}", " {[,]}", "", " where `fontsize` defaults to 12 points and the layout defaults to `landscape`.", " `` and `` are the number of graphs in the horizontal and", " vertical directions; these default to unity.", "", " Example:", " set terminal imagen portrait [2,3]", "", " puts six graphs on the page in three rows of two in portrait orientation." END_HELP(imagen) #endif /* * $Id: iris4d.trm,v 1.16 1998/04/14 00:17:52 drd Exp $ * */ /* GNUPLOT - iris4d.trm */ /*[ * Copyright 1990 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * IRIS terminals * * AUTHORS * John H. Merritt * (Applied Research Corporation) 7/1/89 * INTERNET: merritt@iris613.gsfc.nasa.gov * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(iris4d) #endif #ifdef TERM_PROTO TERM_PUBLIC void IRIS4D_options __PROTO((void)); TERM_PUBLIC void IRIS4D_init __PROTO((void)); TERM_PUBLIC void IRIS4D_graphics __PROTO((void)); TERM_PUBLIC void IRIS4D_text __PROTO((void)); TERM_PUBLIC void IRIS4D_linetype __PROTO((int linetype)); TERM_PUBLIC void IRIS4D_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void IRIS4D_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void IRIS4D_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void IRIS4D_reset __PROTO((void)); #define IRIS4D_XMAX 1024 #define IRIS4D_YMAX 1024 #define IRIS4D_VCHAR (IRIS4D_YMAX/30) #define IRIS4D_HCHAR (IRIS4D_XMAX/72) #define IRIS4D_VTIC (IRIS4D_YMAX/80) #define IRIS4D_HTIC (IRIS4D_XMAX/80) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void IRIS4D_cmove __PROTO((unsigned int x, unsigned int y)); #include #define IRIS4DRC ".gnuplot_iris4d" #define IRIS4D_XLAST (IRIS4D_XMAX - 1) #define IRIS4D_YLAST (IRIS4D_YMAX - 1) static short colors24bits[][3] = { {85, 85, 85}, /* 0. BACK GROUND ( DARKGRAY ) */ {0, 0, 0}, /* 1. BLACK */ {170, 0, 170}, /* 2. MAGENTA */ {85, 255, 255}, /* 3. LIGHTCYAN */ {170, 0, 0}, /* 4. RED */ {0, 170, 0}, /* 5. GREEN */ {255, 85, 255}, /* 6. LIGHTMAGENTA */ {255, 255, 85}, /* 7. YELLOW */ {255, 85, 85}, /* 8. LIGHTRED */ {85, 255, 85}, /* 9. LIGHTGREEN */ {0, 170, 170}, /* 10. CYAN */ {170, 170, 0}, /* 11. BROWN */ }; #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3)) static iris24bits = FALSE; #define IRIS4D_BACKGROUND 0 #define IRIS4D_BLACK 1 #define IRIS4D_MAGENTA 2 #define IRIS4D_LIGHTCYAN 3 #define IRIS4D_RED 4 #define IRIS4D_GREEN 5 #define IRIS4D_LIGHTMAGENTA 6 #define IRIS4D_YELLOW 7 #define IRIS4D_LIGHTRED 8 #define IRIS4D_LIGHTGREEN 9 #define IRIS4D_CYAN 10 #define IRIS4D_BROWN 11 TERM_PUBLIC void IRIS4D_options() { int i = 0; struct value a; if (!END_OF_COMMAND) { i = (int) real(const_express(&a)); } iris24bits = (i == 24); sprintf(term_options, "%s", iris24bits ? "24" : "8"); } TERM_PUBLIC void IRIS4D_init() { int i; char homedirfile[80], line[80]; FILE *f; foreground(); winopen("Gnuplot"); if (iris24bits) { RGBmode(); gconfig(); } /* BAD CODING STYLE! What about error checking? lh */ strcat(strcat(strcpy(homedirfile, getenv("HOME")), "/"), IRIS4DRC); if ((f = fopen(IRIS4DRC, "r")) != NULL || (f = fopen(homedirfile, "r")) != NULL) { int c1, c2, c3; for (i = 0; i < COLOR24_SIZE; i++) { if (fgets(line, 79, f) == NULL || sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3) int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET); colors24bits[i][0] = c1; colors24bits[i][1] = c2; colors24bits[i][2] = c3; } fclose(f); } deflinestyle(1, 0x3FFF); /* long dash */ deflinestyle(2, 0x5555); /* dotted */ deflinestyle(3, 0x3333); /* short dash */ deflinestyle(4, 0xB5AD); /* dotdashed */ deflinestyle(5, 0x0F0F); /* dashed */ deflinestyle(6, 0xBBBB); /* dotdashed */ deflinestyle(7, 0x3F3F); /* mid-long dash */ deflinestyle(8, 0x7777); /* mid-long dash */ return; } TERM_PUBLIC void IRIS4D_graphics() { reshapeviewport(); ortho2((Coord) 0, (Coord) IRIS4D_XMAX, (Coord) 0, (Coord) IRIS4D_YMAX); if (iris24bits) RGBcolor(colors24bits[IRIS4D_BACKGROUND][0], colors24bits[IRIS4D_BACKGROUND][1], colors24bits[IRIS4D_BACKGROUND][2]); else color(WHITE); clear(); return; } TERM_PUBLIC void IRIS4D_text() { gflush(); /* flush buffer */ return; /* enter text from another window!!! */ } TERM_PUBLIC void IRIS4D_linetype(linetype) int linetype; { static int pen_color_24[11] = { IRIS4D_BLACK, /* reserved for border and numbers */ IRIS4D_MAGENTA, /* reserved for axis traces */ IRIS4D_LIGHTCYAN, IRIS4D_RED, IRIS4D_GREEN, IRIS4D_LIGHTMAGENTA, IRIS4D_YELLOW, IRIS4D_LIGHTRED, IRIS4D_LIGHTGREEN, IRIS4D_CYAN, IRIS4D_BROWN, }; static int pen_color[8] = {0, 1, 4, 5, 6, 1, 2, 4}; if (iris24bits) { int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2]; RGBcolor(colors24bits[pencolor][0], colors24bits[pencolor][1], colors24bits[pencolor][2]); /* Make all lines solid (linestyle 0) upto to the ninth. If more than * 9 colors are needed, start to use the different line styles (1 to 8). */ setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1); } else { linetype = linetype % 8; color((Colorindex) pen_color[linetype]); setlinestyle(linetype); } return; } TERM_PUBLIC void IRIS4D_move(x, y) unsigned int x, y; { move2i(x, y); return; } void IRIS4D_cmove(x, y) unsigned int x, y; { cmov2i(x, y); return; } TERM_PUBLIC void IRIS4D_vector(x, y) unsigned int x, y; { draw2i(x, y); return; } TERM_PUBLIC void IRIS4D_put_text(x, y, str) unsigned int x, y; char *str; { IRIS4D_cmove(x, y - IRIS4D_VCHAR / 2); charstr(str); return; } TERM_PUBLIC void IRIS4D_reset() { return; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(iris4d_driver) "iris4d", "Silicon Graphics IRIS 4D Series Computer", IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector, IRIS4D_linetype, IRIS4D_put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(iris4d_driver) #undef LAST_TERM #define LAST_TERM iris4d_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(iris4d) "1 iris4d", "?commands set terminal iris4d", "?set terminal iris4d", "?set term iris4d", "?terminal iris4d", "?term iris4d", "?iris4d", " The `iris4d` terminal driver supports Silicon Graphics IRIS 4D computers.", " Its only option is 8- or 24-bit color depth. The default is 8.", "", " Syntax:", " set terminal iris4d {8 | 24}", "", " The color depth is not really a choice -- the value appropriate for the", " hardware should be selected.", "", " When using 24-bit mode, the colors can be directly specified via the file", " .gnuplot_iris4d that is searched in the current directory and then in the", " home directory specified by the HOME environment variable. This file holds", " RGB values for the background, border, labels and nine plotting colors, in", " that order. For example, here is a file containing the default colors:", "", " 85 85 85 Background (dark gray)", " 0 0 0 Boundary (black)", " 170 0 170 Labeling (magenta)", " 85 255 255 Plot Color 1 (light cyan)", " 170 0 0 Plot Color 2 (red)", " 0 170 0 Plot Color 3 (green)", " 255 85 255 Plot Color 4 (light magenta)", " 255 255 85 Plot Color 5 (yellow)", " 255 85 85 Plot Color 6 (light red)", " 85 255 85 Plot Color 7 (light green)", " 0 170 170 Plot Color 8 (cyan)", " 170 170 0 Plot Color 9 (brown)", "", " This file must have exactly 12 lines of RGB triples. No empty lines are", " allowed, and anything after the third number on a line is ignored." END_HELP(iris4d) #endif /* TERM_TABLE */ /* * $Id: kyo.trm,v 1.12 1998/04/14 00:17:52 drd Exp $ * */ /* Prescribe (KYOCERA) driver - Michael Waldor */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* Modified for gnuplot 2.0 sk@sun4 24-Apr-1990 13:23 */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(prescribe) register_term(kyo) #endif #ifdef TERM_PROTO TERM_PUBLIC void PRE_init __PROTO((void)); TERM_PUBLIC void KYO_init __PROTO((void)); TERM_PUBLIC void PRE_graphics __PROTO((void)); TERM_PUBLIC void PRE_text __PROTO((void)); TERM_PUBLIC void PRE_linetype __PROTO((int linetype)); TERM_PUBLIC void PRE_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PRE_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PRE_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int PRE_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void PRE_reset __PROTO((void)); #define PRE_XMAX 2567 #define PRE_YMAX 1815 /* X:Y = sqrt(2) */ #define PRE_VCHAR (PRE_YMAX/30) #define PRE_HCHAR 33 /* about 9 chars per inch */ #define PRE_HTIC (PRE_XMAX/80) #define PRE_VTIC PRE_HTIC /* for Courier font: */ #define KYO_VCHAR (14*(300/72)) /* 12 pt + 2 pt baselineskip */ #define KYO_HCHAR (300/10) /* 10 chars per inch */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #define PRE_XLAST (PRE_XMAX - 1) #define PRE_YLAST (PRE_YMAX - 1) enum JUSTIFY pre_justify = LEFT; /* text is flush left */ TERM_PUBLIC void PRE_init() { fputs("!R! RES;\n", gpoutfile); /* UNIT: units are dots, 300 dots = 1 in = 72 pt */ /* SPO: landscape format */ /* STM, SLM set top, left margin */ /* Font: bold Helvetica (proportional font) */ fputs("PAGE; UNIT D; SPO L; STM 280; SLM 440;\n", gpoutfile); fputs("FTMD 15; FONT 29; SCPI 9;\n", gpoutfile); } TERM_PUBLIC void KYO_init() { fputs("!R! RES;\n", gpoutfile); /* UNIT: units are dots, 300 dots = 1 in = 72 pt */ /* SPO: landscape format */ /* STM, SLM set top, left margin */ /* Font: Courier (fixed width font) */ fputs("PAGE; UNIT D; SPO L; STM 280; SLM 440;\n", gpoutfile); fputs("FTMD 15; FONT 17; SCPI 10;\n", gpoutfile); } TERM_PUBLIC void PRE_graphics() { } TERM_PUBLIC void PRE_text() { /* eject page after each plot */ fputs("PAGE;\n", gpoutfile); } TERM_PUBLIC void PRE_linetype(linetype) int linetype; { /* actually choose pendiameter */ if (linetype < 0) linetype = -linetype; else linetype = 3; (void) fprintf(gpoutfile, "SPD %d;\n", linetype); } TERM_PUBLIC void PRE_move(x, y) unsigned int x, y; { (void) fprintf(gpoutfile, "MAP %1d,%1d;\n", x, PRE_YMAX - y); } TERM_PUBLIC void PRE_vector(x, y) unsigned int x, y; { (void) fprintf(gpoutfile, "DAP %1d, %1d;\n", x, PRE_YMAX - y); } TERM_PUBLIC void PRE_put_text(x, y, str) unsigned int x, y; char *str; { PRE_move(x, y); switch (pre_justify) { case RIGHT: (void) fprintf(gpoutfile, "RTXT \"%s\", B;\n", str); break; default: (void) fprintf(gpoutfile, "TEXT \"%s\", B;\n", str); } } TERM_PUBLIC int PRE_justify_text(mode) enum JUSTIFY mode; { pre_justify = mode; switch (pre_justify) { case LEFT: case RIGHT: return (TRUE); default: return (FALSE); } } TERM_PUBLIC void PRE_reset() { fputs("PAGE; RES; EXIT;\n", gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(prescribe_driver) "prescribe", "Prescribe - for the Kyocera Laser Printer", PRE_XMAX, PRE_YMAX, PRE_VCHAR, PRE_HCHAR, PRE_VTIC, PRE_HTIC, options_null, PRE_init, PRE_reset, PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, PRE_linetype, PRE_put_text, null_text_angle, PRE_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(prescribe_driver) #undef LAST_TERM #define LAST_TERM prescribe_driver TERM_TABLE_START(kyo_driver) "kyo", "Kyocera Laser Printer with Courier font", PRE_XMAX, PRE_YMAX, KYO_VCHAR, KYO_HCHAR, PRE_VTIC, PRE_HTIC, options_null, KYO_init, PRE_reset, PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, PRE_linetype, PRE_put_text, null_text_angle, PRE_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(kyo_driver) #undef LAST_TERM #define LAST_TERM kyo_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(kyo) "1 kyo", "?commands set terminal kyo", "?set terminal kyo", "?set term kyo", "?terminal kyo", "?term kyo", "?kyo", "?commands set terminal prescribe", "?set terminal prescribe", "?set term prescribe", "?terminal prescribe", "?term prescribe", "?prescribe", " The `kyo` and `prescribe` terminal drivers support the Kyocera laser printer.", " The only difference between the two is that `kyo` uses \"Helvetica\" whereas", " `prescribe` uses \"Courier\". There are no options." END_HELP(kyo) #endif /* * $Id: latex.trm,v 1.63 1998/04/14 00:17:53 drd Exp $ * */ /* GNUPLOT - latex.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * LaTeX pictures (latex). * LaTeX pictures with emTeX specials (emtex). * * AUTHORS * David Kotz, Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* modified to optimize use of \rule for long lines */ /* TLDC: modified to have nice line types */ /* the following LATEX driver has been modified by Russell Lang, eln272v@monu1.cc.monash.oz from the GnuTeX 1.3 driver by David Kotz, David.Kotz@Dartmouth.edu. Since then it has been further extended by David Kotz. EmTeX driver by Russell Lang. */ /* 9 Dec 1992 LATEX_put_text rewritten to handle \\ newlines Daniel S. Lewart (d-lewart@uiuc.edu) */ /* Since it took me a little while to figure out what is happening, * I may as well write it down. * There are three length scales of interest: inches, points * and dots. inches are obvious. points are the usual typesetting * thing (ie approx 72 points per inch). This driver works in * units of dots, which corresponds to pixels on a 300 DPI printer. * We do a \setlength{unitlength}{...pt} to make teX work in * terms of dots. The ... is called LATEX_UNIT in here. * The reason I had to get involved in all of this is because * font size (in pts) was not being scaled up by DOTS_PER_POINT * - drd, Sept 1996 */ #include "driver.h" #ifdef TERM_REGISTER register_term(latex) #ifdef EMTEX register_term(emtex) #endif #endif #ifdef TERM_PROTO TERM_PUBLIC void LATEX_options __PROTO((void)); TERM_PUBLIC void LATEX_init __PROTO((void)); TERM_PUBLIC void LATEX_graphics __PROTO((void)); TERM_PUBLIC void LATEX_text __PROTO((void)); TERM_PUBLIC void LATEX_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void LATEX_linetype __PROTO((int linetype)); TERM_PUBLIC void LATEX_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void LATEX_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void LATEX_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void LATEX_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC int LATEX_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int LATEX_text_angle __PROTO((int ang)); TERM_PUBLIC void LATEX_reset __PROTO((void)); #ifdef EMTEX TERM_PUBLIC void EMTEX_init __PROTO((void)); TERM_PUBLIC void EMTEX_reset __PROTO((void)); TERM_PUBLIC void EMTEX_text __PROTO((void)); #endif #define TINY_STEP 0.5 /* tiny steps for high quality lines */ #define LATEX_PTS_PER_INCH (72.27) #define DOTS_PER_INCH (300) /* resolution of printer we expect to use */ #define LATEX_UNIT (LATEX_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */ /* 5 inches wide by 3 inches high (default) */ #define LATEX_XMAX (5*DOTS_PER_INCH) /* (LATEX_PTS_PER_INCH/LATEX_UNIT*5.0) */ #define LATEX_YMAX (3*DOTS_PER_INCH) /* (LATEX_PTS_PER_INCH/LATEX_UNIT*3.0) */ #define LATEX_HTIC (5*DOTS_PER_INCH/72) /* (5 pts) */ #define LATEX_VTIC (5*DOTS_PER_INCH/72) /* (5 pts) */ #define LATEX_HCHAR (DOTS_PER_INCH*53/10/72) /* (5.3 pts) */ #define LATEX_VCHAR (DOTS_PER_INCH*11/72) /* (11 pts) */ #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int LATEX_posx; static int LATEX_posy; static int LATEX_fontsize = 10; static char LATEX_font[MAX_ID_LEN+1] = "cmr"; static enum JUSTIFY latex_justify = LEFT; static int latex_angle = 0; /* Default line-drawing character */ /* the definition of plotpoint varies with linetype */ #define LATEX_DOT "\\usebox{\\plotpoint}" #define LATEX_TINY_DOT "\\rule{1pt}{1pt}" /* for dots plot style */ /* POINTS */ #define LATEX_POINT_TYPES 12 /* we supply more point types */ static char GPFAR *GPFAR LATEX_points[] = { "\\raisebox{-.8pt}{\\makebox(0,0){$\\Diamond$}}", "\\makebox(0,0){$+$}", "\\raisebox{-.8pt}{\\makebox(0,0){$\\Box$}}", "\\makebox(0,0){$\\times$}", "\\makebox(0,0){$\\triangle$}", "\\makebox(0,0){$\\star$}", "\\circle{12}", "\\circle{18}", "\\circle{24}", "\\circle*{12}", "\\circle*{18}", "\\circle*{24}" }; /* LINES */ static float LATEX_size = 0; /* current thick of line in points */ static float LATEX_dotspace = 0; /* current dotspace of line in points */ #define LATEX_LINE_TYPES 6 /* number of line types below */ #define LATEX_THIN_LINE 0 /* the thinnest solid line type */ static struct { float size; /* size of dot, or thick of line in points */ float dotspace; /* inter-dot space in points; 0 for lines */ } GPFAR LATEX_lines[] = { {0.4, 0.0}, /* thin solid line */ {0.4, 5.0}, /* thin dotted line */ {0.8, 0.0}, /* thick solid line */ {1.0, 5.0}, /* thick dotted line */ {1.2, 0.0}, /* Thick solid line */ {1.0, 10.0}, /* thick widely dotted line */ }; /* for drawing dotted and solid lines */ static void LATEX_dot_line __PROTO((int x1, int x2, int y1, int y2)); static void LATEX_solid_line __PROTO((int x1, int x2, int y1, int y2)); static void LATEX_rule __PROTO((int code, double x, double y, double width, double height)); static void LATEX_flushdot __PROTO((void)); #define LATEX_flushrule() LATEX_rule(2, 0.,0.,0.,0.) /* flush old rule */ static TBOOLEAN LATEX_moved = TRUE; /* pen is up after move */ static float LATEX_dotsize; /* size of LATEX_DOT in units */ static TBOOLEAN LATEX_needsdot = FALSE; /* does dotted line need termination? */ #ifdef EMTEX TBOOLEAN emtex = FALSE; /* not currently using emtex */ static void EMTEX_solid_line __PROTO((int x1, int x2, int y1, int y2)); #endif /* ARROWS */ /* the set of non-vertical/non-horizontal LaTeX vector slopes */ /* except negatives - they are handled specially */ static struct vslope { int dx, dy; } GPFAR LATEX_slopes[] = { {1, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 1}, {2, 3}, {3, 1}, {3, 2}, {3, 4}, {4, 1}, {4, 3}, {0, 0} /* terminator */ }; /* figure out the best arrow */ void best_latex_arrow __PROTO((int, int, int, int, int, TBOOLEAN)); TERM_PUBLIC void LATEX_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "c$ourier")) { strcpy(LATEX_font, "cmtt"); c_token++; } else if (almost_equals(c_token, "r$oman")) { strcpy(LATEX_font, "cmr"); c_token++; } else if (almost_equals(c_token, "d$efault")) { strcpy(LATEX_font, "cmr"); LATEX_fontsize = 10; c_token++; } } if (!END_OF_COMMAND) { struct value a; LATEX_fontsize = (int) real(const_express(&a)); } /* tell gnuplot core about char. sizes. Horizontal spacing * is about half the text pointsize */ term->v_char = (unsigned int) (LATEX_fontsize * DOTS_PER_INCH / 72); term->h_char = (unsigned int) (LATEX_fontsize * DOTS_PER_INCH / 144); sprintf(term_options, "%s %d", LATEX_font[2] == 't' ? "courier" : "roman", LATEX_fontsize); } TERM_PUBLIC void LATEX_init() { #ifdef EMTEX emtex = FALSE; #endif LATEX_posx = LATEX_posy = 0; fprintf(gpoutfile, "\ %% GNUPLOT: LaTeX picture\n\ \\setlength{\\unitlength}{%fpt}\n\ \\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n", LATEX_UNIT); LATEX_linetype(-1); LATEX_size = 0; } TERM_PUBLIC void LATEX_graphics() { register struct termentry *t = term; /* bounding box */ int xscale = xsize * t->xmax; int yscale = ysize * t->ymax; fprintf(gpoutfile, "\ \\begin{picture}(%d,%d)(0,0)\n\ \\font\\gnuplot=%s10 at %dpt\n\ \\gnuplot\n", xscale, yscale, LATEX_font, LATEX_fontsize); } TERM_PUBLIC void LATEX_text() { LATEX_flushrule(); LATEX_flushdot(); fputs("\\end{picture}\n", gpoutfile); LATEX_posx = LATEX_posy = 0; /* current position */ LATEX_moved = TRUE; /* pen is up after move */ } TERM_PUBLIC void LATEX_linetype(linetype) int linetype; { float size; if (linetype >= LATEX_LINE_TYPES) linetype %= LATEX_LINE_TYPES; #ifdef EMTEX if (!emtex) #endif LATEX_flushrule(); LATEX_flushdot(); /* Find the new desired line thickness. */ /* negative linetypes (for axes) use a thin line */ /* only relevant for drawing axes/border in 3d */ size = (linetype >= 0 ? LATEX_lines[linetype].size : LATEX_lines[LATEX_THIN_LINE].size); /* If different from current size, redefine \plotpoint */ if (size != LATEX_size) { fprintf(gpoutfile, "\\sbox{\\plotpoint}{\\rule[%.3fpt]{%.3fpt}{%.3fpt}}%%\n", -size / 2, size, size); #ifdef EMTEX if (emtex) /* change line width */ fprintf(gpoutfile, "\\special{em:linewidth %.1fpt}%%\n", size); #endif } LATEX_size = size; LATEX_dotsize = size / LATEX_UNIT; LATEX_dotspace = (linetype >= 0) ? LATEX_lines[linetype].dotspace : 0; LATEX_moved = TRUE; /* reset */ } TERM_PUBLIC void LATEX_move(x, y) unsigned int x, y; { LATEX_flushdot(); LATEX_posx = x; LATEX_posy = y; LATEX_moved = TRUE; /* reset */ } TERM_PUBLIC void LATEX_point(x, y, number) /* version of line_and_point */ unsigned int x, y; int number; /* type of point */ { LATEX_move(x, y); /* Print the character defined by 'number'; number < 0 means to use a dot, otherwise one of the defined points. */ fprintf(gpoutfile, "\\put(%d,%d){%s}\n", x, y, (number < 0 ? LATEX_TINY_DOT : LATEX_points[number % LATEX_POINT_TYPES])); } TERM_PUBLIC void LATEX_vector(ux, uy) unsigned int ux, uy; { if (LATEX_dotspace == 0.0) { /* solid line */ #ifdef EMTEX if (emtex) EMTEX_solid_line(LATEX_posx, (int) ux, LATEX_posy, (int) uy); else #endif LATEX_solid_line(LATEX_posx, (int) ux, LATEX_posy, (int) uy); } else /* dotted line */ LATEX_dot_line(LATEX_posx, (int) ux, LATEX_posy, (int) uy); LATEX_posx = ux; LATEX_posy = uy; } static void LATEX_solid_line(x1, x2, y1, y2) int x1, x2, y1, y2; { float slope; int inc; float dx, dy, x, y; float offset, length; int code; /* possibly combine with previous rule */ /* we draw a solid line using the current line thickness (size) */ /* we do it with lots of \\rules */ if (x1 == x2 && y1 == y2) { /* zero-length line - just a dot */ if (LATEX_moved) { LATEX_flushrule(); /* plot a dot */ fprintf(gpoutfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT); } } else { code = (LATEX_moved ? 0 : 1); /* no combine after move */ LATEX_moved = FALSE; if (x1 == x2) /* vertical line - special case */ LATEX_rule(code, (double) x1, (double) y1, LATEX_dotsize, (double) y2 - y1); else if (y1 == y2) /* horizontal line - special case */ LATEX_rule(code, (double) x1, (double) y1, (double) x2 - x1, LATEX_dotsize); else { dx = (float) x2 - x1; dy = (float) y2 - y1; slope = dy / dx; if (ABS(slope) <= 1.0) { /* longer than high */ x = GPMIN(ABS(dx), (0.25 + 1.0 / ABS(slope)) * LATEX_dotsize); offset = sign(dy) * GPMIN(LATEX_dotsize, ABS(dy)); dy = dy - offset; length = x * LATEX_UNIT; inc = (x == ABS(dx) ? 1 : GPMAX(1, ABS(dy) / TINY_STEP + 0.5)); if (inc == 1) { fprintf(gpoutfile, "\\put(%u,%.2f){\\rule{%.3fpt}{%.3fpt}}\n", (x2 >= x1 ? x1 : x2), ((float) y1 + y2 - LATEX_dotsize) / 2, length, LATEX_dotsize * LATEX_UNIT); } else { dy = dy / inc; dx = (dx - sign(dx) * x) / (inc - 1); fprintf(gpoutfile, "\\multiput(%.2f,%.2f)(%.3f,%.3f){%u}{\\rule{%.3fpt}{%.3fpt}}\n", (dx >= 0.0 ? (float) x1 : x1 - x), (float) y1 - (ABS(dy) - offset) / 2, dx, dy, inc, length, ABS(dy) * LATEX_UNIT); } /* done with one section, now smooth it */ x = x / 2; dx = sign(dx) * x; dx = (float) x2 - x1 - dx; dy = (float) y2 - y1; fprintf(gpoutfile, "\\multiput(%.2f,%.2f)(%.3f,%.3f){2}{\\rule{%.3fpt}{%.3fpt}}\n", (dx >= 0.0 ? (float) x1 : x1 - x), (float) y1 - LATEX_dotsize / 2, dx, dy, x * LATEX_UNIT, LATEX_dotsize * LATEX_UNIT); LATEX_moved = TRUE; } else { /* higher than long */ y = GPMIN(ABS(dy), (0.25 + ABS(slope)) * LATEX_dotsize); offset = sign(dx) * GPMIN(LATEX_dotsize, ABS(dx)); dx = dx - offset; length = y * LATEX_UNIT; inc = (y == ABS(dy) ? 1 : GPMAX(1, ABS(dx) / TINY_STEP + 0.5)); if (inc == 1) { fprintf(gpoutfile, "\\put(%.2f,%u){\\rule{%.3fpt}{%.3fpt}}\n", ((float) x1 + x2 - LATEX_dotsize) / 2, (y2 >= y1 ? y1 : y2), LATEX_dotsize * LATEX_UNIT, length); } else { dx = dx / inc; dy = (dy - sign(dy) * y) / (inc - 1); fprintf(gpoutfile, "\\multiput(%.2f,%.2f)(%.3f,%.3f){%u}{\\rule{%.3fpt}{%.3fpt}}\n", (float) x1 - (ABS(dx) - offset) / 2, (dy >= 0 ? (float) y1 : y1 - y), dx, dy, inc, ABS(dx) * LATEX_UNIT, length); } /* done with one section, now smooth it */ y = y / 2; dx = (float) x2 - x1; dy = sign(dy) * y; dy = (float) y2 - y1 - dy; fprintf(gpoutfile, "\\multiput(%.2f,%.2f)(%.3f,%.3f){2}{\\rule{%.3fpt}{%.3fpt}}\n", (float) x1 - LATEX_dotsize / 2, (dy >= 0.0 ? (float) y1 : y1 - y), dx, dy, LATEX_dotsize * LATEX_UNIT, y * LATEX_UNIT); LATEX_moved = TRUE; } } } } /* Draw a \rule. Width or height may be negative; we can correct. * The rule is never output immediately. The previous rule is output * as-is if code is 0, and the previous rule is * combined with the current rule (if possible) if code is 1. * The previous rule is output, and the new one ignored, if code is 2. */ static void LATEX_rule(code, x, y, width, height) int code; /* how do we treat this rule? */ double x, y; double width; double height; { static float lastx, lasty; static float lastw, lasth; static TBOOLEAN isvalid = FALSE; /* is 'last' data valid? */ TBOOLEAN combine = (code == 1); TBOOLEAN flush = (code == 2); if (!flush) if (width == 0 || height == 0) return; /* ignore this rule */ if (isvalid && combine) { /* try to combine new rule with old rule */ if ((int) lastx == (int) x && lastw == width) { /* vertical rule */ if (lasth * height >= 0) { /* same sign */ lasth += height; return; } } else if ((int) lasty == (int) y && lasth == height) { /* horiz rule */ if (lastw * width >= 0) { /* same sign */ lastw += width; return; } } /* oh well, output last and remember the new one */ } if (isvalid) { /* output the rule */ if (lastw < 0) { lastx += lastw; lastw = -lastw; } if (lasth < 0) { lasty += lasth; lasth = -lasth; } /* if very small use canned dot */ if (lastw < LATEX_dotsize || lasth < LATEX_dotsize) fprintf(gpoutfile, "\\put(%.1f,%.1f){%s}\n", lastx, lasty, LATEX_DOT); else fprintf(gpoutfile, "\\put(%.1f,%.1f){\\rule[%.3fpt]{%.3fpt}{%.3fpt}}\n", lastx, lasty, -LATEX_dotsize * LATEX_UNIT / 2, lastw * LATEX_UNIT, lasth * LATEX_UNIT); } if (flush) { isvalid = FALSE; } else { lastx = x; lasty = y; lastw = width; lasth = height; isvalid = TRUE; } } static void LATEX_dot_line(x1, x2, y1, y2) int x1, x2, y1, y2; { static float LATEX_left; /* fraction of space left after last dot */ /* we draw a dotted line using the current dot spacing */ if (LATEX_moved) LATEX_left = 1.0; /* reset after a move */ /* zero-length line? */ if (x1 == x2 && y1 == y2) { if (LATEX_moved) /* plot a dot */ fprintf(gpoutfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT); } else { float dotspace = LATEX_dotspace / LATEX_UNIT; float x, y; /* current position */ float xinc, yinc; /* increments */ float slope; /* slope of line */ float lastx = -1; /* last x point plotted */ float lasty = -1; /* last y point plotted */ int numdots = 0; /* number of dots in this section */ /* first, figure out increments for x and y */ if (x2 == x1) { xinc = 0.0; yinc = (y2 - y1 > 0) ? dotspace : -dotspace; } else { slope = ((float) y2 - y1) / ((float) x2 - x1); xinc = dotspace / sqrt(1 + slope * slope) * sign(x2 - x1); yinc = slope * xinc; } /* now draw the dotted line */ /* we take into account where we last placed a dot */ for (x = x1 + xinc * (1 - LATEX_left), y = y1 + yinc * (1 - LATEX_left); (x2 - x) * xinc >= 0 && (y2 - y) * yinc >= 0; /* same sign or zero */ lastx = x, x += xinc, lasty = y, y += yinc) numdots++; if (numdots == 1) fprintf(gpoutfile, "\\put(%.2f,%.2f){%s}\n", lastx, lasty, LATEX_DOT); else if (numdots > 0) fprintf(gpoutfile, "\\multiput(%u,%u)(%.3f,%.3f){%u}{%s}\n", x1, y1, xinc, yinc, numdots, LATEX_DOT); /* how much is left over, as a fraction of dotspace? */ if (xinc != 0.0) /* xinc must be nonzero */ if (lastx >= 0) LATEX_left = ABS(x2 - lastx) / ABS(xinc); else LATEX_left += ABS(x2 - x1) / ABS(xinc); else if (lasty >= 0) LATEX_left = ABS(y2 - lasty) / ABS(yinc); else LATEX_left += ABS(y2 - y1) / ABS(yinc); } LATEX_needsdot = (LATEX_left > 0); LATEX_moved = FALSE; } static void LATEX_flushdot() { if (LATEX_needsdot) fprintf(gpoutfile, "\\put(%d,%d){%s}\n", LATEX_posx, LATEX_posy, LATEX_DOT); LATEX_needsdot = FALSE; } TERM_PUBLIC void LATEX_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; TBOOLEAN head; { best_latex_arrow(sx, sy, ex, ey, 1, head); LATEX_posx = ex; LATEX_posy = ey; } void best_latex_arrow(sx, sy, ex, ey, who, head) int sx, sy, ex, ey; /* start and end points */ int who; /* 1=LATEX, 2=EEPIC */ TBOOLEAN head; { int dx = ex - sx; int dy = ey - sy; float m; /* slope of line */ float arrowslope; /* slope of arrow */ float minerror = 0; /* best-case error */ struct vslope *slope; /* one of the slopes */ struct vslope *bestslope; /* the slope with min error */ /* We try to draw a real arrow (ie, \vector). If we can't get * a slope that is close, we draw a bent arrow. */ if (dx == 0) { /* vertical arrow */ fprintf(gpoutfile, "\\put(%d,%d){\\%s(0,%d){%d}}\n", sx, sy, head ? "vector" : "line", sign(ey - sy), ABS(ey - sy)); } else if (dy == 0) { /* horizontal arrow */ fprintf(gpoutfile, "\\put(%d,%d){\\%s(%d,0){%d}}\n", sx, sy, head ? "vector" : "line", sign(ex - sx), ABS(ex - sx)); } else { /* Slanted arrow. We'll give it a try. * we try to find the closest-slope arrowhead. */ bestslope = NULL; minerror = 0; /* to shut up turbo C */ m = ABS((float) dy / dx); /* the slope we want */ for (slope = LATEX_slopes; slope->dx != 0.0; slope++) { /* find the slope of the arrow */ arrowslope = (float) slope->dy / slope->dx; if (bestslope == NULL || ABS(m - arrowslope) < minerror) { minerror = ABS(m - arrowslope); bestslope = slope; } } /* now we have the best slope arrow */ /* maybe it's exactly the right slope! */ if (minerror == 0.0) /* unlikely but possible */ fprintf(gpoutfile, "\\put(%d,%d){\\%s(%d,%d){%d}}\n", sx, sy, head ? "vector" : "line", bestslope->dx * sign(ex - sx), bestslope->dy * sign(ey - sy), ABS(ex - sx)); else { /* we draw the line the usual way, with thin lines */ #ifdef EMTEX if (emtex) { LATEX_linetype(LATEX_THIN_LINE); EMTEX_solid_line(sx, ex, sy, ey); } else #endif if (who == 1) { LATEX_linetype(LATEX_THIN_LINE); LATEX_solid_line(sx, ex, sy, ey); } #ifdef EEPIC else { EEPIC_move(sx, sy); EEPIC_vector(ex, ey); } #endif /* EEPIC */ /* and then draw an arrowhead (a short vector) there */ if (head) fprintf(gpoutfile, "\\put(%d,%d){\\vector(%d,%d){0}}\n", ex, ey, bestslope->dx * sign(ex - sx), bestslope->dy * sign(ey - sy)); } } } TERM_PUBLIC void LATEX_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char str[]; /* the text */ { static char *justify[] = {"[l]", "", "[r]"}; int flag, i; /* ignore empty strings */ if (str[0] == NUL) return; for (flag = FALSE, i = 0; str[i] && !flag;) flag = (str[i++] == '\\') && (str[i++] == '\\'); fprintf(gpoutfile, "\\put(%d,%d)", x, y); if ((str[0] == '{') || (str[0] == '[')) { fprintf(gpoutfile, "{\\makebox(0,0)%s}\n", str); } else if (flag) fprintf(gpoutfile, "{\\makebox(0,0)%s{\\shortstack{%s}}}\n", justify[latex_justify], str); else fprintf(gpoutfile, "{\\makebox(0,0)%s{%s}}\n", justify[latex_justify], str); } TERM_PUBLIC int LATEX_justify_text(mode) enum JUSTIFY mode; { latex_justify = mode; return (TRUE); } TERM_PUBLIC int LATEX_text_angle(ang) int ang; { /* we can't really write text vertically, but this will put the ylabel centred at the left of the plot, and then we'll make a \shortstack */ latex_angle = ang; return (TRUE); } TERM_PUBLIC void LATEX_reset() { LATEX_posx = LATEX_posy = 0; /* current position */ LATEX_moved = TRUE; /* pen is up after move */ } #ifdef EMTEX TERM_PUBLIC void EMTEX_init() { emtex = TRUE; LATEX_posx = LATEX_posy = 0; fprintf(gpoutfile, "\ %% GNUPLOT: LaTeX picture with emtex specials\n\ \\setlength{\\unitlength}{%fpt}\n\ \\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n", LATEX_UNIT); LATEX_linetype(-1); } TERM_PUBLIC void EMTEX_reset() { emtex = FALSE; LATEX_posx = LATEX_posy = 0; } TERM_PUBLIC void EMTEX_text() { fputs("\\end{picture}\n", gpoutfile); } static void EMTEX_solid_line(x1, x2, y1, y2) int x1, x2, y1, y2; { /* emtex special solid line */ if (LATEX_moved) fprintf(gpoutfile, "\\put(%d,%d){\\special{em:moveto}}\n", x1, y1); if ((x1 != x2) || (y1 != y2)) fprintf(gpoutfile, "\\put(%d,%d){\\special{em:lineto}}\n", x2, y2); LATEX_posx = x2; LATEX_posy = y2; LATEX_moved = FALSE; } #endif /* EMTEX */ #endif /* TERM_BODY */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_TABLE TERM_TABLE_START(latex_driver) "latex", "LaTeX picture environment", LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, LATEX_VTIC, LATEX_HTIC, LATEX_options, LATEX_init, LATEX_reset, LATEX_text, null_scale, LATEX_graphics, LATEX_move, LATEX_vector, LATEX_linetype, LATEX_put_text, LATEX_text_angle, LATEX_justify_text, LATEX_point, LATEX_arrow, set_font_null TERM_TABLE_END(latex_driver) #undef LAST_TERM #define LAST_TERM latex_driver #ifdef EMTEX TERM_TABLE_START(emtex_driver) "emtex", "LaTeX picture environment with emTeX specials", LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, LATEX_VTIC, LATEX_HTIC, LATEX_options, EMTEX_init, EMTEX_reset, EMTEX_text, null_scale, LATEX_graphics, LATEX_move, LATEX_vector, LATEX_linetype, LATEX_put_text, LATEX_text_angle, LATEX_justify_text, LATEX_point, LATEX_arrow, set_font_null TERM_TABLE_END(emtex_driver) #undef LAST_TERM #define LAST_TERM emtex_driver #endif /* EMTEX */ #endif /* TERM_TABLE */ #ifdef TERM_HELP START_HELP(latex) "1 latex", "?commands set terminal emtex", "?set terminal emtex", "?set term emtex", "?terminal emtex", "?term emtex", "?latex", "?commands set terminal latex", "?set terminal latex", "?set term latex", "?terminal latex", "?term latex", "?emtex", " The `latex` and `emtex` drivers allow two options.", "", " Syntax:", " set terminal latex | emtex {courier | roman} {}", "", " `fontsize` may be any size you specify. The default is 10-point Roman.", "", " Unless your driver is capable of building fonts at any size (e.g. dvips),", " stick to the standard 10, 11 and 12 point sizes.", "", " METAFONT users beware: METAFONT does not like odd sizes.", "", " All drivers for LaTeX offer a special way of controlling text positioning:", " If any text string begins with '{', you also need to include a '}' at the", " end of the text, and the whole text will be centered both horizontally", " and vertically by LaTeX. --- If the text string begins with '[', you need", " to continue it with: a position specification (up to two out of t,b,l,r),", " ']{', the text itself, and finally, '}'. The text itself may be anything", " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.", "", " Examples:", " About label positioning:", " Use gnuplot defaults (mostly sensible, but sometimes not really best):", " set title '\\LaTeX\\ -- $ \\gamma $'", " Force centering both horizontally and vertically:", " set label '{\\LaTeX\\ -- $ \\gamma $}' at 0,0", " Specify own positioning (top here):", " set xlabel '[t]{\\LaTeX\\ -- $ \\gamma $}'", " The other label -- account for long ticlabels:", " set ylabel '[r]{\\LaTeX\\ -- $ \\gamma $\\rule{7mm}{0pt}'" END_HELP(latex) #endif /* TERM_TABLE */ /* * $Id: linux.trm,v 1.21 1998/06/18 14:59:20 ddenholm Exp $ * */ /* GNUPLOT - linux.trm */ /*[ * Copyright 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * SVGA up to 1024x768x256 for PC's running the Linux Operating System * (also VGA 640x480x16, and SVGA 800x600x256) * * AUTHOR * Scott Heavner (sdh@po.cwru.edu) * based on original linux.trm by Tommy Frandsen (frandsen@diku.dk) * patched by David J. Liu (liu@molecule.phri.nyu.edu) * to increase perfomance and safety based on the features of SVGALib/GL. * send your comments or suggestions to (pixar!info-gnuplot@sun.com). */ /* * Compile with Linux SVGAlib 0.95 currently maintained by * Harm Hanemaayer (hhanemaa@cs.ruu.nl). * supports Trident, Tseng, Cirrus, Oak and generic vga. */ #include "driver.h" #ifdef TERM_REGISTER register_term(linux) #endif #ifdef TERM_PROTO #define LINUX_VCHAR FNT5X9_VCHAR #define LINUX_HCHAR FNT5X9_HCHAR #define LINUX_VTIC 5 #define LINUX_HTIC 5 #define LINUX_XMAX 0 /* These two entries are just place holders. */ #define LINUX_YMAX 0 /* The actual values will be filled in init. */ TERM_PUBLIC void LINUX_options __PROTO((void)); TERM_PUBLIC void LINUX_init __PROTO((void)); TERM_PUBLIC void LINUX_reset __PROTO((void)); TERM_PUBLIC void LINUX_text __PROTO((void)); TERM_PUBLIC void LINUX_graphics __PROTO((void)); TERM_PUBLIC void LINUX_linetype __PROTO((int linetype)); TERM_PUBLIC void LINUX_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void LINUX_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC int LINUX_text_angle __PROTO((int ang)); TERM_PUBLIC void LINUX_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void LINUX_suspend __PROTO((void)); TERM_PUBLIC void LINUX_resume __PROTO((void)); #endif #ifdef TERM_BODY #define _STRING_H_ #include static int linux_vmode = G1024x768x256; /* default mode */ static int vgacolor[] = { 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 }; static int graphics_on = FALSE; vga_modeinfo *modeinfo; static int linux_startx, linux_starty, linux_lasty; static int linux_angle; int LINUX_graphics_allowed; typedef (*linux_line_func_ptr) __PROTO((int x1, int y1, int x2, int y2)); static void LINUX_putc __PROTO((unsigned int x, unsigned int y, int c, int ang, linux_line_func_ptr line_func)); /* this function is called at the very beginning of main() to initialize * the vgalib and to revoke suid privileges. * /dev/console and /dev/tty\d are considered graphic terminals, all other * don't support the linux terminal */ void LINUX_setup(void) { char line[256]; FILE *pipe; LINUX_graphics_allowed = FALSE; if (geteuid() != 0) return; /* if we aren't root, we cannot init graphics */ if ((pipe = popen("/usr/bin/tty", "r")) != NULL) { line[0] = 0; fgets(line, 256, pipe); pclose(pipe); line[strlen(line) - 1] = '\0'; if (strcmp(line, "/dev/console") == 0 || (strncmp(line, "/dev/tty", 8) == 0 && isdigit(line[8]))) LINUX_graphics_allowed = TRUE; } if (LINUX_graphics_allowed) { vga_init(); } else { /* err - shouldn't we give up root uid whatever happens ? * or perhaps vga_init() does it ? */ setuid(getuid()); } } TERM_PUBLIC void LINUX_options() { if (!LINUX_graphics_allowed) { int_error("Linux terminal driver not available", NO_CARET); } fprintf(stderr, "%s\n", vga_getmodename(linux_vmode)); } TERM_PUBLIC void LINUX_init() { /* vga_init () has been moved to immediately after main () for security */ if (vga_getdefaultmode() != -1) linux_vmode = vga_getdefaultmode(); /* get the default mode from GSVGAMODE, if available */ if (!vga_hasmode(linux_vmode)) linux_vmode = G640x480x16; /* test default mode first */ if (!vga_hasmode(linux_vmode)) { fputs("Error, unable to initiate graphics.\n", stderr); return; } /* this mode is the bottom line */ modeinfo = vga_getmodeinfo(linux_vmode); term->xmax = modeinfo->width; term->ymax = modeinfo->height; linux_lasty = modeinfo->height - 1; } TERM_PUBLIC void LINUX_reset() { if (graphics_on) { vga_setmode(TEXT); graphics_on = FALSE; } } TERM_PUBLIC void LINUX_text() { if (graphics_on) { vga_getch(); vga_setmode(TEXT); graphics_on = FALSE; } } TERM_PUBLIC void LINUX_graphics() { if (!graphics_on) { vga_setmode(linux_vmode); graphics_on = TRUE; } } TERM_PUBLIC void LINUX_suspend() { vga_flip(); } TERM_PUBLIC void LINUX_resume() { vga_flip(); } TERM_PUBLIC void LINUX_linetype(linetype) int linetype; { if (linetype >= 13) linetype %= 13; vga_setcolor(vgacolor[linetype + 2]); } TERM_PUBLIC void LINUX_move(x, y) unsigned int x; unsigned int y; { linux_startx = x; linux_starty = y; } TERM_PUBLIC void LINUX_vector(x, y) unsigned int x; unsigned int y; { vga_drawline(linux_startx, linux_lasty - linux_starty, x, linux_lasty - y); linux_startx = x; linux_starty = y; } TERM_PUBLIC int LINUX_text_angle(ang) int ang; { linux_angle = ang; return TRUE; } static void LINUX_putc(x, y, c, ang, line_func) unsigned int x, y; int c; int ang; linux_line_func_ptr line_func; { int i, j, k; unsigned int pixelon; i = (int) (c) - 32; for (j = 0; j < FNT5X9_VBITS; j++) { for (k = 0; k < FNT5X9_HBITS; k++) { pixelon = (((unsigned int) (fnt5x9[i][j])) >> k & 1); if (pixelon) { switch (ang) { case 0: (*line_func) (x + k + 1, y - j, x + k + 1, y - j); break; case 1: (*line_func) (x - j, y - k - 1, x - j, y - k - 1); break; } } } } } TERM_PUBLIC void LINUX_put_text(x, y, str) unsigned int x, y; char *str; { int i; switch (linux_angle) { case 0: y -= LINUX_VCHAR / 2; break; case 1: x += LINUX_VCHAR / 2; break; } for (i = 0; str[i]; i++) { LINUX_putc(x, linux_lasty - y, str[i], linux_angle, vga_drawline); switch (linux_angle) { case 0: x += LINUX_HCHAR; break; case 1: y += LINUX_HCHAR; break; } } } #endif #ifdef TERM_TABLE TERM_TABLE_START(linux_driver) "linux", "Linux PC with (s)vgalib", LINUX_XMAX, LINUX_YMAX, LINUX_VCHAR, LINUX_HCHAR, LINUX_VTIC, LINUX_HTIC, LINUX_options, LINUX_init, LINUX_reset, LINUX_text, null_scale, LINUX_graphics, LINUX_move, LINUX_vector, LINUX_linetype, LINUX_put_text, LINUX_text_angle, null_justify_text, do_point, do_arrow, set_font_null, 0, /* pointsize */ TERM_CAN_MULTIPLOT, LINUX_suspend, LINUX_resume TERM_TABLE_END(linux_driver) #undef LAST_TERM #define LAST_TERM linux_driver #endif #ifdef TERM_HELP START_HELP(linux) "1 linux", "?commands set terminal linux", "?set terminal linux", "?set term linux", "?terminal linux", "?term linux", "?linux", " The `linux` driver has no additional options to specify. It looks at the", " environment variable GSVGAMODE for the default mode; if not set, it uses", " 1024x768x256 as default mode or, if that is not possible, 640x480x16", " (standard VGA)." END_HELP(linux) #endif /* * $Id: $ * */ /* GNUPLOT -- mac.trm */ /* Macintosh graphics terminal */ /*[ * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ #ifndef GOT_DRIVER_H #include "driver.h" #endif #ifdef TERM_REGISTER register_term(mac) #endif /****************************************************************************** * * * struct TERMENTRY { * * char *name; * * char *description; * * unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic; * * * * void (*options) __PROTO((void)); * * void (*init) __PROTO((void)); * * void (*reset) __PROTO((void)); * * void (*text) __PROTO((void)); * * int (*scale) __PROTO((double, double)); * * void (*graphics) __PROTO((void)); * * void (*move) __PROTO((unsigned int, unsigned int)); * * void (*vector) __PROTO((unsigned int, unsigned int)); * * void (*linetype) __PROTO((int)); * * void (*put_text) __PROTO((unsigned int, unsigned int,char*)); * * // the following are optional. set term ensures they are not NULL * * int (*text_angle) __PROTO((int)); * * int (*justify_text) __PROTO((enum JUSTIFY)); * * void (*point) __PROTO((unsigned int, unsigned int,int)); * * void (*arrow) __PROTO((unsigned int, unsigned int, unsigned int, unsigned int,int)); * * int (*set_font) __PROTO((char *font)); * * void (*pointsize) __PROTO((double)); * * int flags; * * void (*suspend) __PROTO((void)); // called after one plot of multiplot * * void (*resume) __PROTO((void)); // called before plots of multiplot * * void (*fillbox) __PROTO((int style, unsigned int x1, unsigned int y1, unsigned)) // clear in multiplot mode * * void (*linewidth) __PROTO((double linewidth)); * * }; * * * ******************************************************************************/ #ifdef TERM_PROTO #define MAC_XMAX 494 #define MAC_YMAX 274 /* * #define MAC_XOFFSET (497-MAC_XMAX) * * //#define MAC_XLAST (MAC_XMAX - 1) * //#define MAC_YLAST (MAC_YMAX - 1) */ #define MAC_VCHAR 12 /* monaco 9 point plain style */ #define MAC_HCHAR 6 #define MAC_VTIC 3 #define MAC_HTIC 3 void MAC_init __PROTO(()); void MAC_graphics __PROTO(()); void MAC_text __PROTO(()); void MAC_linetype __PROTO((int linetype)); void MAC_move __PROTO((unsigned int x,unsigned int y)); void MAC_vector __PROTO((unsigned int x,unsigned int y)); void MAC_put_text __PROTO((unsigned int x,unsigned int y,char *str)); int MAC_text_angle __PROTO((int angle)); int MAC_justify_text __PROTO((enum JUSTIFY just)); void MAC_reset __PROTO(()); void MAC_options __PROTO(()); void MAC_suspend __PROTO(()); void MAC_resume __PROTO(()); int MAC_setfont __PROTO((char *font)); #endif #ifdef TERM_HELP START_HELP(mac) "1 macintosh", "?set terminal macintosh", "?set term macintosh", "?terminal macintosh", "?term macintosh", "?macintosh", " Several options may be set in the 'macintosh' driver.", "", " Syntax:", " set terminal macintosh {singlewin | multiwin} {vertical | novertical} {size , | default}", "", " 'singlewin' limits the output to a single window and is useful for animations.", " 'multiwin' allows multiple windows.", " 'vertical' is only valid under the gx option. With this option, rotated text", " be drawn vertically. novertical turns this option off.", " size , overrides the graph size set in the preferences", " dialog until it is cleared with either 'set term mac size default'", " or 'set term mac default'.", "", " 'set term mac size default' sets the window size settings to those set in", " the preferences dialog.", "", " 'set term mac default' sets all options to their default values.", " Default values: nogx, multiwin, novertical.", "", " If you generate graphs under the multiwin option and then switch to singlewin,", " the next plot command will cause one more window to be created. This new", " window will be reused as long as singlewin is in effect. If you switch back", " to multiwin, generate some graphs, and then switch to singlewin again, the", " orginal 'singlewin' window will be resused if it is still open. Otherwise", " a new 'singlewin' window will be created. The 'singlewin' window is not numbered.", #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #endif #ifdef TERM_TABLE TERM_TABLE_START(mac_driver) "macintosh", "Macintosh Graphic Window", MAC_XMAX, MAC_YMAX, MAC_VCHAR+1, MAC_HCHAR, MAC_VTIC, MAC_HTIC, MAC_options,MAC_init, MAC_reset, MAC_text, null_scale, MAC_graphics, MAC_move, MAC_vector, MAC_linetype, MAC_put_text, MAC_text_angle, MAC_justify_text, do_point, do_arrow, MAC_setfont, NULL, TERM_CAN_MULTIPLOT+TERM_BINARY, MAC_suspend, MAC_resume} #undef LAST_TERM #define LAST_TERM mac_driver #endif #endif /* TERM_PROTO_ONLY */ /* * $Id: metafont.trm,v 1.14 1998/04/14 00:17:54 drd Exp $ */ /* GNUPLOT - metafont.trm */ /*[ * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * GNUPLOT -- mf.trm * * This terminal driver supports: * Metafont Plot Commands * * Written by : Pl Hedne * Trondheim, Norway * Pal.Hedne@termo.unit.no */ /* * Improvements and bug fixes by Carsten Steger: * - Set default plot size to 5 by 3 inches as in the latex- and eepic- * drivers * - Fixed some bugs concerning resolution dependent output * - Added MF_scale function * - Added MF_justify_text function and modified MF_put_text function and * put_text macro accordingly * - Modified MF_move and MF_vector to make output shorter and modified * MF_text accordingly * - Added various linetypes by plotting dashed lines; had to modify * MF_linetype and MF_vector for this * - Added MF_arrow function * - All global variables and #define'd names begin with MF_ now * As a consequence almost nothing of the original code by Pl Hedne remains * but credit goes to him for the ingenious trick of storing the character * images into picture variables, without which this driver would have been * impossible for me to write. * * 10/03/95: Converted to new terminal layout by Carsten Steger. */ #include "driver.h" #ifdef TERM_REGISTER register_term(mf) #endif #ifdef TERM_PROTO #define MF_DPI (300) /* resolution of printer we expect to use; the value itself is not * particularly important... it is here only for compatibility to the * LaTeX-driver and to get the spacing right. */ /* 5 inches wide by 3 inches high (default) */ #define MF_XSIZE 5.0 #define MF_YSIZE 3.0 #define MF_XMAX (MF_XSIZE*MF_DPI) #define MF_YMAX (MF_YSIZE*MF_DPI) #define MF_HTIC (5*MF_DPI/72) #define MF_VTIC (5*MF_DPI/72) #define MF_HCHAR (MF_DPI*53/10/72) #define MF_VCHAR (MF_DPI*11/72) TERM_PUBLIC void MF_init __PROTO((void)); TERM_PUBLIC void MF_graphics __PROTO((void)); TERM_PUBLIC void MF_text __PROTO((void)); TERM_PUBLIC int MF_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int MF_text_angle __PROTO((int ang)); TERM_PUBLIC void MF_linetype __PROTO((int linetype)); TERM_PUBLIC void MF_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void MF_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void MF_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC void MF_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void MF_reset __PROTO((void)); #define GOT_MF_PROTO #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* Plot size in inches */ static double MF_xsize = MF_XSIZE; static double MF_ysize = MF_YSIZE; static int MF_char_code; static int MF_ang; static int MF_line_type; static enum JUSTIFY MF_justify; static double MF_dist_left; static int MF_is_solid; static int MF_picked_up_pen; /* * We keep track of where we are with respect to dashed lines by using * the next five variables. MF_dash_index indicates which element of * MF_lines[..].dashlen should be used. The MF_last.. variables keep * track of the position of the pen. */ static int MF_dash_index; static unsigned int MF_last_x, MF_last_y; static struct { int solid; /* Is the line solid? */ float thickness; /* Thickness of pen we are going to use */ int dashlen[4]; /* Length of individual segments; even: line; odd: gap */ } MF_lines[10] = { { 1, 1.5, { 0, 0, 0, 0 } }, { 0, 1.0, { MF_DPI / 60, MF_DPI / 50, MF_DPI / 60, MF_DPI / 50 } }, { 1, 1.5, { 0, 0, 0, 0 } }, { 0, 1.5, { MF_DPI / 20, MF_DPI / 30, MF_DPI / 20, MF_DPI / 30 } }, { 0, 1.5, { MF_DPI / 30, MF_DPI / 20, MF_DPI / 30, MF_DPI / 20 } }, { 0, 1.5, { MF_DPI / 15, MF_DPI / 30, MF_DPI / 60, MF_DPI / 30 } }, { 0, 1.5, { MF_DPI / 30, MF_DPI / 50, MF_DPI / 30, MF_DPI / 50 } }, { 0, 1.5, { MF_DPI / 20, MF_DPI / 50, MF_DPI / 60, MF_DPI / 30 } }, { 0, 1.5, { MF_DPI / 30, MF_DPI / 50, MF_DPI / 30, MF_DPI / 30 } }, { 0, 1.5, { MF_DPI / 60, MF_DPI / 50, MF_DPI / 60, MF_DPI / 30 } } /* dash: line, gap, line, gap */ }; TERM_PUBLIC void MF_init() { MF_char_code = 0; MF_ang = 0; fputs("\ if unknown cmbase: input cmbase fi\n\n\ tracingstats:=1;\n\ picture r[];\n\ \ndef openit = openwindow currentwindow\n\ from (0,0) to (400,800) at (-50,500) enddef;\n\ \nmode_setup;\n", gpoutfile); fputs("\ \n%Include next eight lines if you have problems with the mode on your system..\n\ %proofing:=0;\n\ %fontmaking:=1;\n\ %tracingtitles:=0;\n\ %pixels_per_inch:=300;\n\ %blacker:=0;\n\ %fillin:=.2;\n\ %o_correction:=.6;\n\ %fix_units;\n", gpoutfile); /* Next lines must be included if text support is needed (CM base used) */ fputs("\ \ndef put_text(expr ts,xstart,ystart,rot,justification) =\n\ begingroup\n\ text_width:=0;text_height:=0;\n\ for ind:=0 step 1 until length(ts)-1:\n\ dec_num:=ASCII substring (ind,ind+1) of ts;\n\ if unknown r[dec_num]: dec_num:=32; fi\n\ if dec_num=32: \n\ text_width:=text_width+wd[65];\n\ text_height:=GPMAX(text_height,ht[65]+dp[65]);\n\ elseif dec_num>=0: \n\ text_width:=text_width+wd[dec_num];\n\ text_height:=GPMAX(text_height,ht[dec_num]+dp[dec_num]);\n\ fi\n\ endfor\n\ if rot=90:\n\ if justification=1: ynext:=ystart;\n\ elseif justification=2: ynext:=round(ystart-text_width/2);\n\ else: ynext:=round(ystart-text_width);\n\ fi\n\ xnext:=xstart+text_height/2;\n\ else:\n\ if justification=1: xnext:=xstart;\n\ elseif justification=2: xnext:=round(xstart-text_width/2);\n\ else: xnext:=round(xstart-text_width);\n\ fi\n\ ynext:=ystart-text_height/2;\n\ fi\n\ for ind:=0 step 1 until length(ts)-1:\n\ dec_num:=ASCII substring (ind,ind+1) of ts;\n\ if unknown r[dec_num]: dec_num:=32; fi\n\ if dec_num=32: \n\ xnext:=xnext+wd[65]*cosd rot;\n\ ynext:=ynext+wd[65]*sind rot;\n\ elseif dec_num>=0: \n\ currentpicture:=currentpicture+r[dec_num] shifted(xnext,ynext)\n\ rotatedaround ((xnext,ynext),rot); \n\ xnext:=xnext+wd[dec_num]*cosd rot;\n\ ynext:=ynext+wd[dec_num]*sind rot;\n\ fi\n\ endfor\n\ endgroup \n\ enddef;\n", gpoutfile); fputs("\ \ndef endchar =\n\ r[charcode]:=currentpicture;\n\ wd[charcode]:=w;ht[charcode]:=h;dp[charcode]:=d;\n\ message \"Picture of charcode no.\" & decimal charcode;\n\ endgroup;\n\ enddef;\n\ let endchar_ = endchar;\n\ let generate = relax;\n\ let roman = relax;\n", gpoutfile); fputs("\ input cmr10.mf\n\ if ligs>1: font_coding_scheme:=\"TeX text\";\n\ spanish_shriek=oct\"074\"; spanish_query=oct\"076\";\n\ else: font_coding_scheme:=\n\ if ligs=0: \"TeX typewriter text\"\n\ else: \"TeX text without f-ligatures\" fi;\n\ spanish_shriek=oct\"016\"; spanish_query=oct\"017\"; fi\n\ font_setup;\n\ input romanu.mf %Roman uppercase.\n\ input romanl.mf %Roman lowerrcase.\n\ input greeku.mf %Greek uppercase.\n\ input romand.mf %Numerals.\n\ input romanp.mf %Ampersand, question marks, currency sign.\n\ input romspl.mf %Lowercase specials (dotless \\i, ligature \\ae, etc.)\n\ input romspu.mf %Uppercase specials (\\AE, \\OE, \\O)\n\ input punct.mf %Punctuation symbols.\n\ \nminus=ASCII\"-\"; cmchar \"Minus sign\";\n\ beginarithchar(minus); \n\ pickup rule.nib;\n\ lft x1=hround 1.5u-eps;\n\ x2=w-x1; y1=y2=math_axis;\n\ draw z1--z2; % bar\n\ labels(1,2); \n\ endchar;\n", gpoutfile); fputs("\ \ncmchar \"Period\";\n\ numeric dot_diam#; dot_diam#:=if monospace: 5/4 fi\\ dot_size#;\n\ define_whole_blacker_pixels(dot_diam);\n\ beginchar(\".\",5u#,dot_diam#,0);\n\ adjust_fit(0,0); pickup fine.nib;\n\ pos1(dot_diam,0); pos2(dot_diam,90);\n\ lft x1l=hround(.5w-.5dot_diam); bot y2l=0; z1=z2; dot(1,2); % dot\n\ penlabels(1,2);\n\ endchar;\n", gpoutfile); fputs("\ \ndef endchar =\n\ % Next line should probably be removed if CM base is used\n\ l:=0; r:=w;\n\ %Include the next two lines if you want to\n\ %rotate the picture 90 deg.(Portrait to Landscape)\n\ %currentpicture:=currentpicture rotated 90 shifted (h,0);\n\ %tmp:=charht; charht:=charwd; charwd:=tmp;\n\ scantokens extra_endchar;\n\ if proofing>0: makebox(proofrule); fi\n\ chardx:=w;\n\ shipit;\n\ if displaying>0: makebox(screenrule); showit; fi\n\ endgroup \n\ enddef;\n\ let endchar_ = endchar;\n\ let generate = input;\n\ let roman = roman;\n", gpoutfile); /* font_size must be bigger than em#/16 by METAFONT rules. * Therefore make it pretty big so big figures will be * handled correctly. Setting font_size to 72pt# lets us * handle characters up to 15.94 by 15.94 inches. */ fputs("\ \n\nfont_identifier:=\"GNUPLOT\";\n\ font_size 72pt#;\n\ th#=0.4pt#; define_whole_pixels(th);\n\ \npath arrowhead;\n\ arrowhead = (-7pt,-2pt){dir30}..(-6pt,0pt)..\ {dir150}(-7pt,2pt) &\n\ (-7pt,2pt)--(0pt,0pt)--(-7pt,-2pt) & cycle;\n", gpoutfile); } TERM_PUBLIC void MF_graphics() { register struct termentry *t = term; fprintf(gpoutfile, "\n\nbeginchar(%d,%gin#,%gin#,0);\n", MF_char_code, MF_xsize, MF_ysize); MF_char_code++; fprintf(gpoutfile, "a:=w/%d;b:=h/%d;\n", t->xmax, t->ymax); MF_picked_up_pen = 0; } TERM_PUBLIC void MF_text() { fputs("endchar;\n", gpoutfile); } TERM_PUBLIC int MF_justify_text(mode) enum JUSTIFY mode; { MF_justify = mode; return TRUE; } TERM_PUBLIC int MF_text_angle(ang) int ang; { if (ang > 0) MF_ang = 90; else MF_ang = 0; return TRUE; } TERM_PUBLIC void MF_linetype(linetype) int linetype; { if (linetype >= 8) linetype %= 8; linetype += 2; /* Only output change in pens if it actually affects the pen used */ if ((MF_lines[linetype].thickness != MF_lines[MF_line_type].thickness) || (!MF_picked_up_pen)) { fprintf(gpoutfile, "pickup pencircle scaled %gth;\n", MF_lines[linetype].thickness); MF_picked_up_pen = 1; } MF_line_type = linetype; MF_dash_index = 0; MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index]; MF_is_solid = MF_lines[MF_line_type].solid; } TERM_PUBLIC void MF_move(x, y) unsigned int x, y; { MF_last_x = x; MF_last_y = y; MF_dash_index = 0; MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index]; } TERM_PUBLIC void MF_vector(x, y) unsigned int x, y; { if (MF_is_solid) { if (x == MF_last_x && y == MF_last_y) fprintf(gpoutfile, "drawdot (%da,%db);\n", x, y); else fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n", MF_last_x, MF_last_y, x, y); } else { double dist_to_go, delta_x, delta_y, inc_x, inc_y; double last_x_d, last_y_d, next_x_d, next_y_d; unsigned int next_x, next_y; if (x == MF_last_x && y == MF_last_y) { if (!(MF_dash_index & 1)) fprintf(gpoutfile, "drawdot (%da,%db);\n", x, y); } else { last_x_d = MF_last_x; last_y_d = MF_last_y; delta_x = x - last_x_d; delta_y = y - last_y_d; dist_to_go = sqrt(delta_x * delta_x + delta_y * delta_y); inc_x = delta_x / dist_to_go; inc_y = delta_y / dist_to_go; while (MF_dist_left < dist_to_go) { next_x_d = last_x_d + inc_x * MF_dist_left; next_y_d = last_y_d + inc_y * MF_dist_left; next_x = floor(next_x_d + 0.5); next_y = floor(next_y_d + 0.5); /* MF_dash_index & 1 == 0 means: draw a line; otherwise just move */ if (!(MF_dash_index & 1)) fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n", MF_last_x, MF_last_y, next_x, next_y); MF_last_x = next_x; MF_last_y = next_y; last_x_d = next_x_d; last_y_d = next_y_d; dist_to_go -= MF_dist_left; MF_dash_index = (MF_dash_index + 1) & 3; MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index]; } delta_x = x - last_x_d; delta_y = y - last_y_d; MF_dist_left -= sqrt(delta_x * delta_x + delta_y * delta_y); if (!(MF_dash_index & 1)) { if (x == MF_last_x && y == MF_last_y) fprintf(gpoutfile, "drawdot (%da,%db);\n", x, y); else fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n", MF_last_x, MF_last_y, x, y); } } } MF_last_x = x; MF_last_y = y; } TERM_PUBLIC void MF_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; TBOOLEAN head; { int delta_x, delta_y; MF_move(sx, sy); MF_vector(ex, ey); if (head) { delta_x = ex - sx; delta_y = ey - sy; fprintf(gpoutfile, "fill arrowhead rotated angle(%d,%d) shifted (%da,%db);\n", delta_x, delta_y, ex, ey); } } TERM_PUBLIC void MF_put_text(x, y, str) unsigned int x, y; char *str; { int i, j = 0; for (i = 0; i < strlen(str); i++) if (str[i] == '"') str[i] = '\''; /* Replace " with ' */ switch (MF_justify) { case LEFT: j = 1; break; case CENTRE: j = 2; break; case RIGHT: j = 3; break; } fprintf(gpoutfile, "put_text(\"%s\",%da,%db,%d,%d);\n", str, x, y, MF_ang, j); } TERM_PUBLIC void MF_reset() { fputs("end.\n", gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(mf_driver) "mf", "Metafont plotting standard", MF_XMAX, MF_YMAX, MF_VCHAR, MF_HCHAR, MF_VTIC, MF_HTIC, options_null, MF_init, MF_reset, MF_text, null_scale, MF_graphics, MF_move, MF_vector, MF_linetype, MF_put_text, MF_text_angle, MF_justify_text, line_and_point, MF_arrow, set_font_null TERM_TABLE_END(mf_driver) #undef LAST_TERM #define LAST_TERM mf_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(mf) "1 mf", "?commands set terminal mf", "?set terminal mf", "?set term mf", "?terminal mf", "?term mf", "?mf", "?metafont", " The `mf` terminal driver creates a input file to the METAFONT program. Thus a", " figure may be used in the TeX document in the same way as is a character.", "", " To use a picture in a document, the METAFONT program must be run with the", " output file from `gnuplot` as input. Thus, the user needs a basic knowledge", " of the font creating process and the procedure for including a new font in a", " document. However, if the METAFONT program is set up properly at the local", " site, an unexperienced user could perform the operation without much trouble.", "", " The text support is based on a METAFONT character set. Currently the", " Computer Modern Roman font set is input, but the user is in principal free to", " chose whatever fonts he or she needs. The METAFONT source files for the", " chosen font must be available. Each character is stored in a separate", " picture variable in METAFONT. These variables may be manipulated (rotated,", " scaled etc.) when characters are needed. The drawback is the interpretation", " time in the METAFONT program. On some machines (i.e. PC) the limited amount", " of memory available may also cause problems if too many pictures are stored.", "", " The `mf` terminal has no options.", "2 METAFONT Instructions", "?commands set terminal mf detailed", "?set terminal mf detailed", "?set term mf detailed", "?mf detailed", "?metafont detailed", "", " - Set your terminal to METAFONT:", " set terminal mf", " - Select an output-file, e.g.:", " set output \"myfigures.mf\"", " - Create your pictures. Each picture will generate a separate character. Its", " default size will be 5*3 inches. You can change the size by saying `set size", " 0.5,0.5` or whatever fraction of the default size you want to have.", "", " - Quit `gnuplot`.", "", " - Generate a TFM and GF file by running METAFONT on the output of `gnuplot`.", " Since the picture is quite large (5*3 in), you will have to use a version of", " METAFONT that has a value of at least 150000 for memmax. On Unix systems", " these are conventionally installed under the name bigmf. For the following", " assume that the command virmf stands for a big version of METAFONT. For", " example:", "", " - Invoke METAFONT:", " virmf '&plain'", " - Select the output device: At the METAFONT prompt ('*') type:", " \\mode:=CanonCX; % or whatever printer you use", " - Optionally select a magnification:", " mag:=1; % or whatever you wish", " - Input the `gnuplot`-file:", " input myfigures.mf", " On a typical Unix machine there will usually be a script called \"mf\" that", " executes virmf '&plain', so you probably can substitute mf for virmf &plain.", " This will generate two files: mfput.tfm and mfput.$$$gf (where $$$ indicates", " the resolution of your device). The above can be conveniently achieved by", " typing everything on the command line, e.g.:", " virmf '&plain' '\\mode:=CanonCX; mag:=1; input myfigures.mf'", " In this case the output files will be named myfigures.tfm and", " myfigures.300gf.", "", " - Generate a PK file from the GF file using gftopk:", " gftopk myfigures.300gf myfigures.300pk", " The name of the output file for gftopk depends on the DVI driver you use.", " Ask your local TeX administrator about the naming conventions. Next, either", " install the TFM and PK files in the appropriate directories, or set your", " environment variables properly. Usually this involves setting TEXFONTS to", " include the current directory and doing the same thing for the environment", " variable that your DVI driver uses (no standard name here...). This step is", " necessary so that TeX will find the font metric file and your DVI driver will", " find the PK file.", "", " - To include your pictures in your document you have to tell TeX the font:", " \\font\\gnufigs=myfigures", " Each picture you made is stored in a single character. The first picture is", " character 0, the second is character 1, and so on... After doing the above", " step, you can use the pictures just like any other characters. Therefore, to", " place pictures 1 and 2 centered in your document, all you have to do is:", " \\centerline{\\gnufigs\\char0}", " \\centerline{\\gnufigs\\char1}", " in plain TeX. For LaTeX you can, of course, use the picture environment and", " place the picture wherever you wish by using the \\makebox and \\put macros.", "", " This conversion saves you a lot of time once you have generated the font;", " TeX handles the pictures as characters and uses minimal time to place them,", " and the documents you make change more often than the pictures do. It also", " saves a lot of TeX memory. One last advantage of using the METAFONT driver", " is that the DVI file really remains device independent, because no \\special", " commands are used as in the eepic and tpic drivers." END_HELP(mf) #endif /* TERM_HELP */ /* * Id: $ */ /* GNUPLOT - mgr.trm */ /*[ * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Mgr window system, color display * * AUTHOR * Vincent Broman, broman@nosc.mil */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(mgr) #endif #ifdef TERM_PROTO TERM_PUBLIC void MGR_init __PROTO((void)); TERM_PUBLIC void MGR_graphics __PROTO((void)); TERM_PUBLIC void MGR_text __PROTO((void)); TERM_PUBLIC void MGR_linetype __PROTO((int linetype)); TERM_PUBLIC void MGR_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void MGR_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void MGR_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void MGR_reset __PROTO((void)); #define MGR_XMAX 640 #define MGR_YMAX 400 #define MGR_VCHAR 16 #define MGR_HCHAR 8 #define MGR_VTIC 4 #define MGR_HTIC 4 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #undef ESC #include /* from Mgr, not gnuplot */ static int MGR_border = 5; static int MGR_winnbr = 0; static int MGR_rowcount = 24; static int MGR_winwidth = MGR_XMAX; static int MGR_winheight = MGR_YMAX; static int MGR_vchar = MGR_VCHAR; static int MGR_hchar = MGR_HCHAR; TERM_PUBLIC void MGR_init() { char res[300]; int winnbr; int w, h, bor; m_setup(0); m_ttyset(); m_getinfo(G_SYSTEM); if (m_gets(res) && sscanf(res, "%*s%d%d%d", &w, &h, &bor) == 3) MGR_border = bor; m_newwin(0, 0, MGR_winwidth + 2 * MGR_border, MGR_winheight + 2 * MGR_border); if (m_gets(res) && sscanf(res, "%d", &winnbr) == 1) MGR_winnbr = winnbr; /* if no alt window is created, then the main window is used * and if size is different, term_tbl updated later */ m_selectwin(MGR_winnbr); m_setmode(M_ABS); m_getinfo(G_FONT); if (m_gets(res) && sscanf(res, "%d %d", &w, &h) == 2) { MGR_vchar = h; MGR_hchar = w; } m_ttyreset(); term->v_char = MGR_vchar; term->h_char = MGR_hchar; term->v_tic = MGR_vchar / 4; term->h_tic = MGR_hchar / 2; m_selectwin(0); m_flush(); } TERM_PUBLIC void MGR_graphics() { char res[32]; int c, r, w, h; m_selectwin(MGR_winnbr); m_setmode(M_ACTIVATE); m_clear(); /* we permit the user to reshape the window arbitrarily. do_plot calls boundary to recheck the term_tbl for each plot */ m_ttyset(); m_getinfo(G_WINSIZE); if (m_gets(res) && sscanf(res, "%d %d", &c, &r) == 2) MGR_rowcount = r; m_getinfo(G_COORDS); if (m_gets(res) && sscanf(res, "%d %d %d %d", &c, &r, &w, &h) == 4) { term->xmax = MGR_winwidth = w; term->ymax = MGR_winheight = h; } m_ttyreset(); m_flush(); } TERM_PUBLIC void MGR_text() { m_go(0, 0); m_aligntext(); if (MGR_winnbr == 0) m_move(0, MGR_rowcount - 1); m_selectwin(0); m_flush(); } TERM_PUBLIC void MGR_linetype(linetype) int linetype; { /* * this mapping of colors is intended for a color sun on which * colors 0-23 are defined, 0 is white, 1 is black. */ m_linecolor(B_SRC, (linetype < 0) ? 1 : (2 + (linetype % 22))); } TERM_PUBLIC void MGR_move(x, y) unsigned int x, y; { m_go(x, MGR_winheight - 1 - y); } TERM_PUBLIC void MGR_vector(x, y) unsigned int x, y; { m_draw(x, MGR_winheight - 1 - y); } TERM_PUBLIC void MGR_put_text(x, y, str) unsigned int x, y; char *str; { MGR_move(x, y - MGR_vchar / 2); m_aligntext(); m_printstr(str); } TERM_PUBLIC void MGR_reset() { m_destroywin(MGR_winnbr); MGR_winnbr = 0; m_setmode(M_ACTIVATE); m_flush(); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(mgr_driver) "mgr", "Mgr window system", /* dimensions nominal, replaced during MGR_graphics call */ MGR_XMAX, MGR_YMAX, MGR_VCHAR, MGR_HCHAR, MGR_VTIC, MGR_HTIC, options_null, MGR_init, MGR_reset, MGR_text, null_scale, MGR_graphics, MGR_move, MGR_vector, MGR_linetype, MGR_put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(mgr_driver) #undef LAST_TERM #define LAST_TERM mgr_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(mgr) "1 mgr", "?commands set terminal mgr", "?set terminal mgr", "?set term mgr", "?terminal mgr", "?term mgr", "?mgr", " The `mgr` terminal driver supports the Mgr Window system. It has no options." END_HELP(mgr) #endif /* * $Id: $ */ /* GNUPLOT -- mif.trm */ /*[ * Copyright 1992, 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver was developed for * gnuplot for unix version 3.0 (patchlevel 1) * gnuplot for unix version 3.2 (patchlevel 2) * * This terminal driver supports: * Frame Maker MIF format version 3.00 * * Options for this terminal driver (set terminal mif [options]): * colour / Draw primitives with line types >= 0 in colour (sep. 2-7) * monochrome Draw primitives in black (sep. 0) * * polyline / Draw lines as continous curves * vectors Draw lines as collections of vectors * * help / ? Print short usage description on stderr * * Properties for this terminal driver: * -Gnuplot size of worksheet: MIF_XMAX * MIF_YMAX * -Unit in MIF output: cm * -Plot primitives with the same pen will * be grouped in the same MIF group. * -Plot primitives with line types >= 0 * will as default be drawn in colour. * -Lines are plotted as collections of * vectors, or as continous lines (default) * -Plot primitives in a plot will be in a * Frame in MIF. Several plot Frames will * be collected in one large Frame. * -Point size of MIF output characters: MIF_PSIZE * -Used font for MIF output characters: Times * -Supports vertical text * -points and dots as characters * -character formats for TextLines * * AUTHORS: * Olof Franksson, Physics IV, KTH, S-100 44 Stockholm, Sweden * * NEW TERMINAL FORMAT: David C. Schooley * COMMENTS: * Send comments and/or suggestions to olof@fysik4.kth.se * * CHANGES: * Changed to new terminal format 9/29/95 schooley@ee.gatech.edu * Changed order of routine declarations. olof@fysik4.kth.se * Changed mechanism for pen pattern selection. kssingvo@immd4.informatik.uni-erlangen.de * Support for vertical text. kssingvo@immd4.informatik.uni-erlangen.de * Fixed plot bug for "set size XS,YS", XS/YS > 1. olof@fysik4.kth.se * */ #include "driver.h" #ifdef TERM_REGISTER register_term(mif) #endif #ifdef TERM_PROTO TERM_PUBLIC void MIF_init __PROTO((void)); TERM_PUBLIC void MIF_graphics __PROTO((void)); TERM_PUBLIC void MIF_text __PROTO((void)); TERM_PUBLIC void MIF_linetype __PROTO((int linetype)); TERM_PUBLIC void MIF_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void MIF_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void MIF_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int MIF_text_angle __PROTO((int ang)); TERM_PUBLIC void MIF_reset __PROTO((void)); TERM_PUBLIC void MIF_options __PROTO((void)); TERM_PUBLIC int MIF_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void MIF_point __PROTO((unsigned int x, unsigned int y, int number)); /** Coordinates **/ /* The cast to float is not necessary because we are dividing by a float */ /* On OSK the cast to a float is not allowed in a constant expression wich */ /* is used by the declaration and initialization of mif_line */ /* Converts gnuplot units to MIF units */ #define GNP_TO_MIF(P) ((P) / 1000.0) /* Basic unit: 0.01 mm (15cm -> 15*10*100=15000) */ #define MIF_XMAX 15000 /* Basic unit: 0.01 mm (10cm -> 10*10*100=10000) */ #define MIF_YMAX 10000 #define MIF_XLAST (MIF_XMAX - 1) #define MIF_YLAST (MIF_YMAX - 1) static int insert_mif_line __PROTO((double fx, double fy)); static int proc_group_id __PROTO((int group_id)); static void free_mif_line __PROTO((void)); static void put_mif_line __PROTO((void)); static void MIF_set_font __PROTO((char *)); static void mif_put_point __PROTO((unsigned int x, unsigned int y, int np)); #ifndef cfree # define cfree free #endif /* Declared in ../setshow.c */ extern char term_options[]; /* From version.c */ extern char version[]; extern char patchlevel[]; static struct mif_line { /* Line point structure specification */ float fpos_x; /* Line point X coordinate */ float fpos_y; /* Y coordinate */ struct mif_line *next; /* Pointer to next line point */ struct mif_line *prev; /* Pointer to previous line point */ } mif_line = { /* Current position structure. Adjust for orign. Local for this file. */ GNP_TO_MIF(0), GNP_TO_MIF(MIF_YLAST), &mif_line, &mif_line }; /** Characters **/ #define MIF_PSIZE 9 /* Point size of used characters */ #define MIF_VCHAR (MIF_YMAX/31) /* Distance between rows (a guess) */ #define MIF_HCHAR (MIF_XMAX/95) /* Distance between characters (a guess) */ /** Scale marks **/ #define MIF_VTIC (MIF_YMAX/150) /* Size of scale mark (vert) */ #define MIF_HTIC (MIF_XMAX/225) /* Size of scale mark (hor) */ /** Drawing properties **/ static char mif_justify[64]; /* How to justify the used text */ static char mif_pen[64], mif_pen_width[64], mif_separation[64]; /* How to plot */ #define MIF_TEXT_HOR 0 #define MIF_TEXT_VER 1 static int mif_text_ang = MIF_TEXT_HOR; /* Rotation angle of text */ #define MIF_NPENS 16 /* Number of MIF pen types */ static int mif_pentype = 0; /* Pen type to use. Also used to create groups for graphics */ #define MIF_PEN_TO_GROUP(P) ( 1 + (P) ) /* Map pen type to group number. Must be >= 1 */ static int mif_pattern_table[MIF_NPENS] = { /* Table, which pattern should be used for drawing */ 0, /* border */ 1, /* not used */ 2, 3, 4, 8, 12, 13, /* other lines: functions, data, ... (5 is used for grid; 6,7 is (nearly) invisible) */ 5, /* grid */ 9, 10, 11, 12, 13, 14, 15 /* not used */ }; /** MIF groups administration **/ #define MIF_NGROUP_ID 20 static struct mif_group_id { int group_existance; /* This group id should generate a MIF group */ #define MIF_GROUP_EXISTS 1 /* This group id should not generate a MIF group */ #define MIF_GROUP_NOT_EXISTS 0 int group_id; #define MIF_INVALID_GROUP_ID 0 /* An invalid MIF group ID */ } mif_group_id[MIF_NGROUP_ID]; /* List of used group ID:s and corresponding MIF groups existance */ /** Semaphores **/ static int mif_initialized = 0; /* != 0 when output is active */ static int mif_in_frame = 0; /* != 0 when inside a plot frame */ static int mif_frameno = -1; /* Current frame number */ static int mif_colour = TRUE; /* == TRUE when colour should be used */ static int mif_polyline = TRUE; /* == TRUE when lines are drawn as continous curves */ struct mpt { /* point definition structure */ int chr; /* character for point */ float x_offset, y_offset; /* offset for vertical positioning */ char *font; /* font */ }; char zgnuplot[] = "ZGnuplot"; /* character formats */ char zgnuplotp[] = "ZGnuplotP"; char zgnuplotd[] = "ZGnuplotD"; char *mif_font = NULL; /* actual character format */ struct mpt mpt[POINT_TYPES + 1] = { /* point definition data */ {'.', 0.000, 0.005, zgnuplotd, /* dot */ }, {'G', 0.002, 0.084, zgnuplotp, /* diamond */ }, {';', 0.002, 0.084, zgnuplotp, /* plus */ }, {'n', 0.002, 0.084, zgnuplotp, /* box */ }, {'5', 0.002, 0.084, zgnuplotp, /* X */ }, {'s', 0.002, 0.062, zgnuplotp, /* triangle */ }, {'K', 0.005, 0.075, zgnuplotp, /* star */ }, }; /* diamond is offset 0, dot is offset -1 */ struct mpt *mif_point = &(mpt[1]); #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /** Declaration of routine/s for internal use **/ static int insert_mif_line __PROTO((double fx, double fy)); static int proc_group_id __PROTO((int group_id)); /** Routine/s **/ /* Called when this terminal type is set in order to parse options */ TERM_PUBLIC void MIF_options() { if (!END_OF_COMMAND) { /* Colour options */ if (!END_OF_COMMAND && almost_equals(c_token, "m$onochrome")) { /* Compare up to $ */ mif_colour = FALSE; c_token++; } if (!END_OF_COMMAND && (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour"))) { /* Compare up to $ */ mif_colour = TRUE; c_token++; } /* Curve options */ if (!END_OF_COMMAND && almost_equals(c_token, "v$ectors")) { /* Compare up to $ */ mif_polyline = FALSE; c_token++; } if (!END_OF_COMMAND && almost_equals(c_token, "p$olyline")) { /* Compare up to $ */ mif_polyline = TRUE; c_token++; } /* Short help */ if (!END_OF_COMMAND && (almost_equals(c_token, "h$elp") || almost_equals(c_token, "?$"))) { /* Compare up to $ */ fprintf(stderr, "\ Usage: set terminal mif [options]\n\ \toptions:\n\ \t\tcolour / Draw primitives with line types >= 0 in colour (sep. 2-7)\n\ \t\tmonochrome Draw primitives in black (sep. 0)\n\n\ \t\tpolyline / Draw lines as continous curves\n\ \t\tvectors Draw lines as collections of vectors\n\n\ \t\thelp / ? Print short usage description on stderr\n"); c_token++; } } sprintf(term_options, "%s %s", (mif_colour == TRUE) ? "colour" : "monochrome", (mif_polyline == TRUE) ? "polyline" : "vectors"); } /* Deallocate the used line structure elements */ static void free_mif_line() { struct mif_line *tline; while (mif_line.prev != &mif_line) { /* Unlink */ tline = mif_line.prev; mif_line.prev = mif_line.prev->prev; mif_line.prev->next = &mif_line; /* Deallocate */ free(tline); } /* Make sure that the list will be empty */ mif_line.prev = &mif_line; mif_line.next = &mif_line; } /* Draw the pending line. Change current position. */ static void put_mif_line() { int np, i; struct mif_line *tline; /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Count the number of available points */ for (tline = mif_line.next, np = 1; tline != &mif_line; tline = tline->next, np++); /* Draw line (at least two points) */ if (np >= 2) { /* Line preamble */ fprintf(gpoutfile, "\t %s %s %s\n", MIF_PEN_TO_GROUP(mif_pentype), mif_pen, mif_pen_width, mif_separation); /* Draw the line elements */ fprintf(gpoutfile, "\t\t ", np); for (i = 0, tline = &mif_line; i < np; i++, tline = tline->next) { if (i % 4 == 0) fputs("\n\t\t", gpoutfile); fprintf(gpoutfile, " ", tline->fpos_x, tline->fpos_y); } /* Line post amble */ fputs("\n\t>\n", gpoutfile); /* Register the used group ID */ proc_group_id(MIF_PEN_TO_GROUP(mif_pentype)); /* Avoid to redraw this. The MIF system should remember it. */ mif_pen[0] = '\0'; mif_pen_width[0] = '\0'; mif_separation[0] = '\0'; /* Move current position to end of line */ mif_line.fpos_x = mif_line.prev->fpos_x; mif_line.fpos_y = mif_line.prev->fpos_y; /* Restore the line */ free_mif_line(); } } /* Line processed */ } /* Draw a point */ static void mif_put_point(x, y, np) unsigned int x, y; int np; { /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Draw pending line */ if (mif_polyline == TRUE) put_mif_line(); /* Adjust current position for text-graphics alignment */ MIF_move(x, y); /* center text */ MIF_justify_text(CENTRE); /* Draw the point */ fprintf(gpoutfile, "\t\n", MIF_PEN_TO_GROUP(mif_pentype)); MIF_set_font(mif_point[np].font); fprintf(gpoutfile, "\t\t %s \n", mif_line.fpos_x + mif_point[np].x_offset, mif_line.fpos_y + mif_point[np].y_offset, mif_justify, mif_point[np].chr); fputs("\t>\n", gpoutfile); /* Register the used group ID */ proc_group_id(MIF_PEN_TO_GROUP(mif_pentype)); /* Avoid to redraw this. The MIF system should remember it. */ mif_justify[0] = '\0'; } /* Point processed */ } /* * draw points */ TERM_PUBLIC void MIF_point(x, y, number) unsigned int x, y; int number; { if (number < 0) { /* dot */ number = -1; } else { /* point */ number %= POINT_TYPES; } mif_put_point(x, y, number); } /* Set up a MIF output file */ TERM_PUBLIC void MIF_init() { int i; /* Process if not inside a MIF file and Frame */ if (mif_initialized == 0 && mif_in_frame == 0) { /* Tell this terminal driver that the output is initialized and no current frames are processed */ mif_initialized = 1; mif_in_frame = 0; /* Reset internal position */ free_mif_line(); mif_line.fpos_x = GNP_TO_MIF(0); mif_line.fpos_y = GNP_TO_MIF(MIF_YLAST); /* Reset drawing properties strings */ mif_pen[0] = '\0'; mif_pen_width[0] = '\0'; mif_separation[0] = '\0'; MIF_justify_text(LEFT); /* Reset group ID generator */ for (i = 0; i < MIF_NGROUP_ID; i++) { mif_group_id[i].group_id = MIF_INVALID_GROUP_ID; mif_group_id[i].group_existance = MIF_GROUP_NOT_EXISTS; } /* Identify ourselves */ /*bs show borders */ /* Setup a default environment to use */ fprintf(gpoutfile, "\ # Generated by gnuplot version %s patchlevel %s; identifies this as a MIF file\n\ #\n\ # show borders\n\ \n>\n\ # Set a default pen pattern, pen width, unit and font for subsequent objects\n\ \n\ \n\ \n\ \n\ \n\ >\n\ \t>\n\ \t>\n\ >\n\ #\n", version, patchlevel, zgnuplot, MIF_PSIZE, zgnuplotp, zgnuplotd); } /* MIF file created */ } /* Finish of a MIF output file */ TERM_PUBLIC void MIF_reset() { /* Process if inside a MIF file and not inside a Frame */ if (mif_initialized != 0 && mif_in_frame == 0) { /* Finish off the MIF file */ fputs("\ #\n\ # End of MIFFile\n", gpoutfile); /* Tell this terminal driver that the output is finished */ mif_initialized = 0; /* bs: reset frame number */ mif_frameno = -1; } /* MIF file finished */ } /* Start plotting a Frame (-> graphics mode) */ TERM_PUBLIC void MIF_graphics() { int i; /* Process if not inside a Frame */ if (mif_initialized != 0 && mif_in_frame == 0) { /* Tell that this terminal driver is working with a plot frame */ mif_in_frame = 1; /* Update frame number */ mif_frameno++; /* Set current position */ free_mif_line(); mif_line.fpos_x = GNP_TO_MIF(0); mif_line.fpos_y = GNP_TO_MIF(MIF_YLAST); /* Set drawing properties */ mif_pen[0] = '\0'; mif_pen_width[0] = '\0'; mif_separation[0] = '\0'; MIF_justify_text(LEFT); /* Reset group ID generator */ for (i = 0; i < MIF_NGROUP_ID; i++) { mif_group_id[i].group_id = MIF_INVALID_GROUP_ID; mif_group_id[i].group_existance = MIF_GROUP_NOT_EXISTS; } /* Frame preamble */ fprintf(gpoutfile, "\ #\n\ # Frame number %d with plot of graphics\n\ \n\ \t\n\ \t\n\ \t\n\ \t\n\ \t\n\ \t\n", mif_frameno, ((float) mif_frameno) * GNP_TO_MIF(MIF_YMAX + 100), GNP_TO_MIF(MIF_XMAX), GNP_TO_MIF(MIF_YMAX)); } /* Frame created */ } /* Stop plotting a Frame (-> text mode) */ TERM_PUBLIC void MIF_text() { int i; /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Draw pending line */ if (mif_polyline == TRUE) put_mif_line(); /* Group the used plot primitives */ fputs("\ \t#\n\ \t# Group the the objects in groups to make the chart easier to manipulate\n\ \t# after it's imported into FrameMaker.\n", gpoutfile); for (i = 0; i < MIF_NGROUP_ID; i++) { if (mif_group_id[i].group_id != MIF_INVALID_GROUP_ID && mif_group_id[i].group_existance == MIF_GROUP_EXISTS) { fprintf(gpoutfile, "\ \t\n\ \t>\n", mif_group_id[i].group_id); } } /* Frame post amble */ fprintf(gpoutfile, "\ >\n\ # End of Frame number %d\n\ #\n", mif_frameno); /* Tell that this terminal driver is not working with a plot frame */ mif_in_frame = 0; } /* Frame finshed */ } /* Select type of line in grapics */ /* NOTE: actually written to output the first time a primitive * is drawn AFTER this call */ TERM_PUBLIC void MIF_linetype(linetype) /* -2=border, -1=X/Y-axis, 0-13=lines, and 14-=mapped back */ int linetype; { /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Draw pending line */ if (mif_polyline == TRUE) put_mif_line(); /* Translate gnuplot pen types to MIF pen types */ if (linetype < 0) { /* Special lines */ if (linetype == -1) { mif_pentype = 8 + MIF_NPENS; /* -1 */ if (mif_colour == TRUE) sprintf(mif_separation, " "); } else { mif_pentype = 0 + MIF_NPENS; /* -2 or less */ if (mif_colour == TRUE) sprintf(mif_separation, " "); } sprintf(mif_pen_width, " "); } else { /* Normal lines */ mif_pentype = (linetype) % MIF_NPENS; /* 0-(MIF_NPENS-1) */ sprintf(mif_pen_width, " "); if (mif_colour == TRUE) sprintf(mif_separation, " ", 2 + (mif_pentype % 6)); /* 2-7 */ } /* Set pen type */ sprintf(mif_pen, " ", mif_pattern_table[mif_pentype % MIF_NPENS]); } /* Primitive processed */ } /* Draw the text horisontally or vertically (90 degrees counterclockwise) */ TERM_PUBLIC int MIF_text_angle(ang) int ang; { if (ang != 0) mif_text_ang = MIF_TEXT_VER; else mif_text_ang = MIF_TEXT_HOR; return (TRUE); } /* Justify following text lines (MIF_put_text()) relative to the insertion point */ TERM_PUBLIC int MIF_justify_text(mode) /* NOTE: actually written to output in text primitives which are * drawn AFTER this call */ enum JUSTIFY mode; { int rval = TRUE; /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { switch (mode) { case LEFT: sprintf(mif_justify, " "); break; case CENTRE: sprintf(mif_justify, " "); break; case RIGHT: sprintf(mif_justify, " "); break; default: rval = FALSE; break; } } /* Primitive processed */ else { rval = FALSE; } return (rval); } /* Draw a vector from current position to (x, y) and change current position. */ /* NOTE: actually written to output the first time another primitive * is called AFTER this call */ TERM_PUBLIC void MIF_vector(x, y) unsigned int x, y; { /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Setup the vector as a part of the line */ insert_mif_line(GNP_TO_MIF(x), GNP_TO_MIF(MIF_YLAST - (int) y)); /* Draw pending line -> vector */ if (mif_polyline == FALSE) put_mif_line(); } /* Vector processed */ } /* Move current position */ TERM_PUBLIC void MIF_move(x, y) unsigned int x, y; { /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Draw pending line */ if (mif_polyline == TRUE) put_mif_line(); mif_line.fpos_x = GNP_TO_MIF(x); mif_line.fpos_y = GNP_TO_MIF(MIF_YLAST - (int) y); } } /* set font */ static void MIF_set_font(font) char *font; { if (font != mif_font) { fprintf(gpoutfile, "\t\t\n\t\t>\n", font); mif_font = font; } } /* Draw the text string str at (x, y). Adjust according to MIF_justify_text(). * Change current position. */ TERM_PUBLIC void MIF_put_text(x, y, str) unsigned int x, y; char str[]; { /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Draw pending line */ if (mif_polyline == TRUE) put_mif_line(); /* Adjust current position for text-graphics alignment */ MIF_move(x, y - MIF_VCHAR / 5); if (strlen(str) > 0) { /* Draw the text */ fprintf(gpoutfile, "\t %s %s %s\n", MIF_PEN_TO_GROUP(mif_pentype), mif_pen, mif_pen_width, mif_separation); MIF_set_font(zgnuplot); fprintf(gpoutfile, "\ \t\t %s %s \n\ \t>\n", mif_line.fpos_x, mif_line.fpos_y, mif_justify, (mif_text_ang == MIF_TEXT_VER) ? "" : "", str); /* Register the used group ID */ proc_group_id(MIF_PEN_TO_GROUP(mif_pentype)); /* Avoid to redraw this. The MIF system should remember it. */ mif_pen[0] = '\0'; mif_pen_width[0] = '\0'; mif_separation[0] = '\0'; mif_justify[0] = '\0'; /* Independent of linetype */ } } /* Text processed */ } /* Insert one point in the line */ static int insert_mif_line(fx, fy) double fx, fy; { int rval = TRUE; if ((mif_line.prev->next = (struct mif_line *) gp_alloc(sizeof(struct mif_line), "MIF driver")) != (struct mif_line *) NULL) { /* Link */ mif_line.prev->next->next = &mif_line; mif_line.prev->next->prev = mif_line.prev; mif_line.prev = mif_line.prev->next; /* Fill */ mif_line.prev->fpos_x = fx; mif_line.prev->fpos_y = fy; rval = TRUE; } else { /* Failed to allocate */ /* Relink */ mif_line.prev->next = &mif_line; rval = FALSE; } return (rval); } /* Register group ID. Update group ID existance. */ /* Returns: 1 group_id belongs to a MIF group 0 group_id does not belong to a MIF group -1 not inside a Frame -2 group ID list is full */ static int proc_group_id(group_id) int group_id; { int i, rval = 0; /* Process if inside a Frame */ if (mif_initialized != 0 && mif_in_frame != 0) { /* Find out the group ID, or a free group ID slot index. */ for (i = 0; i < MIF_NGROUP_ID && mif_group_id[i].group_id != MIF_INVALID_GROUP_ID && mif_group_id[i].group_id != group_id; i++) { /* Don't check the group_existance variable */ } if (i < MIF_NGROUP_ID) { if (mif_group_id[i].group_id == MIF_INVALID_GROUP_ID) { /* Register as new group ID for eventual use as MIF group */ mif_group_id[i].group_id = group_id; mif_group_id[i].group_existance = MIF_GROUP_NOT_EXISTS; } else { /* If second use of this group ID -> create a new MIF group */ if (mif_group_id[i].group_id == group_id) { mif_group_id[i].group_existance = MIF_GROUP_EXISTS; /* NOTE: a group MUST have at least two members. */ rval = 1; } } } else { rval = -2; /* No place for this group ID in the list */ } } /* Group ID processed */ else { rval = -1; /* Not inside a Frame */ } /* Return MIF group status */ return (rval); } #endif #ifdef TERM_TABLE TERM_TABLE_START(mif_driver) "mif", "Frame maker MIF 3.00 format", MIF_XMAX, MIF_YMAX, MIF_VCHAR, MIF_HCHAR, MIF_VTIC, MIF_HTIC, MIF_options, MIF_init, MIF_reset, MIF_text, null_scale, MIF_graphics, MIF_move, MIF_vector, MIF_linetype, MIF_put_text, MIF_text_angle, MIF_justify_text, MIF_point, do_arrow, set_font_null TERM_TABLE_END(mif_driver) #undef LAST_TERM #define LAST_TERM mif_driver #endif #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(mif) "1 mif", "?commands set terminal mif", "?set terminal mif", "?set term mif", "?terminal mif", "?term mif", "?mif", " The `mif` terminal driver produces Frame Maker MIF format version 3.00. It", " plots in MIF Frames with the size 15*10 cm, and plot primitives with the same", " pen will be grouped in the same MIF group. Plot primitives in a `gnuplot`", " page will be plotted in a MIF Frame, and several MIF Frames are collected in", " one large MIF Frame. The MIF font used for text is \"Times\".", "", " Several options may be set in the MIF 3.00 driver.", "", " Syntax:", " set terminal mif {colour | monochrome} {polyline | vectors}", " {help | ?}", "", " `colour` plots lines with line types >= 0 in colour (MIF sep. 2--7) and", " `monochrome` plots all line types in black (MIF sep. 0).", " `polyline` plots curves as continuous curves and `vectors` plots curves as", " collections of vectors.", " `help` and `?` print online help on standard error output---both print a", " short description of the usage; `help` also lists the options;", "", " Examples:", " set term mif colour polylines # defaults", " set term mif # defaults", " set term mif vectors", " set term mif help" END_HELP(mif) #endif /* TERM_HELP */ /* * $Id: $ */ /* GNUPLOT - multitos.trm */ /*[ * Copyright 1994, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * mtos : ATARI Systems MiNT/MULTITOS/MAGIC with external client * * AUTHOR * Dirk Stadler (email: dirk_stadler@n.maus.de, dirk@lstm.uni-erlangen.de) * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ #include "driver.h" #ifdef TERM_REGISTER register_term(mtos) #endif #ifdef TERM_PROTO /* function-prototypes */ TERM_PUBLIC void MTOS_options(void); TERM_PUBLIC void MTOS_init(void); TERM_PUBLIC void MTOS_reset(void); TERM_PUBLIC void MTOS_graphics(void); TERM_PUBLIC void MTOS_text(void); TERM_PUBLIC void MTOS_move(unsigned int x, unsigned int y); TERM_PUBLIC void MTOS_vector(unsigned int x, unsigned int y); TERM_PUBLIC void MTOS_linetype(int lt); TERM_PUBLIC int MTOS_text_angle(int ang); TERM_PUBLIC void MTOS_put_text(unsigned int x, unsigned int y, char *str); TERM_PUBLIC int MTOS_justify_text(enum JUSTIFY mode); TERM_PUBLIC void MTOS_point(unsigned int x, unsigned int y, int number); /* default to ST high resolution */ #define MTOS_XMAX 640 #define MTOS_YMAX 400 #define MTOS_VCHAR 18 #define MTOS_HCHAR 12 #define MTOS_HTIC 5 #define MTOS_VTIC MTOS_HTIC #define GOT_MTOS_PROTO #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #include #include #include #include #include #include #include #include #include #include #include #include int MTOS_pause(char *str); static void MTOS_quit(void); void MTOS_open_pipe(void); static void write_pid(void); static void init_exit(void); /* commands for GPCLIENT */ #define SET_GRAPHICS 'G' #define SET_TEXT 'E' #define SET_LINE 'L' #define SET_ANGLE 'A' #define SET_JUSTIFY 'J' #define SET_POINTMODE 'D' #define GR_MOVE 'M' #define GR_DRAW 'V' #define GR_RESET 'R' #define GR_TEXT 'T' #define PAUSE 'P' #define PID 'I' #define QUIT 'Q' /* for creating pipes */ #define PIPE1 "u:\\pipe\\GPLT%d" #define PIPE2 "u:\\pipe\\gpclient.tmp" #define NAMESIZE 25 #define SIZE ((unsigned)sizeof(short)) /* default name for client */ #define GPCLIENT1 "gpclient.prg" #define GPCLIENT2 "gpclient" /* environment */ #define MYENV "GNUPLOTPATH" #define PATH "PATH" /* some global variables */ static char MTOS_mode = 0; static int handle = -1; static int pid = -1; TERM_PUBLIC void MTOS_options() { term_options[0] = NUL; } TERM_PUBLIC void MTOS_init() { char pipe[NAMESIZE]; char *file, cmd[MAXPATHLEN+1]; char const *const ext[] = { "prg", "app", NULL }; if (handle < 0) { if (aesid < 0) { if ((aesid = appl_init()) < 0) int_error("APPL_INIT failed !", NO_CARET); } file = findfile(GPCLIENT2, getenv(MYENV), ext); if (!file) safe_strncpy(cmd, GPCLIENT1, sizeof(cmd)); else if (file && !strchr(file, '\\') && !strchr(file, '/')) safe_strncpy(cmd, file, sizeof(cmd)); else unx2dos(file, cmd); if (!shel_find(cmd)) int_error("Cannot find GPCLIENT !", NO_CARET); sprintf(&pipe[1], PIPE1, aesid); if ((handle = open(&pipe[1], O_RDWR | O_CREAT)) < 0) { if ((handle = (int) Fcreate(&pipe[1], 0)) < 0) int_error("Cannot open PIPE to GPCLIENT !", NO_CARET); } pipe[0] = (char) (strlen(&pipe[1]) + 1); if (!shel_write(1, 1, 100, cmd, pipe)) { close(handle); handle = -1; int_error("Cannot spawn GPCLIENT !", NO_CARET); } init_exit(); } if (aesid > -1) menu_register(aesid, " Terminal: mtos"); } TERM_PUBLIC void MTOS_reset() { short buff; buff = (short) GR_RESET; write(handle, &buff, SIZE); } TERM_PUBLIC void MTOS_text() { short buff; buff = (short) SET_TEXT; if (MTOS_mode != SET_TEXT) write(handle, &buff, SIZE); MTOS_mode = SET_TEXT; } TERM_PUBLIC void MTOS_graphics() { short buff; buff = (short) SET_GRAPHICS; write(handle, &buff, SIZE); MTOS_mode = SET_GRAPHICS; } TERM_PUBLIC void MTOS_move(unsigned int x, unsigned int y) { short x_1, y_1, buff; x_1 = (short) x; y_1 = (short) y; buff = (short) GR_MOVE; write(handle, &buff, SIZE); write(handle, &x_1, SIZE); write(handle, &y_1, SIZE); } TERM_PUBLIC void MTOS_vector(unsigned int x, unsigned int y) { short x_1, y_1, buff; x_1 = (short) x; y_1 = (short) y; buff = (short) GR_DRAW; write(handle, &buff, SIZE); write(handle, &x_1, SIZE); write(handle, &y_1, SIZE); } TERM_PUBLIC void MTOS_linetype(int lt) { short lt_1, buff; lt_1 = (short) lt; buff = (short) SET_LINE; write(handle, &buff, SIZE); write(handle, <_1, SIZE); } TERM_PUBLIC int MTOS_text_angle(int ang) { short ta_1, buff; ta_1 = (short) ang; buff = (short) SET_ANGLE; write(handle, &buff, SIZE); write(handle, &ta_1, SIZE); return (TRUE); } TERM_PUBLIC void MTOS_put_text(unsigned int x, unsigned int y, char *str) { short x_1, y_1, len, buff; x_1 = (short) x; y_1 = (short) y; len = (short) strlen(str) + 1; buff = (short) GR_TEXT; write(handle, &buff, SIZE); write(handle, &x_1, SIZE); write(handle, &y_1, SIZE); write(handle, &len, SIZE); write(handle, str, (unsigned) len); } TERM_PUBLIC int MTOS_justify_text(enum JUSTIFY mode) { short j_mode, buff; j_mode = (short) mode; buff = (short) SET_JUSTIFY; write(handle, &buff, SIZE); write(handle, &j_mode, SIZE); return (TRUE); } TERM_PUBLIC void MTOS_point(unsigned int x, unsigned int y, int number) { short mode, buff; buff = (short) SET_POINTMODE; mode = 1; write(handle, &buff, SIZE); write(handle, &mode, SIZE); do_point(x, y, number); mode = 0; write(handle, &buff, SIZE); write(handle, &mode, SIZE); } int MTOS_pause(char *str) { short len, buff; len = (short) strlen(str) + 1; buff = (short) PAUSE; write(handle, &buff, SIZE); write(handle, &len, SIZE); write(handle, str, (unsigned) len); read(handle, &len, SIZE); return ((int) len); } static void MTOS_quit() { short buff; if (pid > -1) kill(pid, SIGTERM); if (handle > -1) { buff = (short) QUIT; write(handle, &buff, SIZE); close(handle); } } void MTOS_open_pipe() { char pipe[NAMESIZE]; short len; if (handle < 0) { if ((handle = open(PIPE2, O_RDWR)) < 0) return; read(handle, &len, SIZE); if (len > 0) { read(handle, pipe, (unsigned) len); close(handle); if ((handle = open(pipe, O_RDWR)) < 0) { fprintf(stderr, "\n\n\33p Can't open Pipe: (%s) Error: (%s) !\33q\n\n", pipe,sys_errlist[errno]); fflush(stderr); return; } } init_exit(); } } static void write_pid() { short buff, mypid, gpclpid; mypid = (short) getpid(); buff = (short) PID; while (write(handle, &buff, SIZE) <= 0) Fselect(100, 0L, 0L, 0L); while (read(handle, &gpclpid, SIZE) <= 0) Fselect(100, 0L, 0L, 0L); write(handle, &mypid, SIZE); pid = (int) gpclpid; } static void init_exit() { Cconout(7); write_pid(); atexit(MTOS_quit); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(mtos_driver) "mtos", "Atari MiNT/MULTITOS/Magic Terminal", MTOS_XMAX, MTOS_YMAX, MTOS_VCHAR, MTOS_HCHAR, MTOS_VTIC, MTOS_HTIC, MTOS_options, MTOS_init, MTOS_reset, MTOS_text, null_scale, MTOS_graphics, MTOS_move, MTOS_vector, MTOS_linetype, MTOS_put_text, MTOS_text_angle, MTOS_justify_text, MTOS_point, do_arrow, set_font_null, 0, TERM_CAN_MULTIPLOT, 0, 0 TERM_TABLE_END(mtos_driver) #undef LAST_TERM #define LAST_TERM mtos_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(mtos) "1 mtos", "?commands set terminal mtos", "?set terminal mtos", "?set term mtos", "?terminal mtos", "?term mtos", "?mtos", " The `mtos` terminal has no options. It sends data via a pipe to an external", " program called GPCLIENT. It runs under MULTITOS, Magic 3.x, MagicMAC. and", " MiNT. If you cannot find GPCLIENT, than mail to dirk@lstm.uni-erlangen.de." END_HELP(mtos) #endif /* TERM_HELP */ /* * $Id: next.trm,v 1.22 1998/06/18 14:59:21 ddenholm Exp $ * */ /* GNUPLOT - next.trm */ /*[ * Copyright 1991 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c via ../term.h. * * This terminal driver supports: * next * * AUTHORS * Robert Lutwak from Russell Lang's post.trm * 'old' option invokes Nick Strobel's original, single viewport terminal * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * * This terminal attempts to connect, via the NeXTstep Distributed * Objects system, to the "gnuplotServer." If there is no such * service registered with the OS, the terminal attempts to fire * up GnuTerm.app. If the user has not set the environment variable * GNUTERMPATH, the terminal uses the users ApplicationPaths Workspace * dwrite to search for GnuTerm.app (Note: this is usually something * like ~/Apps, ~/LocalApps, ~/NextApps, etc.). * In order to use this filter, you MUST have GnuTerm.app installed * on your system. * * Once connected to the server, this filter is basically Russell Lang's * Postscript filter, except that the resultant postscript code * is sent, via the D.O. system, to GnuTerm.app, which manages * the windows which produce the postscript output on the screen. * * * Defaults are * 'set term next new dashed auto "Helvetica" 14' * * To change font to Times-Roman and font size to 20pts use * 'set term next "Times-Roman" 20'. * * to choose window by title * 'set term next title "Window title" * * Monitor Options: * monochrome, color * * To invoke Nick Strobel's old terminal * 'set term next old' */ #include "driver.h" #ifdef TERM_REGISTER register_term(next) #endif #ifdef TERM_PROTO /* whether or not to compile support for the old (self-contained) NeXT terminal */ /* #define NEXT_OLDTERMINAL 1 */ #import #import /* setProtocolForProxy */ #import /* setProtocolForProxy */ #import #import #import #ifdef NEXT_OLDTERMINAL static void window_create __PROTO((void)); @interface EpsViewer:Application { id theNewWin; } -windowCreate:(NXCoord) width Height:(NXCoord) height; -(NXRect *) nextRectForWidth:(NXCoord) width Height:(NXCoord) height; @end #endif /* NEXT_OLDTERMINAL */ TERM_PUBLIC void NEXT_options __PROTO((void)); TERM_PUBLIC void NEXT_common_init __PROTO((int uses_fonts, unsigned int xoff, unsigned int yoff, unsigned int xsize, unsigned int ysize, char **dict)); TERM_PUBLIC void NEXT_init __PROTO((void)); TERM_PUBLIC void NEXT_graphics __PROTO((void)); TERM_PUBLIC void NEXT_text __PROTO((void)); TERM_PUBLIC void NEXT_reset __PROTO((void)); TERM_PUBLIC void NEXT_linetype __PROTO((int linetype)); TERM_PUBLIC void NEXT_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void NEXT_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void NEXT_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int NEXT_text_angle __PROTO((int ang)); TERM_PUBLIC int NEXT_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void NEXT_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC int NEXT_set_font __PROTO((char *font)); TERM_PUBLIC char *NEXT_RememberFont __PROTO((char *fname)); TERM_PUBLIC void NEXT_set_pointsize __PROTO((double size)); #define NEXT_POINT_TYPES 8 /* div */ #define NEXT_XOFF 1 /* page offset in pts */ #define NEXT_YOFF 1 #define NEXT_XMAX 6400 #define NEXT_YMAX 4800 #define NEXT_XLAST (NEXT_XMAX - 1) #define NEXT_YLAST (NEXT_YMAX - 1) #define NEXT_VTIC (NEXT_YMAX/80) #define NEXT_HTIC (NEXT_YMAX/80) #define NEXT_SC (10) /* scale is 1pt = 10 units */ #define NEXT_LW (0.5*NEXT_SC) /* linewidth = 0.5 pts */ #define NEXT_VCHAR (14*NEXT_SC) /* default is 14 point characters */ #define NEXT_HCHAR (14*NEXT_SC*6/10) #define GOT_NEXT_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY @interface GnuTermDriver:Object < NXSenderIsInvalid > { id server; } -senderIsInvalid:(id) sender; -plot:(char *) PSstr; -init; @end #define DEFAULTNEXTSIZE 10000 static id gnuTermAccess; /* local object manages the D.O. connection */ static char *NEXTBuffer, *NEXTBufAt, *NEXTBufEnd; static int NEXTsize; static char NEXTTmpBuf[1000]; static void NEXTPrintf(char *,...); static TBOOLEAN NEXT_oldterminal = FALSE; /*static TBOOLEAN NEXT_colordetect();*/ static char NEXT_title[MAX_LINE_LEN + 1]; /* name of font */ static char NEXT_font[MAX_LINE_LEN + 1] = "Helvetica"; /* name of font */ static int NEXT_fontsize = 14; /* size of font in pts */ static TBOOLEAN NEXT_color = FALSE; static TBOOLEAN NEXT_solid = FALSE; /* use dashed lines */ static int NEXT_path_count = 0; /* count of lines in path */ static int NEXT_ang = 0; /* text angle */ static enum JUSTIFY NEXT_justify = LEFT; /* text is flush left */ static TBOOLEAN NEXT_duplex_state = FALSE; static TBOOLEAN NEXT_duplex_option = FALSE; static char GPFAR *GPFAR NEXT_header[] = { "/M {moveto} bind def\n", "/L {lineto} bind def\n", "/R {rmoveto} bind def\n", "/V {rlineto} bind def\n", "/vpt2 vpt 2 mul def\n", "/hpt2 hpt 2 mul def\n", /* flush left show */ "/Lshow { currentpoint stroke M\n", " 0 vshift R show } def\n", /* flush right show */ "/Rshow { currentpoint stroke M\n", " dup stringwidth pop neg vshift R show } def\n", /* centred show */ "/Cshow { currentpoint stroke M\n", " dup stringwidth pop -2 div vshift R show } def\n", /* Dash or Color Line */ "/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }\n", " {pop pop pop Solid {pop []} if 0 setdash} ifelse } def\n", /* Border Lines */ "/BL { stroke gnulinewidth 2 mul setlinewidth } def\n", /* Axes Lines */ "/AL { stroke gnulinewidth 2 div setlinewidth } def\n", /* Plot Lines */ "/PL { stroke gnulinewidth setlinewidth } def\n", /* Line Types */ "/LTb { BL [] 0 0 0 DL } def\n", /* border */ "/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */ "/LT0 { PL [] 0 1 0 DL } def\n", "/LT1 { PL [4 dl 2 dl] 0 0 1 DL } def\n", "/LT2 { PL [2 dl 3 dl] 1 0 0 DL } def\n", "/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n", "/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n", "/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n", "/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n", "/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n", "/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n", /* Point (Round) *//* Matt Heffron make it round */ "/Pnt { stroke [] 0 setdash\n", " gsave 1 setlinecap M 0 0 V stroke grestore } def\n", /* Diamond */ "/Dia { stroke [] 0 setdash 2 copy vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath stroke\n", " Pnt } def\n", /* Plus */ "/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V\n", " currentpoint stroke M\n", " hpt neg vpt neg R hpt2 0 V stroke\n", " } def\n", /* Box */ "/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath stroke\n", " Pnt } def\n", /* Cross (X) */ "/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " hpt2 vpt2 neg V currentpoint stroke M\n", " hpt2 neg 0 R hpt2 vpt2 V stroke } def\n", /* Triangle Up*/ "/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath stroke\n", " Pnt } def\n", /* Star */ "/Star { 2 copy Pls Crs } def\n", /* div added filed box */ /* Filled Box */ "/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath fill } def\n", /* div added filled triangle */ /* Triangle Up, Filled */ "/TriUF { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath fill } def\n", /* Matt Heffron: added a few more types */ /* Triangle Down */ "/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath stroke\n", " Pnt } def\n", /* Triangle Down, Filled*/ "/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath fill} def\n", /* Diamond, Filled */ "/DiaF { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath fill } def\n", /* Pentagon */ "/Pent { stroke [] 0 setdash 2 copy gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath stroke grestore Pnt } def\n", /* Pentagon, Filled */ "/PentF { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath fill grestore } def\n", /* Circle */ "/Circle { stroke [] 0 setdash 2 copy\n", " hpt 0 360 arc stroke Pnt } def\n", /* Circle,Filled */ "/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def\n", /* 16 differently filled circles */ "/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450 arc } bind def\n", "/C1 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C2 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C3 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C4 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 180 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C5 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc\n", " 2 copy moveto\n", " 2 copy vpt 180 270 arc closepath fill\n", " vpt 0 360 arc } bind def\n", "/C6 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C7 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C8 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 270 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C9 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 270 450 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 90 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C11 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C12 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C13 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C14 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 360 arc closepath fill\n", " vpt 0 360 arc } bind def\n", "/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", /* Auxiliary definitions for rectangles */ "/Rec { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto\n", " neg 0 rlineto closepath } bind def\n", "/Square { dup Rec } bind def\n", "/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def\n", /* 16 differently filled squares */ "/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def\n", "/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def\n", "/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n", "/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def\n", "/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n", "/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill\n", " exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n", "/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def\n", "/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill\n", " 2 copy vpt Square fill\n", " Bsquare } bind def\n", "/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def\n", "/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def\n", "/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill\n", " Bsquare } bind def\n", "/S11 { 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill\n", " Bsquare } bind def\n", "/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def\n", "/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n", " 2 copy vpt Square fill Bsquare } bind def\n", "/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n", " 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n", "/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def\n", /* 16 different diamonds (actually just rotated squares) */ "/D0 { gsave translate 45 rotate 0 0 Box stroke grestore } bind def\n", "/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def\n", "/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def\n", "/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def\n", "/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def\n", "/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def\n", "/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def\n", "/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def\n", "/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def\n", "/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def\n", "/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def\n", "/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def\n", "/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def\n", "/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def\n", "/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def\n", "/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def\n", NULL }; static char GPFAR *GPFAR ENHNEXT_header[] = { /* For MFshow and MFwidth the tos is an array with the string and font info: */ /* [ ] */ "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n", " [ currentpoint ] exch dup 2 get 0 exch rmoveto dup 4 get show dup\n", " 3 get {2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n", "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n", " 4 get stringwidth pop add}\n", " {pop} ifelse} forall} bind def\n", /* flush left show */ "/MLshow { currentpoint stroke M\n", " 0 exch R MFshow } bind def\n", /* flush right show */ "/MRshow { currentpoint stroke M\n", " exch dup MFwidth neg 3 -1 roll R MFshow } def\n", /* centred show */ "/MCshow { currentpoint stroke M\n", " exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n", NULL }; /* added to post by Matt Heffron */ /* moved to post.trm by drd */ struct NEXT_FontName { char *name; struct NEXT_FontName *next; } *NEXT_DocFonts = NULL; TERM_PUBLIC char *NEXT_RememberFont(fname) char *fname; { struct NEXT_FontName *fnp; for (fnp = NEXT_DocFonts; fnp && strcmp(fnp->name, fname); fnp = fnp->next); if (fnp) return fnp->name; /* we must have found it in the list */ if (encoding == ENCODING_ISO_8859_1) { NEXTPrintf("/%s reencodeISO def\n", fname); } fnp = (struct NEXT_FontName *) gp_alloc(sizeof(struct NEXT_FontName), "PostScript Font record"); fnp->name = gp_alloc(1 + strlen(fname), "PostScript Font name"); strcpy(fnp->name, fname); fnp->next = NEXT_DocFonts; NEXT_DocFonts = fnp; return fnp->name; } int NEXT_pen_x, NEXT_pen_y; int NEXT_taken; int NEXT_linetype_last; TBOOLEAN NEXT_relative_ok; TERM_PUBLIC void NEXT_options() { char buf[40]; for (; !END_OF_COMMAND; ++c_token) { if (almost_equals(c_token, "d$efault")) { NEXT_oldterminal = FALSE; /*NEXT_color=NEXT_colordetect(); */ NEXT_color = FALSE; NEXT_solid = FALSE; NEXT_duplex_option = FALSE; strcpy(NEXT_font, "Helvetica"); NEXT_fontsize = 14; term->v_char = (unsigned int) (NEXT_fontsize * NEXT_SC); term->h_char = (unsigned int) (NEXT_fontsize * NEXT_SC * 6 / 10); term->put_text = NEXT_put_text; } else if (almost_equals(c_token, "mono$chrome")) { NEXT_color = FALSE; } else if (almost_equals(c_token, "col$or") || almost_equals(c_token, "col$our")) { NEXT_color = TRUE; } /* else if (almost_equals(c_token,"auto$detect")) { NEXT_color = NEXT_colordetect(); } */ else if (almost_equals(c_token, "so$lid")) { NEXT_solid = TRUE; } else if (almost_equals(c_token, "da$shed")) { NEXT_solid = FALSE; } else if (almost_equals(c_token, "si$mplex")) { NEXT_duplex_state = FALSE; NEXT_duplex_option = TRUE; } else if (almost_equals(c_token, "du$plex")) { NEXT_duplex_state = TRUE; NEXT_duplex_option = TRUE; } else if (almost_equals(c_token, "defaultp$lex")) { NEXT_duplex_option = FALSE; } else if (isstring(c_token)) { quote_str(NEXT_font, c_token, MAX_LINE_LEN + 1); /* We must have font size specified */ copy_str(buf, ++c_token, 40); NEXT_fontsize = atoi(buf); term->v_char = (unsigned int) (NEXT_fontsize * NEXT_SC); term->h_char = (unsigned int) (NEXT_fontsize * NEXT_SC * 6 / 10); sprintf(default_font, "%s,%d", NEXT_font, NEXT_fontsize); } else if (almost_equals(c_token, "ti$tle")) { if (!isstring(++c_token)) { fprintf(stderr, "usage: set term next title \"newtitle\"\n"); --c_token; } quote_str(NEXT_title, c_token, MAX_LINE_LEN + 1); } else if (almost_equals(c_token, "old")) { NEXT_oldterminal = TRUE; } else if (almost_equals(c_token, "new")) { NEXT_oldterminal = FALSE; } } sprintf(term_options, "%s %s %s %s \"%s\" %d title \"%s\"", NEXT_oldterminal ? "old" : "new", NEXT_color ? "color" : "monochrome", NEXT_solid ? "solid" : "dashed", NEXT_duplex_option ? (NEXT_duplex_state ? "duplex" : "simplex") : "defaultplex", NEXT_font, NEXT_fontsize, NEXT_title); } /* store settings passed to common_init() for use in NEXT_graphics() * are reserved for storing the term options */ static int NEXT_common_uses_fonts; static unsigned int NEXT_common_xoff, NEXT_common_yoff; TERM_PUBLIC void NEXT_common_init(uses_fonts, xoff, yoff, width, height, dict) int uses_fonts; /* 0 for NEXT(la)tex */ unsigned int xoff, yoff; /* offset - 50 for /post, 0 for NEXT(la)tex */ unsigned int width, height; /* for bounding box */ char **dict; /* extra entries for the dictionary */ { static char GPFAR NEXTi1[] = "%%%%Creator: gnuplot\n\ %%%%DocumentFonts: %s\n"; static char GPFAR NEXTi2[] = "%%%%EndComments\n\ /gnudict 120 dict def\ngnudict begin\n\ /Color %s def\n\ /Solid %s def\n\ /gnulinewidth %.3f def\n\ /vshift %d def\n\ /dl {%d mul} def\n\ /hpt %.1f def\n\ /vpt %.1f def\n"; static char GPFAR *NEXT_iso_8859_1_encoding[] = { "/reencodeISO {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "/Encoding ISOLatin1Encoding def\n", "currentdict end definefont\n", "} def\n", "/ISOLatin1Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n", "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n", "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n", "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n", "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n", "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n", "/guillemotright/onequarter/onehalf/threequarters/questiondown\n", "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n", "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n", "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n", "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n", "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n", "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n", "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n", "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n", "/yacute/thorn/ydieresis\n", "] def\n", NULL}; struct termentry *t = term; int i; NEXT_common_uses_fonts = uses_fonts; NEXT_common_xoff = xoff; NEXT_common_yoff = yoff; NEXTPrintf("%%!NEXT-Adobe-2.0\n"); NEXTPrintf(NEXTi1, uses_fonts ? "(atend)" : ""); NEXTPrintf("%%%%BoundingBox: %d %d %d %d\n", xoff, yoff, (int) (xsize * width / NEXT_SC + 0.5 + xoff), (int) (ysize * height / NEXT_SC + 0.5 + yoff)); NEXTPrintf(NEXTi2, NEXT_color ? "true" : "false", NEXT_solid ? "true" : "false", NEXT_LW, /* line width */ (int) (t->v_char) / (-3), /* shift for vertical centring */ NEXT_SC, /* dash length */ NEXT_HTIC / 2.0, /* half point width */ NEXT_VTIC / 2.0); /* half point height */ if (uses_fonts && (encoding == ENCODING_ISO_8859_1)) { for (i = 0; NEXT_iso_8859_1_encoding[i] != NULL; i++) { NEXTPrintf("%s", NEXT_iso_8859_1_encoding[i]); } } for (i = 0; NEXT_header[i] != NULL; i++) NEXTPrintf("%s", NEXT_header[i]); if (NEXT_duplex_option) NEXTPrintf("statusdict begin %s setduplexmode end\n", NEXT_duplex_state ? "true" : "false"); NEXT_RememberFont(NEXT_font); if (dict) while (*dict) NEXTPrintf("%s", *(dict++)); NEXTPrintf("end\n%%%%EndProlog\n"); } /* the init fn for the NeXT Terminal driver */ TERM_PUBLIC void NEXT_init() { /* Initialize output string */ NEXTsize = DEFAULTNEXTSIZE; if ((NEXTBuffer = malloc(NEXTsize)) == NULL) { printf("Malloc error in next filter init\n"); exit(1); } NEXTBufEnd = NEXTBuffer + NEXTsize; NEXTBufAt = NEXTBuffer; term->xmax = NEXT_XMAX; term->ymax = NEXT_YMAX; #ifdef NEXT_OLDTERMINAL if (NEXT_oldterminal) window_create(); else gnuTermAccess =[[GnuTermDriver alloc] init]; #else gnuTermAccess =[[GnuTermDriver alloc] init]; #endif } TERM_PUBLIC void NEXT_graphics() { static char GPFAR NEXTg1[] = "0 setgray\nnewpath\n"; struct termentry *t = term; *NEXTBuffer = 0; NEXTBufAt = NEXTBuffer; NEXT_common_init(1, NEXT_XOFF, NEXT_YOFF, term->xmax, term->ymax, ENHNEXT_header); NEXTPrintf("gnudict begin\ngsave\n"); NEXTPrintf("%d %d translate\n", NEXT_common_xoff, NEXT_common_yoff); NEXTPrintf("%.3f %.3f scale\n", 1.0 / NEXT_SC, 1.0 / NEXT_SC); NEXTPrintf(NEXTg1); if (NEXT_common_uses_fonts) NEXTPrintf("(%s) findfont %d scalefont setfont\n", NEXT_font, (t->v_char)); NEXT_path_count = 0; NEXT_relative_ok = FALSE; NEXT_pen_x = NEXT_pen_y = -4000; NEXT_taken = 0; NEXT_linetype_last = -1; #ifdef NEXT_OLDTERMINAL if (NEXT_oldterminal) { /* Fill window with white */ NEXTPrintf("1 setgray\n"); NEXTPrintf("0 0 %d %d rectfill\n", NEXT_XMAX, NEXT_YMAX); NEXTPrintf("0 setgray\n"); } #endif } TERM_PUBLIC void NEXT_text() { static DPSContext d; NEXT_path_count = 0; NEXTPrintf("stroke\ngrestore\nend\n"); /* Terminate string */ *NEXTBufAt = 0; if (NEXT_oldterminal) { d = DPSGetCurrentContext(); DPSPrintf(d, NEXTBuffer); DPSFlushContext(d); } else { /* Here's the call that dumps the string to the server */ [gnuTermAccess plot:NEXTBuffer]; } } TERM_PUBLIC void NEXT_reset() { NEXTPrintf("%%%%Trailer\n"); if (!NEXT_common_uses_fonts) { NEXTPrintf("%%%%DocumentFonts: "); while (NEXT_DocFonts) { struct NEXT_FontName *fnp; fnp = NEXT_DocFonts->next; NEXTPrintf("%s%s", NEXT_DocFonts->name, fnp ? ", " : "\n"); free(NEXT_DocFonts->name); free(NEXT_DocFonts); NEXT_DocFonts = fnp; } } } TERM_PUBLIC void NEXT_linetype(linetype) int linetype; { linetype = (linetype % 9) + 2; if (linetype < 0) linetype = 0; NEXT_relative_ok = FALSE; if (NEXT_linetype_last == linetype) return; NEXT_linetype_last = linetype; NEXTPrintf("LT%c\n", "ba012345678"[linetype]); NEXT_path_count = 0; } TERM_PUBLIC void NEXT_move(x, y) unsigned int x, y; { int dx, dy; char abso[20], rel[20]; dx = x - NEXT_pen_x; dy = y - NEXT_pen_y; /* can't cancel all null moves--need a move after stroke'ing */ if (dx == 0 && dy == 0 && NEXT_relative_ok) return; sprintf(abso, "%d %d M\n", x, y); sprintf(rel, "%d %d R\n", dx, dy); if (strlen(rel) < strlen(abso) && NEXT_relative_ok) { NEXTPrintf("%s", rel); NEXT_taken++; } else NEXTPrintf("%s", abso); NEXT_relative_ok = TRUE; NEXT_path_count += 1; NEXT_pen_x = x; NEXT_pen_y = y; } TERM_PUBLIC void NEXT_vector(x, y) unsigned int x, y; { int dx, dy; char abso[20], rel[20]; dx = x - NEXT_pen_x; dy = y - NEXT_pen_y; if (dx == 0 && dy == 0) return; sprintf(abso, "%d %d L\n", x, y); sprintf(rel, "%d %d V\n", dx, dy); if (strlen(rel) < strlen(abso) && NEXT_relative_ok) { NEXTPrintf("%s", rel); NEXT_taken++; } else NEXTPrintf("%s", abso); NEXT_relative_ok = TRUE; NEXT_path_count += 1; NEXT_pen_x = x; NEXT_pen_y = y; if (NEXT_path_count >= 400) { NEXTPrintf("currentpoint stroke M\n"); NEXT_path_count = 0; } } TERM_PUBLIC int NEXT_text_angle(ang) int ang; { NEXT_ang = ang; return TRUE; } TERM_PUBLIC int NEXT_justify_text(mode) enum JUSTIFY mode; { NEXT_justify = mode; return TRUE; } TERM_PUBLIC int NEXT_set_font(font) /* Entry font added by DJL */ char *font; { char name[32]; int size, sep; sep = strcspn(font, ","); strncpy(name, font, sep); name[sep] = NUL; size = NEXT_fontsize; sscanf(&(font[sep + 1]), "%d", &size); NEXTPrintf("/%s findfont %d scalefont setfont\n", name, size * NEXT_SC); NEXT_RememberFont(name); return TRUE; } /* postscript point routines */ TERM_PUBLIC void NEXT_set_pointsize(size) double size; { NEXTPrintf("/vpt %.1f def /hpt %.1f def /vpt2 vpt 2 mul def /hpt2 hpt 2 mul def\n", pointsize * NEXT_VTIC * 0.5, pointsize * NEXT_HTIC * 0.5); } TERM_PUBLIC void NEXT_point(x, y, number) unsigned int x, y; int number; { static char *pointFNS[] = {"Pnt", "Pls", "Crs", "Star", "Box", "BoxF", "Circle", "CircleF", "TriU", "TriUF", "TriD", "TriDF", "Dia", "DiaF", "Pent", "PentF", "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11", "C12", "C13", "C14", "C15", "S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10", "S11", "S12", "S13", "S14", "S15", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15" }; if (number < 0) number = -1; /* negative types are all 'dot' */ else number %= sizeof(pointFNS) / sizeof(pointFNS[0]) - 1; NEXTPrintf("%d %d %s\n", x, y, pointFNS[number + 1]); NEXT_relative_ok = 0; NEXT_path_count = 0; NEXT_linetype_last = -1; /* force next linetype change */ } /* All lifted from the enhanced postscript driver */ static TBOOLEAN NEXT_opened_string; /* try to cut out empty ()'s */ /* used in determining height of processed text */ static float NEXT_max_height, NEXT_min_height; /* process a bit of string, and return the last character used. * p is start of string * brace is TRUE to keep processing to }, FALSE for do one character * fontname & fontsize are obvious * base is the current baseline * widthflag is TRUE if the width of this should count, * FALSE for zero width boxes */ static char *NEXT_recurse(p, brace, fontname, fontsize, base, widthflag) char *p, *fontname; TBOOLEAN brace, widthflag; double fontsize, base; { /* close a postscript string if it has been opened */ #define NEXT_FLUSH \ { if (NEXT_opened_string) \ { NEXTPrintf("%s", ")]\n"); \ NEXT_opened_string = FALSE; \ } \ } #define NEXT_OPEN \ { if (!NEXT_opened_string) \ { NEXTPrintf( "[(%s) %.1f %.1f %s (", \ fontname, fontsize, base, \ widthflag ? "true" : "false"); \ NEXT_opened_string = TRUE; \ } \ } /* Start each recursion with a clean string */ NEXT_FLUSH if (base + fontsize > NEXT_max_height) { NEXT_max_height = base + fontsize; } if (base < NEXT_min_height) { NEXT_min_height = base; } for (; *p; ++p) { float shift; float f = 0; /* used for getting new font size */ char *localfontname, ch; switch (*p) { case '}': if (brace) return (p); fprintf(stderr, "next driver - spurious }\n"); break; case '_': case '^': shift = (*p == '^') ? 0.5 : -0.3; NEXT_FLUSH p = NEXT_recurse(p + 1, FALSE, fontname, fontsize * 0.8, base + shift * fontsize, widthflag); break; case '{': /*{{{ recurse (possibly with a new font) */ if (*++p == '/') { /* then parse a fontname, optional fontsize */ while (*++p == ' '); localfontname = p; while ((ch = *p) > ' ' && ch != '=') ++p; if (ch == '=') { *p++ = '\0'; /*{{{ get optional font size */ f = (float) strtod(p, &p); if (f) f *= NEXT_SC; /* remember the scaling */ else f = fontsize; /*}}} */ } else { *p++ = '\0'; f = fontsize; } while (*p == ' ') ++p; if (*localfontname) localfontname = NEXT_RememberFont(localfontname); else localfontname = fontname; } else { localfontname = fontname; f = fontsize; } /*}}} */ p = NEXT_recurse(p, TRUE, localfontname, f, base, widthflag); NEXT_FLUSH break; case '@': /*{{{ phantom box - prints next 'char', then restores currentpoint */ NEXT_FLUSH p = NEXT_recurse(++p, FALSE, fontname, fontsize, base, FALSE); break; /*}}} */ case '(': case ')': /* special cases */ NEXT_OPEN NEXTPrintf("\\"); NEXTPrintf("%c", *p); break; /*}}} */ case '\\': /*{{{ is it an escape */ /* special cases */ if (p[1] == '\\' || p[1] == '(' || p[1] == ')') { NEXT_OPEN NEXTPrintf("%c", '\\'); } else if ((ch = p[1]) >= '0' && ch <= '7') { /* up to 3 octal digits */ NEXT_OPEN NEXTPrintf("%c", '\\'); NEXTPrintf("%c", ch); ++p; if ((ch = p[1]) >= '0' && ch <= '7') { NEXTPrintf("%c", ch); ++p; if ((ch = p[1]) >= '0' && ch <= '7') { NEXTPrintf("%c", ch); ++p; } } break; } ++p; /* just go and print it (fall into the 'default' case) */ /*}}} */ default: NEXT_OPEN NEXTPrintf("%c", *p); } /* like TeX, we only do one character in a recursion, unless it's * in braces */ if (!brace) { NEXT_FLUSH return (p); /* the ++p in the outer copy will increment us */ } } NEXT_FLUSH return p; } TERM_PUBLIC void NEXT_put_text(x, y, str) unsigned int x, y; char *str; { /* flush any pending graphics (all the XShow routines do this...) */ if (!strlen(str)) return; if (NEXT_path_count) { NEXTPrintf(" stroke\n"); NEXT_path_count = 0; NEXT_relative_ok = FALSE; } NEXT_move(x, y); if (NEXT_ang != 0) NEXTPrintf("currentpoint gsave translate %d rotate 0 0 moveto\n", NEXT_ang * 90); NEXTPrintf("[ "); /* set up the globals */ NEXT_opened_string = FALSE; NEXT_max_height = -1000; NEXT_min_height = 1000; while (*(str = NEXT_recurse(str, TRUE, NEXT_font, (double) term->v_char, 0.0, TRUE))); NEXT_max_height += NEXT_min_height; NEXTPrintf("] %.1f ", -NEXT_max_height / 3); switch (NEXT_justify) { case LEFT: NEXTPrintf("MLshow\n"); break; case CENTRE: NEXTPrintf("MCshow\n"); break; case RIGHT: NEXTPrintf("MRshow\n"); break; } if (NEXT_ang != 0) NEXTPrintf("grestore\n"); NEXT_path_count = 0; NEXT_relative_ok = FALSE; } /* static TBOOLEAN NEXT_colordetect() { NXScreen * mainscreen; mainscreen = [Application mainScreen]; if (mainscreen->depth == NX_TwoBitGrayDepth) return(FALSE); return(TRUE); } */ /* This just packs all the postscript into one (possibly huge) string * which will be passed (as a fake pointer) via D.O. to the server */ void NEXTPrintf(char *fmt,...) { va_list ap; char *pb; int NEXToff; /* Process formatting instructions */ va_start(ap, fmt); vsprintf(NEXTTmpBuf, fmt, ap); va_end(ap); /* Add to buffer */ for (pb = NEXTTmpBuf; (*pb != 0); ++pb, ++NEXTBufAt) { /* reallocate if necessary */ if (NEXTBufAt >= NEXTBufEnd) { NEXToff = NEXTBufAt - NEXTBuffer; NEXTsize *= 2; NEXTBuffer = realloc(NEXTBuffer, NEXTsize); NEXTBufEnd = NEXTBuffer + NEXTsize; NEXTBufAt = NEXTBuffer + NEXToff; } *NEXTBufAt = *pb; } return; } /* This next section implements the GnuTermDriver object which manages the D.O. connection and interface to OBjC */ @protocol GnuTermServerMethods /*- (oneway) executePScode:(in char *)PStext termTitle:(in char *)title;*/ - executePScode:(in char *) PStext termTitle:(in char *) title; @end @ implementation GnuTermDriver - init { NXConnection *myConnection; char serverpath[100], *envstring; int GnuTermPathSet = 0; /* Ask OS for connection to server */ server =[NXConnection connectToName:"gnuplotServer"]; /* Server is running ready to go */ if (server) /*printf("Connected to server\n") */ ; /* Server isn't running, we must fire it up */ else { /*printf("Launching GnuTerm\n"); */ *serverpath = 0; /* Check for path set in environment */ if ((envstring = getenv("GNUTERMPATH")) != (char *) NULL) { sprintf(serverpath, "%s/GnuTerm.app/GnuTerm", envstring); GnuTermPathSet = 1; } /* Not in environment */ else strcpy(serverpath, "GnuTerm"); /* Try to launch application */ if ([[Application workspace] launchApplication:serverpath] == NO) { printf("Failed to launch %s.\n", serverpath); /* Offer a little advice */ if (GnuTermPathSet) { printf("You must have setenv GNUTERMPATH to something wrong\n"); printf("I recommend you exit gnuplot and fix this.\n"); } else { printf("It must be located in ~/Apps or /LocalApps\n"); printf("I recommend that you either\n"); printf("- move GnuTerm.app to one of these locations\n"); printf("- set GNUTERMPATH with host%% setenv GNUTERMPATH /directory/containing_GnuTerm.app\n"); printf("- start GnuTerm ahead of the first plot command\n"); #ifdef NEXT_OLDTERMINAL printf("- use the old driver version (set term next old)\n"); #endif } } /* I wish the gnuplot terminal interface would let me return an error here. */ /* Application is launching */ else { /* Wait for it to register Server methods with OS */ do { server =[NXConnection connectToName:"gnuplotServer"]; } while (!server); /* This could result in a hang, but I've never seen it fail */ } } /* By limiting ourselves to known protocol * we speed up the messaging */ [server setProtocolForProxy:@protocol(GnuTermServerMethods)]; myConnection =[server connectionForProxy]; /* If the server dies we want to know about it */ [myConnection registerForInvalidationNotification:self]; /* In fact, we'll worry about it */ [NXPort worryAboutPortInvalidation]; return self; } -plot:(char *) PSstr; { /* If server has become invalid, re-initialize */ if (!server) [self init]; /* This is where we send the huge postscript string to the server Note: The D.O. system doesn't actually give this pointer to the server. The pointer is dereferenced on the client side and the resulting data is sent to the server. On the server side, space for the data is automatically allocated, and a pointer to the local data is received. For details check out: /NextLibrary/Documentation/NextDev/GeneralRef/06_DistributedObjects/IntroDistObjects.rtf */ /*printf("Calling server..."); */ [server executePScode: PSstr termTitle:NEXT_title]; /*printf("returned\n"); */ *NEXT_title = 0; return self; } /* This gets called by OS if server goes down */ -senderIsInvalid:(id) sender { server = 0; } @end #ifdef NEXT_OLDTERMINAL static void window_create() { float width, height; width = (xsize * (NEXT_XMAX) / NEXT_SC + 0.5 + NEXT_XOFF); height = (ysize * (NEXT_YMAX) / NEXT_SC + 0.5 + NEXT_YOFF); NXApp =[EpsViewer new]; [NXApp windowCreate: width Height:height]; } @implementation EpsViewer - windowCreate:(NXCoord) width Height:(NXCoord) height { /* create the new window, in a good place */ theNewWin =[Window newContent: [self nextRectForWidth: width Height:height] style: NX_TITLEDSTYLE backing: NX_RETAINED buttonMask: (NX_CLOSEBUTTONMASK | NX_MINIATURIZEBUTTONMASK) defer: NO]; /* we need to receive windowDidBecomeMain: and windowDidResignMain: */ [theNewWin setDelegate:self]; /* * create a new View, make it the contentView of our new window, * and destroy the window's old contentView */ [[theNewWin setContentView:[[View alloc] init]] free]; /* display the window, and bring it forth */ [theNewWin display]; [theNewWin makeKeyAndOrderFront:self]; /* [theNewWin orderBack:self]; */ /* show the frame */ return self; } /***************************************************************************/ /* nextRectForWidth:Height: - return the next good content rectangle */ /* from Carl F. Sutter's wonderful ViewGif2 'Controller' method... */ /***************************************************************************/ /* nextTopLeft - return the next good top left window position */ /***************************************************************************/ -(NXRect *) nextRectForWidth:(NXCoord) width Height:(NXCoord) height { #define OFFSET 10.0 #define MAX_STEPS 20 #define INITIAL_X 356.0 #define INITIAL_Y 241.0 NXPoint nxpTopLeft; NXRect nxrTemp; /* used to find window height */ NXRect nxrWinHeight; /* bounds of enclosing window */ NXSize nxsScreen; /* size of screen */ static NXRect nxrResult; /* the Answer! */ static int nCurStep = 0; /* find a good top-left coord */ nxpTopLeft.x = INITIAL_X + nCurStep * OFFSET; nxpTopLeft.y = INITIAL_Y + nCurStep * OFFSET; if (++nCurStep > MAX_STEPS) nCurStep = 0; /* find window height using nxrTemp */ nxrTemp.size.width = width; nxrTemp.size.height = height; nxrTemp.origin.x = nxrTemp.origin.y = 0; [Window getFrameRect: &nxrWinHeight forContentRect:&nxrTemp style:NX_TITLEDSTYLE]; [NXApp getScreenSize:&nxsScreen]; /* find the lower-left coord */ nxrResult.origin.x = nxpTopLeft.x; nxrResult.origin.y = nxsScreen.height - nxrWinHeight.size.height - nxpTopLeft.y; nxrResult.size.width = width; nxrResult.size.height = height; return (&nxrResult); } @end #endif /* NEXT_OLDTERMINAL */ #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(next_driver) "next", "Interface to GnuTerm.app under NeXTstep", NEXT_XMAX, NEXT_YMAX, NEXT_VCHAR, NEXT_HCHAR, NEXT_VTIC, NEXT_HTIC, NEXT_options, NEXT_init, NEXT_reset, NEXT_text, null_scale, NEXT_graphics, NEXT_move, NEXT_vector, NEXT_linetype, NEXT_put_text, NEXT_text_angle, NEXT_justify_text, NEXT_point, do_arrow, NEXT_set_font, NEXT_set_pointsize TERM_TABLE_END(next_driver) #undef LAST_TERM #define LAST_TERM next_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(next) "1 next", "?commands set terminal next", "?set terminal next", "?set term next", "?terminal next", "?term next", "?next", "?NeXT", " Several options may be set in the next driver.", "", " Syntax:", " set terminal next {} { } {} {}", " {\"\"} {} title {\"\"}", "", " where is `default`, which sets all options to their defaults;", " is either `new` or `old`, where `old` invokes the old single window;", " is either `color` or `monochrome`;", " is either `solid` or `dashed`;", " \"\" is the name of a valid PostScript font;", " is the size of the font in PostScript points; and", " is the title for the GnuTerm window.", " Defaults are `new`, `monochrome`, `dashed`, \"Helvetica\", 14pt.", "", " Examples:", " set term next default", " set term next 22", " set term next color \"Times-Roman\" 14", " set term next color \"Helvetica\" 12 title \"MyPlot\"", " set term next old", "", " Pointsizes may be changed with `set linestyle`." END_HELP(next) #endif /* TERM_HELP */ /* * $Id: pbm.trm,v 1.19 1998/06/18 14:59:21 ddenholm Exp $ * */ /* GNUPLOT - pbm.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * pbm * * AUTHORS * Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* The following pbmplus drivers use the generic bit mapped graphics routines from bitmap.c to build up a bit map in memory. The driver interchanges colomns and lines in order to access entire lines easily and returns the lines to get bits in the right order : (x,y) -> (y,XMAX-1-x). */ /* This interchange is done by calling b_makebitmap() with reversed xmax and ymax, and then setting b_rastermode to TRUE. b_setpixel() will then perform the interchange before each pixel is plotted */ /* See Jef Poskanzer's excellent PBMplus package for more details of the Portable BitMap format and for programs to convert PBM files to other bitmap formats. */ #include "driver.h" #ifdef TERM_REGISTER register_term(pbm_driver) #endif #ifdef TERM_PROTO TERM_PUBLIC void PBMoptions __PROTO((void)); TERM_PUBLIC void PBMinit __PROTO((void)); TERM_PUBLIC void PBMreset __PROTO((void)); TERM_PUBLIC void PBMsetfont __PROTO((void)); TERM_PUBLIC void PBMgraphics __PROTO((void)); TERM_PUBLIC void PBMmonotext __PROTO((void)); TERM_PUBLIC void PBMgraytext __PROTO((void)); TERM_PUBLIC void PBMcolortext __PROTO((void)); TERM_PUBLIC void PBMtext __PROTO((void)); TERM_PUBLIC void PBMlinetype __PROTO((int linetype)); TERM_PUBLIC void PBMpoint __PROTO((unsigned int x, unsigned int y, int point)); #endif /* TERM_PROTO */ #ifdef TERM_BODY /* make XMAX and YMAX a multiple of 8 */ #define PBM_XMAX (640) #define PBM_YMAX (480) #define PBM_VCHAR (FNT5X9_VCHAR) #define PBM_HCHAR (FNT5X9_VCHAR) #define PBM_VTIC FNT5X9_HBITS #define PBM_HTIC FNT5X9_HBITS static int pbm_font = 1; /* small font */ static int pbm_mode = 0; /* 0:monochrome 1:gray 2:color */ /* 7=black, 0=white */ static int pgm_gray[] = { 7, 1, 6, 5, 4, 3, 2, 1, 7 }; /* grays */ /* bit3=!intensify, bit2=!red, bit1=!green, bit0=!blue */ static int ppm_color[] ={ 15, 8, 3, 5, 6, 2, 4, 1, 11, 13, 14 }; /* colors */ TERM_PUBLIC void PBMoptions() { pbm_font = 1; pbm_mode = 0; term_options[0] = NUL; while (!END_OF_COMMAND) { if (almost_equals(c_token, "s$mall")) pbm_font = 1; else if (almost_equals(c_token, "me$dium")) pbm_font = 2; else if (almost_equals(c_token, "l$arge")) pbm_font = 3; else if (almost_equals(c_token, "mo$nochrome")) pbm_mode = 0; else if (almost_equals(c_token, "g$ray")) pbm_mode = 1; else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) pbm_mode = 2; else { /* reset to default, since term is already set */ pbm_font = 1; pbm_mode = 0; int_error("expecting: {small, medium, large} and {monochrome, gray, color}", c_token); } c_token++; } /* setup options string */ switch (pbm_font) { case 1: strcat(term_options, "small"); break; case 2: strcat(term_options, "medium"); break; case 3: strcat(term_options, "large"); break; } switch (pbm_mode) { case 0: strcat(term_options, " monochrome"); break; case 1: strcat(term_options, " gray"); break; case 2: strcat(term_options, " color"); break; } } TERM_PUBLIC void PBMinit() { PBMsetfont(); /* HBB 980226: call it here! */ } TERM_PUBLIC void PBMreset() { #ifdef VMS fflush_binary(); #endif /* VMS */ } TERM_PUBLIC void PBMsetfont() { switch (pbm_font) { case 1: b_charsize(FNT5X9); term->v_char = FNT5X9_VCHAR; term->h_char = FNT5X9_HCHAR; term->v_tic = FNT5X9_HBITS; term->h_tic = FNT5X9_HBITS; break; case 2: b_charsize(FNT9X17); term->v_char = FNT9X17_VCHAR; term->h_char = FNT9X17_HCHAR; term->v_tic = FNT9X17_HBITS; term->h_tic = FNT9X17_HBITS; break; case 3: b_charsize(FNT13X25); term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; term->v_tic = FNT13X25_HBITS; term->h_tic = FNT13X25_HBITS; break; } } TERM_PUBLIC void PBMgraphics() { int numplanes = 1; switch (pbm_mode) { case 1: numplanes = 3; break; case 2: numplanes = 4; break; } /* HBB 980226: this is not the right place to do this: setfont() influences * fields of the termtable entry, and therefore must be called by init() * already. */ /* PBMsetfont(); */ /* rotate plot -90 degrees by reversing XMAX and YMAX and by setting b_rastermode to TRUE */ b_makebitmap((unsigned int) (PBM_YMAX * ysize), (unsigned int) (PBM_XMAX * xsize), numplanes); b_rastermode = TRUE; if (pbm_mode != 0) b_setlinetype(0); /* solid lines */ } static void PBMmonotext() { register int x, j, row; fputs("P4\n", gpoutfile); fprintf(gpoutfile, "%u %u\n", b_ysize, b_xsize); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; for (j = row; j >= 0; j--) { (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile); } } b_freebitmap(); } static void PBMgraytext() { register int x, j, row; register int i, value; int mask, plane1, plane2, plane3; fprintf(gpoutfile, "\ P5\n\ %u %u\n\ %u\n", b_ysize, b_xsize, 255); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; for (j = row; j >= 0; j--) { mask = 0x80; plane1 = (*((*b_p)[j] + x)); plane2 = (*((*b_p)[j + b_psize] + x)); plane3 = (*((*b_p)[j + b_psize + b_psize] + x)); for (i = 0; i < 8; i++) { /* HBB: The values below are set to span the full range * from 0 up to 255 in 7 steps: */ value = 255; if (plane1 & mask) value -= 36; if (plane2 & mask) value -= 73; if (plane3 & mask) value -= 146; (void) fputc((char) (value), gpoutfile); mask >>= 1; } } } b_freebitmap(); } static void PBMcolortext() { register int x, j, row; register int i; int mask, plane1, plane2, plane3, plane4; int red, green, blue; fprintf(gpoutfile, "P6\n\ %u %u\n\ %u\n", b_ysize, b_xsize, 255); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; for (j = row; j >= 0; j--) { mask = 0x80; plane1 = (*((*b_p)[j] + x)); plane2 = (*((*b_p)[j + b_psize] + x)); plane3 = (*((*b_p)[j + b_psize + b_psize] + x)); plane4 = (*((*b_p)[j + b_psize + b_psize + b_psize] + x)); for (i = 0; i < 8; i++) { red = (plane3 & mask) ? 1 : 3; green = (plane2 & mask) ? 1 : 3; blue = (plane1 & mask) ? 1 : 3; if (plane4 & mask) { red--; green--; blue--; } /* HBB: '85' is exactly 255/3, so this spans the full * range of colors in three steps: */ (void) fputc((char) (red * 85), gpoutfile); (void) fputc((char) (green * 85), gpoutfile); (void) fputc((char) (blue * 85), gpoutfile); mask >>= 1; } } } b_freebitmap(); } TERM_PUBLIC void PBMtext() { switch (pbm_mode) { case 0: PBMmonotext(); break; case 1: PBMgraytext(); break; case 2: PBMcolortext(); break; } } TERM_PUBLIC void PBMlinetype(linetype) int linetype; { switch (pbm_mode) { case 0: b_setlinetype(linetype); break; case 1: if (linetype >= 7) linetype %= 7; b_setvalue(pgm_gray[linetype + 2]); break; case 2: if (linetype >= 9) linetype %= 9; b_setvalue(ppm_color[linetype + 2]); break; } } TERM_PUBLIC void PBMpoint(x, y, point) unsigned int x, y; int point; { if (pbm_mode == 0) line_and_point(x, y, point); else do_point(x, y, point); } #endif /* TERM_BODY */ #ifdef TERM_TABLE #define PBMmove b_move #define PBMvector b_vector #define PBMtext_angle b_text_angle #define PBMput_text b_put_text TERM_TABLE_START(pbm_driver) "pbm", "Portable bitmap [small medium large] [monochrome gray color]", PBM_XMAX, PBM_YMAX, PBM_VCHAR, PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions, PBMinit, PBMreset, PBMtext, null_scale, PBMgraphics, PBMmove, PBMvector, PBMlinetype, PBMput_text, PBMtext_angle, null_justify_text, PBMpoint, do_arrow, set_font_null, 0, /* pointsize */ TERM_CAN_MULTIPLOT | TERM_BINARY TERM_TABLE_END(pbm_driver) #undef LAST_TERM #define LAST_TERM pbm_driver #endif /* TERM_TABLE */ #ifdef TERM_HELP START_HELP(pbm) "1 pbm", "?commands set terminal pbm", "?set terminal pbm", "?set term pbm", "?terminal pbm", "?term pbm", "?pbm", " Several options may be set in the `pbm` terminal---the driver for PBMplus.", "", " Syntax:", " set terminal pbm {<fontsize>} {<mode>}", "", " where <fontsize> is `small`, `medium`, or `large` and <mode> is `monochrome`,", " `gray` or `color`. The default plot size is 640 pixels wide and 480 pixels", " high; this may be changed by `set size`.", "", " The output of the `pbm` driver depends upon <mode>: `monochrome` produces a", " portable bitmap (one bit per pixel), `gray` a portable graymap (three bits", " per pixel) and `color` a portable pixmap (color, four bits per pixel).", "", " The output of this driver can be used with Jef Poskanzer's excellent PBMPLUS", " package, which provides programs to convert the above PBMPLUS formats to GIF,", " TIFF, MacPaint, Macintosh PICT, PCX, X11 bitmap and many others. PBMPLUS may", " be obtained from ftp.x.org. The relevant files have names that begin with", " \"netpbm-1mar1994.p1\"; they reside in /contrib/utilities. The package can", " probably also be obtained from one of the many sites that mirrors ftp.x.org.", "", " Examples:", " set terminal pbm small monochrome # defaults", " set size 2,2; set terminal pbm color medium" END_HELP(pbm) #endif /* TERM_HELP */ /* * $Id: pc.trm,v 1.20 1998/06/18 14:59:22 ddenholm Exp $ * */ /* GNUPLOT - pc.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Under Microsoft C * cga, egabios, egalib, vgabios, hercules, corona325, att * Under Turboc C * cga, ega/vga, vgamono, svga, mcga, hercules, att * Under Watcom C * cga, ega/vga, vgamono, svga, mcga, hercules, ??? * * AUTHORS * Colin Kelley, Thomas Williams, William Wilson, Russell Lang * modified by David J. Liu (liu@csb.yale.edu) for version 3.6 * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * * Because only one compiler is used to generate gnuplot.exe * and the type of the single graphics board is auto-detected, * we can combine all these parts into one terminal type: PC * and let the computer take care of the rest. -- DJL * * Since I don't have MicroSoft C, I assume it would define MSC. * Please correct it if you are using MS C. Thank you. -- DJL * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(dospc) #endif #ifdef TERM_PROTO TERM_PUBLIC void PC_text __PROTO((void)); TERM_PUBLIC void PC_reset __PROTO((void)); TERM_PUBLIC void PC_init __PROTO((void)); TERM_PUBLIC void PC_graphics __PROTO((void)); TERM_PUBLIC void PC_linetype __PROTO((int linetype)); TERM_PUBLIC void PC_move __PROTO((int x, int y)); TERM_PUBLIC void PC_vector __PROTO((int x, int y)); TERM_PUBLIC void PC_put_text __PROTO((int x, int y, char *str)); TERM_PUBLIC int PC_text_angle __PROTO((int ang)); TERM_PUBLIC int PC_justify_text __PROTO((enum JUSTIFY ang)); #define PC_HCHAR FNT5X9_HCHAR #define PC_VCHAR FNT5X9_VCHAR #define PC_HTIC 5 #define PC_VTIC 4 #define PC_XMAX 100 /* These two entries are just place holders. */ #define PC_YMAX 100 /* The actual values will be found in init. */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #ifdef __TURBOC__ static int huge detect_svga __PROTO((void)); #endif /* __TURBOC__ */ #include <string.h> #include <stdlib.h> #ifdef __TURBOC__ #include <graphics.h> #include <conio.h> #include <dos.h> #endif /* __TURBOC__ */ #ifdef __WATCOMC__ #include <graph.h> #endif /* WATCOMC */ #ifdef MSC #include "mcega.h" #endif /* MSC */ static int pattern[] ={ 0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f }; static int vga_color[] ={ 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 }; static int pc_driver, pc_mode; static int graphics_on = FALSE, pc_graphics = FALSE; static int startx, starty, pc_lastx, pc_lasty, pc_colors; static int pc_angle, pc_hjustify, pc_vjustify, pc_text_size, pc_text_dir, pc_corscreen = -1; #ifdef __TURBOC__ extern int far _Cdecl SVGA_driver_far[]; #endif /* __TURBOC__ */ #ifdef __WATCOMC__ enum { HORIZ_DIR, VERT_DIR }; static void _settextang(ang) int ang; { if (ang == HORIZ_DIR) { _settextorient(1, 0); } else { _settextorient(0, 1); } } #endif /* WATCOMC */ static int huge detect_svga(void) { return 0; /* the default mode, just a place holder */ } void PC_setup() { /* called from the beginning of main() */ int i, t, x, y; char pc_modename[9]; #ifdef __WATCOMC__ struct videoconfig VC; #endif /* WATCOMC */ /* First link all BRI dribers, then detect the display card. */ /* If environment PCTRM is set, try initiate the card/mode. */ /* special instruction on mode */ safe_strncpy(pc_modename, getenv("PCTRM"), 8); #ifdef __TURBOC__ /* Some of this code including BGI drivers are copyright Borland Intl. */ registerfarbgidriver(EGAVGA_driver_far); registerfarbgidriver(CGA_driver_far); registerfarbgidriver(Herc_driver_far); registerfarbgidriver(ATT_driver_far); registerfarbgidriver(PC3270_driver_far); pc_driver = DETECT; detectgraph(&pc_driver, &pc_mode); if (graphresult()) { fputs("Unable to initialize graphics.\n", stderr); return; } #ifdef BGI_NAME /* the highest standard pc_driver value, see graphics.h */ #define LAST_BGI 10 /* the last mode of the SVGA.BGI */ #define LAST_SVGA_MODE 6 /* test SVGA if we have VGA */ if ((pc_driver == VGA) && (pc_modename[0] == 'S')) { installuserdriver(BGI_NAME, &detect_svga); registerfarbgidriver(SVGA_driver_far); pc_driver = DETECT; initgraph(&pc_driver, &pc_mode, ""); /* The following code, which is independent of the actual SVGA.BGI * used, tries to find a mode of width defined in the environment * variable PCTRM */ if (pc_driver > LAST_BGI) { /* success */ sscanf(pc_modename, "S%d", &t); switch (t) { case 800: break; /* S800 */ case 1024: break; /* S1024 */ case 1280: break; /* S1280 */ default: t = 640; /* 640x480 */ } for (i = 0; i <= LAST_SVGA_MODE; i++) { setgraphmode(i); if ((getmaxx() + 1 == t) && (getmaxcolor() > 14)) pc_mode = i; } setgraphmode(pc_mode); if (graphresult()) { /* error, go back to VGA */ pc_driver = VGA; pc_mode = 4; } } } /* SVGA tested */ if (pc_driver <= LAST_BGI) #endif /* BGI_NAME */ initgraph(&pc_driver, &pc_mode, ""); pc_colors = getmaxcolor() + 1; pc_lastx = getmaxx(); pc_lasty = getmaxy(); restorecrtmode(); clrscr(); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _getvideoconfig(&VC); if ((pc_driver = VC.adapter) == 0) { fprintf(stderr, "Unable to initialize graphics.\n"); return; } switch (pc_driver = VC.adapter) { case _HERCULES: pc_mode = _HERCMONO; break; case _CGA: pc_mode = _HRESBW; break; case _MCGA: pc_mode = _MRES256COLOR; break; case _EGA: pc_mode = (VC.monitor == _MONO ? _ERESCOLOR : _ERESNOCOLOR); break; case _VGA: pc_mode = _VRES16COLOR; break; case _SVGA: if (pc_modename[0] == 'S') { /* test SVGA resolution */ sscanf(pc_modename, "S%d", &t); switch (t) { case 800: pc_mode = _SVRES256COLOR; break; /* S800 */ case 1024: pc_mode = _XRES256COLOR; break; /* S1024 */ case 1280: pc_mode = _XRES256COLOR + 2; break; /* S1280 */ /* Someone help me, who knows, how a newer Watcom calls that */ default: t = 640; pc_mode = _VRES256COLOR; /* 640x480 */ } while (_setvideomode(pc_mode) == 0) pc_mode--; } break; default: fputs("Unable to initialize graphics.\n", stderr); return; } _setvideomode(pc_mode); _getvideoconfig(&VC); pc_lastx = VC.numxpixels - 1; pc_lasty = VC.numypixels - 1; pc_colors = VC.numcolors; _setvideomode(_DEFAULTMODE); #endif /* WATCOMC */ x = pc_lastx + 1; y = pc_lasty + 1; fprintf(stderr, "\tScreen of %d x %d pixels and %d colors.\n", x, y, pc_colors); pc_graphics = TRUE; } TERM_PUBLIC void PC_init() { char *pathp; #ifdef __WATCOMC__ struct _fontinfo fi; #endif if (!pc_graphics) { fputs("Unable to initialize graphics.\n", stderr); term = 0; return; } /* Double the tic/font sizes. */ pc_text_size = (pc_lasty > 590) ? 2 : 1; term->h_char = PC_HCHAR; term->v_char = PC_VCHAR; term->h_tic = PC_HTIC * pc_text_size; term->v_tic = PC_VTIC * pc_text_size; term->xmax = pc_lastx + 1; term->ymax = pc_lasty + 1; #ifdef __TURBOC__ setgraphmode(pc_mode); settextstyle(DEFAULT_FONT, HORIZ_DIR, pc_text_size); settextjustify(pc_hjustify, pc_vjustify); term->h_char = textheight("X"); /* overriding the default */ term->v_char = textwidth("X"); /* overriding the default */ #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setvideomode(pc_mode); _settextang(HORIZ_DIR); _settextalign(pc_hjustify, pc_vjustify); _setcharsize(pc_text_size * PC_HCHAR, pc_text_size * PC_VCHAR); _getfontinfo(&fi); term->h_char = fi.avgwidth; term->v_char = fi.pixheight * 1.5; #endif /* WATCOMC */ #ifdef MSC #endif /* MSC */ } TERM_PUBLIC void PC_graphics() { graphics_on = TRUE; #ifdef __TURBOC__ setgraphmode(pc_mode); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setvideomode(pc_mode); #endif /* WATCOMC */ #ifdef MSC if (pc_corscreen == -1) Vmode(18); /* VGA */ else { grinit(corscreen); grandtx(); } /* corolla */ #endif /* MSC */ } TERM_PUBLIC void PC_linetype(linetype) { if (pc_colors > 14) { /* 16 or more colors */ if (linetype >= 13) linetype %= 13; #ifdef __TURBOC__ setcolor(vga_color[linetype + 2]); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setcolor(vga_color[linetype + 2]); #endif /* WATCOMC */ #ifdef MSC #endif /* MSC */ } else { /* MONO */ if (linetype >= 5) linetype %= 5; #ifdef __TURBOC__ setlinestyle(4, pattern[linetype + 2], 1); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setlinestyle(pattern[linetype + 2]); #endif /* WATCOMC */ #ifdef MSC if (pc_corscreen != -1) Cor_mask(pattern[linetype + 2]); #endif /* MSC */ } } TERM_PUBLIC void PC_move(x, y) int x, y; { #ifdef __TURBOC__ moveto(x, pc_lasty - y); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _moveto(x, pc_lasty - y); #endif /* WATCOMC */ #ifdef MSC #endif /* MSC */ startx = x; starty = y; } TERM_PUBLIC void PC_vector(x, y) int x, y; { #ifdef __TURBOC__ lineto(x, pc_lasty - y); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _lineto(x, pc_lasty - y); #endif /* WATCOMC */ #ifdef MSC if (pc_corscreen != -1) Cor_line(startx, COR_YLAST - starty, x, COR_YLAST - y); #endif /* MSC */ startx = x; starty = y; } TERM_PUBLIC void PC_reset() { graphics_on = FALSE; #ifdef __TURBOC__ restorecrtmode(); clrscr(); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setvideomode(_DEFAULTMODE); #endif /* WATCOMC */ #ifdef MSC Vmode(3); #endif /* MSC */ } TERM_PUBLIC void PC_text() { if (graphics_on) { graphics_on = FALSE; (void) getch(); #ifdef __TURBOC__ restorecrtmode(); clrscr(); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setvideomode(_DEFAULTMODE); #endif /* WATCOMC */ #ifdef MSC if (pc_corscreen != -1) { grreset(); txonly(); } Vmode(3); #endif /* MSC */ } } TERM_PUBLIC int PC_text_angle(ang) int ang; { switch (ang) { case 0: pc_text_dir = HORIZ_DIR; break; case 1: pc_text_dir = VERT_DIR; break; } return TRUE; } TERM_PUBLIC int PC_justify_text(just) enum JUSTIFY just; { #if defined(__TURBOC__) switch (just) { case LEFT: pc_hjustify = LEFT_TEXT; pc_vjustify = CENTER_TEXT; break; case CENTRE: pc_hjustify = CENTER_TEXT; pc_vjustify = CENTER_TEXT; break; case RIGHT: pc_hjustify = RIGHT_TEXT; pc_vjustify = CENTER_TEXT; break; } settextjustify(pc_hjustify, pc_vjustify); return 1; #elif defined(__WATCOMC__) switch (just) { case LEFT: pc_hjustify = _LEFT; pc_vjustify = _HALF; break; case CENTRE: pc_hjustify = _CENTER; pc_vjustify = _HALF; break; case RIGHT: pc_hjustify = _RIGHT; pc_vjustify = _HALF; break; } _settextalign(pc_hjustify, pc_vjustify); return 1; #else return (just == LEFT); #endif } TERM_PUBLIC void PC_put_text(x, y, str) int x, y; char *str; { #ifdef __TURBOC__ settextstyle(DEFAULT_FONT, pc_text_dir, pc_text_size); settextjustify(pc_hjustify, pc_vjustify); outtextxy(x, pc_lasty - y, str); #endif /* __TURBOC__ */ #ifdef __WATCOMC__ _setcharsize(pc_text_size * PC_VCHAR, pc_text_size * PC_HCHAR); _settextang(pc_text_dir); _settextalign(pc_hjustify, pc_vjustify); _grtext(x, pc_lasty - y, str); #endif /* WATCOMC */ #ifdef MSC #endif /* MSC */ } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(dospc_driver) "dospc", "IBM PC/Clone running DOS", PC_XMAX, PC_YMAX, PC_VCHAR, PC_HCHAR, PC_VTIC, PC_HTIC, options_null, PC_init, PC_reset, PC_text, null_scale, PC_graphics, PC_move, PC_vector, PC_linetype, PC_put_text, PC_text_angle, PC_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(pc_driver) #undef LAST_TERM #define LAST_TERM dospc_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(dospc) "1 dospc", "?commands set terminal dospc", "?set terminal dospc", "?set term dospc", "?terminal dospc", "?term dospc", "?dospc", " The `dospc` terminal driver supports PCs with arbitrary graphics boards, which", " will be automatically detected. It should be used only if you are not using", " the gcc or Zortec C/C++ compilers." END_HELP(dospc) #endif /* TERM_HELP */ /* * $Id: $ */ /* GNUPLOT - pm.trm */ /*[ * Copyright 1992, 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * pm.trm --- inboard terminal driver for Presentation Manager * --- after X-11 driver, by R.W.Fearick 31/1/92. * v1.1 11/8/92 -- speed things up */ #include "driver.h" #ifdef TERM_REGISTER register_term(pm) #endif #ifdef TERM_PROTO TERM_PUBLIC void PM_init __PROTO((void)); TERM_PUBLIC void PM_options __PROTO((void)); TERM_PUBLIC void PM_reset __PROTO((void)); TERM_PUBLIC void PM_text __PROTO((void)); TERM_PUBLIC void PM_graphics __PROTO((void)); TERM_PUBLIC void PM_linetype __PROTO((int lt)); TERM_PUBLIC void PM_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PM_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC int PM_text_angle __PROTO((int ang)); TERM_PUBLIC void PM_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int PM_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void PM_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void PM_suspend __PROTO((void)); TERM_PUBLIC void PM_resume __PROTO((void)); TERM_PUBLIC void PM_linewidth __PROTO((double linewidth)); /* define PM world coordinate limits */ #define PM_XMAX 19500 #define PM_YMAX 12500 /* approximations for typical font/screen sizes */ #define PM_VCHAR (550) #define PM_HCHAR (220) #define PM_VTIC (200) #define PM_HTIC (200) #endif #ifdef TERM_BODY #include <stdio.h> #include <process.h> #include <io.h> #define INCL_DOSPROCESS #define INCL_DOSSEMAPHORES #define INCL_DOSMISC #define INCL_DOSMODULEMGR #include <os2.h> /* graphics commands */ #define SET_GRAPHICS 'G' #define SET_TEXT 'E' #define SET_LINE 'L' #define SET_LINEWIDTH 'W' #define SET_ANGLE 'A' #define SET_JUSTIFY 'J' #define SET_POINTMODE 'D' #define SET_FONT 'F' #define SET_OPTIONS 'O' #define GR_QUERY 'Q' #define GR_SUSPEND 'E' /*'s' */ #define GR_RESUME 'r' #define GR_MOVE 'M' #define GR_DRAW 'V' #define GR_RESET 'R' #define GR_TEXT 'T' #define GR_PAUSE 'P' #define GR_HELP 'H' #define PM_nopts 1 /* path for pm program */ static char PM_path[256] = ""; /* track mode to avoid redraw after hitting break */ static int PM_mode = 0; static HEV hev; static int PM_termmode = 0; static int PM_must_reset_opts = FALSE; static int PM_must_abort = 0; static char PM_opts[256] = ""; static int PM_optargs = 0; static int PM_plot_number = 0; static char PM_term_title[128] = ""; FILE *fopen(); static FILE *PM_pipe = NULL; static FILE *PM_savepipe = NULL; int PM_pause __PROTO((char *str)); void PM_setup(void); static void PM_reset_opts(void); static void PM_query(void); static void PM_make_servername(char *); static void PM_abortplot(); TERM_PUBLIC void PM_init() { static char buffer[1024]; int pid; int rc; int spawnmode; PPIB pib; PTIB tib; char semname[32]; char pipename[32]; char tempname[32]; term_force_init = TRUE; if (PM_savepipe != NULL && PM_termmode == 0) { PM_pipe = PM_savepipe; } if ((PM_pipe == NULL) && (PM_termmode & 2)) { /* check if term is running */ PM_make_servername(tempname); strcpy(pipename, "\\pipe\\"); strcat(pipename, tempname); // sprintf( pipename, "\\pipe\\gpServ%d", PM_plot_number ) ; DosGetInfoBlocks(&tib, &pib); PM_pipe = fopen(pipename, "r+b"); if (PM_pipe != NULL) { setvbuf(PM_pipe, buffer, _IOFBF, 1024); pid = pib->pib_ulpid; fwrite(&pid, 1, 4, PM_pipe); fflush(PM_pipe); /* set new options */ // PM_reset_opts() ; } } /* else we start up term here */ if (PM_pipe == NULL) { if (PM_termmode & 2) { PM_make_servername(tempname); // sprintf( tempname, "gpServ%d", PM_plot_number ) ; } else { static int gpid = 0; gpid++; sprintf(tempname, "gp%X%d", getpid(), gpid); } strcpy(semname, "\\sem32\\"); strcpy(pipename, "\\pipe\\"); strcat(semname, tempname); strcat(pipename, tempname); strcat(PM_path, "\\gnupmdrv.exe"); rc = access(PM_path, 0); /* find exe file */ if (rc != 0) rc = DosSearchPath(0x0002, /* search GNUPLOT environment */ "GNUPLOT", "gnupmdrv.exe", PM_path, 256); if (rc != 0) rc = DosSearchPath(0x0003, /* then try current directory & path */ "PATH", "gnupmdrv.exe", PM_path, 256); if (rc != 0) { fputs("Cannot find gnupmdrv.exe !\n", stderr); exit(3); } rc = DosCreateEventSem(semname, &hev, 1, 0); if (rc != 0) { fputs("Cannot create semaphore !\n", stderr); exit(3); } spawnmode = P_SESSION | P_DEFAULT; if (PM_optargs != 0) spawnmode |= P_UNRELATED; pid = spawnl(spawnmode, PM_path, "GnuplotPM", tempname, PM_opts, NULL); if (pid == -1) { fputs("Cannot spawn gnupmdrv.exe !\n", stderr); exit(3); } DosGetInfoBlocks(&tib, &pib); DosWaitEventSem(hev, 10000); DosCloseEventSem(hev); PM_pipe = fopen(pipename, "r+b"); if (PM_pipe == NULL) { fputs("Cannot open pipe to gnupmdrv.exe !\n", stderr); exit(3); } else if (PM_termmode == 0) PM_savepipe = PM_pipe; setvbuf(PM_pipe, buffer, _IOFBF, 1024); pid = pib->pib_ulpid; fwrite(&pid, 1, 4, PM_pipe); fflush(PM_pipe); } else { if (PM_must_reset_opts) PM_reset_opts(); } PM_query(); } static void PM_make_servername(char *str) { if (PM_term_title[0]) { int hash = 0; char *p = PM_term_title + 1; int match = PM_term_title[0]; while (*p != match) { hash = (hash << 1) + hash + *p++; } hash %= (256 * 256 * 256 - 1); sprintf(str, "gp%x", hash); } else sprintf(str, "gpServ%d", PM_plot_number); } TERM_PUBLIC void PM_options() { int old_termmode = PM_termmode; PM_termmode = 0; term_options[0] = NUL; PM_term_title[0] = NUL; PM_opts[0] = NUL; PM_optargs = 0; while (!END_OF_COMMAND) { if (almost_equals(c_token, "pe$rsist")) { strcat(PM_opts, "-p "); strcat(term_options, "persist "); PM_termmode |= 1; PM_optargs = 1; if (!(old_termmode & 1)) PM_pipe = NULL; } else if (almost_equals(c_token, "s$erver")) { strcat(PM_opts, "-s "); strcat(term_options, "server "); PM_termmode |= 2; PM_optargs = 1; if (!(old_termmode & 2)) PM_pipe = NULL; if (isanumber(c_token + 1)) { struct value t; char *p = PM_opts + strlen(PM_opts); c_token++; PM_plot_number = (int) real(const_express(&t)); sprintf(p, "%d", PM_plot_number); sprintf(term_options + strlen(term_options), "%d", PM_plot_number); } } else if (almost_equals(c_token, "w$idelines")) { strcat(PM_opts, "-w "); strcat(term_options, "widelines "); PM_optargs = 1; } else if (almost_equals(c_token, "e$nhanced")) { strcat(PM_opts, "-e "); strcat(term_options, "enhanced "); PM_optargs = 1; } else if (isstring(c_token)) { copy_str(PM_term_title, c_token, 127); } #if 0 else if (almost_equals(c_token, "po$rtrait")) { strcat(PM_opts, "-l "); strcat(term_options, "portrait "); PM_optargs = 1; } #endif c_token++; } if (PM_term_title[0]) { strcat(PM_opts, " "); strcat(term_options, " "); strcat(PM_opts, PM_term_title); strcat(term_options, PM_term_title); } PM_must_reset_opts = TRUE; } static void PM_reset_opts() { int len; putc(SET_OPTIONS, PM_pipe); len = strlen(PM_opts) + 1; fwrite(&len, sizeof(int), 1, PM_pipe); fwrite(PM_opts, 1, len, PM_pipe); for (len = sizeof(int) - len % sizeof(int); len > 0; len--) { /* pad rest of int with zeros */ putc(NUL, PM_pipe); } fflush(PM_pipe); PM_must_reset_opts = FALSE; } static void PM_query() { int rc; ULONG cbR; putc(GR_QUERY, PM_pipe); fflush(PM_pipe); rc = DosRead(fileno(PM_pipe), &term->h_char, sizeof(int), &cbR); rc = DosRead(fileno(PM_pipe), &term->v_char, sizeof(int), &cbR); } TERM_PUBLIC void PM_reset() { putc(GR_RESET, PM_pipe); fflush(PM_pipe); term_force_init = FALSE; if (PM_termmode > 0) { fclose(PM_pipe); PM_pipe = NULL; } } TERM_PUBLIC void PM_suspend() { putc(GR_SUSPEND, PM_pipe); fflush(PM_pipe); } TERM_PUBLIC void PM_resume() { putc(GR_RESUME, PM_pipe); fflush(PM_pipe); } TERM_PUBLIC void PM_text() { fflush(PM_pipe); if (PM_mode != SET_TEXT) { putc(SET_TEXT, PM_pipe); fflush(PM_pipe); // keep_term_initialised = term_initialised ; // term_initialised = FALSE ; /* need to force init */ } PM_mode = SET_TEXT; } TERM_PUBLIC void PM_graphics() { putc(SET_GRAPHICS, PM_pipe); fflush(PM_pipe); PM_mode = SET_GRAPHICS; } TERM_PUBLIC void PM_move(unsigned int x, unsigned int y) { if (PM_must_abort) PM_abortplot(); putc(GR_MOVE, PM_pipe); fwrite(&x, sizeof(int), 1, PM_pipe); fwrite(&y, sizeof(int), 1, PM_pipe); } TERM_PUBLIC void PM_vector(unsigned int x, unsigned int y) { if (PM_must_abort) PM_abortplot(); putc(GR_DRAW, PM_pipe); fwrite(&x, sizeof(int), 1, PM_pipe); fwrite(&y, sizeof(int), 1, PM_pipe); } TERM_PUBLIC void PM_linetype(int lt) { putc(SET_LINE, PM_pipe); fwrite(<, sizeof(int), 1, PM_pipe); } TERM_PUBLIC int PM_text_angle(int ang) { putc(SET_ANGLE, PM_pipe); fwrite(&ang, sizeof(int), 1, PM_pipe); return (TRUE); } TERM_PUBLIC void PM_put_text(unsigned int x, unsigned int y, char *str) { int len; if (PM_must_abort) PM_abortplot(); putc(GR_TEXT, PM_pipe); fwrite(&x, sizeof(int), 1, PM_pipe); fwrite(&y, sizeof(int), 1, PM_pipe); len = strlen(str) + 1; fwrite(&len, sizeof(int), 1, PM_pipe); fwrite(str, 1, len, PM_pipe); for (len = sizeof(int) - len % sizeof(int); len > 0; len--) { /* pad rest of int with zeros */ putc(NUL, PM_pipe); } } TERM_PUBLIC int PM_justify_text(enum JUSTIFY mode) { putc(SET_JUSTIFY, PM_pipe); fwrite(&mode, sizeof(int), 1, PM_pipe); return (TRUE); } TERM_PUBLIC int PM_set_font(font) /* Entry font added by DJL */ char *font; { int len, fontsize; char *p; p = strchr(font, ','); if (p == NULL || *p == NUL) fontsize = 14; else fontsize = strtol(p + 1, NULL, 10); if (fontsize <= 0) fontsize = 14; putc(SET_FONT, PM_pipe); len = strlen(font) + 1; fwrite(&len, sizeof(int), 1, PM_pipe); fwrite(font, 1, len, PM_pipe); for (len = sizeof(int) - len % sizeof(int); len > 0; len--) { /* pad rest of int with zeros */ putc(NUL, PM_pipe); } return TRUE; } TERM_PUBLIC void PM_point(unsigned int x, unsigned int y, int number) /* ** tell the driver we are plotting a point so it can decide whether to ** use colour or not */ { int mode; mode = 1; putc(SET_POINTMODE, PM_pipe); fwrite(&mode, sizeof(int), 1, PM_pipe); do_point(x, y, number); mode = 0; putc(SET_POINTMODE, PM_pipe); fwrite(&mode, sizeof(int), 1, PM_pipe); } void PM_abortplot() { PM_must_abort = 0; term_reset(); (void) putc('\n', stderr); bail_to_command_line(); } void PM_intc_cleanup() { if (PM_pipe == NULL || PM_mode == SET_TEXT) PM_abortplot(); PM_must_abort = 1; } void PM_setup(void) /* ** Initial terminal setup */ { char *envpath; PPIB pib; PTIB tib; char path[256], *p; DosGetInfoBlocks(&tib, &pib); DosQueryModuleName(pib->pib_hmte, 256, path); if (PM_path[0] == NUL) { strcpy(PM_path, path); p = strrchr(PM_path, '\\'); if (p != NULL) *p = NUL; else { p = strrchr(PM_path, ':'); if (p != NULL) *(p + 1) = NUL; } if (p == NULL) _getcwd2(PM_path, 256); } if (getenv("GNUHELP") == NULL) { int n = strlen("GNUHELP") + strlen(PM_path) + strlen("gnuplot.gih") + 3; envpath = (char *) malloc(n); if (envpath != NULL) { strcpy(envpath, "GNUHELP"); strcat(envpath, "="); strcat(envpath, PM_path); strcat(envpath, "/"); strcat(envpath, "gnuplot.gih"); putenv(envpath); } } if (getenv("GNUPLOT") == NULL) { int n = strlen("GNUPLOT") + strlen(PM_path) + 2; envpath = (char *) malloc(n); if (envpath != NULL) { strcpy(envpath, "GNUPLOT"); strcat(envpath, "="); strcat(envpath, PM_path); putenv(envpath); } } } int PM_pause(char *str) /* ** pause - using message box on PM screen */ { int len, rc; ULONG cbR; char buf[256]; char *bp; if (PM_pipe == NULL) return 2; bp = buf; putc(GR_PAUSE, PM_pipe); len = strlen(str) + 1; fwrite(&len, sizeof(int), 1, PM_pipe); fwrite(str, 1, len, PM_pipe); for (rc = sizeof(int) - len % sizeof(int); rc > 0; rc--) { /* pad rest of int with zeros */ putc(NUL, PM_pipe); } fflush(PM_pipe); rc = DosRead(fileno(PM_pipe), &len, sizeof(int), &cbR); return len; } TERM_PUBLIC void PM_linewidth(double linewidth) { int lw; lw = linewidth * 100; putc(SET_LINEWIDTH, PM_pipe); fwrite(&lw, sizeof(int), 1, PM_pipe); } #endif #ifdef TERM_TABLE TERM_TABLE_START(PM_driver) "pm", "OS/2 Presentation Manager", PM_XMAX, PM_YMAX, PM_VCHAR, PM_HCHAR, PM_VTIC, PM_HTIC, PM_options, PM_init, PM_reset, PM_text, null_scale, PM_graphics, PM_move, PM_vector, PM_linetype, PM_put_text, PM_text_angle, PM_justify_text, PM_point, do_arrow, PM_set_font, 0 /*pointsize */ , TERM_CAN_MULTIPLOT, PM_suspend, PM_resume, 0 /*fillbox */ , PM_linewidth TERM_TABLE_END(PM_driver) #undef LAST_TERM #define LAST_TERM PM_driver #endif /* TERM_TABLE */ #ifdef TERM_HELP START_HELP(pm) "1 pm", "?commands set terminal pm", "?set terminal pm", "?set term pm", "?terminal pm", "?term pm", "?pm", " The `pm` terminal driver provides an OS/2 Presentation Manager window in", " which the graph is plotted. The window is opened when the first graph is", " plotted. This window has its own online help as well as facilities for", " printing, copying to the clipboard and some line type and color adjustments.", " The `multiplot` option is supported.", "", " Syntax:", " set terminal pm {server {n}} {persist} {widelines} {enhanced} {\"title\"}", "", " If `persist` is specified, each graph appears in its own window and all", " windows remain open after `gnuplot` exits. If `server` is specified, all", " graphs appear in the same window, which remains open when `gnuplot` exits.", " This option takes an optional numerical argument which specifies an instance", " of the server process. Thus multiple server windows can be in use at the", " same time.", "", " If `widelines` is specified, all plots will be drawn with wide lines. If", " `enhanced` is specified, sub- and superscripts and multiple fonts are", " enabled using the same syntax as the `enhanced postscript` option (see", " `set terminal postscript enhanced` for details). Font names for the basic", " PostScript fonts may be abbreviated to single letters.", "", " If `title` is specified, it will be used as the title of the plot window.", " It will also be used as the name of the server instance, and will override", " the optional numerical argument.", "", " Linewidths may be changed with `set linestyle`." END_HELP(pm) #endif /* TERM_HELP */ /* * $Id: png.trm,v 1.13 1998/06/18 14:59:23 ddenholm Exp $ * */ /* GNUPLOT - png.trm */ /*[ * Copyright 1995, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * png * * AUTHORS * Alexander Lehmann * derived from pbm.trm by Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* To compile this terminal driver, you need libpng and zlib, both are available at ftp://ftp.uu.net/graphics/png. Remember to add the include dirs and libraries to TERMFLAGS and TERMLIBS. */ /* The following png drivers use the generic bit mapped graphics routines from bitmap.c to build up a bit map in memory. The driver interchanges colomns and lines in order to access entire lines easily and returns the lines to get bits in the right order : (x,y) -> (y,XMAX-1-x). */ /* This interchange is done by calling b_makebitmap() with reversed xmax and ymax, and then setting b_rastermode to TRUE. b_setpixel() will then perform the interchange before each pixel is plotted */ #include "driver.h" #ifdef TERM_REGISTER register_term(png_driver) #endif #ifdef TERM_PROTO TERM_PUBLIC void PNGoptions __PROTO((void)); TERM_PUBLIC void PNGinit __PROTO((void)); TERM_PUBLIC void PNGreset __PROTO((void)); TERM_PUBLIC void PNGsetfont __PROTO((void)); TERM_PUBLIC void PNGgraphics __PROTO((void)); TERM_PUBLIC void PNGtext __PROTO((void)); TERM_PUBLIC void PNGlinetype __PROTO((int linetype)); TERM_PUBLIC void PNGpoint __PROTO((unsigned int x, unsigned int y, int point)); #endif /* TERM_PROTO */ #ifdef TERM_BODY #include "png.h" /* I'm not sure exactly which is the first version we work with, * but I know that some older ones don't define all the symbols * we use */ /* png version test now in configure */ /* From version.c */ extern char version[]; extern char patchlevel[]; /* make XMAX and YMAX a multiple of 8 */ #define PNG_XMAX (640) #define PNG_YMAX (480) #define PNG_VCHAR (FNT5X9_VCHAR) #define PNG_HCHAR (FNT5X9_VCHAR) #define PNG_VTIC FNT5X9_HBITS #define PNG_HTIC FNT5X9_HBITS static int png_font = 1; /* small font */ static int png_mode = 0; /* 0:monochrome 1:gray 2:color */ /* 7=black, 0=white */ static int png_gray[] = { 7, 1, 6, 5, 4, 3, 2, 1, 7 }; /* grays */ /* bit3=!intensify, bit2=!red, bit1=!green, bit0=!blue */ static int png_color_table[] ={ 15, 8, 3, 5, 6, 4, 2, 1, 11, 13, 14 }; /* colors */ static png_color png_palette[16]; void PNGoptions() { png_font = 1; png_mode = 0; term_options[0] = NUL; while (!END_OF_COMMAND) { if (almost_equals(c_token, "s$mall")) png_font = 1; else if (almost_equals(c_token, "me$dium")) png_font = 2; else if (almost_equals(c_token, "l$arge")) png_font = 3; else if (almost_equals(c_token, "mo$nochrome")) png_mode = 0; else if (almost_equals(c_token, "g$ray")) png_mode = 1; else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) png_mode = 2; else { /* reset to default, since term is already set */ png_font = 1; png_mode = 0; int_error("expecting: {small, medium, large} and {monochrome, gray, color}", c_token); } c_token++; } /* setup options string */ switch (png_font) { case 1: strcat(term_options, "small"); break; case 2: strcat(term_options, "medium"); break; case 3: strcat(term_options, "large"); break; } switch (png_mode) { case 0: strcat(term_options, " monochrome"); break; case 1: strcat(term_options, " gray"); break; case 2: strcat(term_options, " color"); break; } } void PNGinit() { PNGsetfont(); /* HBB 980226: do this here! */ } void PNGreset() { #ifdef VMS fflush_binary(); #endif /* VMS */ } void PNGsetfont() { switch (png_font) { case 1: b_charsize(FNT5X9); term->v_char = FNT5X9_VCHAR; term->h_char = FNT5X9_HCHAR; term->v_tic = FNT5X9_HBITS; term->h_tic = FNT5X9_HBITS; break; case 2: b_charsize(FNT9X17); term->v_char = FNT9X17_VCHAR; term->h_char = FNT9X17_HCHAR; term->v_tic = FNT9X17_HBITS; term->h_tic = FNT9X17_HBITS; break; case 3: b_charsize(FNT13X25); term->v_char = FNT13X25_VCHAR; term->h_char = FNT13X25_HCHAR; term->v_tic = FNT13X25_HBITS; term->h_tic = FNT13X25_HBITS; break; } } void PNGgraphics() { int numplanes; switch (png_mode) { case 0: numplanes = 1; break; case 1: numplanes = 3; break; case 2: numplanes = 4; break; } /* PNGsetfont(); *//* HBB 980226: do this in init() ! */ /* rotate plot -90 degrees by reversing XMAX and YMAX and by setting b_rastermode to TRUE */ b_makebitmap((unsigned int) (PNG_YMAX * ysize), (unsigned int) (PNG_XMAX * xsize), numplanes); b_rastermode = TRUE; if (png_mode != 0) b_setlinetype(0); /* solid lines */ } void PNGtext() { register int x, j, row; png_structp png_ptr; png_infop info_ptr; register int i, value; png_bytep prow; int mask, plane1, plane2, plane3, plane4; int red, green, blue; png_text pngtext, *pngtext_copy; char text[100]; png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { b_freebitmap(); return; } info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_write_struct(&png_ptr, (png_infopp) NULL); b_freebitmap(); return; } prow = malloc(b_ysize); if (!prow) { png_destroy_write_struct(&png_ptr, &info_ptr); b_freebitmap(); return; } if (setjmp(png_ptr->jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); free(prow); b_freebitmap(); return; } png_info_init(info_ptr); png_write_init(png_ptr); png_init_io(png_ptr, gpoutfile); info_ptr->width = b_ysize; info_ptr->height = b_xsize; info_ptr->bit_depth = png_mode == 0 ? 1 : 4; info_ptr->color_type = png_mode == 2 ? PNG_COLOR_TYPE_PALETTE : PNG_COLOR_TYPE_GRAY; if (png_mode == 2) { info_ptr->valid |= PNG_INFO_PLTE; info_ptr->palette = png_palette; info_ptr->num_palette = 16; } if (png_mode != 0) { info_ptr->valid |= PNG_INFO_sBIT; if (png_mode == 1) { info_ptr->sig_bit.gray = 3; png_set_shift(png_ptr, &(info_ptr->sig_bit)); } else { info_ptr->sig_bit.red = 2; info_ptr->sig_bit.green = 2; info_ptr->sig_bit.blue = 2; } } info_ptr->interlace_type = 0; if (png_mode == 0) png_set_invert_mono(png_ptr); if (png_mode == 2) for (i = 0; i < 16; i++) { red = (i & 4) ? 1 : 3; green = (i & 2) ? 1 : 3; blue = (i & 1) ? 1 : 3; if (i & 8) { red--; green--; blue--; } png_palette[i].red = red * 85; png_palette[i].green = green * 85; png_palette[i].blue = blue * 85; } sprintf(text, "gnuplot %sversion %s patchlevel %s", OS, version, patchlevel); pngtext.compression = -1; pngtext.key = "Software"; pngtext.text = text; pngtext.text_length = strlen(text); pngtext_copy = malloc(sizeof(*pngtext_copy)); *pngtext_copy = pngtext; info_ptr->num_text = 1; info_ptr->text = pngtext_copy; png_write_info(png_ptr, info_ptr); info_ptr->num_text = 0; if (info_ptr->text) free(info_ptr->text); info_ptr->text = NULL; png_set_packing(png_ptr); /* dump bitmap in raster mode */ for (x = b_xsize - 1; x >= 0; x--) { row = (b_ysize / 8) - 1; for (j = row; j >= 0; j--) { mask = 0x80; plane1 = (*((*b_p)[j] + x)); if (png_mode != 0) { plane2 = (*((*b_p)[j + b_psize] + x)); plane3 = (*((*b_p)[j + b_psize + b_psize] + x)); } else { plane2 = 0; plane3 = 0; } if (png_mode == 2) plane4 = (*((*b_p)[j + b_psize + b_psize + b_psize] + x)); else plane4 = 0; for (i = 0; i < 8; i++) { value = 0; if (plane1 & mask) value += 1; if (plane2 & mask) value += 2; if (plane3 & mask) value += 4; if (plane4 & mask) value += 8; if (png_mode == 1) value = 7 - value; prow[(row - j) * 8 + i] = (png_byte) value; mask >>= 1; } } png_write_rows(png_ptr, &prow, 1); } png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); free(prow); b_freebitmap(); } void PNGlinetype(linetype) int linetype; { switch (png_mode) { case 0: b_setlinetype(linetype); break; case 1: if (linetype >= 7) linetype %= 7; b_setvalue(png_gray[linetype + 2]); break; case 2: if (linetype >= 9) linetype %= 9; b_setvalue(png_color_table[linetype + 2]); break; } } void PNGpoint(x, y, point) unsigned int x, y; int point; { if (png_mode == 0) line_and_point(x, y, point); else do_point(x, y, point); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(png_driver) "png", "Portable Network Graphics [small medium large] [monochrome gray color]", PNG_XMAX, PNG_YMAX, PNG_VCHAR, PNG_HCHAR, PNG_VTIC, PNG_HTIC, PNGoptions, PNGinit, PNGreset, PNGtext, null_scale, PNGgraphics, b_move, b_vector, PNGlinetype, b_put_text, b_text_angle, null_justify_text, PNGpoint, do_arrow, set_font_null, 0, /* pointsize */ TERM_CAN_MULTIPLOT | TERM_BINARY TERM_TABLE_END(png_driver) #undef LAST_TERM #define LAST_TERM png_driver #endif /* TERM_TABLE */ #ifdef TERM_HELP START_HELP(png) "1 png", "?commands set terminal png", "?set terminal png", "?set term png", "?terminal png", "?term png", "?png", " The `png` terminal driver supports Portable Network Graphics. To compile it,", " you will need the third-party libraries \"libpng\" and \"zlib\"; both are", " available at ftp://ftp.uu.net/graphics/png. `png` has two options.", "", " Syntax:", " set terminal png {small | medium | large}", " {monochrome | gray | color}", "", " The defaults are small (fontsize) and monochrome." END_HELP(png) #endif /* TERM_HELP */ /* * $Id: post.trm,v 1.46 1998/06/18 14:59:23 ddenholm Exp $ */ /* GNUPLOT - post.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This terminal driver supports: * postscript * * AUTHORS * Russell Lang * * modified 10/5/95 by drd - put in support for other postscript drivers * (enhpost, pslatex, ...) so they dont have to work quite so hard * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * * The 'postscript' driver produces landscape output 10" wide and 7" high. * To change font to Times-Roman and font size to 20pts use * 'set term postscript "Times-Roman" 20'. * To get a smaller (5" x 3.5") eps output use 'set term post eps' * and make only one plot per file. Font size for eps will be half * the specified size. * * Erik Luijten 30/5/97: added %%CreationDate, made %%DocumentFonts conform * to DSC, added version no. and patchl. to %%Creator */ #include "driver.h" #ifdef TERM_REGISTER register_term(post) #endif #ifdef TERM_PROTO TERM_PUBLIC void PS_options __PROTO((void)); TERM_PUBLIC void PS_common_init __PROTO((int encap, int portrait, int uses_fonts, unsigned int xoff, unsigned int yoff, unsigned int bb_xmin, unsigned int bb_ymin, unsigned int bb_xmax, unsigned int bb_ymax, char **dict)); TERM_PUBLIC void PS_init __PROTO((void)); TERM_PUBLIC void PS_graphics __PROTO((void)); TERM_PUBLIC void PS_text __PROTO((void)); TERM_PUBLIC void PS_reset __PROTO((void)); TERM_PUBLIC void PS_linetype __PROTO((int linetype)); TERM_PUBLIC void PS_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PS_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void ENHPS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int PS_text_angle __PROTO((int ang)); TERM_PUBLIC int PS_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void PS_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC int PS_set_font __PROTO((char * font)); TERM_PUBLIC int ENHPS_set_font __PROTO((char * font)); TERM_PUBLIC void PS_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height)); TERM_PUBLIC void PS_linewidth __PROTO((double linewidth)); /* JFi [linewidth] */ TERM_PUBLIC void PS_pointsize __PROTO((double ptsize)); /* JFi [pointsize] */ #define PS_POINT_TYPES 8 #define PS_XOFF 50 /* page offset in pts */ #define PS_YOFF 50 #define PS_XMAX 7200 /* assumes landscape */ #define PS_YMAX 5040 #define PS_XLAST (PS_XMAX - 1) #define PS_YLAST (PS_YMAX - 1) #define PS_VTIC (PS_YMAX/80) #define PS_HTIC (PS_YMAX/80) #define PS_SC (10) /* scale is 1pt = 10 units */ #define PS_LW (0.5*PS_SC) /* linewidth = 0.5 pts */ #define PS_VCHAR (14*PS_SC) /* default is 14 point characters */ #define PS_HCHAR (14*PS_SC*6/10) #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */ /* From version.c */ extern char version[]; extern char patchlevel[]; #define PS_FLUSH_PATH \ if (ps_path_count) { fprintf(gpoutfile, "stroke "); ps_path_count = 0; } static char *PS_RememberFont __PROTO((char *fname, int reencode)); static void ENHPS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); static char *ENHPS_recurse __PROTO((char *p, TBOOLEAN brace, char *fontname, double fontsize, double base, TBOOLEAN widthflag, TBOOLEAN showflag)); static char ps_font[MAX_ID_LEN+1] = "Helvetica" ; /* name of font */ static int ps_fontsize = 14; /* size of font in pts */ /* for enhanced mode, we keep a separate font name and size, which * is restored to the default value on font of "" */ static char ps_enh_font[MAX_ID_LEN+1]; static int ps_enh_fontsize; static TBOOLEAN ps_portrait = FALSE; /* vertical page */ static TBOOLEAN ps_color = FALSE; static TBOOLEAN ps_solid = FALSE; /* use solid lines */ static TBOOLEAN ps_eps = FALSE; /* Is this for an eps file? */ /* Added by Robert Davis <davis@ecn.purdue.edu> */ static int ps_page=0; /* page count */ static int ps_path_count=0; /* count of lines in path */ static int ps_ang=0; /* text angle */ static enum JUSTIFY ps_justify=LEFT; /* text is flush left */ /* added by Matt Heffron <heffron@falstaff.css.beckman.com> */ static TBOOLEAN ps_duplex_state = FALSE; static TBOOLEAN ps_duplex_option = FALSE; static char GPFAR * GPFAR PS_header[] = { "/M {moveto} bind def\n", "/L {lineto} bind def\n", "/R {rmoveto} bind def\n", "/V {rlineto} bind def\n", "/vpt2 vpt 2 mul def\n", "/hpt2 hpt 2 mul def\n", /* flush left show */ "/Lshow { currentpoint stroke M\n", " 0 vshift R show } def\n", /* flush right show */ "/Rshow { currentpoint stroke M\n", " dup stringwidth pop neg vshift R show } def\n", /* centred show */ "/Cshow { currentpoint stroke M\n", " dup stringwidth pop -2 div vshift R show } def\n", /* set pointsize */ "/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def\n", " /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def\n", /* Dash or Color Line */ "/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }\n", " {pop pop pop Solid {pop []} if 0 setdash} ifelse } def\n", /* Border Lines */ "/BL { stroke gnulinewidth 2 mul setlinewidth } def\n", /* Axes Lines */ "/AL { stroke gnulinewidth 2 div setlinewidth } def\n", /* set user defined linewidth */ "/UL { gnulinewidth mul /userlinewidth exch def } def\n", /* Plot Lines */ "/PL { stroke userlinewidth setlinewidth } def\n", /* Line Types */ "/LTb { BL [] 0 0 0 DL } def\n", /* border */ "/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */ "/LT0 { PL [] 1 0 0 DL } def\n", "/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def\n", "/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def\n", "/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n", "/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n", "/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n", "/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n", "/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n", "/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n", /* Point (Round) */ /* Matt Heffron make it round */ "/Pnt { stroke [] 0 setdash\n", " gsave 1 setlinecap M 0 0 V stroke grestore } def\n", /* Diamond */ "/Dia { stroke [] 0 setdash 2 copy vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath stroke\n", " Pnt } def\n", /* Plus */ "/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V\n", " currentpoint stroke M\n", " hpt neg vpt neg R hpt2 0 V stroke\n", " } def\n", /* Box */ "/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath stroke\n", " Pnt } def\n", /* Cross (X) */ "/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " hpt2 vpt2 neg V currentpoint stroke M\n", " hpt2 neg 0 R hpt2 vpt2 V stroke } def\n", /* Triangle Up*/ "/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath stroke\n", " Pnt } def\n", /* Star */ "/Star { 2 copy Pls Crs } def\n", /* div added filed box */ /* Filled Box */ "/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath fill } def\n", /* div added filled triangle */ /* Triangle Up, Filled */ "/TriUF { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath fill } def\n", /* Matt Heffron: added a few more types */ /* Triangle Down */ "/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath stroke\n", " Pnt } def\n", /* Triangle Down, Filled*/ "/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath fill} def\n", /* Diamond, Filled */ "/DiaF { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath fill } def\n", /* Pentagon */ "/Pent { stroke [] 0 setdash 2 copy gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath stroke grestore Pnt } def\n", /* Pentagon, Filled */ "/PentF { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath fill grestore } def\n", /* Circle */ "/Circle { stroke [] 0 setdash 2 copy\n", " hpt 0 360 arc stroke Pnt } def\n", /* Circle,Filled */ "/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def\n", /* 16 differently filled circles */ "/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450 arc } bind def\n", "/C1 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C2 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C3 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C4 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 180 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C5 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc\n", " 2 copy moveto\n", " 2 copy vpt 180 270 arc closepath fill\n", " vpt 0 360 arc } bind def\n", "/C6 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C7 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C8 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 270 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C9 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 270 450 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 90 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C11 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 180 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 270 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C12 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C13 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C14 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 360 arc closepath fill\n", " vpt 0 360 arc } bind def\n", "/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", /* Auxiliary definitions for rectangles */ "/Rec { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto\n", " neg 0 rlineto closepath } bind def\n", "/Square { dup Rec } bind def\n", "/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def\n", /* 16 differently filled squares */ "/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def\n", "/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def\n", "/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n", "/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def\n", "/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n", "/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill\n", " exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n", "/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def\n", "/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill\n", " 2 copy vpt Square fill\n", " Bsquare } bind def\n", "/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def\n", "/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def\n", "/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill\n", " Bsquare } bind def\n", "/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill\n", " Bsquare } bind def\n", "/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def\n", "/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n", " 2 copy vpt Square fill Bsquare } bind def\n", "/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n", " 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n", "/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def\n", /* 16 different diamonds (actually just rotated squares) */ "/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def\n", "/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def\n", "/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def\n", "/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def\n", "/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def\n", "/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def\n", "/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def\n", "/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def\n", "/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def\n", "/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def\n", "/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def\n", "/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def\n", "/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def\n", "/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def\n", "/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def\n", "/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def\n", /* closed figures w/o the point in the middle (added by Dick Crawford) */ /* Diamond */ "/DiaE { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath stroke } def\n", /* Box */ "/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath stroke } def\n", /* Triangle Up*/ "/TriUE { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath stroke } def\n", /* Triangle Down */ "/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath stroke } def\n", /* Pentagon */ "/PentE { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath stroke grestore } def\n", /* Circle */ "/CircE { stroke [] 0 setdash \n", " hpt 0 360 arc stroke } def\n", /* opaque closed figures w/o the point in the middle (added by Dick Crawford) */ "/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def\n", /* Diamond */ "/DiaW { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V Opaque stroke } def\n", /* Box */ "/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V Opaque stroke } def\n", /* Triangle Up*/ "/TriUW { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V Opaque stroke } def\n", /* Triangle Down */ "/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V Opaque stroke } def\n", /* Pentagon */ "/PentW { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " Opaque stroke grestore } def\n", /* Circle */ "/CircW { stroke [] 0 setdash \n", " hpt 0 360 arc Opaque stroke } def\n", /* filled box : usage x1 y1 x2 y2 BoxFill */ "/BoxFill { gsave Rec 1 setgray fill grestore } def\n", NULL }; static char GPFAR * GPFAR ENHPS_header[] = { /* For MFshow and MFwidth the tos is an array with the string and font info: */ /* [<fontname (a string)> <fontsize> <vertical offset> <width significant?> <printed?> <text string>] */ "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n", " [ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n", " {show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n", " {2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n", "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n", " 5 get stringwidth pop add}\n", " {pop} ifelse} forall} bind def\n", /* flush left show */ "/MLshow { currentpoint stroke M\n", " 0 exch R MFshow } bind def\n", /* flush right show */ "/MRshow { currentpoint stroke M\n", " exch dup MFwidth neg 3 -1 roll R MFshow } def\n", /* centred show */ "/MCshow { currentpoint stroke M\n", " exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n", NULL }; /* added to enhpost by Matt Heffron <heffron@falstaff.css.beckman.com> */ /* moved to post.trm by drd */ static struct PS_FontName { char *name; struct PS_FontName *next; } *PS_DocFonts = NULL; /* given a font, look in store to see if it is there already * if so, return NULL. If not, reencode it if allowed to, otherwise * return an appropriate re-encode string */ TERM_PUBLIC char *PS_RememberFont(fname, can_reencode) char *fname; int can_reencode; { struct PS_FontName *fnp; char *recode = NULL; for (fnp=PS_DocFonts; fnp ; fnp = fnp->next) if (strcmp(fnp->name, fname)==0) return NULL; /* we did not find the name */ fnp = (struct PS_FontName *)gp_alloc(sizeof(struct PS_FontName), "PostScript Font record"); fnp->name = gp_alloc(1+strlen(fname), "PostScript Font name"); strcpy(fnp->name, fname); fnp->next = PS_DocFonts; PS_DocFonts = fnp; switch(encoding) { case ENCODING_ISO_8859_1: recode = "reencodeISO def\n"; break; case ENCODING_CP_437: recode = "reencodeCP437 def\n"; break; case ENCODING_CP_850 : recode = "reencodeCP850 def\n"; break; } if (can_reencode && recode) { fprintf(gpoutfile,"/%s %s",fname, recode); return NULL; } else return recode; } static int PS_pen_x, PS_pen_y; static int PS_taken; static int PS_linetype_last; static TBOOLEAN PS_relative_ok; TERM_PUBLIC void PS_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token,"p$ortrait")) { ps_portrait=TRUE; ps_eps=FALSE; c_token++; } else if (almost_equals(c_token,"l$andscape")) { ps_portrait=FALSE; ps_eps=FALSE; c_token++; } else if (almost_equals(c_token,"ep$sf")) { ps_portrait=TRUE; ps_eps = TRUE; c_token++; } else if (almost_equals(c_token,"d$efault")) { ps_portrait=FALSE; ps_eps=FALSE; ps_color=FALSE; ps_solid=FALSE; ps_duplex_option=FALSE; strcpy(ps_font,"Helvetica"); ps_fontsize = 14; term->v_char = (unsigned int)(ps_fontsize*PS_SC); term->h_char = (unsigned int)(ps_fontsize*PS_SC*6/10); term->put_text = PS_put_text; c_token++; } } if (almost_equals(c_token, "enh$anced")) { term->put_text = ENHPS_put_text; term->set_font = ENHPS_set_font; ++c_token; } else if (almost_equals(c_token, "noenh$anced")) { term->put_text = PS_put_text; term->set_font = PS_set_font; ++c_token; } if (!END_OF_COMMAND) { if (almost_equals(c_token,"m$onochrome")) { ps_color=FALSE; c_token++; } else if (almost_equals(c_token,"c$olor") || almost_equals(c_token,"c$olour")) { ps_color=TRUE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token,"so$lid")) { ps_solid=TRUE; c_token++; } else if (almost_equals(c_token,"da$shed")) { ps_solid=FALSE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token,"si$mplex")) { ps_duplex_state = FALSE; ps_duplex_option = TRUE; c_token++; } else if (almost_equals(c_token,"du$plex")) { ps_duplex_state = TRUE; ps_duplex_option = TRUE; c_token++; } else if (almost_equals(c_token,"defaultp$lex")) { ps_duplex_option = FALSE; c_token++; } } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(ps_font,c_token, MAX_ID_LEN); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; ps_fontsize = (int)real(const_express(&a)); term->v_char = (unsigned int)(ps_fontsize*PS_SC); term->h_char = (unsigned int)(ps_fontsize*PS_SC*6/10); } sprintf(default_font,"%s,%d",ps_font,ps_fontsize); /* default_font holds the font and size set at 'set term' */ /* Entry font added by DJL */ sprintf(term_options,"%s %senhanced %s %s %s \"%s\" %d", ps_eps ? "eps" : (ps_portrait ? "portrait" : "landscape"), term->put_text == ENHPS_put_text ? "" : "no", ps_color ? "color" : "monochrome", ps_solid ? "solid" : "dashed", ps_duplex_option ? (ps_duplex_state ? "duplex" : "simplex") : "defaultplex", ps_font,ps_fontsize); } /* store settings passed to common_init() for use in PS_graphics() * ps_eps, ps_portrait, etc are reserved for storing the term options */ static int ps_common_encap; static int ps_common_portrait; static int ps_common_uses_fonts; static unsigned int ps_common_xoff, ps_common_yoff; TERM_PUBLIC void PS_common_init(encap, portrait, uses_fonts, xoff, yoff, bb_xmin, bb_ymin, bb_xmax, bb_ymax, dict) int encap; /* encapsulated or not - 1 for pslatex */ int portrait; /* 1 for pslatex */ int uses_fonts; /* 0 for ps(la)tex */ unsigned int xoff, yoff; /* how much to translate by */ unsigned int bb_xmin, bb_ymin, bb_xmax, bb_ymax; /* bounding box */ char **dict; /* extra entries for the dictionary */ { static char GPFAR psi1[] = "%%%%Creator: gnuplot %s patchlevel %s\n\ %%%%CreationDate: %s\ %%%%DocumentFonts: %s\n"; static char GPFAR psi2[] = "%%%%EndComments\n\ /gnudict 256 dict def\ngnudict begin\n\ /Color %s def\n\ /Solid %s def\n\ /gnulinewidth %.3f def\n\ /userlinewidth gnulinewidth def\n\ /vshift %d def\n\ /dl {%d mul} def\n\ /hpt_ %.1f def\n\ /vpt_ %.1f def\n\ /hpt hpt_ def\n\ /vpt vpt_ def\n"; static char GPFAR * GPFAR PS_iso_8859_1_encoding[] = { "/reencodeISO {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "currentdict /CharStrings known {\n", "\tCharStrings /Idieresis known {\n", "\t\t/Encoding ISOLatin1Encoding def } if\n} if\n", "currentdict end definefont\n", "} def\n", "/ISOLatin1Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n", "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n", "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n", "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n", "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n", "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n", "/guillemotright/onequarter/onehalf/threequarters/questiondown\n", "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n", "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n", "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n", "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n", "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n", "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n", "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n", "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n", "/yacute/thorn/ydieresis\n", "] def\n", NULL }; /* encoding for code page 437 */ /* */ /* version 1.0: - Mainly letters are mapped. The following positions */ /* (JFi) are left blank (undefined): */ /* -- first 32 positions, */ /* -- frame characters, */ /* -- greek characters, */ /* -- some more special characters. */ /* */ /* version 1.1: - added some more special characters */ /* */ static char GPFAR * GPFAR PS_cp_437_encoding[] = { "/reencodeCP437 {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "currentdict /CharStrings known {\n", "\tCharStrings /Idieresis known {\n", "\t\t/Encoding CP437Encoding def } if\n} if\n", "currentdict end definefont\n", "} def\n", "/CP437Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef\n", "/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla\n", "/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring\n", "/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave\n", "/ydieresis/Odieresis/Udieresis/cent/sterling/yen/.notdef/florin\n", "/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine\n", "/questiondown/.notdef/logicalnot/onehalf/onequarter/exclamdown/guillemotleft/guillemotright\n", "/space/space/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/germandbls/.notdef/.notdef/.notdef/.notdef/mu/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/infinity/.notdef/.notdef/.notdef\n", "/.notdef/plusminus/greaterequal/lessequal/.notdef/.notdef/divide/.notdef\n", "/degree/bullet/periodcentered/.notdef/nsuperior/twosuperior/.notdef\n", "] def\n", NULL }; /* encoding for code page 850 */ /* */ /* version 1.0: - Mainly letters are mapped. The following positions */ /* (JFi) are left blank (undefined): */ /* -- first 32 positions, */ /* -- frame characters, */ /* -- a few special characters. */ /* */ static char GPFAR * GPFAR PS_cp_850_encoding[] = { "/reencodeCP850 {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "currentdict /CharStrings known {\n", "\tCharStrings /Idieresis known {\n", "\t\t/Encoding CP850Encoding def } if\n} if\n", "currentdict end definefont\n", "} def\n", "/CP850Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef\n", "/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla\n", "/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring\n", "/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave\n", "/ydieresis/Odieresis/Udieresis/oslash/sterling/Oslash/multiply/florin\n", "/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine\n", "/questiondown/registered/logicalnot/onehalf/onequarter/exclamdown/guillemotleft/guillemotright\n", "/space/space/.notdef/.notdef/.notdef/Aacute/Acircumflex/Agrave\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/cent/yen/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/atilde/Atilde\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/currency\n", "/eth/Eth/Ecircumflex/Edieresis/Egrave/dotlessi/Iacute/Icircumflex\n", "/Idieresis/.notdef/.notdef/.notdef/.notdef/brokenbar/Igrave/.notdef\n", "/Oacute/germandbls/Ocircumflex/Ograve/otilde/Otilde/mu/thorn\n", "/Thorn/Uacute/Ucircumflex/Ugrave/yacute/Yacute/macron/acute\n", "/hyphen/plusminus/equal/threequarters/paragraph/section/divide/.notdef\n", "/degree/.notdef/periodcentered/onesuperior/threesuperior/twosuperior/.notdef\n", "] def\n", NULL }; struct termentry *t = term; int i; time_t now; ps_common_encap = encap; /* store for later */ ps_common_portrait = portrait; /* store for later */ ps_common_uses_fonts = uses_fonts; ps_common_xoff = xoff; ps_common_yoff = yoff; ps_page = 0; if (!encap) fprintf(gpoutfile,"%%!PS-Adobe-2.0\n"); else fprintf(gpoutfile,"%%!PS-Adobe-2.0 EPSF-2.0\n"); if (outstr) fprintf(gpoutfile, "%%%%Title: %s\n", outstr ); /* JFi */ time(&now); fprintf(gpoutfile, psi1, version, patchlevel, asctime(localtime(&now)), uses_fonts ? "(atend)" : ""); fprintf(gpoutfile,"%%%%BoundingBox: %d %d %d %d\n", xoff + bb_xmin, yoff + bb_ymin, xoff + bb_xmax, yoff + bb_ymax); fprintf(gpoutfile,"%%%%Orientation: %s\n", ps_portrait ? "Portrait" : "Landscape"); if (!encap) fprintf(gpoutfile,"%%%%Pages: (atend)\n"); fprintf(gpoutfile, psi2, ps_color ? "true" : "false", ps_solid ? "true" : "false", PS_LW, /* line width */ (int)(t->v_char)/(-3), /* shift for vertical centring */ PS_SC, /* dash length */ PS_HTIC/2.0, /* half point width */ PS_VTIC/2.0); /* half point height */ if (uses_fonts && (encoding == ENCODING_ISO_8859_1)) { for (i=0; PS_iso_8859_1_encoding[i] != NULL; i++) { fprintf(gpoutfile,"%s",PS_iso_8859_1_encoding[i]); } } if (uses_fonts && (encoding == ENCODING_CP_437)) { /* JFi */ for (i=0; PS_cp_437_encoding[i] != NULL; i++) { fprintf(gpoutfile,"%s",PS_cp_437_encoding[i]); } } if (uses_fonts && (encoding == ENCODING_CP_850)) { /* JFi */ for (i=0; PS_cp_850_encoding[i] != NULL; i++) { fprintf(gpoutfile,"%s",PS_cp_850_encoding[i]); } } /* Duplicate code! As long as only two code pages are implemented, that's not a big problem. Otherwise a small procedure might be beneficial. */ for ( i=0; PS_header[i] != NULL; i++) fprintf(gpoutfile,"%s",PS_header[i]); if (ps_duplex_option) fprintf(gpoutfile, "statusdict begin %s setduplexmode end\n", ps_duplex_state ? "true" : "false"); PS_RememberFont(ps_font, 1); if (dict) while (*dict) fputs(*(dict++), gpoutfile); fprintf(gpoutfile,"end\n%%%%EndProlog\n"); } /* the init fn for the postscript driver */ TERM_PUBLIC void PS_init() { unsigned int xmin_t, ymin_t, xmax_t, ymax_t; if (ps_eps) { term->xmax = PS_XMAX; term->ymax = PS_YMAX; xmin_t = PS_XMAX * xoffset / (2*PS_SC); xmax_t = PS_XMAX * (xsize + xoffset) / (2*PS_SC); ymin_t = PS_YMAX * yoffset / (2*PS_SC); ymax_t = PS_YMAX * (yoffset + ysize) / (2*PS_SC); } else if (ps_portrait) { term->xmax = PS_YMAX; term->ymax = PS_XMAX; xmin_t = PS_YMAX * xoffset / PS_SC; xmax_t = PS_YMAX * (xsize + xoffset) / PS_SC; ymin_t = PS_XMAX * yoffset / PS_SC; ymax_t = PS_XMAX * (ysize + yoffset) / PS_SC; } else { term->xmax = PS_XMAX; term->ymax = PS_YMAX; ymin_t = PS_XMAX * xoffset / PS_SC; ymax_t = PS_XMAX * (xsize+xoffset) / PS_SC; xmin_t = PS_YMAX * (1-ysize-yoffset) / PS_SC; xmax_t = PS_YMAX * (1-yoffset) / PS_SC; } /* for enhanced postscript, copy ps_font to ps_enh_font * does no harm for non-enhanced */ strcpy(ps_enh_font, ps_font); ps_enh_fontsize = ps_fontsize; PS_common_init(ps_eps, ps_portrait, 1, PS_XOFF, PS_YOFF, xmin_t, ymin_t, xmax_t, ymax_t, (term->put_text == ENHPS_put_text) ? ENHPS_header : NULL); } TERM_PUBLIC void PS_graphics() { static char GPFAR psg1[] = "0 setgray\nnewpath\n"; struct termentry *t = term; ps_page++; if (!ps_common_encap) fprintf(gpoutfile,"%%%%Page: %d %d\n",ps_page,ps_page); fprintf(gpoutfile,"gnudict begin\ngsave\n"); fprintf(gpoutfile,"%d %d translate\n",ps_common_xoff, ps_common_yoff); fprintf(gpoutfile,"%.3f %.3f scale\n", (ps_eps ? 0.5 : 1.0)/PS_SC, (ps_eps ? 0.5 : 1.0)/PS_SC); if (!ps_common_portrait) { fprintf(gpoutfile,"90 rotate\n0 %d translate\n", (int)(-PS_YMAX)); } fprintf(gpoutfile, psg1); if (ps_common_uses_fonts) fprintf(gpoutfile, "(%s) findfont %d scalefont setfont\n", ps_font, (t->v_char) ); ps_path_count = 0; PS_relative_ok = FALSE; PS_pen_x = PS_pen_y = -4000; PS_taken = 0; PS_linetype_last = -1; } TERM_PUBLIC void PS_text() { ps_path_count = 0; fprintf(gpoutfile,"stroke\ngrestore\nend\nshowpage\n"); /* fprintf(stderr,"taken %d times\n",PS_taken); */ /* informational: tells how many times it was "cheaper" to do a relative moveto or lineto rather than an absolute one */ } TERM_PUBLIC void PS_reset() { fprintf(gpoutfile,"%%%%Trailer\n"); /* I think the following commands should be executed `if (ps_common_uses_fonts)`. So I changed the next line. Please see "PS_RememberFont", too. */ /* JFi */ /* if (!ps_common_uses_fonts) { */ /* JFi */ if (ps_common_uses_fonts) { fprintf(gpoutfile,"%%%%DocumentFonts: "); while (PS_DocFonts) { struct PS_FontName *fnp; fnp = PS_DocFonts->next; fprintf(gpoutfile, "%s%s", PS_DocFonts->name, fnp ? " " : "\n"); free(PS_DocFonts->name); free(PS_DocFonts); PS_DocFonts=fnp; } } if (!ps_common_encap) fprintf(gpoutfile,"%%%%Pages: %d\n",ps_page); } TERM_PUBLIC void PS_linetype(linetype) int linetype; { linetype = (linetype % 9) + 2; if (linetype < 0) linetype = 0; PS_relative_ok = FALSE; #if 0 /* In order to make 'PS_linewidth' work properly, I need to comment * this line out. Especially in combination with the line width * extension of the `set arrow` command this is necessary. * Can we live with that drawback? (JFi) */ if (PS_linetype_last == linetype) return; #endif PS_linetype_last = linetype; fprintf(gpoutfile,"LT%c\n", "ba012345678"[linetype]); ps_path_count = 0; } TERM_PUBLIC void PS_linewidth (linewidth) double linewidth; { fprintf(gpoutfile,"%.3f UL\n",linewidth); /* Documentation of the 'change linewidth' strategy of the postscript terminal: 1. define a new postscript variable with a default value: /userlinewidth gnulinewidth def 2. define a new postscript command to change the contents of that variable: /UL { gnulinewidth mul /userlinewidth exch def } def usage: multiplication_factor UL 3. modify the already known postscript command /PL for the plot lines: /PL { stroke userlinewidth setlinewidth } def 4. issue the new command before every change of the plot linestyle: example: 4.0 UL LT0 result: Linetype 0 is drawn four times as thick as defined by the contents of the postscript variable 'gnulinewidth'. */ } TERM_PUBLIC void PS_pointsize (ptsize) double ptsize; { fprintf(gpoutfile,"%.3f UP\n",ptsize); /* Documentation of the 'change pointsize' strategy of the postscript terminal: 1. define two new postscript variables to hold the overall pointsize: /hpt_ and /vpt_ 2. define a new postscript command to use the contents of these variables: /UP { cf. definition above } def usage: multiplication_factor UP [3.] [doesn't exist, skip to next number] 4. issue the new command whereever you change the symbols (and linetype): example: 2.5 UP 4.0 UL % optionally change linewidth, too LT0 result: Next symbols will be drawn 2.5 times as big as defined by the GNUPLOT `set pointsize` command (= overall pointsize). */ } TERM_PUBLIC void PS_move(x,y) unsigned int x,y; { int dx, dy; /* Make this semi-dynamic and independent of architecture */ char abso[5+2*INT_STR_LEN], rel[5+2*INT_STR_LEN]; dx = x - PS_pen_x; dy = y - PS_pen_y; /* can't cancel all null moves--need a move after stroke'ing */ if (dx==0 && dy==0 && PS_relative_ok) return; sprintf(abso, "%d %d M\n", x, y); sprintf(rel, "%d %d R\n", dx, dy); if (strlen(rel) < strlen(abso) && PS_relative_ok){ fputs(rel, gpoutfile); PS_taken++; }else fputs(abso, gpoutfile); PS_relative_ok = TRUE; ps_path_count += 1; PS_pen_x = x; PS_pen_y = y; } TERM_PUBLIC void PS_vector(x,y) unsigned int x,y; { int dx, dy; char abso[5+2*INT_STR_LEN], rel[5+2*INT_STR_LEN]; dx = x - PS_pen_x; dy = y - PS_pen_y; if (dx==0 && dy==0) return; sprintf(abso, "%d %d L\n", x, y); sprintf(rel, "%d %d V\n", dx, dy); if (strlen(rel) < strlen(abso) && PS_relative_ok){ fputs(rel, gpoutfile); PS_taken++; }else fputs(abso, gpoutfile); PS_relative_ok = TRUE; ps_path_count += 1; PS_pen_x = x; PS_pen_y = y; if (ps_path_count >= 400) { fprintf(gpoutfile,"currentpoint stroke M\n"); ps_path_count = 0; } } TERM_PUBLIC void PS_put_text(x,y,str) unsigned int x, y; char *str; { char ch; if (!strlen(str)) return; PS_move(x,y); if (ps_ang != 0) fprintf(gpoutfile,"currentpoint gsave translate %d rotate 0 0 M\n" ,ps_ang*90); putc('(',gpoutfile); ch = *str++; while(ch!='\0') { if ( (ch=='(') || (ch==')') || (ch=='\\') ) putc('\\',gpoutfile); putc(ch,gpoutfile); ch = *str++; } switch(ps_justify) { case LEFT : fprintf(gpoutfile,") Lshow\n"); break; case CENTRE : fprintf(gpoutfile,") Cshow\n"); break; case RIGHT : fprintf(gpoutfile,") Rshow\n"); break; } if (ps_ang != 0) fprintf(gpoutfile,"grestore\n"); ps_path_count = 0; PS_relative_ok = FALSE; } TERM_PUBLIC int PS_text_angle(ang) int ang; { ps_ang=ang; return TRUE; } TERM_PUBLIC int PS_justify_text(mode) enum JUSTIFY mode; { ps_justify=mode; return TRUE; } TERM_PUBLIC int PS_set_font(font) /* Entry font added by DJL */ char *font; { char name[32]; int size,sep; sep=strcspn(font,","); strncpy(name,font,sep); name[sep]=NUL; size=ps_fontsize; sscanf (&(font[sep+1]),"%d",&size); fprintf(gpoutfile,"/%s findfont %d scalefont setfont\n",name,size*PS_SC); PS_RememberFont(name,1 ); return TRUE; } /* postscript point routines */ TERM_PUBLIC void PS_point(x,y,number) unsigned int x,y; int number; { static char GPFAR * GPFAR pointFNS[] = {"Pnt", "Pls", "Crs", "Star", "Box", "BoxF", "Circle", "CircleF", "TriU", "TriUF", "TriD", "TriDF", "Dia", "DiaF", "Pent", "PentF", "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11", "C12", "C13", "C14", "C15", "S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10", "S11", "S12", "S13", "S14", "S15", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15", "BoxE", "CircE", "TriUE", "TriDE", "DiaE", "PentE", "BoxW", "CircW", "TriUW", "TriDW", "DiaW", "PentW" }; if (number < 0) number = -1; /* negative types are all 'dot' */ else number %= sizeof(pointFNS)/sizeof(pointFNS[0]) -1; fprintf(gpoutfile,"%d %d %s\n", x, y, pointFNS[number+1]); PS_relative_ok = 0; ps_path_count = 0; PS_linetype_last = -1; /* force next linetype change */ } TERM_PUBLIC void PS_fillbox(style, x1,y1,x2,y2) int style; unsigned int x1,y1,x2,y2; { PS_FLUSH_PATH fprintf(gpoutfile, "%d %d %d %d BoxFill\n", x1,y1, x2,y2); PS_relative_ok = 0; PS_linetype_last = -1; } /* ENHPOST */ #ifdef DEBUG_ENHPS #define ENHPS_DEBUG(x) printf x; #else #define ENHPS_DEBUG(x) #endif static TBOOLEAN ENHps_opened_string; /* try to cut out empty ()'s */ /* used in determining height of processed text */ static float ENHps_max_height, ENHps_min_height; /* process a bit of string, and return the last character used. * p is start of string * brace is TRUE to keep processing to }, FALSE for do one character * fontname & fontsize are obvious * base is the current baseline * widthflag is TRUE if the width of this should count, * FALSE for zero width boxes * showflag is TRUE if this should be shown, * FALSE if it should not be shown (like TeX \phantom) */ static char *ENHPS_recurse(p, brace, fontname, fontsize, base, widthflag, showflag) char *p, *fontname; TBOOLEAN brace, widthflag, showflag; double fontsize, base; { /* close a postscript string if it has been opened */ #define ENHPS_FLUSH \ { if (ENHps_opened_string) \ { fputs(")]\n", gpoutfile); \ ENHps_opened_string = FALSE; \ } \ } #define ENHPS_OPEN \ { if (!ENHps_opened_string) \ { fprintf(gpoutfile, "[(%s) %.1f %.1f %s %s (", \ fontname, fontsize, base, \ widthflag ? "true" : "false", \ showflag ? "true" : "false"); \ ENHps_opened_string = TRUE; \ } \ } ENHPS_DEBUG(("RECURSE WITH [%p] \"%s\", %d %s %.1f %.1f %d %d\n", p, p, brace, fontname, fontsize, base, widthflag, showflag)) /* Start each recursion with a clean string */ ENHPS_FLUSH if (base + fontsize > ENHps_max_height) { ENHps_max_height = base + fontsize; ENHPS_DEBUG(("Setting max height to %.1f\n", ENHps_max_height)); } if (base < ENHps_min_height) { ENHps_min_height = base; ENHPS_DEBUG(("Setting min height to %.1f\n", ENHps_min_height)); } while (*p) { float shift; switch (*p) { case '}' : /*{{{ deal with it*/ if (brace) return (p); fprintf(stderr, "enhpost printer driver - spurious }\n"); break; /*}}}*/ case '_' : case '^' : /*{{{ deal with super/sub script*/ shift = (*p == '^') ? 0.5 : -0.3; ENHPS_FLUSH p = ENHPS_recurse(p+1, FALSE, fontname, fontsize*0.8, base+shift*fontsize, widthflag, showflag); break; /*}}}*/ case '{' : { char *savepos=NULL, save=0; char *localfontname=fontname, ch; int recode=1; float f=fontsize; /*{{{ recurse (possibly with a new font) */ ENHPS_DEBUG(("Dealing with {\n")) if (*++p == '/') { /* then parse a fontname, optional fontsize */ while (*++p == ' '); if (*p=='-') { recode=0; while (*++p == ' '); } localfontname = p; while ((ch = *p) > ' ' && ch != '=' && ch != '*') ++p; save = *(savepos=p); if (ch == '=') { *p++ = '\0'; /*{{{ get optional font size*/ ENHPS_DEBUG(("Calling strtod(\"%s\") ...", p)) f = (float)strtod(p, &p); ENHPS_DEBUG(("Returned %.1f and \"%s\"\n", f, p)) if (f) f *= PS_SC; /* remember the scaling */ else f = fontsize; ENHPS_DEBUG(("Font size %.1f\n", f)) /*}}}*/ } else if (ch == '*') { *p++ = '\0'; /*{{{ get optional font size scale factor*/ ENHPS_DEBUG(("Calling strtod(\"%s\") ...", p)) f = (float)strtod(p, &p); ENHPS_DEBUG(("Returned %.1f and \"%s\"\n", f, p)) if (f) f *= fontsize; /* apply the scale factor */ else f = fontsize; ENHPS_DEBUG(("Font size %.1f\n", f)) /*}}}*/ } else { *p++ = '\0'; f = fontsize; } while (*p == ' ') ++p; if (*localfontname) { /* only allow RememberFont to re-encode it if no string active */ char *recodestring = PS_RememberFont(localfontname, recode && !ENHps_opened_string); if (recode && recodestring) { ENHPS_FLUSH fprintf(gpoutfile, "/%s %s", localfontname, recodestring); } } else localfontname = fontname; } /*}}}*/ ENHPS_DEBUG(("Before recursing, we are at [%p] \"%s\"\n", p, p)) p = ENHPS_recurse(p, TRUE, localfontname, f, base, widthflag, showflag); ENHPS_DEBUG(("BACK WITH \"%s\"\n", p)); ENHPS_FLUSH if (savepos) /* restore overwritten character */ *savepos = save; break; } case '@' : /*{{{ phantom box - prints next 'char', then restores currentpoint */ ENHPS_FLUSH p = ENHPS_recurse(++p, FALSE, fontname, fontsize, base, FALSE, showflag); break; /*}}}*/ case '&' : /*{{{ character skip - skips space equal to length of character(s) */ ENHPS_FLUSH p = ENHPS_recurse(++p, FALSE, fontname, fontsize, base, widthflag, FALSE); break; /*}}}*/ case '(' : case ')' : /*{{{ an escape and print it */ /* special cases */ ENHPS_OPEN fputc('\\', gpoutfile); fputc(*p, gpoutfile); break; /*}}}*/ case '\\' : /*{{{ is it an escape */ /* special cases */ if (p[1]=='\\' || p[1]=='(' || p[1]==')') { ENHPS_OPEN fputc('\\', gpoutfile); } else if (p[1] >= '0' && p[1] <= '7') { /* up to 3 octal digits */ ENHPS_OPEN fputc('\\', gpoutfile); fputc(p[1], gpoutfile); ++p; if (p[1] >= '0' && p[1] <= '7') { fputc(p[1], gpoutfile); ++p; if (p[1] >= '0' && p[1] <= '7') { fputc(p[1], gpoutfile); ++p; } } break; } ++p; /* just go and print it (fall into the 'default' case) */ /*}}}*/ default: /*{{{ print it */ ENHPS_OPEN fputc(*p, gpoutfile); /*}}}*/ } /* like TeX, we only do one character in a recursion, unless it's * in braces */ if (!brace) { ENHPS_FLUSH return(p); /* the ++p in the outer copy will increment us */ } if (*p) /* only not true if { not terminated, I think */ ++p; } ENHPS_FLUSH return p; } /* a set-font routine for enhanced post : simply copies * the font into a global, or restores the globals * to the ps_font default */ TERM_PUBLIC int ENHPS_set_font(font) /* Entry font added by DJL */ char *font; { ENHPS_DEBUG(("ENHPS_set_font(\"%s\")\n", font)); if (*font) { int sep=strcspn(font,","); strncpy(ps_enh_font,font,sep); ps_enh_font[sep]=NUL; ps_enh_fontsize=ps_fontsize; sscanf (font+sep+1,"%d",&ps_enh_fontsize); PS_RememberFont(ps_enh_font, 1); } else { /* return to defaults */ strcpy(ps_enh_font, ps_font); ps_enh_fontsize = ps_fontsize; } return TRUE; } TERM_PUBLIC void ENHPS_put_text(x, y, str) unsigned int x, y; char *str; { /* flush any pending graphics (all the XShow routines do this...) */ if (!strlen(str)) return; if (ps_path_count) { fputs(" stroke\n",gpoutfile); ps_path_count=0; PS_relative_ok=FALSE; } /* if there are no magic characters, we should just be able * punt the string to PS_put_text(), which will give shorter * ps output [eg tics and stuff rarely need extra processing], * but we need to make sure that the current font is the * default one before we can do that. {ie I tried it and it * used the wrong font !} * if (!strpbrk(str, "{}^_@&")) * { * - do something to ensure default font is selected * PS_put_text(x,y,str); * return; * } */ PS_move(x,y); if (ps_ang != 0) fprintf(gpoutfile,"currentpoint gsave translate %d rotate 0 0 moveto\n", ps_ang*90); fputs("[ ",gpoutfile); /* set up the globals */ ENHps_opened_string = FALSE; ENHps_max_height = -1000; ENHps_min_height = 1000; /* Set the recursion going. We say to keep going until a * closing brace, but we don't really expect to find one. * If the return value is not the nul-terminator of the * string, that can only mean that we did find an unmatched * closing brace in the string. We increment past it (else * we get stuck in an infinite loop) and try again. * * ps_enh_font and ps_enh_fontsize are either set to the * the defaults set on option line, or have been set to * "font,size". That is to say, ps_font is used only * at startup and by ENHPS_set_font */ while (*(str = ENHPS_recurse(str, TRUE, ps_enh_font, (double)(ps_enh_fontsize*PS_SC), 0.0, TRUE, TRUE))) { ENHPS_FLUSH /* I think we can only get here if *str == '}' */ if (*str == '}') fprintf(stderr, "enhpost printer driver - ignoring spurious }\n"); else fprintf(stderr, "internal error in enhpost driver - *str=0x%x\n", *str); if (!*++str) break; /* end of string */ /* else carry on and process the rest of the string */ } ENHps_max_height += ENHps_min_height; fprintf(gpoutfile, "] %.1f ", -ENHps_max_height/3); switch(ps_justify) { case LEFT : fprintf(gpoutfile, "MLshow\n"); break; case CENTRE : fprintf(gpoutfile, "MCshow\n"); break; case RIGHT : fprintf(gpoutfile, "MRshow\n"); break; } if (ps_ang != 0) fputs("grestore\n", gpoutfile); ps_path_count = 0; PS_relative_ok=FALSE; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(post_driver) "postscript", "PostScript graphics language [mode \042fontname\042 font_size]", PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR, PS_VTIC, PS_HTIC, PS_options, PS_init, PS_reset, PS_text, null_scale, PS_graphics, PS_move, PS_vector, PS_linetype, PS_put_text, PS_text_angle, PS_justify_text, PS_point, do_arrow, PS_set_font, PS_pointsize, 0 /*flags*/, 0 /*suspend*/, 0 /*resume*/, PS_fillbox, PS_linewidth TERM_TABLE_END(post_driver) #undef LAST_TERM #define LAST_TERM post_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(post) "1 postscript", "?commands set terminal postscript", "?set terminal postscript", "?set term postscript", "?terminal postscript", "?term postscript", "?postscript", " Several options may be set in the `postscript` driver.", "", " Syntax:", " set terminal postscript {<mode>} {enhanced | noenhanced}", " {color | monochrome} {solid | dashed}", " {<duplexing>}", " {\"<fontname>\"} {<fontsize>}", "", " where <mode> is `landscape`, `portrait`, `eps` or `default`;", " `solid` draws all plots with solid lines, overriding any dashed patterns;", " <duplexing> is `defaultplex`, `simplex` or `duplex` (\"duplexing\" in", " PostScript is the ability of the printer to print on both sides of the same", " page---don't set this if your printer can't do it);", " `enhanced` activates the \"enhanced PostScript\" features (subscripts,", " superscripts and mixed fonts);", " `\"<fontname>\"` is the name of a valid PostScript font; and `<fontsize>` is", " the size of the font in PostScript points.", "", " `default` mode sets all options to their defaults: `landscape`, `monochrome`,", " `dashed`, `defaultplex`, `noenhanced`, \"Helvetica\" and 14pt.", " Default size of a PostScript plot is 10 inches wide and 7 inches high.", "", " `eps` mode generates EPS (Encapsulated PostScript) output, which is just", " regular PostScript with some additional lines that allow the file to be", " imported into a variety of other applications. (The added lines are", " PostScript comment lines, so the file may still be printed by itself.) To", " get EPS output, use the `eps` mode and make only one plot per file. In `eps`", " mode the whole plot, including the fonts, is reduced to half of the default", " size.", "", " Examples:", " set terminal postscript default # old postscript", " set terminal postscript enhanced # old enhpost", " set terminal postscript landscape 22 # old psbig", " set terminal postscript eps 14 # old epsf1", " set terminal postscript eps 22 # old epsf2", " set size 0.7,1.4; set term post portrait color \"Times-Roman\" 14", "", " Linewidths and pointsizes may be changed with `set linestyle`.", "", " The `postscript` driver supports about 70 distinct pointtypes, selectable", " through the `pointtype` option on `plot` and `set linestyle`.", "", " Several possibly useful files about `gnuplot`'s PostScript are included", " in the /docs/ps subdirectory of the `gnuplot` distribution and at the", " distribution sites. These are \"ps_symbols.gpi\" (a `gnuplot` command file", " that, when executed, creates the file \"ps_symbols.ps\" which shows all the", " symbols available through the `postscript` terminal), \"ps_guide.ps\" (a", " PostScript file that contains a summary of the enhanced syntax and a page", " showing what the octal codes produce with text and symbol fonts) and", " \"ps_file.doc\" (a text file that contains a discussion of the organization", " of a PostScript file written by `gnuplot`).", "", " A PostScript file is editable, so once `gnuplot` has created one, you are", " free to modify it to your heart's desire. See the \"editing postscript\"", " section for some hints.", "2 enhanced postscript", "?commands set terminal postscript enhanced", "?set terminal postscript enhanced", "?set term postscript enhanced", "?terminal postscript enhanced", "?term postscript enhanced", "?enhanced_postscript", "@start table - first is interactive cleartext form", " Control Examples Explanation", " ^ a^x superscript", " _ a_x subscript", " @ @x or a@^b_c phantom box (occupies no width)", " & &{space} inserts space of specified length", "#\\begin{tabular}{|ccl|} \\hline", "#\\multicolumn{3}{|c|}{Enhanced Text Control Codes} \\\\ \\hline", "#Control & Examples & Explanation \\\\ \\hline", "#\\verb~^~ & \\verb~a^x~ & superscript\\\\", "#\\verb~_~ & \\verb~a_x~ & subscript\\\\", "#\\verb~@~ & \\verb~@x or a@^b_c~ & phantom box (occupies no width)\\\\", "#\\verb~&~ & \\verb~&{space}~ & inserts space of specified length\\\\", "%c c l .", "%.TE", /* ugly - doc2ms uses @ for column separator, but here we */ "%.TS", /* need @ in table, so end and restart the table ! */ "%center box tab ($) ;", "%c c l .", "%Control$Examples$Explanation", "%_", "%^$a^x$superscript", "%\\&_$a\\&_x$subscript", "% @ $ @x or a\\&@^b\\&_c$phantom box (occupies no width)", "% & $ &{space}$inserts space of specified length", "@end table", "", " Braces can be used to place multiple-character text where a single character", " is expected (e.g., 2^{10}). To change the font and/or size, use the full", " form: {/[fontname][=fontsize | *fontscale] text}. Thus {/Symbol=20 G} is a", " 20-point GAMMA) and {/*0.75 K} is a K at three-quarters of whatever fontsize", " is currently in effect. (The '/' character MUST be the first character after", " the '{'.)", "", " If the encoding vector has been changed by `set encoding`, the default", " encoding vector can be used instead by following the slash with a dash. This", " is unnecessary if you use the Symbol font, however---since /Symbol uses its", " own encoding vector, `gnuplot` will not apply any other encoding vector to", " it.", "", " The phantom box is useful for a@^b_c to align superscripts and subscripts", " but does not work well for overwriting an accent on a letter. (To do the", " latter, it is much better to use `set encoding iso_8859_1` to change to the", " ISO Latin-1 encoding vector, which contains a large variety of letters with", " accents or other diacritical marks.) Since the box is non-spacing, it is", " sensible to put the shorter of the subscript or superscript in the box (that", " is, after the @).", "", " Space equal in length to a string can be inserted using the '&' character.", " Thus", " 'abc&{def}ghi'", " would produce", " 'abc ghi'.", "", " You can access special symbols numerically by specifying \\character-code (in", " octal), e.g., {/Symbol \\245} is the symbol for infinity.", "", " You can escape control characters using \\, e.g., \\\\, \\{, and so on.", "", " But be aware that strings in double-quotes are parsed differently than those", " enclosed in single-quotes. The major difference is that backslashes may need", " to be doubled when in double-quoted strings.", "", " Examples (these are hard to describe in words---try them!):", " set xlabel 'Time (10^6 {/Symbol m}s)'", " set title '{/Symbol=18 \\362@_{/=9.6 0}^{/=12 x}} \\", " {/Helvetica e^{-{/Symbol m}^2/2} d}{/Symbol m}'", "", " The file \"ps_guide.ps\" in the /docs/ps subdirectory of the `gnuplot` source", " distribution contains more examples of the enhanced syntax.", "2 editing postscript", "?commands set terminal postscript editing", "?set terminal postscript editing", "?set term postscript editing", "?terminal postscript editing", "?term postscript editing", "?editing_postscript", " The PostScript language is a very complex language---far too complex to", " describe in any detail in this document. Nevertheless there are some things", " in a PostScript file written by `gnuplot` that can be changed without risk of", " introducing fatal errors into the file.", "", " For example, the PostScript statement \"/Color true def\" (written into the", " file in response to the command `set terminal postscript color`), may be", " altered in an obvious way to generate a black-and-white version of a plot.", " Similarly line colors, text colors, line weights and symbol sizes can also be", " altered in straight-forward ways. Text (titles and labels) can be edited to", " correct misspellings or to change fonts. Anything can be repositioned, and", " of course anything can be added or deleted, but modifications such as these", " may require deeper knowledge of the PostScript language.", "", " The organization of a PostScript file written by `gnuplot` is discussed in", " the text file \"ps_file.doc\" in the /docs/ps subdirectory." END_HELP(post) #endif /* * $Id: pslatex.trm,v 1.35 1998/06/18 14:59:24 ddenholm Exp $ */ /* GNUPLOT - pslatex.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This file supplies the terminal drivers: * pslatex --latex with embedded postscript * pstex --plain TeX with embedded postscript * * AUTHORS * George Phillips * Russell Lang * David Kotz * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). */ #include "driver.h" #ifdef TERM_REGISTER register_term(pslatex) register_term(pstex) #endif #ifdef TERM_PROTO TERM_PUBLIC void PSLATEX_options __PROTO((void)); TERM_PUBLIC void PSLATEX_init __PROTO((void)); TERM_PUBLIC void PSLATEX_graphics __PROTO((void)); TERM_PUBLIC void PSLATEX_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int PSLATEX_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int PSLATEX_text_angle __PROTO((int ang)); TERM_PUBLIC void PSLATEX_reset __PROTO((void)); TERM_PUBLIC void PSLATEX_text __PROTO((void)); TERM_PUBLIC void PSLATEX_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PSLATEX_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PSLATEX_linetype __PROTO((int lt)); TERM_PUBLIC void PSLATEX_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void PSLATEX_pointsize __PROTO((double size)); TERM_PUBLIC void PSLATEX_linewidth __PROTO((double width)); #define PSLATEX_XMAX (5*720) #define PSLATEX_YMAX (3*720) /* 10 pt char is about 10 pts high (say) */ #define PSLATEX_VCHAR (100) /* 10 pt char is about 6 pts wide (say) */ /* I find about 5 points (output from test) - div */ #define PSLATEX_HCHAR (50) #define GOT_PSLATEX_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int PSLATEX_angle; static int PSLATEX_justify; static int PSLATEX_rotate = TRUE; static char *PSLATEX_psfile = NULL; static TBOOLEAN PSLATEX_useAuxFile = FALSE; /* do we write two files? */ static FILE *PSLATEX_auxFile; static TBOOLEAN PSLATEX_output = TRUE; /* do we write LaTeX? */ struct text_command { int x, y, angle, justify; char *label; struct text_command *next; }; static struct text_command *PSLATEX_labels; TERM_PUBLIC void PSLATEX_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "d$efault")) { ps_color = FALSE; ps_solid = FALSE; PSLATEX_rotate = TRUE; PSLATEX_useAuxFile = FALSE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { ps_color = TRUE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "m$onochrome")) { ps_color = FALSE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "so$lid")) { ps_solid = TRUE; c_token++; } else if (almost_equals(c_token, "da$shed")) { ps_solid = FALSE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "r$otate")) { PSLATEX_rotate = TRUE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "n$orotate")) { PSLATEX_rotate = FALSE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "a$uxfile")) { PSLATEX_useAuxFile = TRUE; c_token++; } } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; int ps_fontsize = (int) real(const_express(&a)); term->v_char = (unsigned int) (ps_fontsize * PS_SC); term->h_char = (unsigned int) (ps_fontsize * PS_SC / 2); } /* be sure to generate an options string that PSLATEX_init understands */ sprintf(term_options, "%s %s %s%s", ps_color ? "color" : "monochrome", ps_solid ? "solid" : "dashed", PSLATEX_rotate ? "rotate" : "norotate", PSLATEX_useAuxFile ? " auxfile" : ""); } TERM_PUBLIC void PSLATEX_init() { char *dotIndex; if (strcmp(term->name, "pstex") == 0) PSLATEX_output = FALSE; PSLATEX_auxFile = NULL; /* until we know otherwise */ /* dont tweak PSLATEX_useAuxFile if we decide we cannot comply * since this affects subsequent plots even after a set out * Instead, we will use PSLATEX_auxFile != NULL to indicate * use of an aux file */ /* try to open the auxiliary file for the postscript parts. */ if (outstr && PSLATEX_useAuxFile == TRUE && (dotIndex = strrchr(outstr, '.'))) { /* assume file name is ending in ".tex" */ if (PSLATEX_psfile) free(PSLATEX_psfile); PSLATEX_psfile = gp_alloc(dotIndex - outstr + 3, "pslatex aux filename"); if (PSLATEX_psfile) { /* including . */ safe_strncpy(PSLATEX_psfile, outstr, dotIndex - outstr + 1); strcpy(PSLATEX_psfile + (dotIndex - outstr) + 1, "ps"); if ((PSLATEX_auxFile = fopen(PSLATEX_psfile, "w")) == (FILE *) NULL) { fprintf(stderr, "Cannot open aux file %s for output\n", PSLATEX_psfile); } } else { fprintf(stderr, "\ Cannot make PostScript file name from %s\n\ Turning off auxfile option\n", outstr); PSLATEX_auxFile = NULL; } } if (PSLATEX_output) { fputs("\ % GNUPLOT: LaTeX picture with Postscript\n\ \\begingroup%\n\ \\makeatletter%\n\ \\newcommand{\\GNUPLOTspecial}{%\n\ \\@sanitize\\catcode`\\%=14\\relax\\special}%\n\ \\setlength{\\unitlength}{0.1bp}%\n", gpoutfile); } else { /* write plain TeX header */ fputs("\ % GNUPLOT: plain TeX with Postscript\n\ \\begingroup\n\ \\catcode`\\@=11\\relax\n\ \\def\\GNUPLOTspecial{%\n\ \\def\\do##1{\\catcode`##1=12\\relax}\\dospecials\n\ \\catcode`\\{=1\\catcode`\\}=2\\catcode\\%=14\\relax\\special}%\n\ %\n\ \\expandafter\\ifx\\csname GNUPLOTpicture\\endcsname\\relax\n\ \\csname newdimen\\endcsname\\GNUPLOTunit\n\ \\gdef\\GNUPLOTpicture(#1,#2){\\vbox to#2\\GNUPLOTunit\\bgroup\n\ \\def\\put(##1,##2)##3{\\unskip\\raise##2\\GNUPLOTunit\n\ \\hbox to0pt{\\kern##1\\GNUPLOTunit ##3\\hss}\\ignorespaces}%\n\ \\def\\ljust##1{\\vbox to0pt{\\vss\\hbox to0pt{##1\\hss}\\vss}}%\n\ \\def\\cjust##1{\\vbox to0pt{\\vss\\hbox to0pt{\\hss ##1\\hss}\\vss}}%\n\ \\def\\rjust##1{\\vbox to0pt{\\vss\\hbox to0pt{\\hss ##1}\\vss}}%\n\ \\def\\stack##1{\\let\\\\=\\cr\\tabskip=0pt\\halign{\\hfil ####\\hfil\\cr ##1\\crcr}}%\n\ \\def\\lstack##1{\\hbox to0pt{\\vbox to0pt{\\vss\\stack{##1}}\\hss}}%\n\ \\def\\cstack##1{\\hbox to0pt{\\hss\\vbox to0pt{\\vss\\stack{##1}}\\hss}}%\n\ \\def\\rstack##1{\\hbox to0pt{\\vbox to0pt{\\stack{##1}\\vss}\\hss}}%\n\ \\vss\\hbox to#1\\GNUPLOTunit\\bgroup\\ignorespaces}%\n\ \\gdef\\endGNUPLOTpicture{\\hss\\egroup\\egroup}%\n\ \\fi\n\ \\GNUPLOTunit=0.1bp\n", gpoutfile); } { unsigned int xmin_t = xoffset * PSLATEX_XMAX / PS_SC; unsigned int xmax_t = (xoffset + xsize) * PSLATEX_XMAX / PS_SC; unsigned int ymin_t = yoffset * PSLATEX_YMAX / PS_SC; unsigned int ymax_t = (yoffset + ysize) * PSLATEX_YMAX / PS_SC; if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_common_init(1, 1, 0, 0, 0, xmin_t, ymin_t, xmax_t, ymax_t, NULL); gpoutfile = tmp; } else { fputs("{\\GNUPLOTspecial{!\n", gpoutfile); PS_common_init(1, 1, 0, 0, 0, xmin_t, ymin_t, xmax_t, ymax_t, NULL); fputs("}}%\n", gpoutfile); } } PSLATEX_angle = 0; PSLATEX_justify = 0; PSLATEX_labels = 0; } TERM_PUBLIC void PSLATEX_graphics() { struct termentry *t = term; if (PSLATEX_output) fprintf(gpoutfile, "\\begin{picture}(%d,%d)(0,0)%%\n", (int) (xsize * t->xmax), (int) (ysize * t->ymax)); else fprintf(gpoutfile, "\\GNUPLOTpicture(%d,%d)\n", (int) (xsize * t->xmax), (int) (ysize * t->ymax)); if (PSLATEX_auxFile) { FILE *tmp; /* * these are taken from the post.trm file computation * of the bounding box, but without the X_OFF and Y_OFF */ int urx = (int) (xsize * (PS_XMAX) / PS_SC + 0.5), ury = (int) (ysize * (PS_YMAX) / PS_SC + 0.5); /* generate special which xdvi and dvips can handle */ fprintf(gpoutfile, "\\special{psfile=%s llx=0 lly=0 urx=%d ury=%d rwi=%d}\n", PSLATEX_psfile, urx, ury, 10 * urx); tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_graphics(); gpoutfile = tmp; } else { fputs("{\\GNUPLOTspecial{\"\n", gpoutfile); PS_graphics(); } PSLATEX_labels = (struct text_command *) NULL; } TERM_PUBLIC void PSLATEX_put_text(x, y, str) unsigned int x, y; char str[]; { struct text_command *tc; /* ignore empty strings */ if (str[0] == NUL) return; tc = (struct text_command *) gp_alloc(sizeof(struct text_command), term->name); tc->x = x; tc->y = y; tc->label = (char *) gp_alloc(strlen(str) + 1, term->name); strcpy(tc->label, str); tc->justify = PSLATEX_justify; tc->angle = PSLATEX_angle; tc->next = PSLATEX_labels; PSLATEX_labels = tc; } TERM_PUBLIC int PSLATEX_justify_text(mode) enum JUSTIFY mode; { PSLATEX_justify = mode; return TRUE; } TERM_PUBLIC int PSLATEX_text_angle(ang) int ang; { /* rotated text is put in a short stack, and optionally uses * postscript specials depending on PSLATEX_rotate */ PSLATEX_angle = ang; return TRUE; } TERM_PUBLIC void PSLATEX_reset() { if (PSLATEX_auxFile) { fclose(PSLATEX_auxFile); PSLATEX_auxFile = NULL; } if (PSLATEX_psfile) { free(PSLATEX_psfile); PSLATEX_psfile = NULL; } } TERM_PUBLIC void PSLATEX_text() { struct text_command *tc; if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_text(); gpoutfile = tmp; } else { PS_text(); fputs("}}%\n", gpoutfile); } for (tc = PSLATEX_labels; tc != (struct text_command *) NULL; tc = tc->next) { fprintf(gpoutfile, "\\put(%d,%d){", tc->x, tc->y); if (PSLATEX_output && ((tc->label[0] == '{') || (tc->label[0] == '['))) { fprintf(gpoutfile, "\\makebox(0,0)%s", tc->label); } else switch (tc->angle) { case 0: switch (tc->justify) { case LEFT: fprintf(gpoutfile, (PSLATEX_output ? "\\makebox(0,0)[l]{%s}" : "\\ljust{%s}"), tc->label); break; case CENTRE: fprintf(gpoutfile, (PSLATEX_output ? "\\makebox(0,0){%s}" : "\\cjust{%s}"), tc->label); break; case RIGHT: fprintf(gpoutfile, (PSLATEX_output ? "\\makebox(0,0)[r]{%s}" : "\\rjust{%s}"), tc->label); break; } break; case 1: /* put text in a short stack */ if (PSLATEX_rotate) { fputs("\ %\n\\special{ps: gsave currentpoint currentpoint translate\n\ 270 rotate neg exch neg exch translate}%\n", gpoutfile); } switch (tc->justify) { case LEFT: fprintf(gpoutfile, (PSLATEX_output ? "\\makebox(0,0)[lb]{\\shortstack{%s}}" : "\\lstack{%s}"), tc->label); break; case CENTRE: fprintf(gpoutfile, (PSLATEX_output ? "\\makebox(0,0)[b]{\\shortstack{%s}}" : "\\cstack{%s}"), tc->label); break; case RIGHT: fprintf(gpoutfile, (PSLATEX_output ? "\\makebox(0,0)[lt]{\\shortstack{%s}}" : "\\rstack{%s}"), tc->label); break; } if (PSLATEX_rotate) { fputs("%\n\\special{ps: currentpoint grestore moveto}%\n", gpoutfile); } } fputs("}%\n", gpoutfile); } while (PSLATEX_labels) { tc = PSLATEX_labels->next; free(PSLATEX_labels->label); free(PSLATEX_labels); PSLATEX_labels = tc; } if (PSLATEX_output) { fputs("\ \\end{picture}%\n\ \\endgroup\n\ \\endinput\n", gpoutfile); } else { fputs("\ \\endGNUPLOTpicture\n\ \\endgroup\n\ \\endinput\n", gpoutfile); } } TERM_PUBLIC void PSLATEX_move(x, y) unsigned int x, y; { if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_move(x, y); gpoutfile = tmp; } else { PS_move(x, y); } } TERM_PUBLIC void PSLATEX_vector(x, y) unsigned int x, y; { if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_vector(x, y); gpoutfile = tmp; } else { PS_vector(x, y); } } TERM_PUBLIC void PSLATEX_linetype(lt) int lt; { if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_linetype(lt); gpoutfile = tmp; } else { PS_linetype(lt); } } TERM_PUBLIC void PSLATEX_point(x, y, number) unsigned int x, y; int number; { if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_point(x, y, number); gpoutfile = tmp; } else PS_point(x, y, number); } TERM_PUBLIC void PSLATEX_pointsize(ps) double ps; { if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_pointsize(ps); gpoutfile = tmp; } else PS_pointsize(ps); } TERM_PUBLIC void PSLATEX_linewidth(ps) double ps; { if (PSLATEX_auxFile) { FILE *tmp = gpoutfile; gpoutfile = PSLATEX_auxFile; PS_linewidth(ps); gpoutfile = tmp; } else PS_linewidth(ps); } #endif /* TERM_BODY */ #ifdef TERM_TABLE #ifndef GOT_POST_PROTO #define TERM_PROTO_ONLY #include "post.trm" #undef TERM_PROTO_ONLY #endif TERM_TABLE_START(pslatex_driver) "pslatex", "LaTeX picture environment with PostScript \\specials", PSLATEX_XMAX, PSLATEX_YMAX, PSLATEX_VCHAR, PSLATEX_HCHAR, PS_VTIC, PS_HTIC, PSLATEX_options, PSLATEX_init, PSLATEX_reset, PSLATEX_text, null_scale, PSLATEX_graphics, PSLATEX_move, PSLATEX_vector, PSLATEX_linetype, PSLATEX_put_text, PSLATEX_text_angle, PSLATEX_justify_text, PSLATEX_point, do_arrow, set_font_null, PSLATEX_pointsize, 0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , 0 /*fillbox */ , PSLATEX_linewidth TERM_TABLE_END(pslatex_driver) #undef LAST_TERM #define LAST_TERM pslatex_driver TERM_TABLE_START(pstex_driver) "pstex", "plain TeX with PostScript \\specials", PSLATEX_XMAX, PSLATEX_YMAX, PSLATEX_VCHAR, PSLATEX_HCHAR, PS_VTIC, PS_HTIC, PSLATEX_options, PSLATEX_init, PSLATEX_reset, PSLATEX_text, null_scale, PSLATEX_graphics, PSLATEX_move, PSLATEX_vector, PSLATEX_linetype, PSLATEX_put_text, PSLATEX_text_angle, PSLATEX_justify_text, PSLATEX_point, do_arrow, set_font_null, PSLATEX_pointsize, 0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , 0 /*fillbox */ , PSLATEX_linewidth TERM_TABLE_END(pstex_driver) #undef LAST_TERM #define LAST_TERM pstex_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(pslatex) "1 pslatex and pstex", "?commands set terminal pslatex", "?set terminal pslatex", "?set term pslatex", "?terminal pslatex", "?term pslatex", "?pslatex", "?commands set terminal pstex", "?set terminal pstex", "?set term pstex", "?terminal pstex", "?term pstex", "?pstex", " The `pslatex` and `pstex` drivers generate output for further processing by", " LaTeX and TeX, respectively. Figures generated by `pstex` can be included", " in any plain-based format (including LaTeX).", "", " Syntax:", " set terminal pslatex | |pstex {<color>} {<dashed>} {<rotate>}", " {auxfile} {<font_size>}", "", " <color> is either `color` or `monochrome`. <rotate> is either `rotate` or", " `norotate` and determines if the y-axis label is rotated. <font_size> is", " used to scale the font from its usual size.", "", " If `auxfile` is specified, it directs the driver to put the PostScript", " commands into an auxiliary file instead of directly into the LaTeX file.", " This is useful if your pictures are large enough that dvips cannot handle", " them. The name of the auxiliary PostScript file is derived from the name of", " the TeX file given on the `set output` command; it is determined by replacing", " the trailing `.tex` (actually just the final extent in the file name---and", " the option will be turned off if there is no extent) with `.ps` in the output", " file name. Remember to close the file before leaving `gnuplot`.", "", " All drivers for LaTeX offer a special way of controlling text positioning:", " If any text string begins with '{', you also need to include a '}' at the", " end of the text, and the whole text will be centered both horizontally", " and vertically by LaTeX. --- If the text string begins with '[', you need", " to continue it with: a position specification (up to two out of t,b,l,r),", " ']{', the text itself, and finally, '}'. The text itself may be anything", " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.", "", " Examples:", " set term pslatex monochrome dashed rotate # set to defaults", " To write the PostScript commands into the file \"foo.ps\":", " set term pslatex auxfile", " set output \"foo.tex\"; plot ...: set output", " About label positioning:", " Use gnuplot defaults (mostly sensible, but sometimes not really best):", " set title '\\LaTeX\\ -- $ \\gamma $'", " Force centering both horizontally and vertically:", " set label '{\\LaTeX\\ -- $ \\gamma $}' at 0,0", " Specify own positioning (top here):", " set xlabel '[t]{\\LaTeX\\ -- $ \\gamma $}'", " The other label -- account for long ticlabels:", " set ylabel '[r]{\\LaTeX\\ -- $ \\gamma $\\rule{7mm}{0pt}'", "", " Linewidths and pointsizes may be changed with `set linestyle`." END_HELP(pslatex) #endif /* TERM_HELP */ /* Hey Emacs this is -*- C -*- * * $Id: pstricks.trm,v 1.16 1998/06/18 14:59:25 ddenholm Exp $ */ /* GNUPLOT - pstricks.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * The PSTricks macros for LaTeX. * * AUTHORS * David Kotz * * Raymond Toy toy@soho.crd.ge.com * Modified the eepic.trm file to use PSTricks macros instead. * * 20 Mar 93: * Utilized many suggestions from Gisli Ottarsson * (gisli@liapunov.eecs.umich.edu) to create a new version. * Should also work with TeX as well as LaTeX. * * If you have PSTricks version 0.91, #define OLD_PST to * get the right dots. * * Added a really ugly hack (enabled by default) to print * "nice" numbers for axis labels. This should really be at * a higher level in the code, but I'm lazy right now. * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * This file contains the PSTricks terminal driver, intended for use with the * pstricks.sty macro package for LaTeX. This is an alternative to the * eepic and latex driver. You need pstricks.sty, and, of course, a printer * that understands PostScript. Ghostscript understands Postscript too. * * PSTricks is available via anonymous ftp from the /pub directory * at Princeton.EDU. This driver definitely does not come close to * using the full capability of the PSTricks package. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(pstricks) #endif #ifdef TERM_PROTO TERM_PUBLIC void PSTRICKS_options __PROTO((void)); TERM_PUBLIC void PSTRICKS_init __PROTO((void)); TERM_PUBLIC void PSTRICKS_graphics __PROTO((void)); TERM_PUBLIC void PSTRICKS_text __PROTO((void)); TERM_PUBLIC void PSTRICKS_linetype __PROTO((int linetype)); TERM_PUBLIC void PSTRICKS_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PSTRICKS_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void PSTRICKS_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void PSTRICKS_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC void PSTRICKS_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int PSTRICKS_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int PSTRICKS_text_angle __PROTO((int ang)); TERM_PUBLIC void PSTRICKS_reset __PROTO((void)); #define PSTRICKS_XMAX 10000.0 #define PSTRICKS_YMAX 10000.0 #define PSTRICKS_HTIC 150 #define PSTRICKS_VTIC 200 #define PSTRICKS_HCHAR 160 #define PSTRICKS_VCHAR 420 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static void PSTRICKS_endline __PROTO((void)); static char *PSTRICKS_hack_text __PROTO((char s[])); static float PSTRICKS_xscale = 1.0; static float PSTRICKS_yscale = 1.0; static float PSTRICKS_posx; static float PSTRICKS_posy; enum JUSTIFY PSTRICKS_justify = LEFT; static int PSTRICKS_angle = 0; #define PSTRICKS_TINY_DOT 0.00025 /* A tiny dot */ /* POINTS */ #define PSTRICKS_POINT_TYPES 12 /* we supply more point types */ static char *PSTRICKS_points[] = { "\\PST@Diamond", "\\PST@Plus", "\\PST@Square", "\\PST@Cross", "\\PST@Circle", "\\PST@Triangle", "\\PST@Pentagon", "\\PST@Filldiamond", "\\PST@Fillsquare", "\\PST@Filltriangle", "\\PST@Fillcircle", "\\PST@Fillpentagon" }; /* LINES */ #define PSTRICKS_NUMLINES 6 /* number of linetypes below */ static char *PSTRICKS_lines[] = { "\\PST@Border", "\\PST@Axes", "\\PST@Solid", "\\PST@Dashed", "\\PST@Dotted", "\\PST@LongDash" }; /* current line type */ static int PSTRICKS_type; /* are we in the middle of a line */ static TBOOLEAN PSTRICKS_inline = FALSE; /* terminate any line in progress */ static void PSTRICKS_endline __PROTO((void)); /* number of points in line so far */ static int PSTRICKS_linecount = 0; /* max value for linecount */ #define PSTRICKS_LINEMAX 100 /* * Handle options */ static int PST_hack_text = TRUE; /* Hack text on */ static int PST_unit_plot = FALSE; /* Unit-sized plot off */ TERM_PUBLIC void PSTRICKS_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "no$hacktext")) { PST_hack_text = FALSE; c_token++; } else if (almost_equals(c_token, "u$nit")) { PST_unit_plot = TRUE; c_token++; } } } TERM_PUBLIC void PSTRICKS_init() { PSTRICKS_posx = PSTRICKS_posy = 0; PSTRICKS_linetype(-1); fputs("% GNUPLOT: LaTeX picture using PSTRICKS macros\n", gpoutfile); } TERM_PUBLIC void PSTRICKS_graphics() { fputs("\ % Define new PST objects, if not already defined\n\ \\ifx\\PSTloaded\\undefined\n\ \\def\\PSTloaded{t}\n\ \\psset{arrowsize=.01 3.2 1.4 .3}\n\ \\psset{dotsize=.01}\n\ \\catcode`@=11\n\n", gpoutfile); /* Define line type objects */ fputs("\ \\newpsobject{PST@Border}{psline}{linewidth=.0015,linestyle=solid}\n\ \\newpsobject{PST@Axes}{psline}{linewidth=.0015,linestyle=dotted,dotsep=.004}\n\ \\newpsobject{PST@Solid}{psline}{linewidth=.0015,linestyle=solid}\n\ \\newpsobject{PST@Dashed}{psline}{linewidth=.0015,linestyle=dashed,dash=.01 .01}\n\ \\newpsobject{PST@Dotted}{psline}{linewidth=.0025,linestyle=dotted,dotsep=.008}\n\ \\newpsobject{PST@LongDash}{psline}{linewidth=.0015,linestyle=dashed,dash=.02 .01}\n", gpoutfile); /* Define point objects */ #ifdef OLD_PST /* PSTricks version 0.91 had x and diamond dot types */ fputs("\ \\newpsobject(PST@Diamond}{psdots}{linewidth=.001,linestyle=solid,dotstyle=diamond}\n\ \\newpsobject(PST@Filldiamond}{psdots}{linewidth=.001,linestyle=solid,dotstyle=diamond*}\n\ \\newpsobject{PST@Cross}{psdots}{linewidth=.001,linestyle=solid,dotstyle=x}\n", gpoutfile); #else /* Newer versions use rotated plus and square to get the x and diamond dots */ fputs("\ \\newpsobject{PST@Diamond}{psdots}{linewidth=.001,linestyle=solid,dotstyle=square,dotangle=45}\n\ \\newpsobject{PST@Filldiamond}{psdots}{linewidth=.001,linestyle=solid,dotstyle=square*,dotangle=45}\n\ \\newpsobject{PST@Cross}{psdots}{linewidth=.001,linestyle=solid,dotstyle=+,dotangle=45}\n", gpoutfile); #endif fputs("\ \\newpsobject{PST@Plus}{psdots}{linewidth=.001,linestyle=solid,dotstyle=+}\n\ \\newpsobject{PST@Square}{psdots}{linewidth=.001,linestyle=solid,dotstyle=square}\n\ \\newpsobject{PST@Circle}{psdots}{linewidth=.001,linestyle=solid,dotstyle=o}\n\ \\newpsobject{PST@Triangle}{psdots}{linewidth=.001,linestyle=solid,dotstyle=triangle}\n\ \\newpsobject{PST@Pentagon}{psdots}{linewidth=.001,linestyle=solid,dotstyle=pentagon}\n\ \\newpsobject{PST@Fillsquare}{psdots}{linewidth=.001,linestyle=solid,dotstyle=square*}\n\ \\newpsobject{PST@Fillcircle}{psdots}{linewidth=.001,linestyle=solid,dotstyle=*}\n\ \\newpsobject{PST@Filltriangle}{psdots}{linewidth=.001,linestyle=solid,dotstyle=triangle*}\n\ \\newpsobject{PST@Fillpentagon}{psdots}{linewidth=.001,linestyle=solid,dotstyle=pentagon*}\n", gpoutfile); /* Define arrow object */ fputs("\ \\newpsobject{PST@Arrow}{psline}{linewidth=.001,linestyle=solid}\n\ \\catcode`@=12\n\n\ \\fi\n", gpoutfile); /* Set the scaled plot size, if it's not a unit plot */ if (!PST_unit_plot) { fprintf(gpoutfile, "\\psset{unit=%fin,xunit=%fin,yunit=%fin}\n", 5.0 * PSTRICKS_xscale, 5.0 * PSTRICKS_xscale, 3.0 * PSTRICKS_yscale); } fputs("\ \\pspicture(0,0)(1,1)\n\ \\ifx\\nofigs\\undefined\n\ \\catcode`@=11\n\n", gpoutfile); } TERM_PUBLIC void PSTRICKS_text() { PSTRICKS_endline(); fputs("\ \\catcode`@=12\n\ \\fi\n\ \\endpspicture\n", gpoutfile); } TERM_PUBLIC void PSTRICKS_linetype(linetype) int linetype; { PSTRICKS_endline(); if (linetype >= PSTRICKS_NUMLINES - 2) linetype %= (PSTRICKS_NUMLINES - 2); PSTRICKS_type = linetype; } TERM_PUBLIC void PSTRICKS_move(x, y) unsigned int x; unsigned int y; { PSTRICKS_endline(); PSTRICKS_posx = x / PSTRICKS_XMAX; PSTRICKS_posy = y / PSTRICKS_YMAX; } TERM_PUBLIC void PSTRICKS_point(x, y, number) /* version of line_and_point */ unsigned x; unsigned y; int number; { PSTRICKS_move(x, y); /* Print the character defined by 'number'; number < 0 means to use a dot, otherwise one of the defined points. */ if (number < 0) { fprintf(gpoutfile, "\\qdisk(%.4f,%.4f){%.4f}\n", x / PSTRICKS_XMAX, y / PSTRICKS_YMAX, PSTRICKS_TINY_DOT); } else { fprintf(gpoutfile, "%s(%.4f,%.4f)\n", PSTRICKS_points[number % PSTRICKS_POINT_TYPES], x / PSTRICKS_XMAX, y / PSTRICKS_YMAX); } } TERM_PUBLIC void PSTRICKS_vector(ux, uy) unsigned ux; unsigned uy; { if (!PSTRICKS_inline) { PSTRICKS_inline = TRUE; /* Start a new line. This depends on line type */ fprintf(gpoutfile, "%s(%.4f,%.4f)\n", PSTRICKS_lines[PSTRICKS_type + 2], PSTRICKS_posx, PSTRICKS_posy); PSTRICKS_linecount = 1; } else { /* * Even though we are in middle of a path, * we may want to start a new path command. * If they are too long then latex will choke. */ if (PSTRICKS_linecount++ >= PSTRICKS_LINEMAX) { /* fprintf(gpoutfile, "\n"); */ fprintf(gpoutfile, "%s(%.4f,%.4f)\n", PSTRICKS_lines[PSTRICKS_type + 2], PSTRICKS_posx, PSTRICKS_posy); PSTRICKS_linecount = 1; } } PSTRICKS_posx = ux / PSTRICKS_XMAX; PSTRICKS_posy = uy / PSTRICKS_YMAX; fprintf(gpoutfile, "(%.4f,%.4f)\n", PSTRICKS_posx, PSTRICKS_posy); } static void PSTRICKS_endline() { if (PSTRICKS_inline) { putc('\n', gpoutfile); PSTRICKS_inline = FALSE; } } TERM_PUBLIC void PSTRICKS_arrow(sx, sy, ex, ey, head) unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; TBOOLEAN head; { fprintf(gpoutfile, "\\PST@Arrow%s(%.4f,%.4f)(%.4f,%.4f)\n", head ? "{->}" : "", sx / PSTRICKS_XMAX, sy / PSTRICKS_YMAX, ex / PSTRICKS_XMAX, ey / PSTRICKS_YMAX); PSTRICKS_posx = ex / PSTRICKS_XMAX; PSTRICKS_posy = ey / PSTRICKS_YMAX; } /* * A really ugly hack!!! * * This function takes an input string and hacks it up. If the * input string starts with a number, it converts the number into a * TeX style number including exponential notation. Thus, if * the input is the string "3.14159e3 is a number", then * the output is "$3.14159\cdot 10^{3}$ is a number", so that TeX * will produce something nice. * * This is basically meant for producing axis labels that look nice. * * What a hack! */ static char *PSTRICKS_hack_text(s) char s[]; { double value; char *ends; static char hack[BUFSIZ]; /* * Does the string start with a number? */ value = strtod(s, &ends); if (s == ends) { /* * This doesn't start a number, so just copy the string over */ strcpy(hack, s); } else { char *ptr; /* * We have a number! Check to see if the number * is in scientific notation */ safe_strncpy(hack, s, ends - s); /* hack[ends - s] = '\0'; */ ptr = strchr(hack, 'e'); if (ptr == NULL) { ptr = strchr(hack, 'E'); } if (ptr != NULL) { /* * Exponential notation! Let's get the mantissa and exponent separately */ double man_val; int expo_val; *ptr = NUL; man_val = atof(hack); expo_val = atoi(ptr + 1); if (man_val == 0) { sprintf(hack, "0"); } else if (man_val == 1) { sprintf(hack, "$10^{%d}$", expo_val); } else if (man_val == (int) man_val) { if (expo_val == 1) { sprintf(hack, "$%d$", (int) man_val); } else { sprintf(hack, "$%d \\times 10^{%d}$", (int) man_val, expo_val); } } else { if (expo_val == 1) { sprintf(hack, "$%f$", man_val); } else { sprintf(hack, "$%f \\times 10^{%d}$", man_val, expo_val); } } } /* * Copy anything that's left of the string */ strcat(hack, ends); } return hack; } TERM_PUBLIC void PSTRICKS_put_text(x, y, str) unsigned int x; unsigned int y; char str[]; { PSTRICKS_endline(); /* Skip this if the string is empty */ if (strlen(str) > 0) { fputs("\\rput", gpoutfile); /* Set justification */ switch (PSTRICKS_justify) { case LEFT: fputs("[l]", gpoutfile); break; case CENTRE: break; case RIGHT: fputs("[r]", gpoutfile); break; } /* Set text angle */ switch (PSTRICKS_angle) { case 0: break; case 1: fputs("{L}", gpoutfile); break; } /* Set reference position and text */ fprintf(gpoutfile, "(%.4f,%.4f)", x / PSTRICKS_XMAX, y / PSTRICKS_YMAX); if (PST_hack_text) { char *hack; /* Hack leading numbers to something nice for TeX */ hack = PSTRICKS_hack_text(str); fprintf(gpoutfile, "{%s}\n", hack); } else { fprintf(gpoutfile, "{%s}\n", str); } } } TERM_PUBLIC int PSTRICKS_justify_text(mode) enum JUSTIFY mode; { PSTRICKS_justify = mode; return (TRUE); } TERM_PUBLIC int PSTRICKS_text_angle(ang) int ang; { PSTRICKS_angle = ang; return (TRUE); } TERM_PUBLIC void PSTRICKS_reset() { PSTRICKS_endline(); PSTRICKS_posx = PSTRICKS_posy = 0; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(pstricks_driver) "pstricks", "LaTeX picture environment with PSTricks macros", PSTRICKS_XMAX, PSTRICKS_YMAX, PSTRICKS_VCHAR, PSTRICKS_HCHAR, PSTRICKS_VTIC, PSTRICKS_HTIC, PSTRICKS_options, PSTRICKS_init, PSTRICKS_reset, PSTRICKS_text, null_scale, PSTRICKS_graphics, PSTRICKS_move, PSTRICKS_vector, PSTRICKS_linetype, PSTRICKS_put_text, PSTRICKS_text_angle, PSTRICKS_justify_text, PSTRICKS_point, PSTRICKS_arrow, set_font_null TERM_TABLE_END(pstricks_driver) #undef LAST_TERM #define LAST_TERM pstricks_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(pstricks) "1 pstricks", "?commands set terminal pstricks", "?set terminal pstricks", "?set term pstricks", "?terminal pstricks", "?term pstricks", "?pstricks", " The `pstricks` driver is intended for use with the \"pstricks.sty\" macro", " package for LaTeX. It is an alternative to the `eepic` and `latex` drivers.", " You need \"pstricks.sty\", and, of course, a printer that understands", " PostScript, or a converter such as Ghostscript.", "", " PSTricks is available via anonymous ftp from the /pub directory at", " Princeton.EDU. This driver definitely does not come close to using the full", " capability of the PSTricks package.", "", " Syntax:", " set terminal pstricks {hacktext | nohacktext} {unit | nounit}", "", " The first option invokes an ugly hack that gives nicer numbers; the second", " has to do with plot scaling. The defaults are `hacktext` and `nounit`." END_HELP(pstricks) #endif /* TERM_HELP */ /* * $Id: qms.trm,v 1.14 1998/04/14 00:18:05 drd Exp $ * */ /* GNUPLOT - qms.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * QMS laser printers * * AUTHORS * Colin Kelley, Thomas Williams, Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(qms) #endif #ifdef TERM_PROTO TERM_PUBLIC void QMS_init __PROTO((void)); TERM_PUBLIC void QMS_graphics __PROTO((void)); TERM_PUBLIC void QMS_text __PROTO((void)); TERM_PUBLIC void QMS_linetype __PROTO((int linetype)); TERM_PUBLIC void QMS_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void QMS_vector __PROTO((unsigned int x2, unsigned int y2)); TERM_PUBLIC void QMS_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void QMS_reset __PROTO((void)); #define QMS_XMAX 9000 #define QMS_YMAX 6000 #define QMS_XLAST (QMS_XMAX - 1) #define QMS_YLAST (QMS_YMAX - 1) #define QMS_VCHAR 120 #define QMS_HCHAR 70 #define QMS_VTIC 70 #define QMS_HTIC 70 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int qms_line = 0; /* to remember current line type */ TERM_PUBLIC void QMS_init() { /* This was just ^IOL, but at Rutgers at least we need some more stuff */ fputs("^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n", gpoutfile); /* ^ QUIC on ^set defaults ^ set botttom,top,left margins * ^landscape ^free format */ /* set defaults are: implicit decimal point, units in inches, * numbers left justified, units in 1/1000 inch, do not ignore spaces * margins are in 1/1000 inch units */ } TERM_PUBLIC void QMS_graphics() { fputs("^IGV\n", gpoutfile); /* ^enter graphics vector mode */ } TERM_PUBLIC void QMS_text() { /* added ^-, because ^, after an ^I command doesn't actually print a page */ /* Did anybody try this code out? [uhh...-cdk] */ fputs("^IGE\n^-^,", gpoutfile); /* ^exit graphics vector mode * ^pass terminator * ^print page */ } TERM_PUBLIC void QMS_linetype(linetype) int linetype; { static int width[2 + 9] = { 7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7 }; static int type[2 + 9] = { 0, 1, 0, 2, 3, 0, 2, 3, 0, 2, 3 }; /* * I don't know about Villanova, but on our printer, using ^V without * previously setting up a pattern crashes the microcode. * [nope, doesn't crash here. -cdk] * [it generates a controller error here on dotted lines. - rjl] */ /* Code to define patterns added by rjl * According to the manual it should work - but it doesn't */ qms_line = linetype; if (linetype >= 9) linetype %= 9; fprintf(gpoutfile, "^PW%02d\n", width[linetype + 2]); /* ^width in dots */ switch (type[linetype + 2]) { case 1: /* short dash */ fputs("^PV102025^G\n^V1\n", gpoutfile); /* ^PV = define pattern vector, 1 = pattern number, * 02 = number of pen downs and ups, 025 = .025" length of ups/downs */ break; case 2: /* medium dash */ fputs("^PV202050^G\n^V2\n", gpoutfile); break; case 3: /* long dash */ fputs("^PV302100^G\n^V3\n", gpoutfile); break; default: case 0: fputs("^V0\n", gpoutfile); break; } } TERM_PUBLIC void QMS_move(x, y) unsigned int x, y; { fprintf(gpoutfile, "^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y); /* ^pen up vector*/ } TERM_PUBLIC void QMS_vector(x2, y2) unsigned int x2, y2; { fprintf(gpoutfile, "^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2); /* ^pen down vector*/ } TERM_PUBLIC void QMS_put_text(x, y, str) unsigned int x, y; char str[]; { char ch; QMS_move(x, y + QMS_VCHAR / 3); fputs("^IGE\n", gpoutfile); ch = *str++; while (ch != NUL) { if (ch == '^') putc('^', gpoutfile); putc(ch, gpoutfile); ch = *str++; } fputs("\n^IGV\n", gpoutfile); QMS_linetype(qms_line); /* restore line type */ } TERM_PUBLIC void QMS_reset() { fputs("^PN^-\n", gpoutfile); /* ^QUIC off */ } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(qms_driver) "qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)", QMS_XMAX, QMS_YMAX, QMS_VCHAR, QMS_HCHAR, QMS_VTIC, QMS_HTIC, options_null, QMS_init, QMS_reset, QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector, QMS_linetype, QMS_put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(qms_driver) #undef LAST_TERM #define LAST_TERM qms_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(qms) "1 qms", "?commands set terminal qms", "?set terminal qms", "?set term qms", "?terminal qms", "?term qms", "?qms", " The `qms` terminal driver supports the QMS/QUIC Laser printer, the Talaris", " 1200 and others. It has no options." END_HELP(qms) #endif /* * $Id: regis.trm,v 1.18 1998/04/14 00:18:06 drd Exp $ * */ /* GNUPLOT - regis.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * REGIS devices * * AUTHORS * Colin Kelley, Thomas Williams * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ #include "driver.h" #ifdef TERM_REGISTER register_term(regis) #endif #ifdef TERM_PROTO TERM_PUBLIC void REGISinit __PROTO((void)); TERM_PUBLIC void REGISgraphics __PROTO((void)); TERM_PUBLIC void REGISinit __PROTO((void)); TERM_PUBLIC void REGISgraphics __PROTO((void)); TERM_PUBLIC void REGIStext __PROTO((void)); TERM_PUBLIC void REGISlinetype __PROTO((int linetype)); TERM_PUBLIC void REGISmove __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void REGISvector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void REGISput_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int REGIStext_angle __PROTO((int ang)); TERM_PUBLIC void REGISreset __PROTO((void)); TERM_PUBLIC void REGISoptions __PROTO((void)); #define REGISXMAX 800 #define REGISYMAX 440 #define REGISXLAST (REGISXMAX - 1) #define REGISYLAST (REGISYMAX - 1) #define REGISVCHAR 20 #define REGISHCHAR 9 #define REGISVTIC 8 #define REGISHTIC 6 /* is defined in plot.h #define TRUE 1 #define FALSE 0 */ #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int REGIS16color = FALSE; static int REGISang = 0; TERM_PUBLIC void REGISinit() { fputs("\033[r\033[24;1H", gpoutfile); /* 1 2 * 1. reset scrolling region * 2. locate cursor on bottom line */ } /* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */ TERM_PUBLIC void REGISgraphics() { fputs("\033[2J\033P1pS(C0)S(E)T(A0)\n", gpoutfile); /* 1 2 3 4 5 * 1. clear screen * 2. enter ReGIS graphics * 3. turn off graphics diamond cursor * 4. clear graphics screen * 5. character set option. */ (void) REGIStext_angle(0); /* select text size and angle */ } TERM_PUBLIC void REGIStext() { fputs("\033\\\033[24;1H", gpoutfile); /* 1 2 * 1. Leave ReGIS graphics mode * 2. locate cursor on last line of screen */ } TERM_PUBLIC void REGISlinetype(linetype) int linetype; { /* This will change color in order G,R,B,G-dot,R-dot,B-dot */ static int in_16_map[15 + 2] = { 7, 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; static int lt_16_map[15 + 2] = { 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; static int in_map[9 + 2] = { 2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1 }; static int lt_map[9 + 2] = { 1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6 }; if (!REGIS16color) { if (linetype >= 9) linetype %= 9; fprintf(gpoutfile, "W(I%d)\n", in_map[linetype + 2]); fprintf(gpoutfile, "W(P%d)\n", lt_map[linetype + 2]); } else { if (linetype >= 15) linetype %= 15; fprintf(gpoutfile, "W(I%d)\n", in_16_map[linetype + 2]); fprintf(gpoutfile, "W(P%d)\n", lt_16_map[linetype + 2]); } } /* ** The \n was added in the functions below (and above) in order to not cause ** a buffer overflow in devices that can't deal with long line lengths. ** The DEC vt-340 doesn't need this, but Reflection 4, a vt-340 emulator ** for PC's under MS-DOS and Microsoft Windows does need it. ** Also needed for DECterm, a vt-340 emulator for use with Motif 1.0 ** on Open/VMS. ** NGB 9/13/93 */ TERM_PUBLIC void REGISmove(x, y) unsigned int x, y; { fprintf(gpoutfile, "P[%d,%d]\n", x, REGISYLAST - y); } TERM_PUBLIC void REGISvector(x, y) unsigned int x, y; { fprintf(gpoutfile, "v[]v[%d,%d]\n", x, REGISYLAST - y); /* the initial v[] is needed to get the first pixel plotted */ } /* put_text and text_angle by rjl */ TERM_PUBLIC void REGISput_text(x, y, str) unsigned int x, y; char *str; { if (REGISang == 1) REGISmove(x - REGISVCHAR / 2 - 1, y); else REGISmove(x, y + REGISVCHAR / 2 - 1); (void) putc('T', gpoutfile); (void) putc('\'', gpoutfile); while (*str) { (void) putc(*str, gpoutfile); if (*str == '\'') (void) putc('\'', gpoutfile); /* send out another one */ str++; } (void) putc('\'', gpoutfile); (void) putc('\n', gpoutfile); } TERM_PUBLIC int REGIStext_angle(ang) int ang; { REGISang = ang; if (ang == 1) fputs("T(D90,S1)\n", gpoutfile); else fputs("T(D0,S1)\n", gpoutfile); return TRUE; } TERM_PUBLIC void REGISreset() { fputs("\033[2J\033[24;1H", gpoutfile); } TERM_PUBLIC void REGISoptions() { int i = 0; struct value a; if (!END_OF_COMMAND) { i = (int) real(const_express(&a)); } REGIS16color = (i == 16); sprintf(term_options, "%s", REGIS16color ? "16" : "4"); } #endif #ifdef TERM_TABLE TERM_TABLE_START(regis_driver) "regis", "REGIS graphics language", REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, REGISVTIC, REGISHTIC, REGISoptions, REGISinit, REGISreset, REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector, REGISlinetype, REGISput_text, REGIStext_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(regis_driver) #undef LAST_TERM #define LAST_TERM regis_driver #endif #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(regis) "1 regis", "?commands set terminal regis", "?set terminal regis", "?set term regis", "?terminal regis", "?term regis", "?regis", " The `regis` terminal device generates output in the REGIS graphics language.", " It has the option of using 4 (the default) or 16 colors.", "", " Syntax:", " set terminal regis {4 | 16}" END_HELP(regis) #endif /* * $Id: rgip.trm,v 1.16 1998/04/14 00:18:06 drd Exp $ */ /* GNUPLOT - rgip.trm Uniplex graphics metafile */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * RGIP metafile * * AUTHORS * Hans Olav Eggestad * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * Original for direct RGIP Metafile output. */ /* * Max pixels for X and Y in one window is 10000. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(rgip) register_term(uniplex) #endif #ifdef TERM_PROTO TERM_PUBLIC void RGIP_init __PROTO((void)); TERM_PUBLIC void RGIP_graphics __PROTO((void)); TERM_PUBLIC void RGIP_text __PROTO((void)); TERM_PUBLIC void RGIP_linetype __PROTO((int lt)); TERM_PUBLIC void RGIP_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void RGIP_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC int RGIP_text_angle __PROTO((int ang)); TERM_PUBLIC int RGIP_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void RGIP_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void RGIP_reset __PROTO((void)); TERM_PUBLIC void RGIP_do_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void RGIP_options __PROTO((void)); #define RGIP_X_MAX 10000 #define RGIP_Y_MAX 6700 #define RGIP_FONTSIZE 1 #define RGIP_SC (300) #define RGIP_XMAX 9900 #define RGIP_YMAX 6600 #define RGIP_HTIC (100) #define RGIP_VTIC (100) #define RGIP_VCHAR (RGIP_FONTSIZE*RGIP_SC) #define RGIP_HCHAR (RGIP_VCHAR*3/7) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void RGIP_write_poly __PROTO((void)); static unsigned char *RGIP_cvts __PROTO((unsigned char *str, int *lcnt)); /* static void RGIP_setfont __PROTO((int sz)); */ #include <sys/types.h> #include <sys/stat.h> #define RGIPDOTS 0 #define RGIPMARK 1 #define RGIPTEXT 2 #define RGIPLINE 3 #define RGIPPOLY 4 #define RGIP_MAX_POLY 250 static char *RGIP_Obj[6] = {"DOTS", "MARK", "TEXT", "LINE", "POLY"}; /* * RGIP fontsises range from 1 to 8 */ #define RGIP_FACES 3 #define RGIP_FSTYLES 4 #define RGIP_FSIZES 8 #define RGIP_HELVETICA 0 #define RGIP_TIMES 1 #define RGIP_COURIER 2 #define RGIP_LINE_WIDTHS 8 /* future, currently invisible and visible 0 and 1 */ #define RGIP_LINE_TYPES 8 #define RGIP_COLORS 16 #define RGIP_POINT_TYPES 8 static int RGIP_orgX; /* absolute-pixel-ORIgin of graph. */ static int RGIP_orgY; static int RGIP_orgx; /* absolute-pixel-ORIgin of current plot. */ static int RGIP_orgy; static int RGIP_posx; /* current drawing position (lines). */ static int RGIP_posy; /* static int RGIP_inplot; */ static int RGIP_xmax = RGIP_XMAX; /* width of graph in pixels. */ static int RGIP_ymax = RGIP_YMAX; /* height of graph in pixels. */ static int RGIP_winx = RGIP_XMAX; /* width of graph in pixels. */ static int RGIP_winy = RGIP_YMAX; /* height of graph in pixels. */ /* static int RGIP_blofs; */ /* BaseLine OFfSet from bounding box.*/ static int RGIP_angle = 0; /* 0 for horizontal text, 90 for vertical */ static int RGIP_portrait = 0; /* 0 for horizontal text, 90 for vertical */ static enum JUSTIFY RGIP_justify = LEFT; /* left/center/right */ static int RGIP_fface = 2; /* Times */ static int RGIP_ftype = 1; /* style roman */ static int RGIP_fontsize = RGIP_FONTSIZE; /* */ static int RGIP_tcol = 7; /* text color */ static int RGIP_lsty = 1; /* line style */ static int RGIP_lcol = 7; /* line color */ static int RGIP_lwid = 1; /* line width */ static int RGIP_fsty = 8; /* fill style */ static int RGIP_fcol = 8; /* fill color */ static int RGIP_mcol = 7; /* marker color */ static int RGIP_msty = 1; /* marker style */ static int RGIP_msize = 1; /* marker size */ static int RGIP_win_horiz = 1; static int RGIP_win_verti = 1; static int RGIP_plot_nr = 0; unsigned int RGIP_vecpos; unsigned int RGIP_xvector[RGIP_MAX_POLY]; unsigned int RGIP_yvector[RGIP_MAX_POLY]; static unsigned char *RGIP_cvts(); TERM_PUBLIC void RGIP_init() { register struct termentry *t = term; RGIP_posx = RGIP_posy = 0; if (RGIP_portrait) { RGIP_orgX = (RGIP_Y_MAX - RGIP_YMAX) / 2; RGIP_orgY = (RGIP_X_MAX - RGIP_XMAX) / 2; RGIP_xmax = RGIP_winx = (int) (RGIP_YMAX / RGIP_win_horiz); RGIP_ymax = RGIP_winy = (int) (RGIP_XMAX / RGIP_win_verti); } else { RGIP_orgX = (RGIP_X_MAX - RGIP_XMAX) / 2; RGIP_orgY = (RGIP_Y_MAX - RGIP_YMAX) / 2; RGIP_xmax = RGIP_winx = (int) (RGIP_XMAX / RGIP_win_horiz); RGIP_ymax = RGIP_winy = (int) (RGIP_YMAX / RGIP_win_verti); } t->xmax = (unsigned int) (RGIP_xmax); t->ymax = (unsigned int) (RGIP_ymax); RGIP_vecpos = 0; } TERM_PUBLIC void RGIP_graphics() { static int Gnr = 0; struct stat buf; unsigned char *p, fn[128]; int tmpx, tmpy; /* int xoff, yoff; */ if (RGIP_vecpos) { RGIP_write_poly(); } if (!Gnr || RGIP_plot_nr >= (RGIP_win_horiz * RGIP_win_verti)) { fstat(fileno(gpoutfile), &buf); if (S_ISREG(buf.st_mode)) { if (outstr && (p = (unsigned char *) strchr(outstr, 'X'))) { /* substitute X with graphnr */ if (!Gnr) { /* delete the base file */ unlink(outstr); /* should we close it first ? ? ? */ } else { fputs("%RI_GROUPEND\n", gpoutfile); fclose(gpoutfile); } *p = NUL; sprintf(fn, "%s%1d%s", outstr, ++Gnr, p + 1); if ((gpoutfile = fopen(fn, "w")) == (FILE *) NULL) { os_error("cannot reopen file with binary type; output unknown", NO_CARET); } *p = 'X'; /* put back X */ } } fprintf(gpoutfile, "\ %RGIP_METAFILE: 1.0a\n\ %RI_GROUPSTART\n\ 0 0 %d %d SetWindow\n\ 100 100 %d %d 10 1 7 1 8 BOX\n", (RGIP_portrait) ? RGIP_Y_MAX : RGIP_X_MAX, (RGIP_portrait) ? RGIP_X_MAX : RGIP_Y_MAX, (RGIP_portrait) ? RGIP_YMAX : RGIP_XMAX, (RGIP_portrait) ? RGIP_XMAX : RGIP_YMAX); RGIP_plot_nr = 0; } else { fputs("%RI_GROUPEND\n", gpoutfile); } fputs("%RI_GROUPSTART\n", gpoutfile); RGIP_plot_nr++; /* Gnr++; */ tmpx = RGIP_orgX + ((RGIP_plot_nr - 1) % RGIP_win_horiz) * RGIP_winx; tmpy = RGIP_orgY + ((RGIP_win_verti - 1) - (int) ((RGIP_plot_nr - 1) / RGIP_win_horiz)) * RGIP_winy; RGIP_orgx = tmpx + (int) ((RGIP_winx - RGIP_xmax) / 2); RGIP_orgy = tmpy + (int) ((RGIP_winy - RGIP_ymax) / 2); /* RGIP_linetype(-1); */ } TERM_PUBLIC void RGIP_text() { } TERM_PUBLIC void RGIP_linetype(lt) int lt; { /* int pen, pattern; */ if (RGIP_vecpos) { RGIP_write_poly(); } /* -2: axis * -1: border * 0: arrow * 1-7: graph */ if (lt == -2) { lt = 1; RGIP_lwid = 5; } else if (lt == -1) { lt = 5; RGIP_lwid = 2; } else { RGIP_lwid = (int) (lt / RGIP_LINE_TYPES); if (RGIP_lwid < 1) RGIP_lwid = 1; RGIP_lwid *= 2; lt = (lt % RGIP_LINE_TYPES) + 1; } fputs("%RI_GROUPEND\n\ %RI_GROUPSTART\n", gpoutfile); /* RGIP_lsty = (lt == 0 || lt == 2) ? 1 : lt; */ RGIP_lsty = lt; } TERM_PUBLIC void RGIP_move(x, y) unsigned int x, y; { /* fputs("%RI_GROUPEND\n", gpoutfile); fputs("%RI_GROUPSTART\n", gpoutfile); */ if (RGIP_vecpos) { RGIP_write_poly(); } RGIP_xvector[0] = x + RGIP_orgx; RGIP_yvector[0] = y + RGIP_orgy; RGIP_vecpos = 1; /* RGIP_posx = x; RGIP_posy = y; */ } TERM_PUBLIC void RGIP_vector(ux, uy) unsigned int ux, uy; { /* store polygon-node */ RGIP_xvector[RGIP_vecpos] = ux + RGIP_orgx; RGIP_yvector[RGIP_vecpos] = uy + RGIP_orgy; RGIP_vecpos++; if (RGIP_vecpos >= RGIP_MAX_POLY) { RGIP_write_poly(); RGIP_xvector[RGIP_vecpos] = ux + RGIP_orgx; RGIP_yvector[RGIP_vecpos] = uy + RGIP_orgy; RGIP_vecpos++; } } void RGIP_write_poly() { register int i; putc('[', gpoutfile); for (i = 0; i < RGIP_vecpos; i++) { if (!(i % 8)) putc('\n', gpoutfile); fprintf(gpoutfile, " %1d\ %1d", RGIP_xvector[i], RGIP_yvector[i]); } RGIP_vecpos = 0; putc(']', gpoutfile); fprintf(gpoutfile, " %1d %d %1d %1d %1d %s\n", RGIP_lwid, RGIP_lsty, RGIP_lcol, RGIP_fsty, RGIP_fcol, RGIP_Obj[RGIPPOLY]); /* RGIP_posx = ux; RGIP_posy = uy; */ /* RGIP_move(ux, uy); */ } TERM_PUBLIC int RGIP_text_angle(ang) int ang; { if (RGIP_vecpos) { RGIP_write_poly(); } if (RGIP_angle != ang) { RGIP_angle = ang; /* record for later use */ } return (TRUE); } TERM_PUBLIC int RGIP_justify_text(mode) enum JUSTIFY mode; { if (RGIP_vecpos) { RGIP_write_poly(); } RGIP_justify = mode; return (TRUE); } static unsigned char *RGIP_cvts(str, lcnt) unsigned char *str; int *lcnt; /* lines */ { unsigned char *cp1; unsigned char *cp2; static unsigned char *buf = NULL; int lc = 1; lc = 1; /* Free up old buffer, if there is one, get a new one. Since */ /* all transformations shorten the string, get a buffer that is */ /* the same size as the input string. */ if (buf != NULL) (void) free(buf); buf = (unsigned char *) gp_alloc(strlen(str), "converted label string"); /* Do the transformations. */ cp1 = str; cp2 = buf; while (strlen(cp1) > 0) { switch (*cp1) { case '\\': /* Escape sequence. */ if (*++cp1 == '\\') { /* Begin new line. */ *cp2++ = '\n'; lc++; break; } case '(': *cp2++ = '\\'; *cp2++ = '('; break; case ')': *cp2++ = '\\'; *cp2++ = ')'; break; /* Fall through to just copy next char out. */ default: *cp2++ = *cp1; break; } cp1++; } *cp2++ = '\n'; *cp2 = NUL; *lcnt = lc; return (buf); } TERM_PUBLIC void RGIP_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char *str; /* the text */ { register struct termentry *t = term; unsigned char *cvstr, *p; int xlines; /* lines */ if (RGIP_vecpos) { RGIP_write_poly(); } cvstr = RGIP_cvts(str, &xlines); x += RGIP_orgx, y += RGIP_orgy; if (!RGIP_angle) { /* horisontal */ y += (int) (t->v_char) * (xlines - 2) / 2; /* y += (t->v_char)*xlines; */ y += (int) (t->v_char) / 4; } else { x -= (int) (t->v_char) * (xlines - 2) / 2; x -= (int) (t->v_char) / 4; } while ((p = (unsigned char *) strchr(cvstr, '\n'))) { *p = '\0'; if (strlen(cvstr)) fprintf(gpoutfile, "%1d %1d %1d %1d (%s) %1d %1d %1d %1d %s\n", x, y, RGIP_justify, RGIP_angle * 90, cvstr, RGIP_fface, RGIP_ftype, RGIP_fontsize, RGIP_tcol, RGIP_Obj[RGIPTEXT]); cvstr = ++p; if (RGIP_angle) { /* vertical */ x += (t->v_char); } else { y -= (t->v_char); } } } TERM_PUBLIC void RGIP_reset() { if (RGIP_vecpos) { RGIP_write_poly(); } fputs("%RI_GROUPEND\n", gpoutfile); /* fputs("%RI_GROUPEND\n", gpoutfile); */ } /* static void RGIP_setfont(sz) int sz; { RGIP_fontsize = (int) (sz); if ( RGIP_fontsize < 1 ) RGIP_fontsize = 1; term->v_char = (unsigned int)(RGIP_fontsize*RGIP_SC); term->h_char = (unsigned int)(RGIP_fontsize*RGIP_SC*3/7); } */ TERM_PUBLIC void RGIP_do_point(x, y, number) unsigned int x, y; int number; { x += RGIP_orgx, y += RGIP_orgy; if (number < 0) { /* do dot */ fprintf(gpoutfile, "%1d %1d %1d %s\n", x, y, RGIP_mcol, RGIP_Obj[RGIPDOTS]); return; } RGIP_msty = (number % RGIP_POINT_TYPES) + 1; RGIP_msize = ((int) (number / RGIP_POINT_TYPES)) + 1; fprintf(gpoutfile, "%1d %1d %1d %1d %1d %s\n", x, y, RGIP_msize, RGIP_msty, RGIP_mcol, RGIP_Obj[RGIPMARK]); } TERM_PUBLIC void RGIP_options() { struct value a; while (!END_OF_COMMAND) { if (almost_equals(c_token, "p$ortrait")) { RGIP_portrait = TRUE; c_token++; } else if (almost_equals(c_token, "l$andscape")) { RGIP_portrait = FALSE; c_token++; } else if (equals(c_token, "[")) { /* windows spesified */ c_token++; /* if (RGIP_plot_nr>1) */ if (equals(c_token, "]")) { /* RGIP_page(); */ c_token++; continue; } if (END_OF_COMMAND) { int_error("no. windows: [horizontal,vertical] expected", c_token); } else if (!equals(c_token, ",")) { RGIP_win_horiz = (int) real(const_express(&a)); } if (!equals(c_token, ",")) int_error("',' expected", c_token); c_token++; if (!equals(c_token, "]")) { RGIP_win_verti = (int) real(const_express(&a)); } if (!equals(c_token, "]")) int_error("expecting ']'", c_token); c_token++; } else { /* We have font size specified */ RGIP_fontsize = (int) real(const_express(&a)); if (RGIP_fontsize < 1) RGIP_fontsize = 1; term->v_char = (unsigned int) (RGIP_fontsize * RGIP_SC); term->h_char = (unsigned int) (RGIP_fontsize * RGIP_SC * 3 / 7); } } sprintf(term_options, "%s %d [%1d,%1d]", (RGIP_portrait) ? "portrait" : "landscape", RGIP_fontsize, RGIP_win_horiz, RGIP_win_verti); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(rgip_driver) "rgip", "RGIP metafile (Uniplex). Option: fontsize (1-8)", RGIP_XMAX, RGIP_YMAX, RGIP_VCHAR, RGIP_HCHAR, RGIP_VTIC, RGIP_HTIC, RGIP_options, RGIP_init, RGIP_reset, RGIP_text, null_scale, RGIP_graphics, RGIP_move, RGIP_vector, RGIP_linetype, RGIP_put_text, RGIP_text_angle, RGIP_justify_text, RGIP_do_point, do_arrow, set_font_null TERM_TABLE_END(rgip_driver) #undef LAST_TERM #define LAST_TERM rgip_driver TERM_TABLE_START(uniplex_driver) "uniplex", "RGIP metafile (Uniplex). Option: fontsize (1-8) (Same as rgip)", RGIP_XMAX, RGIP_YMAX, RGIP_VCHAR, RGIP_HCHAR, RGIP_VTIC, RGIP_HTIC, RGIP_options, RGIP_init, RGIP_reset, RGIP_text, null_scale, RGIP_graphics, RGIP_move, RGIP_vector, RGIP_linetype, RGIP_put_text, RGIP_text_angle, RGIP_justify_text, RGIP_do_point, do_arrow, set_font_null TERM_TABLE_END(uniplex_driver) #undef LAST_TERM #define LAST_TERM uniplex_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(rgip) "1 rgip", "?commands set terminal rgip", "?set terminal rgip", "?set term rgip", "?terminal rgip", "?term rgip", "?rgip", "?commands set terminal uniplex", "?set terminal uniplex", "?set term uniplex", "?terminal uniplex", "?term uniplex", "?uniplex", " The `rgip` and `uniplex` terminal drivers support RGIP metafiles. They can", " combine several graphs on a single page, but only one page is allowed in a", " given output file.", "", " Syntax:", " set terminal rgip | uniplex {portrait | landscape}", " {[<horiz>,<vert>]} {<fontsize>}", "", " permissible values for the font size are in the range 1--8, with the default", " being 1. The default layout is landscape. Graphs are placed on the page in", " a `horiz`x`vert` grid, which defaults to [1,1].", "", " Example:", " set terminal uniplex portrait [2,3]", "", " puts six graphs on a page in three rows of two in portrait orientation." END_HELP(rgip) #endif /* TERM_HELP */ /* * $Id: sun.trm,v 1.15 1998/04/14 00:18:07 drd Exp $ * */ /* GNUPLOT - sun.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * SUNview windowing system * * AUTHORS * Maurice Castro * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(sun) #endif #ifdef TERM_PROTO TERM_PUBLIC void SUN_init __PROTO((void)); TERM_PUBLIC void SUN_graphics __PROTO((void)); TERM_PUBLIC void SUN_text __PROTO((void)); TERM_PUBLIC void SUN_linetype __PROTO((int linetype)); TERM_PUBLIC void SUN_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void SUN_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void SUN_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int SUN_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void SUN_reset __PROTO((void)); #define SUN_XMAX 600 #define SUN_YMAX 512 #define SUN_VCHAR (12) /* default, will be changed */ #define SUN_HCHAR (8) /* default, will be changed */ #define SUN_VTIC (SUN_YMAX/80) #define SUN_HTIC (SUN_XMAX/80) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #include <suntool/sunview.h> #include <suntool/canvas.h> #include <suntool/scrollbar.h> #include <suntool/panel.h> #include <pixrect/pixrect_hs.h> void sun_setmaskpixel __PROTO((unsigned int x, unsigned int y, unsigned int value)); void sun_line __PROTO((unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2)); static Notify_value local_notice_destroy __PROTO((Frame frame, Destroy_status status)); #define MARGIN 5 #define MINWIN 128 static Frame frame; static Canvas canvas; static Pixwin *pw; static struct pixfont *sun_font = NULL; static enum JUSTIFY sun_justify = LEFT; static Notify_value local_notice_destroy(); extern Notify_error notify_dispatch(); /* dotted line generator */ unsigned int sun_value = 1; /* this can be used for colour */ unsigned int sun_line_mask = 0xffff; /* 16 bit mask for dotted lines */ static unsigned int sun_pattern[] = {0xffff, 0x1111, 0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f}; int sun_mask_count = 0; unsigned int sun_lastx, sun_lasty; /* last pixel set - used by sun_line */ TERM_PUBLIC void SUN_init() { struct termentry *t = term; struct pr_subregion bound; frame = window_create(NULL, FRAME, FRAME_LABEL, "Gnuplot", 0); notify_interpose_destroy_func(frame, local_notice_destroy); canvas = window_create(frame, CANVAS, CANVAS_AUTO_EXPAND, TRUE, CANVAS_AUTO_SHRINK, TRUE, CANVAS_MARGIN, MARGIN, 0); notify_do_dispatch(); pw = canvas_pixwin(canvas); window_set(frame, WIN_SHOW, TRUE, 0); /* figure out font and rough size */ sun_font = pf_default(); pf_textbound(&bound, 1, sun_font, "M"); t->v_char = bound.size.y; t->h_char = bound.size.x; return; } TERM_PUBLIC void SUN_graphics() { term->xmax = (int) window_get(canvas, CANVAS_WIDTH); term->ymax = (int) window_get(canvas, CANVAS_HEIGHT); pw_writebackground(pw, 0, 0, term->xmax, term->ymax, PIX_SRC); notify_dispatch(); /* do not let the user make the window too small */ if ((term->xmax) < MINWIN) { window_set(frame, WIN_WIDTH, MINWIN + 2 * MARGIN + 24, 0); notify_dispatch(); SUN_graphics(); } if ((term->ymax) < MINWIN) { window_set(frame, WIN_HEIGHT, MINWIN + 2 * MARGIN + 24, 0); notify_dispatch(); SUN_graphics(); } notify_dispatch(); return; } TERM_PUBLIC void SUN_text() { notify_dispatch(); return; /* enter text from another window!!! */ } TERM_PUBLIC void SUN_linetype(linetype) int linetype; { if (linetype >= 7) linetype %= 7; sun_line_mask = sun_pattern[linetype + 2]; sun_mask_count = 0; } TERM_PUBLIC void SUN_move(x, y) unsigned int x, y; { sun_lastx = x; sun_lasty = y; notify_dispatch(); return; } TERM_PUBLIC void SUN_vector(x, y) unsigned int x, y; { if ((x >= term->xmax) || (y >= term->ymax)) return; sun_line(sun_lastx, x, sun_lasty, y); canvas_pixwin(canvas); notify_dispatch(); return; } TERM_PUBLIC void SUN_put_text(x, y, str) unsigned int x, y; char *str; { struct pr_subregion bound; if ((x >= term->xmax) || (y >= term->ymax)) return; pf_textbound(&bound, strlen(str), sun_font, str); y = term->ymax - 1 - y + bound.size.y / 3; /* vertical centering */ switch (sun_justify) { case LEFT: break; case CENTRE: x -= bound.size.x / 2; break; case RIGHT: x -= bound.size.x; break; } pw_text(pw, x, y, PIX_SRC | PIX_DST, 0, str); canvas_pixwin(canvas); notify_dispatch(); return; } TERM_PUBLIC int SUN_justify_text(mode) enum JUSTIFY mode; { sun_justify = mode; return (TRUE); } TERM_PUBLIC void SUN_reset() { term->xmax = SUN_XMAX; term->ymax = SUN_YMAX; window_set(frame, WIN_SHOW, FALSE, 0); return; } void sun_setmaskpixel(x, y, value) unsigned int x, y, value; { /* dotted line generator */ if ((sun_line_mask >> sun_mask_count) & (unsigned int) (1)) { pw_put(pw, x, term->ymax - 1 - y, sun_value); } sun_mask_count = (sun_mask_count + 1) % 16; sun_lastx = x; /* last pixel set with mask */ sun_lasty = y; } void sun_line(x1, x2, y1, y2) unsigned int x1, x2, y1, y2; { int runcount; int dx, dy; int xinc, yinc; unsigned int xplot, yplot; runcount = 0; dx = ABS((int) (x1) - (int) (x2)); if (x2 > x1) xinc = 1; if (x2 == x1) xinc = 0; if (x2 < x1) xinc = -1; dy = ABS((int) (y1) - (int) (y2)); if (y2 > y1) yinc = 1; if (y2 == y1) yinc = 0; if (y2 < y1) yinc = -1; xplot = x1; yplot = y1; if (dx > dy) { /* iterate x */ if ((sun_line_mask == 0xffff) || ((xplot != sun_lastx) && (yplot != sun_lasty))) sun_setmaskpixel(xplot, yplot, sun_value); while (xplot != x2) { xplot += xinc; runcount += dy; if (runcount >= (dx - runcount)) { yplot += yinc; runcount -= dx; } sun_setmaskpixel(xplot, yplot, sun_value); } } else { /* iterate y */ if ((sun_line_mask == 0xffff) || ((xplot != sun_lastx) && (yplot != sun_lasty))) sun_setmaskpixel(xplot, yplot, sun_value); while (yplot != y2) { yplot += yinc; runcount += dx; if (runcount >= (dy - runcount)) { xplot += xinc; runcount -= dy; } sun_setmaskpixel(xplot, yplot, sun_value); } } } static Notify_value local_notice_destroy(frame, status) Frame frame; Destroy_status status; { if (status != DESTROY_CHECKING) { SUN_reset(); /* extern TBOOLEAN term_init is gone; is it sufficient just */ /* to comment it out? -lh */ /* term_init = FALSE; */ } return (NOTIFY_DONE); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(sun_driver) "sun", "SunView window system", SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR, SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset, SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector, SUN_linetype, SUN_put_text, null_text_angle, SUN_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(sun_driver) #undef LAST_TERM #define LAST_TERM sun_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(sun) "1 sun", "?commands set terminal sun", "?set terminal sun", "?set term sun", "?terminal sun", "?term sun", "?sun", " The `sun` terminal driver supports the SunView window system. It has no", " options." END_HELP(sun) #endif /* * $Id: t410x.trm,v 1.16 1998/04/14 00:18:07 drd Exp $ * */ /* GNUPLOT - t410x.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: Tektronix 410x and 420x series terminals * * AUTHORS * Colin Kelley, Thomas Williams * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* Tektronix 410X and 420X driver written by Cary D. Renzema. * email address: caryr@mxim.com * * I've tested this driver on the following terminals: 4106, 4107A, 4109 * and 4207. It should work, without editing, on other terminals in the * 410x and 420x families. It will probably need to be changed to work * on a 4105 (screen size and character rotation are two guesses). This * file can also be used as a start for a 411x driver. * * Cary R. * April 5, 1990 */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(tek410x) #endif #ifdef TERM_PROTO TERM_PUBLIC void T410X_init __PROTO((void)); TERM_PUBLIC void T410X_reset __PROTO((void)); TERM_PUBLIC void T410X_graphics __PROTO((void)); TERM_PUBLIC void T410X_text __PROTO((void)); TERM_PUBLIC void T410X_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void T410X_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void T410X_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void T410X_linetype __PROTO((int linetype)); TERM_PUBLIC void T410X_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int T410X_text_angle __PROTO((int ang)); #define T410XXMAX 4095 #define T410XYMAX 3131 #define T410XVCHAR 71 #define T410XHCHAR 51 #define T410XVTIC 36 #define T410XHTIC 36 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void T410X_encode_x_y __PROTO((unsigned int x, unsigned int y)); void T410X_encode_int __PROTO((int number)); static int T410X_angle = 0; TERM_PUBLIC void T410X_init() { fputs("\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1", gpoutfile); fputs("\033MG1\033RK!\033SK!\033LZ\033%%!1", gpoutfile); /* 1. set tek mode 2. set character path to 0 (characters placed equal to rotation) 3. set character size to 59 height 4. set character precision to string 5. set character text index to 1 6. set character write mode to overstrike 7. clear the view 8. clear the segments 9. clear the dialog buffer 10. set ansi mode */ (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_reset() { fputs("\033%%!0\033LZ\033%%!1", gpoutfile); /* 1. set tek mode 2. clear the dialog buffer 3. set ansi mode */ (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_graphics() { fputs("\033%%!0\033\014\033LV0", gpoutfile); /* 1. set tek mode 2. clear the screen 3. set dialog area invisible */ (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_text() { fputs("\033LV1\033%%!1", gpoutfile); /* 1. set dialog area visible 2. set ansi mode */ (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_move(x, y) unsigned int x, y; { fputs("\033LF", gpoutfile); (void) T410X_encode_x_y(x, y); (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_vector(x, y) unsigned int x, y; { fputs("\033LG", gpoutfile); (void) T410X_encode_x_y(x, y); (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_point(x, y, number) unsigned int x, y; int number; { fputs("\033MM", gpoutfile); (void) T410X_encode_int(GPMAX(number, 0) % 11); fputs("\033LH", gpoutfile); (void) T410X_encode_x_y(x, y); (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_linetype(linetype) int linetype; { switch (linetype) { case -1: fputs("\033ML5", gpoutfile); break; case -2: fputs("\033ML?", gpoutfile); break; default: fputs("\033ML", gpoutfile); (void) T410X_encode_int(linetype % 14 + 2); break; } fputs("\033MV", gpoutfile); (void) T410X_encode_int(GPMAX(linetype, 0) % 8); (void) fflush(gpoutfile); } TERM_PUBLIC void T410X_put_text(x, y, str) unsigned int x, y; char str[]; { if (T410X_angle == 0) { (void) T410X_move(x, y - T410XVCHAR / 2 + 6); fputs("\033MR00", gpoutfile); } else { (void) T410X_move(x + T410XHCHAR / 2 - 6, y); fputs("\033MRE:0", gpoutfile); } (void) fputs("\033LT", gpoutfile); (void) T410X_encode_int(strlen(str)); (void) fputs(str, gpoutfile); (void) fflush(gpoutfile); } TERM_PUBLIC int T410X_text_angle(ang) int ang; { T410X_angle = ang; return (TRUE); } /* These last two routines are based on fortran code found in the * 4106/4107/4109/CX PROGRAMMERS manual. */ void T410X_encode_x_y(x, y) unsigned int x, y; { static char chix = 0, chiy = 0, cloy = 0, ceb = 0; register unsigned int hix, lox, hiy, loy, eb, lx, ly; lx = (x <= T410XXMAX) ? x : T410XXMAX; ly = (y <= T410XYMAX) ? y : T410XYMAX; hix = lx / 128 + 32; lox = (lx / 4) % 32 + 64; hiy = ly / 128 + 32; loy = (ly / 4) % 32 + 96; eb = (ly % 4) * 4 + lx % 4 + 96; if (chiy != hiy) (void) putc(hiy, gpoutfile); if (ceb != eb) (void) putc(eb, gpoutfile); if ((cloy != loy) || (ceb != eb) || (chix != hix)) (void) putc(loy, gpoutfile); if (chix != hix) (void) putc(hix, gpoutfile); (void) putc(lox, gpoutfile); chix = hix; chiy = hiy; cloy = loy; ceb = eb; } void T410X_encode_int(number) int number; { register unsigned int mag, hi1, hi2, lo; mag = ABS(number); hi1 = mag / 1024 + 64; hi2 = (mag / 16) % 64 + 64; lo = mag % 16 + 32; if (number >= 0) lo += 16; if (hi1 != 64) (void) putc(hi1, gpoutfile); if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, gpoutfile); (void) putc(lo, gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(tek410x_driver) "tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals", T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, T410X_linetype, T410X_put_text, T410X_text_angle, null_justify_text, T410X_point, do_arrow, set_font_null TERM_TABLE_END(tek410x_driver) #undef LAST_TERM #define LAST_TERM tek410x_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(tek410x) "1 tek410x", "?commands set terminal tek410x", "?set terminal tek410x", "?set term tek410x", "?terminal tek410x", "?term tek410x", "?tek410x", " The `tek410x` terminal driver supports the 410x and 420x family of Tektronix", " terminals. It has no options." END_HELP(tek410x) #endif /* * $Id: table.trm,v 1.5 1998/06/18 14:59:25 ddenholm Exp $ * */ /* GNUPLOT - table.trm */ /*[ * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * The terminal 'table' is built into the source code; it is not * available separately. This file is needed only for building * the documentation for gnuplot 3.6 (or higher) using the new * including mechanismn. */ #ifdef TERM_REGISTER register_term(table) #endif #ifdef TERM_HELP START_HELP(table) "1 table", "?commands set terminal table", "?set terminal table", "?set term table", "?terminal table", "?term table", "?table", " Instead of producing a graph, the `table` terminal prints out the points on", " which a graph would be based, i.e., the results of processing the `plot` or", " `splot` command, in a multicolumn ASCII table of X Y {Z} R values. The", " character R takes on one of three values: \"i\" if the point is in the active", " range, \"o\" if it is out-of-range, or \"u\" if it is undefined. The data", " format is determined by the format of the axis labels (see `set format`).", "", " For those times when you want the numbers, you can display them on the", " screen or save them to a file. This can be useful if you want to generate", " contours and then save them for further use, perhaps for plotting with", " `plot`; see `set contour` for an example. The same method can be used to", " save interpolated data (see `set samples` and `set dgrid3d`)." END_HELP(table) #endif /* * $Id: tek.trm,v 1.20 1998/04/14 00:18:07 drd Exp $ * */ /* GNUPLOT - tek.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * tek40xx, bitgraph, kermit_color_tek40xx, kermit_mono_tek40xx, selanar * ln03plus * * AUTHORS * Colin Kelley, Thomas Williams, Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * Modified June 1995 Ian MacPhedran to support newterm format */ #define TEK #define CTEK #define VTTEK #define KERMIT #define SELANAR #define BITGRAPH #include "driver.h" #ifdef TERM_REGISTER register_term(tek40) #ifdef VTTEK register_term(vttek) #endif #ifdef KERMIT register_term(kc_tek40) register_term(km_tek40) #endif #ifdef SELANAR register_term(selanar) #endif #ifdef BITGRAPH register_term(bitgraph) #endif #endif /* TERM_REGISTER */ #ifdef TERM_PROTO TERM_PUBLIC void TEK40init __PROTO((void)); TERM_PUBLIC void TEK40graphics __PROTO((void)); TERM_PUBLIC void TEK40text __PROTO((void)); TERM_PUBLIC void TEK40linetype __PROTO((int linetype)); TERM_PUBLIC void TEK40move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void TEK40vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void TEK40put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void TEK40reset __PROTO((void)); TERM_PUBLIC void BG_text __PROTO((void)); TERM_PUBLIC void BG_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void KTEK40graphics __PROTO((void)); TERM_PUBLIC void KTEK40Ctext __PROTO((void)); TERM_PUBLIC void KTEK40Clinetype __PROTO((int linetype)); TERM_PUBLIC void KTEK40Mlinetype __PROTO((int linetype)); TERM_PUBLIC void KTEK40reset __PROTO((void)); TERM_PUBLIC void SEL_init __PROTO((void)); TERM_PUBLIC void SEL_graphics __PROTO((void)); TERM_PUBLIC void SEL_text __PROTO((void)); TERM_PUBLIC void SEL_reset __PROTO((void)); TERM_PUBLIC void VTTEK40init __PROTO((void)); TERM_PUBLIC void VTTEK40reset __PROTO((void)); TERM_PUBLIC void VTTEK40linetype __PROTO((int linetype)); TERM_PUBLIC void VTTEK40put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void CTEK_linetype __PROTO((int linetype)); TERM_PUBLIC void CTEK_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void CTEK_vector __PROTO((unsigned int x, unsigned int y)); #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #ifdef TEK #define TEK40XMAX 1024 #define TEK40YMAX 780 #define TEK40XLAST (TEK40XMAX - 1) #define TEK40YLAST (TEK40YMAX - 1) #define TEK40VCHAR 25 #define TEK40HCHAR 14 #define TEK40VTIC 11 #define TEK40HTIC 11 #define HX 0x20 /* bit pattern to OR over 5-bit data */ #define HY 0x20 #define LX 0x40 #define LY 0x60 #define LOWER5 31 #define UPPER5 (31<<5) TERM_PUBLIC void TEK40init() { } TERM_PUBLIC void TEK40graphics() { #ifdef VMS term_pasthru(); #endif /* VMS */ fputs("\033\014", gpoutfile); /* 1 1. clear screen */ (void) fflush(gpoutfile); sleep(1); /* sleep 1 second to allow screen time to clear on real tektronix terminals */ } TERM_PUBLIC void TEK40text() { #ifdef VMS (void) fflush(gpoutfile); /* finish the graphics */ #endif TEK40move(0, 12); fputs("\037", gpoutfile); /* 1 1. into alphanumerics */ #ifdef VMS term_nopasthru(); #endif /* VMS */ } TERM_PUBLIC void TEK40linetype(linetype) int linetype; { } TERM_PUBLIC void TEK40move(x, y) unsigned int x, y; { (void) putc('\035', gpoutfile); /* into graphics */ TEK40vector(x, y); } TERM_PUBLIC void TEK40vector(x, y) unsigned int x, y; { (void) putc((HY | (y & UPPER5) >> 5), gpoutfile); (void) putc((LY | (y & LOWER5)), gpoutfile); (void) putc((HX | (x & UPPER5) >> 5), gpoutfile); (void) putc((LX | (x & LOWER5)), gpoutfile); } TERM_PUBLIC void TEK40put_text(x, y, str) unsigned int x, y; char str[]; { TEK40move(x, y - 11); fprintf(gpoutfile, "\037%s\n", str); } TERM_PUBLIC void TEK40reset() { } #endif /* TEK */ /* thanks to dukecdu!evs (Ed Simpson) for the BBN BitGraph driver */ #ifdef BITGRAPH #define BG_XMAX 768 /* width of plot area */ #define BG_YMAX 768 /* height of plot area */ #define BG_SCREEN_HEIGHT 1024 /* full screen height */ #define BG_XLAST (BG_XMAX - 1) #define BG_YLAST (BG_YMAX - 1) #define BG_VCHAR 16 #define BG_HCHAR 9 #define BG_VTIC 8 #define BG_HTIC 8 #define BG_init TEK40init #define BG_graphics TEK40graphics #define BG_linetype TEK40linetype #define BG_move TEK40move #define BG_vector TEK40vector TERM_PUBLIC void BG_text() { #ifdef VMS (void) fflush(gpoutfile); /* finish the graphics */ #endif BG_move(0, BG_SCREEN_HEIGHT - 2 * BG_VCHAR); fputs("\037", gpoutfile); /* 1 1. into alphanumerics */ } TERM_PUBLIC void BG_put_text(x, y, str) unsigned int x, y; char str[]; { BG_move(x, y - 11); fprintf(gpoutfile, "\037%s\n", str); } #define BG_reset TEK40reset #endif /* BITGRAPH */ /* Color and Monochrome specials for the MS-DOS Kermit Tektronix Emulator by Russell Lang, eln272v@monu1.cc.monash.oz */ #ifdef KERMIT #define KTEK40HCHAR 13 TERM_PUBLIC void KTEK40graphics() { #ifdef VMS term_mode_tek(); term_pasthru(); #endif /* VMS */ fputs("\033\014", gpoutfile); /* 1 1. clear screen */ /* kermit tektronix emulation doesn't need to wait */ } TERM_PUBLIC void KTEK40Ctext() { TEK40text(); KTEK40Clinetype(0); /* change to green */ #ifdef VMS term_nopasthru(); #endif /* VMS */ } /* special color linetypes for MS-DOS Kermit v2.31 tektronix emulator */ /* 0 = normal, 1 = bright foreground color (30-37) = 30 + colors where colors are 1=red, 2=green, 4=blue */ static char *kermit_color[15] = {"\033[0;37m", "\033[1;30m", "\033[0;32m", "\033[0;36m", "\033[0;31m", "\033[0;35m", "\033[1;34m", "\033[1;33m", "\033[1;31m", "\033[1;37m", "\033[1;35m", "\033[1;32m", "\033[1;36m", "\033[0;34m", "\033[0;33m"}; TERM_PUBLIC void KTEK40Clinetype(linetype) int linetype; { if (linetype >= 13) linetype %= 13; fprintf(gpoutfile, "%s", kermit_color[linetype + 2]); } /* linetypes for MS-DOS Kermit v2.30 tektronix emulator */ /* `=solid, a=fine dots, b=short dashes, c=dash dot, d=long dash dot, e=dash dot dot */ static char *kerm_linetype = "`a`abcde"; TERM_PUBLIC void KTEK40Mlinetype(linetype) int linetype; { if (linetype >= 6) linetype %= 6; fprintf(gpoutfile, "\033%c", kerm_linetype[linetype + 2]); } TERM_PUBLIC void KTEK40reset() { fputs("\030\n", gpoutfile); /* turn off Tek emulation */ #ifdef VMS term_mode_native(); #endif /* VMS */ } #endif /* KERMIT */ /* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the Selanar driver */ #ifdef SELANAR TERM_PUBLIC void SEL_init() { fputs("\033\062", gpoutfile); /* 1 1. set to ansi mode */ } TERM_PUBLIC void SEL_graphics() { fputs("\033[H\033[J\033\061\033\014", gpoutfile); /* 1 2 3 1. clear ANSI screen 2. set to TEK mode 3. clear screen */ #ifdef VMS term_pasthru(); #endif /* VMS */ } TERM_PUBLIC void SEL_text() { #ifdef VMS (void) fflush(gpoutfile); /* finish the graphics */ #endif TEK40move(0, 12); fputs("\033\062", gpoutfile); /* 1 1. into ANSI mode */ #ifdef VMS term_nopasthru(); #endif /* VMS */ } TERM_PUBLIC void SEL_reset() { fputs("\033\061\033\012\033\062\033[H\033[J", gpoutfile); /* 1 2 3 4 1 set tek mode 2 clear screen 3 set ansi mode 4 clear screen */ } #endif /* SELANAR */ #ifdef VTTEK TERM_PUBLIC void VTTEK40init() { fputs("\033[?38h", gpoutfile); fflush(gpoutfile); sleep(1); /* sleep 1 second to allow screen time to clear on some terminals */ #ifdef VMS term_mode_tek(); #endif /* VMS */ } TERM_PUBLIC void VTTEK40reset() { fputs("\033[?38l", gpoutfile); fflush(gpoutfile); sleep(1); /* sleep 1 second to allow screen time to clear on some terminals */ #ifdef VMS term_mode_native(); #endif /* VMS */ } /* linetypes for VT-type terminals in tektronix emulator mode */ /* `=solid, a=fine dots, b=short dashes, c=dash dot, d=long dash dot, h=bold solid, i=bold fine dots, j=bold short dashes, k=bold dash dot, l=bold long dash dot */ static char *vt_linetype = "`a`abcdhijkl"; static int last_vt_linetype = 0; TERM_PUBLIC void VTTEK40linetype(linetype) int linetype; { if (linetype >= 10) linetype %= 10; fprintf(gpoutfile, "\033%c", vt_linetype[linetype + 2]); last_vt_linetype = linetype; } TERM_PUBLIC void VTTEK40put_text(x, y, str) unsigned int x, y; char str[]; { int linetype; linetype = last_vt_linetype; VTTEK40linetype(0); TEK40put_text(x, y, str); VTTEK40linetype(linetype); } #endif /* VTTEK */ #ifdef LN03P TERM_PUBLIC void LN03Pinit() { fputs("\033[?38h", gpoutfile); } TERM_PUBLIC void LN03Preset() { fputs("\033[?38l", gpoutfile); } #endif /* LN03P */ /* tek40xx (monochrome) with linetype support by Jay I. Choe */ #ifdef CTEK /*#define ABS(A) (((A)>=0)? (A):-(A))*/ #define SIGN(A) (((A) >= 0)? 1:-1) static void CT_solid_vector __PROTO((int x, int y)); static void CT_draw_vpoint __PROTO((int x, int y, int last)); static void CT_pattern_vector __PROTO((int x1, int y1)); /* CT_lines are line types defined as bit pattern */ static unsigned long CT_lines[] = {0xffffffff, /* solid line */ 0x000fffff, /* long dash */ 0x00ff00ff, /* short dash */ 0x00f00fff, /* dash-dot */ 0x00f07fff, /* long dash - dot */ 0x07070707, 0x07ff07ff, 0x070707ff}; /* current line pattern */ static unsigned long *CT_pattern = &CT_lines[0]; /* we need to keep track of tek cursor location */ static int CT_last_linetype = 0, CT_last_x, CT_last_y; TERM_PUBLIC void CTEK_linetype(linetype) int linetype; { if (linetype < 0) linetype = 0; linetype %= (sizeof(CT_lines) / sizeof(unsigned long)); CT_pattern = &CT_lines[linetype]; CT_last_linetype = linetype; } TERM_PUBLIC void CTEK_move(x, y) unsigned int x; unsigned int y; { TEK40move(x, y); CT_last_x = x; CT_last_y = y; } static void CT_solid_vector(x, y) int x; int y; { TEK40vector(x, y); CT_last_x = x; CT_last_y = y; } /* simulate pixel draw using tek vector draw. delays actual line drawing until maximum line segment is determined (or first/last point is defined) */ static int CT_penon = 0; /* is Pen on? */ static void CT_draw_vpoint(x, y, last) int x; int y; int last; { static int xx0, yy0, xx1, yy1; if ((*CT_pattern) & 1) { if (CT_penon) { /* This point is a continuation of current line */ xx1 = x; yy1 = y; } else { /* beginning of new line */ xx0 = xx1 = x; yy0 = yy1 = y; CT_penon = 1; } *CT_pattern = ((*CT_pattern) >> 1) | 0x80000000; /* rotate the pattern */ if (last) { /* draw the line anyway if this is the last point */ TEK40move(xx0, yy0); TEK40vector(xx1, yy1); CT_penon = 0; } } else { /* do not draw this pixel */ if (CT_penon) { /* last line segment ended at the previous pixel. */ /* draw the line */ TEK40move(xx0, yy0); TEK40vector(xx1, yy1); CT_penon = 0; } *CT_pattern = (*CT_pattern) >> 1; /* rotate the current pattern */ } } /* draw vector line with pattern */ static void CT_pattern_vector(x1, y1) int x1; int y1; { int op; /* order parameter */ int x0 = CT_last_x; int y0 = CT_last_y; int dx = x1 - x0; int dy = y1 - y0; int ax = ABS(dx) << 1; int ay = ABS(dy) << 1; int sx = SIGN(dx); int sy = SIGN(dy); if (ax >= ay) { for (op = ay - (ax >> 1); x0 != x1; x0 += sx, op += ay) { CT_draw_vpoint(x0, y0, 0); if (op > 0 || (op == 0 && sx == 1)) { op -= ax; y0 += sy; } } } else { /* ax < ay */ for (op = ax - (ay >> 1); y0 != y1; y0 += sy, op += ax) { CT_draw_vpoint(x0, y0, 0); if (op > 0 || (op == 0 && sy == 1)) { op -= ay; x0 += sx; } } } CT_draw_vpoint(x0, y0, 1); /* last point */ CT_last_x = x1; CT_last_y = y1; } TERM_PUBLIC void CTEK_vector(x, y) unsigned int x; unsigned int y; { if (CT_last_linetype <= 0) CT_solid_vector(x, y); else CT_pattern_vector(x, y); } #endif /* CTEK */ #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(tek40_driver) #ifndef CTEK "tek40xx", "Tektronix 4010 and others; most TEK emulators", TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, TEK40linetype, TEK40put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null #else "tek40xx", "Tektronix 4010 and others; most TEK emulators", TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, TEK40text, null_scale, TEK40graphics, CTEK_move, CTEK_vector, CTEK_linetype, TEK40put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null #endif /* CTEK */ TERM_TABLE_END(tek40_driver) #undef LAST_TERM #define LAST_TERM tek40_driver #ifdef VTTEK TERM_TABLE_START(vttek_driver) "vttek", "VT-like tek40xx terminal emulator", TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset, TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, VTTEK40linetype, VTTEK40put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(vttek_driver) #undef LAST_TERM #define LAST_TERM vttek_driver #endif /* VTTEK */ #ifdef KERMIT TERM_TABLE_START(kc_tek40_driver) "kc_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - color", TEK40XMAX, TEK40YMAX, TEK40VCHAR, KTEK40HCHAR, TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector, KTEK40Clinetype, TEK40put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(kc_tek40_driver) #undef LAST_TERM #define LAST_TERM kc_tek40_driver TERM_TABLE_START(km_tek40_driver) "km_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - monochrome", TEK40XMAX, TEK40YMAX, TEK40VCHAR, KTEK40HCHAR, TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector, KTEK40Mlinetype, TEK40put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(km_tek40_driver) #undef LAST_TERM #define LAST_TERM km_tek40_driver #endif /* KERMIT */ #ifdef SELANAR TERM_TABLE_START(selanar_driver) "selanar", "Selanar", TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset, SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector, TEK40linetype, TEK40put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(selanar_driver) #undef LAST_TERM #define LAST_TERM selanar_driver #endif /* SELANAR */ #ifdef BITGRAPH TERM_TABLE_START(bitgraph_driver) "bitgraph", "BBN Bitgraph Terminal", BG_XMAX, BG_YMAX, BG_VCHAR, BG_HCHAR, BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset, BG_text, null_scale, BG_graphics, BG_move, BG_vector, BG_linetype, BG_put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(bitgraph_driver) #undef LAST_TERM #define LAST_TERM bitgraph_driver #endif /* BITGRAPH */ #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(tek40) "1 tek40", "?commands set terminal tek40xx", "?set terminal tek40xx", "?set term tek40xx", "?terminal tek40xx", "?terminal tek40xx", "?tek40", "?commands set terminal vttek", "?set terminal vttek", "?set term vttek", "?terminal vttek", "?term vttek", "?vttek", "?commands set terminal kc-tek40xx", "?set terminal kc-tek40xx", "?set term kc-tek40xx", "?terminal kc-tek40xx", "?term kc-tek40xx", "?kc-tek40xx", "?commands set terminal km-tek40xx", "?set terminal km-tek40xx", "?set term km-tek40xx", "?terminal km-tek40xx", "?term km-tek40xx", "?km-tek40xx", "?commands set terminal selanar", "?set terminal selanar", "?set term selanar", "?terminal selanar", "?term selanar", "?selanar", "?commands set terminal bitgraph", "?set terminal bitgraph", "?set term bitgraph", "?terminal bitgraph", "?term bitgraph", "?bitgraph", " This family of terminal drivers supports a variety of VT-like terminals.", " `tek40xx` supports Tektronix 4010 and others as well as most TEK emulators;", " `vttek` supports VT-like tek40xx terminal emulators; `kc-tek40xx` supports", " MS-DOS Kermit Tek4010 terminal emulators in color: `km-tek40xx` supports them", " in monochrome; `selanar` supports Selanar graphics; and `bitgraph` supports", " BBN Bitgraph terminals. None have any options." END_HELP(tek40) #endif /* TERM_HELP */ /* * $Id: texdraw.trm,v 1.15 1998/06/18 14:59:26 ddenholm Exp $ */ /* GNUPLOT - texdraw.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * The TEXDRAW macros for LaTeX. * * AUTHORS * Khun Yee Fung. Modified from eepic.trm. * clipper@csd.uwo.ca * January 20, 1992 * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * This file contains the texdraw terminal driver, intended for use with the * texdraw macro package for LaTeX. This is an alternative to the * latex driver. You need texdraw.sty, and texdraw.tex in the texdraw package. * */ #include "driver.h" #ifdef TERM_REGISTER register_term(texdraw) #endif #ifdef TERM_PROTO TERM_PUBLIC void TEXDRAW_init __PROTO((void)); TERM_PUBLIC void TEXDRAW_graphics __PROTO((void)); TERM_PUBLIC void TEXDRAW_text __PROTO((void)); TERM_PUBLIC void TEXDRAW_linetype __PROTO((int linetype)); TERM_PUBLIC void TEXDRAW_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void TEXDRAW_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void TEXDRAW_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void TEXDRAW_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC void TEXDRAW_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int TEXDRAW_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int TEXDRAW_text_angle __PROTO((int ang)); TERM_PUBLIC void TEXDRAW_reset __PROTO((void)); #define TEXDRAW_PTS_PER_INCH (72.27) /* resolution of printer we expect to use */ #define DOTS_PER_INCH (300) /* dot size in pt */ #define TEXDRAW_UNIT (TEXDRAW_PTS_PER_INCH/DOTS_PER_INCH) /* 5 inches wide by 3 inches high (default) */ #define TEXDRAW_XMAX (5*DOTS_PER_INCH) #define TEXDRAW_YMAX (3*DOTS_PER_INCH) #define TEXDRAW_HTIC (5*DOTS_PER_INCH/72) /* (5./TEXDRAW_UNIT) */ #define TEXDRAW_VTIC (5*DOTS_PER_INCH/72) /* (5./TEXDRAW_UNIT) */ #define TEXDRAW_HCHAR (DOTS_PER_INCH*53/10/72) /* (5.3/TEXDRAW_UNIT) */ #define TEXDRAW_VCHAR (DOTS_PER_INCH*11/72) /* (11./TEXDRAW_UNIT) */ #define GOT_TEXDRAW_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static void TEXDRAW_endline __PROTO((void)); static unsigned int TEXDRAW_posx; static unsigned int TEXDRAW_posy; enum JUSTIFY TEXDRAW_justify = LEFT; enum JUSTIFY TEXDRAW_last_justify = LEFT; static int TEXDRAW_angle = 0; static float TEXDRAW_scalefactor = 0.2409; static double TEXDRAW_xscale = 1.0, TEXDRAW_yscale = 1.0; /* for DOTS point style */ #define TEXDRAW_TINY_DOT "\\htext{$\\cdot$}" /* POINTS */ #define TEXDRAW_POINT_TYPES 12 /* we supply more point types */ static char GPFAR *GPFAR TEXDRAW_points[] = { "\\rmove(0 4)\\htext{$\\Diamond$}", "\\htext{$+$}", "\\rmove(0 4)\\htext{$\\Box$}", "\\htext{$\\times$}", "\\htext{$\\triangle$}", "\\htext{$\\star$}", "\\lcir r:9", "\\lcir r:12", "\\lcir r:16", "\\fcir f:0.9 r:9", "\\fcir f:0.9 r:12", "\\fcir f:0.9 r:16" }; /* LINES */ #define TEXDRAW_NUMLINES 5 /* number of linetypes below */ static int TEXDRAW_lines[] = { 4, /* -2 border */ 3, /* -1 axes */ 3, /* 0 solid thin */ 4, /* 1 solid thick */ 6, /* 2 solid Thick */ }; /* The line type selected most recently */ static int TEXDRAW_last_type = 0; /* current line type */ static int TEXDRAW_type; /* are we in the middle of a line */ static TBOOLEAN TEXDRAW_inline = FALSE; /* terminate any line in progress */ static void TEXDRAW_endline __PROTO((void)); /* number of points in line so far */ static int TEXDRAW_linecount = 0; /* max value for linecount */ #define TEXDRAW_LINEMAX 5 TERM_PUBLIC void TEXDRAW_init() { TEXDRAW_posx = TEXDRAW_posy = 0; TEXDRAW_linetype(-1); fputs("%% GNUPLOT: LaTeX using TEXDRAW macros\n", gpoutfile); } TERM_PUBLIC void TEXDRAW_graphics() { static char GPFAR tdg1[] = "\ \\begin{texdraw}\n\ \\normalsize\n\ \\ifx\\pathDEFINED\\relax\\else\\let\\pathDEFINED\\relax\n\ \\def\\QtGfr{\\ifx (\\TGre \\let\\YhetT\\cpath\\else\\let\\YhetT\\relax\\fi\\YhetT}\n\ \\def\\path (#1 #2){\\move (#1 #2)\\futurelet\\TGre\\QtGfr}\n\ \\def\\cpath (#1 #2){\\lvec (#1 #2)\\futurelet\\TGre\\QtGfr}\n\ \\fi\n\ \\drawdim pt\n\ \\setunitscale %2.2f\n\ \\linewd %d\n\ \\textref h:L v:C\n"; fprintf(gpoutfile, tdg1, TEXDRAW_scalefactor, TEXDRAW_lines[2]); TEXDRAW_last_type = 0; TEXDRAW_type = 0; } TERM_PUBLIC void TEXDRAW_text() { TEXDRAW_endline(); fputs("\\end{texdraw}\n", gpoutfile); } TERM_PUBLIC void TEXDRAW_linetype(linetype) int linetype; { TEXDRAW_endline(); if (linetype >= TEXDRAW_NUMLINES - 2) linetype %= (TEXDRAW_NUMLINES - 2); TEXDRAW_type = linetype; } TERM_PUBLIC void TEXDRAW_move(x, y) unsigned int x, y; { TEXDRAW_endline(); TEXDRAW_posx = x; TEXDRAW_posy = y; } TERM_PUBLIC void TEXDRAW_point(x, y, number) unsigned int x, y; int number; { TEXDRAW_move(x, y); /* Print the character defined by 'number'; number < 0 means * to use a dot, otherwise one of the defined points. */ fprintf(gpoutfile, "\\move (%d %d)\n", (int) ((double) x * TEXDRAW_xscale), (int) ((double) y * TEXDRAW_yscale)); if (TEXDRAW_last_justify != CENTRE) { fprintf(gpoutfile, "\\textref h:C v:C "); TEXDRAW_last_justify = CENTRE; } fprintf(gpoutfile, "%s\n", (number < 0 ? TEXDRAW_TINY_DOT : TEXDRAW_points[number % TEXDRAW_POINT_TYPES])); } TERM_PUBLIC void TEXDRAW_vector(ux, uy) unsigned int ux, uy; { if (!TEXDRAW_inline) { TEXDRAW_inline = TRUE; /* Start a new line. This depends on line type */ if (TEXDRAW_type != TEXDRAW_last_type) { if (TEXDRAW_lines[TEXDRAW_type + 2] != TEXDRAW_lines[TEXDRAW_last_type + 2]) fprintf(gpoutfile, "\\linewd %d\n", TEXDRAW_lines[TEXDRAW_type + 2]); TEXDRAW_last_type = TEXDRAW_type; } fprintf(gpoutfile, "\\path (%d %d)", (int) ((double) TEXDRAW_posx * TEXDRAW_xscale), (int) ((double) TEXDRAW_posy * TEXDRAW_yscale)); TEXDRAW_linecount = 1; } else { /* Even though we are in middle of a path, * we may want to start a new path command. * If they are too long then latex will choke. */ if (TEXDRAW_linecount++ >= TEXDRAW_LINEMAX) { fputs("\n\\cpath ", gpoutfile); TEXDRAW_linecount = 1; } } fprintf(gpoutfile, "(%d %d)", (int) ((double) ux * TEXDRAW_xscale), (int) ((double) uy * TEXDRAW_yscale)); TEXDRAW_posx = ux; TEXDRAW_posy = uy; } static void TEXDRAW_endline() { if (TEXDRAW_inline) { putc('\n', gpoutfile); TEXDRAW_inline = FALSE; } } TERM_PUBLIC void TEXDRAW_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; TBOOLEAN head; { char text; if (head) text = 'a'; else text = 'l'; fprintf(gpoutfile, "\\move (%d %d)\\%cvec (%d %d)", (int) ((double) sx * TEXDRAW_xscale), (int) ((double) sy * TEXDRAW_yscale), text, (int) ((double) ex * TEXDRAW_xscale), (int) ((double) ey * TEXDRAW_yscale)); TEXDRAW_posx = ex; TEXDRAW_posy = ey; } TERM_PUBLIC void TEXDRAW_put_text(x, y, str) unsigned int x, y; /* reference point of string */ char str[]; /* the text */ { char text; TEXDRAW_endline(); fprintf(gpoutfile, "\\move (%d %d)", (int) ((double) x * TEXDRAW_xscale), (int) ((double) y * TEXDRAW_yscale)); if (!TEXDRAW_angle) text = 'h'; else text = 'v'; if (TEXDRAW_last_justify != TEXDRAW_justify) { TEXDRAW_last_justify = TEXDRAW_justify; if (TEXDRAW_justify == LEFT) fputs("\\textref h:L v:C ", gpoutfile); else if (TEXDRAW_justify == CENTRE) fputs("\\textref h:C v:C ", gpoutfile); else if (TEXDRAW_justify == RIGHT) fputs("\\textref h:R v:C ", gpoutfile); } fprintf(gpoutfile, "\\%ctext{%s}\n", text, str); } TERM_PUBLIC int TEXDRAW_justify_text(mode) enum JUSTIFY mode; { TEXDRAW_justify = mode; return (TRUE); } TERM_PUBLIC int TEXDRAW_text_angle(ang) int ang; { TEXDRAW_angle = ang; return (TRUE); } TERM_PUBLIC void TEXDRAW_reset() { TEXDRAW_endline(); TEXDRAW_posx = TEXDRAW_posy = 0; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(texdraw_driver) "texdraw", "LaTeX texdraw environment", TEXDRAW_XMAX, TEXDRAW_YMAX, TEXDRAW_VCHAR, TEXDRAW_HCHAR, TEXDRAW_VTIC, TEXDRAW_HTIC, options_null, TEXDRAW_init, TEXDRAW_reset, TEXDRAW_text, null_scale, TEXDRAW_graphics, TEXDRAW_move, TEXDRAW_vector, TEXDRAW_linetype, TEXDRAW_put_text, TEXDRAW_text_angle, TEXDRAW_justify_text, TEXDRAW_point, TEXDRAW_arrow, set_font_null TERM_TABLE_END(texdraw_driver) #undef LAST_TERM #define LAST_TERM texdraw_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(texdraw) "1 texdraw", "?commands set terminal texdraw", "?set terminal texdraw", "?set term texdraw", "?terminal texdraw", "?term texdraw", "?texdraw", " The `texdraw` terminal driver supports the LaTeX texdraw environment. It is", " intended for use with \"texdraw.sty\" and \"texdraw.tex\" in the texdraw package.", "", " It has no options." END_HELP(texdraw) #endif /* TERM_HELP */ /*{{{}}}*/ /***************************************************************************/ /* */ /* $Id: tgif.trm,v 1.66 1998/04/14 00:18:10 drd Exp $ */ /* */ /***************************************************************************/ /* GNUPLOT - tgif.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* */ /* This file is included by ../term.c. */ /* */ /* This terminal driver supports: */ /* TGIF */ /* */ /* AUTHORS: */ /* Werner Geppert and Andreas Kuhlewind */ /* March, 21st 1995 */ /* */ /* send your comments or suggestions to werner@mez.ruhr-uni-bochum.de */ /* */ /* */ /* MODIFIED May, 11st 1997 by NOVÁK Levente (novakl@tigris.klte.hu): */ /* */ /* - Modified the default linewidth for borders from 3 to 2 */ /* - Modified the default size of markers' bounding box */ /* to allow nicer shapes */ /* - Slightly modified the markers and added several new ones, */ /* now we have 64 different pointtypes, the same as for the */ /* PostScript terminal */ /* - I left the %.1f format for pixel positions, but I think */ /* Tgif does only calculate with integer positions */ /***************************************************************************/ /*}}} */ /***************************************************************************/ #include "driver.h" #ifdef TERM_REGISTER register_term(tgif) #endif #ifdef TERM_PROTO TERM_PUBLIC void TGIF_options __PROTO((void)); TERM_PUBLIC void TGIF_init __PROTO((void)); TERM_PUBLIC void TGIF_reset __PROTO((void)); TERM_PUBLIC void TGIF_text __PROTO((void)); TERM_PUBLIC void TGIF_graphics __PROTO((void)); TERM_PUBLIC void TGIF_move __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void TGIF_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void TGIF_linetype __PROTO((int linetype)); TERM_PUBLIC void TGIF_put_text __PROTO((unsigned int ux, unsigned int uy, char *str)); /* ref point and text */ TERM_PUBLIC int TGIF_text_angle __PROTO((int ang)); TERM_PUBLIC int TGIF_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void TGIF_point __PROTO((unsigned int ux, unsigned int uy, int number)); TERM_PUBLIC void TGIF_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); TERM_PUBLIC int TGIF_set_font __PROTO((char *font)); TERM_PUBLIC void TGIF_set_pointsize __PROTO((double size)); /*}}} */ /* default length for static strings */ #define TGIF_STRLEN_MAX 255 /* standard x/y plot size in portrait mode */ #define TGIF_XMAX 950 #define TGIF_YMAX 634 /* total available plotting area */ #define TGIF_XTOT 950 #define TGIF_YTOT 1400 /* Offset */ #define TGIF_XOFF 50 #define TGIF_YOFF 50 #define TGIF_XSHIFT 1030 /* 80 points skip */ #define TGIF_YSHIFT 714 #define TGIF_VCHAR 18 /* default is 18 pt */ #define TGIF_HCHAR (18*6/10) #define TGIF_VTIC (TGIF_YMAX/80) #define TGIF_HTIC (TGIF_YMAX/80) #define TGIF_MAXPOLY 100 /*}}} */ #define GOT_TGIF_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* tgif driver by Werner Geppert, werner@mez.ruhr-uni-bochum.de */ /***************************************************************************/ /* Variables: */ static unsigned int uLastTgifX, uLastTgifY; /* last Coordinate */ static unsigned int uActNr; /* current elementnumber */ static unsigned int uActPage; /* current pagenumber */ static unsigned int uActResolution; /* resolution in percent */ static unsigned int uActZoom; /* zoom factor */ static unsigned int uActAngle; /* current textangle */ static unsigned int uActThick; /* actual linethickness */ static unsigned int uActPointSize; /* point size */ static unsigned int uActStyle; /* actual linestyle */ static unsigned int uActJust; /* actual textjustification */ static unsigned int uXshift; /* actual shift x */ static unsigned int uYshift; /* actual shift y */ static unsigned int uTgifPlotCount; /* counts number of plots */ static unsigned int uTgifPlotRow, uTgifPlotCol; /* actual plot row and col */ static unsigned int uTgif_win_horiz, /* number of plots in x and */ uTgif_win_verti; /* y direction [x,y] */ static char sActColor[TGIF_STRLEN_MAX]; /* current color */ static unsigned int uDefaultFontSize; /* default font size */ static unsigned int uActFontSize; /* current font size */ static char sDefaultFont[TGIF_STRLEN_MAX]; /* default font */ static char sActFont[TGIF_STRLEN_MAX]; /* current font */ /* static char sActPointString[TGIF_STRLEN_MAX]; HBB: unused */ static TBOOLEAN TgifSolid = FALSE; static TBOOLEAN TgifPortrait = TRUE; static unsigned int uTgifPlotsPerPage = 1; static unsigned int uTextAngle[] = {0, 3}; /* * 10 different pointtypes need 10 different linetypes */ /* NL: Modified first value to 2 from 3 */ static unsigned int uLineThick[] = { 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; static unsigned int uLineStyle[] = { 0, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0 }; static char *psColors[] = { "black", "black", /* border and x/y-zero-axes */ "red", "green", "blue", "magenta", "cyan", "yellow", "DarkSeaGreen", "HotPink", "black", "coral"}; #if 0 /* HBB: unused */ static char *psFonts[] = {"Times-Roman", "Courier", "Helvetica", "NewCenturySchlbk-Roman", "Symbol", NULL}; static unsigned int psFontSizes[] = { 8, 10, 11, 12, 14, 17, 18, 20, 24, 25, 34, 40, 45, 50 }; #endif static int iTgifPolyCount; static unsigned int uBuffX[TGIF_MAXPOLY], uBuffY[TGIF_MAXPOLY]; enum eState { NEWPOLY = 100, INPOLY }; static enum eState eTgifState = NEWPOLY; static void TGIF_flush_poly __PROTO((void)); /*}}} */ /***************************************************************************/ static void TGIF_flush_poly() { int i; if (eTgifState == INPOLY) { fprintf(gpoutfile, "poly('%s',%d,[\n\t", sActColor, iTgifPolyCount); for (i = 0; i < iTgifPolyCount - 1; i++) { fprintf(gpoutfile, "%u,%u,", uBuffX[i], uBuffY[i]); if ((i + 1) % 8 == 0) fputs("\n\t", gpoutfile); } fprintf(gpoutfile, "%u,%u],0,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n", uBuffX[iTgifPolyCount - 1], uBuffY[iTgifPolyCount - 1], uActThick, uActNr, uActStyle); uActNr++; eTgifState = NEWPOLY; iTgifPolyCount = 0; if (gpoutfile != (FILE *) NULL) fflush(gpoutfile); } } /* TGIF_flush_poly */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_options() { struct value a, b; double dscaleH, dscaleV; strcpy(sActFont, "Helvetica"); strcpy(sDefaultFont, "Helvetica"); uActFontSize = 18; uDefaultFontSize = 18; term->v_char = (unsigned int) (uActFontSize); term->h_char = (unsigned int) (uActFontSize * 6 / 10); TgifPortrait = TRUE; uTgifPlotsPerPage = 1; uTgifPlotRow = 1; uTgifPlotCol = 1; uTgif_win_horiz = 1; uTgif_win_verti = 1; uActResolution = 100; /*}}} */ if (!END_OF_COMMAND) { if (almost_equals(c_token, "p$ortrait")) { TgifPortrait = TRUE; c_token++; } else if (almost_equals(c_token, "l$andscape")) { TgifPortrait = FALSE; uActResolution = 140; c_token++; } } /*}}} */ if (!END_OF_COMMAND) { if (equals(c_token, "[")) { /* windows specified */ c_token++; if (END_OF_COMMAND) { int_error("no. windows: [horizontal,vertical] expected", c_token); } else if (!equals(c_token, ",")) { uTgif_win_horiz = (int) real(const_express(&a)); } if (!equals(c_token, ",")) int_error("',' expected", c_token); c_token++; if (!equals(c_token, "]")) { uTgif_win_verti = (int) real(const_express(&a)); } if (!equals(c_token, "]")) int_error("expecting ']'", c_token); c_token++; uTgifPlotsPerPage = uTgif_win_verti * uTgif_win_horiz; } } /*}}} */ if (!END_OF_COMMAND) { if (almost_equals(c_token, "s$olid")) { TgifSolid = TRUE; c_token++; } else if (almost_equals(c_token, "d$ashed")) { TgifSolid = FALSE; c_token++; } } /*}}} */ if (!END_OF_COMMAND && isstring(c_token)) { quote_str(sActFont, c_token, MAX_LINE_LEN); strcpy(sDefaultFont, sActFont); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ uActFontSize = (unsigned int) real(const_express(&b)); uDefaultFontSize = uActFontSize; term->v_char = (unsigned int) (uActFontSize); term->h_char = (unsigned int) (uActFontSize * 6 / 10); } /*}}} */ if (TgifPortrait) { dscaleH = (double) 100.0 *(TGIF_XTOT) / (xsize * (TGIF_XMAX + (uTgif_win_horiz - 1) * TGIF_XSHIFT)); dscaleV = (double) 100.0 *(TGIF_YTOT) / (ysize * (TGIF_YMAX + (uTgif_win_verti - 1) * TGIF_YSHIFT)); uActResolution = (int) GPMIN(dscaleH, dscaleV); switch (uTgif_win_verti) { case 1: uActZoom = 0; break; case 2: uActZoom = 1; break; default: uActZoom = 2; break; } } else { dscaleH = (double) 100.0 *(TGIF_YTOT) / (xsize * (TGIF_XMAX + (uTgif_win_horiz - 1) * TGIF_XSHIFT)); dscaleV = (double) 100.0 *(TGIF_XTOT) / (ysize * (TGIF_YMAX + (uTgif_win_verti - 1) * TGIF_YSHIFT)); uActResolution = (unsigned int) GPMIN(dscaleH, dscaleV); switch (uTgif_win_verti) { case 1: uActZoom = 0; break; case 2: uActZoom = 1; break; default: uActZoom = 2; break; } } /*}}} */ sprintf(term_options, "%s [%u,%u] %s \"%s\" %u", TgifPortrait ? "portrait" : "landscape", uTgif_win_horiz, uTgif_win_verti, TgifSolid ? "solid" : "dashed", sActFont, uActFontSize); } /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_init() { if (multiplot) { /* uActResolution= TgifPortrait ? (unsigned int)100 : (unsigned int)145 ; */ uActResolution = (unsigned int) 100; if (uTgifPlotsPerPage > 1) { fputs("warning: using standard multiplot\n", stderr); uTgifPlotsPerPage = 1; } uActZoom = 1; } fprintf(gpoutfile, "\ %%TGIF 2.15-p7\n\ state(%d,30,%u,0,0,%u,16,1,9,1,1,0,0,0,0,1,0,'%s',0,%u,0,0,1,10,0,0,1,1,0,16,0,0,1,1,1).\n\ %%\n%% @(#)$Header: /export/home/cheetah/ddenholm/cvsroot/gnuplot/term/tgif.trm,v 1.66 1998/04/14 00:18:10 drd Exp $\n%% %%W%%\n%%\n\ page(1,\"\").\n", TgifPortrait ? 0 : 1, uActResolution, uActZoom, sActFont, uActFontSize); eTgifState = NEWPOLY; iTgifPolyCount = 0; uTgifPlotCount = 0; uActPage = 1; } /* TGIF_init */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_graphics() { TGIF_flush_poly(); if (multiplot) { term->xmax = (TgifPortrait) ? TGIF_XTOT : TGIF_YTOT; term->ymax = (TgifPortrait) ? TGIF_YTOT : TGIF_XTOT; uLastTgifX = (TgifPortrait) ? TGIF_XOFF : TGIF_YOFF; uLastTgifY = (TgifPortrait) ? TGIF_YTOT + TGIF_YOFF : TGIF_XTOT + TGIF_XOFF; uYshift = uLastTgifY; uXshift = uLastTgifX; } else { if (uTgifPlotCount < uTgifPlotsPerPage) uTgifPlotCount++; else { fprintf(stderr, "error: number of plots > plots per page\n"); return; } uXshift = (unsigned int) TGIF_XOFF *100 / uActResolution + (xsize * (uTgifPlotCol - 1) * TGIF_XSHIFT); uYshift = (unsigned int) TGIF_YOFF *100 / uActResolution + (ysize * (TGIF_YMAX + (uTgifPlotRow - 1) * TGIF_YSHIFT)); if (uTgifPlotCount % uTgif_win_horiz == 0) { uTgifPlotCol = 1; uTgifPlotRow++; } else { uTgifPlotCol++; } uLastTgifX = uXshift; uLastTgifY = uYshift; } /* default settings for each plot */ iTgifPolyCount = 0; uActNr = 0; uActAngle = 0; uActThick = 1; uActStyle = 0; uActJust = LEFT; strcpy(sActColor, psColors[0]); } /* TGIF_graphics */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_text() { TGIF_flush_poly(); } /* TGIF_text */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_reset() { TGIF_flush_poly(); iTgifPolyCount = 0; uTgifPlotCount = 0; uTgifPlotRow = 1; uTgifPlotCol = 1; if (gpoutfile != (FILE *) NULL) fflush(gpoutfile); } /* TGIF_reset */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_linetype(linetype) int linetype; { unsigned int ult; TGIF_flush_poly(); if (linetype >= 0) ult = 2 + linetype % 10; else ult = linetype + 2; strcpy(sActColor, psColors[ult]); uActThick = uLineThick[ult]; if (!TgifSolid) uActStyle = uLineStyle[ult]; else { if (ult == 1) /* grid */ uActStyle = uLineStyle[ult]; else uActStyle = uLineStyle[2]; } } /* TGIF_linetype */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_move(ux, uy) unsigned int ux, uy; { uLastTgifX = ux + uXshift; uLastTgifY = uYshift - uy; if (eTgifState == INPOLY) TGIF_flush_poly(); } /* TGIF_move */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_vector(ux, uy) unsigned int ux, uy; { ux = ux + uXshift; uy = uYshift - uy; if (eTgifState == NEWPOLY) { uBuffX[0] = uLastTgifX; uBuffY[0] = uLastTgifY; iTgifPolyCount = 1; eTgifState = INPOLY; } uBuffX[iTgifPolyCount] = ux; uBuffY[iTgifPolyCount] = uy; uLastTgifX = ux; uLastTgifY = uy; iTgifPolyCount++; eTgifState = INPOLY; if (iTgifPolyCount == TGIF_MAXPOLY) { TGIF_flush_poly(); } } /* TGIF_vector */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; TBOOLEAN head; { TGIF_flush_poly(); sx = sx + uXshift; ex = ex + uXshift; sy = uYshift - sy; ey = uYshift - ey; if (head) { fprintf(gpoutfile, "poly('%s',%d,[\n\t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n", sActColor, 2, sx, sy, ex, ey, uActThick, uActNr, uActStyle); } else { fprintf(gpoutfile, "poly('%s',%d,[\n\t%u,%u,%u,%u],1,%u,1,%u,0,0,%u,0,8,3,0,[\n]).\n", sActColor, 2, sx, sy, ex, ey, uActThick, uActNr, uActStyle); } uActNr++; uLastTgifX = ex; uLastTgifY = ey; } /* TGIF_arrow */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_put_text(ux, uy, str) unsigned int ux, uy; char *str; { unsigned int x, y; struct termentry *t = term; TGIF_flush_poly(); x = ux + uXshift; y = uYshift - uy - t->v_char / 2; if (strlen(str) == 0) return; fprintf(gpoutfile, "text('%s',%u,%u,'%s',0,%u,1,%u,%u,1,55,119,%u,0,15,4,0,0,0,0,[\n\t\"%s\"]).\n", sActColor, x, y, sActFont, uActFontSize, uActJust, uActAngle, uActNr, str); uActNr += 2; /* reset font size and font, they might have been changed */ uActFontSize = uDefaultFontSize; strcpy(sActFont, sDefaultFont); } /* TGIF_put_text */ /*}}} */ /***************************************************************************/ TERM_PUBLIC int TGIF_text_angle(ang) int ang; { uActAngle = uTextAngle[ang]; /* 0=waag. 1=senkrecht */ return (TRUE); } /* TGIF_text_angle */ /*}}} */ /***************************************************************************/ TERM_PUBLIC int TGIF_justify_text(mode) enum JUSTIFY mode; { uActJust = mode; return (TRUE); } /* TGIF_justify_text */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_point(ux, uy, number) unsigned int ux, uy; int number; { double p; /* all pointtypes fit in a (x +/-p)x(y +/-p) box */ double x, y; x = (double) (ux + uXshift); y = (double) (uYshift - uy); p = pointsize * 8.0; /* NL: Increased the bounding box (p value) from 4.0 to 8.0 */ if (p == (double) 0.0) p = 0.1; TGIF_flush_poly(); if (number != -1) number = number % 63; switch (number) { case -1: /* HBB: corrected format string, shuts up gcc -Wall */ fprintf(gpoutfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,1,1,%u,0,0,0,0,8,3,0,[\n]).\n", sActColor, x, y, x + 1, y + 1, uActNr++); break; case 0: /* cross */ /* taking thickness 2 for cross & plus & star */ fprintf(gpoutfile, "\ group([\n\ poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n\ poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr+1, sActColor, x - p, y + p, x + p, y - p, uActNr+2); uActNr += 4; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 1: /* plus */ /* taking thickness 2 for cross & plus & star */ fprintf(gpoutfile, "\ group([\n\ poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]),\n\ poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n])\n", sActColor, x, y - p - 1, x, y + p + 1, uActNr+1, sActColor, x - p - 1, y, x + p + 1, y, uActNr+2); uActNr += 4; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 2: /* star */ /* taking thickness 2 for cross & plus & star */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]),\n", sActColor, x, y - p - 1, x, y + p + 1, uActNr++); fprintf(gpoutfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n])\n", sActColor, x - p - 1, y, x + p + 1, y, uActNr++); fprintf(gpoutfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "poly('%s',2,[\n\t%.1f,%.1f,%.1f,%.1f],0,2,1,%u,0,0,0,0,8,3,0,[\n]).\n", sActColor, x - p, y + p, x + p, y - p, uActNr++); uActNr += 4; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 3: /* box */ fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr); uActNr++; break; /*}}} */ case 4: /* filled box */ fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr); uActNr++; break; /*}}} */ case 5: /* circle */ fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr); uActNr++; break; /*}}} */ case 6: /* filled circle */ fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr); uActNr++; break; /*}}} */ case 7: /* triangle up */ fprintf(gpoutfile, "polygon('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y + 0.75 * p, x - p, y + 0.75 * p, x, y - p, uActNr); uActNr++; break; /*}}} */ case 8: /* filled triangle up */ fprintf(gpoutfile, "polygon('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y + 0.75 * p, x - p, y + 0.75 * p, x, y - p, uActNr); uActNr++; break; /*}}} */ case 9: /* triangle down */ fprintf(gpoutfile, "polygon('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x - p, y - 0.75 * p, x + p, y - 0.75 * p, x, y + p, uActNr); uActNr++; break; /*}}} */ case 10: /* filled triangle down */ fprintf(gpoutfile, "polygon('%s',4,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x - p, y - 0.75 * p, x + p, y - 0.75 * p, x, y + p, uActNr); uActNr++; break; /*}}} */ case 11: /* diamond */ fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); uActNr++; break; /*}}} */ case 12: /* filled diamond */ fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); uActNr++; break; /*}}} */ case 13: /* pentagon */ fprintf(gpoutfile, "polygon('%s',6,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y - p / 4, x + 0.625 * p, y + p, x - 0.625 * p, y + p, x - p, y - p / 4, x, y - p, uActNr); uActNr++; break; /*}}} */ case 14: /* filled pentagon */ fprintf(gpoutfile, "polygon('%s',6,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y - p / 4, x + 0.625 * p, y + p, x - 0.625 * p, y + p, x - p, y - p / 4, x, y - p, uActNr); uActNr++; break; /*}}} */ case 15: /* circle1 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,4480,2560,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x + p * 0.342, y - p * 0.94, x - p * 0.342, y - p * 0.94, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 16: /* circle2 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x + p, y, x, y - p, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 17: /* circle3 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y - p, x - p, y, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 18: /* circle4 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,11520,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x + p, y, x - p, y, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 19: /* circle5 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x - p, y, x, y + p, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 20: /* circle6 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x + p, y, x, y - p, 2 * p, 2 * p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x - p, y, x, y + p, 2 * p, 2 * p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 21: /* circle7 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,11520,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y - p, x, y + p, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 22: /* circle8 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,0,17280,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x + p, y, x, y + p, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 23: /* circle9 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y + p, x + p, y, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 24: /* circle10 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,11520,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y + p, x, y - p, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 25: /* circle11 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y - p, x - p, y, 2 * p, 2 * p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,5760,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y + p, x + p, y, 2 * p, 2 * p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 26: /* circle12 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,17280,17280,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y + p, x - p, y, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 27: /* circle13 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,11520,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x - p, y, x + p, y, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 28: /* circle14 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,11520,17280,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x - p, y, x, y - p, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 29: /* circle15 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "arc('%s',1,1,1,0,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,0,%.1f,%.1f,5760,17280,%u,0,0,8,3,0,[\n]).\n", sActColor, x - p, y - p, x, y, x, y - p, x + p, y, 2 * p, 2 * p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 30: /* circle16 */ fprintf(gpoutfile, "oval('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr); uActNr++; break; /*}}} */ case 31: /* box1 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p / 4, y - p, x + p / 4, y, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 32: /* box2 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 33: /* box3 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x, y, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 34: /* box4 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 35: /* box5 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y, x, y + p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 36: /* box6 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y, x, y + p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 37: /* box7 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x, y + p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 38: /* box8 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y, x, y + p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 39: /* box9 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y, x + p, y + p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 40: /* box10 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y + p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 41: /* box11 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x, y, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y, x + p, y + p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 42: /* box12 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y, x + p, y + p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 43: /* box13 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y, x + p, y + p, uActNr++); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 44: /* box14 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x, y - p, x + p, y, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y, x + p, y + p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 45: /* box15 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,2,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x, y, uActNr++); fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y, x + p, y + p, uActNr++); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 46: /* box16 */ fprintf(gpoutfile, "box('%s',%.1f,%.1f,%.1f,%.1f,1,1,1,%u,0,0,0,[\n]).\n", sActColor, x - p, y - p, x + p, y + p, uActNr); uActNr++; break; /*}}} */ case 47: /* diamond1 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - 0.625 * p, y - 0.375 * p, x - 0.375 * p, y - 0.625 * p, x + p / 8, y - p / 8, x - p / 8, y + p / 8, x - 0.625 * p, y - 0.375 * p, uActNr); fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); uActNr += 2; break; /*}}} */ case 48: /* diamond2 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y - p / 2, x, y - p, x + p / 2, y - p / 2, x, y, x - p / 2, y - p / 2, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 49: /* diamond3 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x - p / 2, y - p / 2, x, y, x - p / 2, y + p / 2, x - p, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 50: /* diamond4 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x, y - p, x + p / 2, y - p / 2, x - p / 2, y + p / 2, x - p, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 51: /* diamond5 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y + p / 2, x, y, x + p / 2, y + p / 2, x, y + p, x - p / 2, y + p / 2, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 52: /* diamond6 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y - p / 2, x, y - p, x + p / 2, y - p / 2, x, y, x - p / 2, y - p / 2, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y + p / 2, x, y, x + p / 2, y + p / 2, x, y + p, x - p / 2, y + p / 2, uActNr); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 53: /* diamond7 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x - p / 2, y - p / 2, x + p / 2, y + p / 2, x, y + p, x - p, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 54: /* diamond8 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x, y - p, x + p / 2, y - p / 2, x, y, x + p / 2, y + p / 2, x, y + p, x - p, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 55: /* diamond9 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y, x + p / 2, y - p / 2, x + p, y, x + p / 2, y + p / 2, x, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 56: /* diamond10 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y - p / 2, x, y - p, x + p, y, x + p / 2, y + p / 2, x - p / 2, y - p / 2, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 57: /* diamond11 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x - p / 2, y - p / 2, x, y, x - p / 2, y + p / 2, x - p, y, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y, x + p / 2, y - p / 2, x + p, y, x + p / 2, y + p / 2, x, y, uActNr); uActNr += 3; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 58: /* diamond12 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x, y - p, x + p, y, x + p / 2, y + p / 2, x, y, x - p / 2, y + p / 2, x - p, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 59: /* diamond13 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y + p / 2, x + p / 2, y - p / 2, x + p, y, x, y + p, x - p / 2, y + p / 2, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 60: /* diamond14 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p / 2, y - p / 2, x, y - p, x + p, y, x, y + p, x - p / 2, y + p / 2, x, y, x - p / 2, y - p / 2, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 61: /* diamond15 */ fprintf(gpoutfile, "group([\n"); fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],0,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); fprintf(gpoutfile, "polygon('%s',7,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x - p, y, x - p / 2, y - p / 2, x, y, x + p / 2, y - p / 2, x + p, y, x, y + p, x - p, y, uActNr); uActNr += 2; fprintf(gpoutfile, "],\n%u,0,[\n]).\n", uActNr++); break; /*}}} */ case 62: /* diamond16 */ fprintf(gpoutfile, "polygon('%s',5,[\n%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f],1,1,1,0,%u,0,0,0,0,0,[\n]).\n", sActColor, x, y + p, x + p, y, x, y - p, x - p, y, x, y + p, uActNr); uActNr++; break; /*}}} */ } /* switch */ } /* TGIF_point */ /*}}} */ /***************************************************************************/ TERM_PUBLIC void TGIF_set_pointsize(size) double size; { uActPointSize = size; } /*}}} */ /***************************************************************************/ TERM_PUBLIC int TGIF_set_font(font) /* Entry font as added by DJL in post.trm */ char *font; { char name[32]; int size, sep; sep = strcspn(font, ","); strncpy(name, font, sep); name[sep] = NUL; size = uActFontSize; sscanf(&(font[sep + 1]), "%d", &size); uActFontSize = size; return TRUE; } /*}}} */ /***************************************************************************/ #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(tgif_driver) "tgif", "TGIF X11 [mode] [x,y] [dashed] [\042font\042 [fontsize]]", TGIF_XMAX, TGIF_YMAX, TGIF_VCHAR, TGIF_HCHAR, TGIF_VTIC, TGIF_HTIC, TGIF_options, TGIF_init, TGIF_reset, TGIF_text, null_scale, TGIF_graphics, TGIF_move, TGIF_vector, TGIF_linetype, TGIF_put_text, TGIF_text_angle, TGIF_justify_text, TGIF_point, TGIF_arrow, TGIF_set_font, TGIF_set_pointsize, TERM_CAN_MULTIPLOT TERM_TABLE_END(tgif_driver) #undef LAST_TERM #define LAST_TERM tgif_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(tgif) "1 tgif", "?commands set terminal tgif", "?set terminal tgif", "?set term tgif", "?terminal tgif", "?term tgif", "?tgif", " Tgif is an X11-based drawing tool---it has nothing to do with GIF.", "", " The `tgif` driver supports different pointsizes (with `set pointsize`),", " different label fonts and font sizes (e.g. `set label \"Hallo\" at x,y font", " \"Helvetica,34\"`) and multiple graphs on the page. The proportions of the", " axes are not changed.", "", " Syntax:", " set terminal tgif {portrait | landscape} {<[x,y]>}", " {solid | dashed}", " {\"<fontname>\"} {<fontsize>}", "", " where <[x,y]> specifies the number of graphs in the x and y directions on the", " page, \"<fontname>\" is the name of a valid PostScript font, and <fontsize>", " specifies the size of the PostScript font. Defaults are `portrait`, `[1,1]`,", " `dashed`, `\"Helvetica\"`, and `18`.", "", " The `solid` option is usually prefered if lines are colored, as they often", " are in the editor. Hardcopy will be black-and-white, so `dashed` should be", " chosen for that.", "", " Multiplot is implemented in two different ways.", "", " The first multiplot implementation is the standard gnuplot multiplot feature:", "", " set terminal tgif", " set output \"file.obj\"", " set multiplot", " set origin x01,y01", " set size xs,ys", " plot ...", " ...", " set origin x02,y02", " plot ...", " set nomultiplot", "", " See `set multiplot` for further information.", "", " The second version is the [x,y] option for the driver itself. The advantage", " of this implementation is that everything is scaled and placed automatically", " without the need for setting origins and sizes; the graphs keep their natural", " x/y proportions of 3/2 (or whatever is fixed by `set size`).", "", " If both multiplot methods are selected, the standard method is chosen and a", " warning message is given.", "", " Examples of single plots (or standard multiplot):", " set terminal tgif # defaults", " set terminal tgif \"Times-Roman\" 24", " set terminal tgif landscape", " set terminal tgif landscape solid", "", " Examples using the built-in multiplot mechanism:", " set terminal tgif portrait [2,4] # portrait; 2 plots in the x-", " # and 4 in the y-direction", " set terminal tgif [1,2] # portrait; 1 plot in the x-", " # and 2 in the y-direction", " set terminal tgif landscape [3,3] # landscape; 3 plots in both", " # directions" END_HELP(tgif) #endif /*{{{}}}*/ /* * $Id: tkcanvas.trm,v 1.7 1998/04/14 00:18:11 drd Exp $ * */ /* GNUPLOT - tkcanvas.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Tk/Tcl canvas widgets * * AUTHORS - original dxy.trm * Martin Yii, eln557h@monu3.OZ * Further modified Jan 1990 by Russell Lang, rjl@monu1.cc.monash.oz * * Port to the Tk/Tcl canvas widget * D. Jeff Dionne, July 1995 jeff@ryeham.ee.ryerson.ca * Alex Woo, woo@playfair.stanford.edu * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Alex Woo (Sept. 1996) */ #include "driver.h" #ifdef TERM_REGISTER register_term(tkcanvas) #endif #ifdef TERM_PROTO TERM_PUBLIC void TK_init __PROTO((void)); TERM_PUBLIC void TK_graphics __PROTO((void)); TERM_PUBLIC void TK_text __PROTO((void)); TERM_PUBLIC void TK_linetype __PROTO((int linetype)); TERM_PUBLIC void TK_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void TK_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void TK_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void TK_reset __PROTO((void)); #define TK_XMAX 1000 #define TK_YMAX 1000 #define TK_XLAST (TK_XMAX - 1) #define TK_YLAST (TK_XMAX - 1) #define TK_VCHAR (25) /* double actual height of characters */ #define TK_HCHAR (16) /* actual width including spacing */ #define TK_VTIC (18) #define TK_HTIC (18) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int tk_angle = 0; static int tk_lastx; static int tk_lasty; static int tk_color = 0; static char *tk_colors[] = { "black", "gray", "red", "blue", "green", "brown", "magenta", "cyan" }; TERM_PUBLIC void TK_init() { fputs("\ proc gnuplot can {\n\ $can delete all\n\ set cmx [lindex [$can configure -width] 4]\n\ set cmy [lindex [$can configure -height] 4]\n", gpoutfile); tk_lastx = tk_lasty = tk_color = 0; } TERM_PUBLIC void TK_graphics() { } TERM_PUBLIC void TK_reset() { } TERM_PUBLIC void TK_linetype(linetype) int linetype; { tk_color = (linetype + 2) & 7; } TERM_PUBLIC void TK_move(x, y) unsigned int x, y; { tk_lastx = x; tk_lasty = 1000 - y; } TERM_PUBLIC void TK_vector(x, y) unsigned int x, y; { y = 1000 - y; fprintf(gpoutfile, "$can create line [expr $cmx * %d /1000] [expr $cmy * %d /1000] [expr $cmx * %d /1000] [expr $cmy * %d /1000] -fill %s\n", tk_lastx, tk_lasty, x, y, tk_colors[tk_color]); tk_lastx = x; tk_lasty = y; } TERM_PUBLIC void TK_put_text(x, y, str) unsigned int x, y; char *str; { y = 1000 - y; fprintf(gpoutfile, "$can create text [expr $cmx * %d /1000] [expr $cmy * %d /1000] -text {%s} -fill %s -anchor w\n", x, y, str, tk_colors[tk_color]); } TERM_PUBLIC void TK_text() { fputs("}\n", gpoutfile); fflush(gpoutfile); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(tkcanvas) "tkcanvas", "Tk/Tcl canvas widget", TK_XMAX, TK_YMAX, TK_VCHAR, TK_HCHAR, TK_VTIC, TK_HTIC, options_null, TK_init, TK_reset, TK_text, null_scale, TK_graphics, TK_move, TK_vector, TK_linetype, TK_put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(tkcanvas) #undef LAST_TERM #define LAST_TERM tkcanvas #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(tkcanvas) "1 tkcanvas", "?commands set terminal tkcanvas", "?set terminal tkcanvas", "?set term tkcanvas", "?terminal tkcanvas", "?term tkcanvas", "?tkcanvas", " This terminal driver generates tk canvas widget commands. To use it, rebuild", " `gnuplot` (after uncommenting or inserting the appropriate line in \"term.h\"),", " then", "", " gnuplot> set term tkcanvas", " gnuplot> set output 'plot.file'", "", " After invoking \"wish\", execute the following sequence of tcl commands:", "", " % source plot.file", " % canvas .c", " % pack .c", " % gnuplot .c", "", " The code generated by `gnuplot` creates a tcl procedure called \"gnuplot\"", " that takes the name of a canvas as its argument. When the procedure is,", " called, it clears the canvas, finds the size of the canvas and draws the plot", " in it, scaled to fit.", "", " The current version of `tkcanvas` supports neither `multiplot` nor `replot`." END_HELP(tkcanvas) #endif /* * $Id: tpic.trm,v 1.19 1998/04/14 00:18:12 drd Exp $ */ /* GNUPLOT - tpic.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * The tpic \specials (version 2.2) for LaTeX. * * AUTHORS * Oh-Yeah? 3 Sep. 1992 (closely following eepic.trm by David Kotz) * A. Woo 5 Oct. 1992 (removed ansi prototypes for braindead compilers) * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * This file contains the tpic terminal driver for use with LaTeX. * This is an alternative to the latex and eepic drivers. You need * a printer driver that supports the tpic \specials version 2.2. * * Comparison with the eepic driver (eepic.trm): * Merits * - More point and line types * - Options to change point size, linewidth, dot & dash intervals * - Dotted and dashed lines for high-sample-rate curves (but may * depend on tpic (da & dt) implementation of your dvi driver :-) * - Overlapped points made fancier by tpic shading facility * - Optional comments for trimming figure margins * - No need for epic and eepic macros * Drawback * - You cannot use eepicemu macro for non-tpic-support dvi drivers * * LATEX must also be defined. */ /* These parameters can be modified as you like, through options. Say "set terminal tpic <pointsize> <linewidth> <interval>". <pointsize> and <linewidth> are integers in milli-inches; <interval> is a float in inches. If non-positive value is specified, the default (below) is chosen. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(tpic) #endif #ifdef TERM_PROTO TERM_PUBLIC void TPIC_options __PROTO((void)); /* get size options */ TERM_PUBLIC void TPIC_init __PROTO((void)); TERM_PUBLIC void TPIC_reset __PROTO((void)); TERM_PUBLIC void TPIC_text __PROTO((void)); TERM_PUBLIC void TPIC_graphics __PROTO((void)); TERM_PUBLIC void TPIC_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void TPIC_vector __PROTO((unsigned int ux, unsigned int uy)); TERM_PUBLIC void TPIC_linetype __PROTO((int linetype)); TERM_PUBLIC void TPIC_put_text __PROTO((unsigned int x, unsigned int y, char *str)); /* ref point and text */ TERM_PUBLIC int TPIC_text_angle __PROTO((int ang)); TERM_PUBLIC int TPIC_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void TPIC_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void TPIC_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head)); /* tpic \specials unit in inches (1 milli-inch) */ #define TPIC_UNIT 0.001 /* 5 inches wide by 3 inches high (default) */ #define TPIC_XMAX (unsigned int) (5 / TPIC_UNIT) #define TPIC_YMAX (unsigned int) (3 / TPIC_UNIT) #define TPIC_PTS_PER_UNIT (72.27 * TPIC_UNIT) #define TPIC_HTIC (unsigned int) ( 5.0 / TPIC_PTS_PER_UNIT) /* 5pt */ #define TPIC_VTIC (unsigned int) ( 5.0 / TPIC_PTS_PER_UNIT) /* 5pt */ #define TPIC_HCHAR (unsigned int) ( 5.3 / TPIC_PTS_PER_UNIT) /* 5.3pt */ #define TPIC_VCHAR (unsigned int) (11.0 / TPIC_PTS_PER_UNIT) /* 11pt */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY static int tpic_pointsize = 40; /* min point radius (in milli-inches) */ static int tpic_linewidth = 6; /* min line thickness (in milli-inches) */ static double tpic_interval = 0.1; /* min dot & dash intervals (in inches) */ /* ARROWS: same code as for LATEX */ /* figure out the best arrow. in latex.trm */ void best_latex_arrow __PROTO((int sx, int sy, int ex, int ey, int who, TBOOLEAN head)); /* all prototypes ... */ static void tpic_startline __PROTO((void)); /* private */ static void tpic_endline __PROTO((void)); /* private */ static void tpic_pushpath __PROTO((unsigned int x, unsigned int y)); /* private */ static void tpic_scanpath __PROTO((void)); void tpic_diamond __PROTO((int size)); void tpic_plus __PROTO((int size)); void tpic_box __PROTO((int size)); void tpic_times __PROTO((int size)); void tpic_triangle __PROTO((int size)); void tpic_star __PROTO((int size)); void tpic_hexagon __PROTO((int size)); void tpic_circle __PROTO((int size)); void tpic_doublecircle __PROTO((int size)); void tpic_vercircle __PROTO((int size)); /* circle with | */ void tpic_horcircle __PROTO((int size)); /* circle with - */ void tpic_pluscircle __PROTO((int size)); /* circle with + */ void tpic_timescircle __PROTO((int size)); /* circle with times */ void tpic_starcircle __PROTO((int size)); /* circle with star */ void tpic_dotcircle __PROTO((int size)); /* circle with dot (black circle) */ void tpic_diamondcircle __PROTO((int size)); /* circle with black diamond */ void tpic_boxcircle __PROTO((int size)); /* circle with black box */ void tpic_trianglecircle __PROTO((int size)); /* circle with black triangle */ void tpic_hexagoncircle __PROTO((int size)); /* circle with black hexagon */ void tpic_plustimescircle __PROTO((int size)); /* no more idea ... with plus & times */ void tpic_abspath __PROTO((unsigned int x, unsigned int y)); /* absolute coord */ void tpic_path __PROTO((int x, int y)); void tpic_flush __PROTO((void)); void tpic_arc __PROTO((int radius)); /* actually, draw a full circle */ void tpic_shade __PROTO((double grayscale)); void tpic_pen __PROTO((int thickness)); void tpic_dottedflush __PROTO((double interval)); void tpic_dashedflush __PROTO((double interval)); typedef enum { tpic_none, tpic_white, tpic_gray, tpic_black } tpic_shadestyle; typedef enum { tpic_nosize, tpic_small, tpic_medium, tpic_large } tpic_size; typedef void (*tpic_function) __PROTO((int size)); typedef struct { tpic_shadestyle shadestyle; tpic_size size; tpic_function function; } tpic_point_info; /* POINTS */ static /*GPFAR */ tpic_point_info GPFAR tpic_point[] = { {tpic_white, tpic_medium, tpic_diamond}, {tpic_none, tpic_medium, tpic_plus}, {tpic_white, tpic_medium, tpic_box}, {tpic_none, tpic_medium, tpic_times}, {tpic_white, tpic_medium, tpic_triangle}, {tpic_none, tpic_medium, tpic_star}, {tpic_white, tpic_small, tpic_circle}, {tpic_white, tpic_medium, tpic_circle}, {tpic_white, tpic_large, tpic_circle}, {tpic_black, tpic_small, tpic_circle}, {tpic_black, tpic_medium, tpic_circle}, {tpic_black, tpic_large, tpic_circle}, {tpic_black, tpic_medium, tpic_diamond}, {tpic_black, tpic_medium, tpic_box}, {tpic_black, tpic_medium, tpic_triangle}, {tpic_white, tpic_medium, tpic_hexagon}, {tpic_black, tpic_medium, tpic_hexagon}, {tpic_white, tpic_medium, tpic_doublecircle}, {tpic_white, tpic_medium, tpic_vercircle}, {tpic_white, tpic_medium, tpic_horcircle}, {tpic_white, tpic_medium, tpic_pluscircle}, {tpic_white, tpic_medium, tpic_timescircle}, {tpic_white, tpic_medium, tpic_starcircle}, {tpic_black, tpic_medium, tpic_doublecircle}, {tpic_white, tpic_medium, tpic_dotcircle}, {tpic_white, tpic_medium, tpic_diamondcircle}, {tpic_white, tpic_medium, tpic_boxcircle}, {tpic_white, tpic_medium, tpic_trianglecircle}, {tpic_white, tpic_medium, tpic_hexagoncircle}, {tpic_white, tpic_medium, tpic_plustimescircle} }; typedef enum { tpic_solid, tpic_dotted, tpic_dashed, tpic_dashed_sdot, tpic_dashed_ddot } tpic_linestyle; typedef struct { tpic_size thickness, interval; tpic_linestyle linestyle; } tpic_line_info; /* LINES */ static /*GPFAR */ tpic_line_info GPFAR tpic_line[] = { {tpic_medium, tpic_nosize, tpic_solid}, /* -2 border */ {tpic_small, tpic_small, tpic_dashed}, /* -1 axes */ {tpic_small, tpic_nosize, tpic_solid}, {tpic_medium, tpic_nosize, tpic_solid}, {tpic_large, tpic_nosize, tpic_solid}, {tpic_small, tpic_small, tpic_dotted}, {tpic_medium, tpic_small, tpic_dotted}, {tpic_large, tpic_small, tpic_dotted}, {tpic_small, tpic_small, tpic_dashed}, {tpic_medium, tpic_small, tpic_dashed}, {tpic_large, tpic_small, tpic_dashed}, {tpic_small, tpic_small, tpic_dashed_sdot}, /* dash with single dots */ {tpic_medium, tpic_small, tpic_dashed_sdot}, {tpic_large, tpic_small, tpic_dashed_sdot}, {tpic_small, tpic_small, tpic_dashed_ddot}, /* dash with double dots */ {tpic_medium, tpic_small, tpic_dashed_ddot}, {tpic_large, tpic_small, tpic_dashed_ddot}, {tpic_small, tpic_medium, tpic_dotted}, {tpic_medium, tpic_medium, tpic_dotted}, {tpic_large, tpic_medium, tpic_dotted}, {tpic_small, tpic_medium, tpic_dashed}, {tpic_medium, tpic_medium, tpic_dashed}, {tpic_large, tpic_medium, tpic_dashed}, {tpic_small, tpic_medium, tpic_dashed_sdot}, {tpic_medium, tpic_medium, tpic_dashed_sdot}, {tpic_large, tpic_medium, tpic_dashed_sdot}, {tpic_small, tpic_medium, tpic_dashed_ddot}, {tpic_medium, tpic_medium, tpic_dashed_ddot}, {tpic_large, tpic_medium, tpic_dashed_ddot}, {tpic_small, tpic_large, tpic_dotted}, {tpic_medium, tpic_large, tpic_dotted}, {tpic_large, tpic_large, tpic_dotted}, {tpic_small, tpic_large, tpic_dashed}, {tpic_medium, tpic_large, tpic_dashed}, {tpic_large, tpic_large, tpic_dashed}, {tpic_small, tpic_large, tpic_dashed_sdot}, {tpic_medium, tpic_large, tpic_dashed_sdot}, {tpic_large, tpic_large, tpic_dashed_sdot}, {tpic_small, tpic_large, tpic_dashed_ddot}, {tpic_medium, tpic_large, tpic_dashed_ddot}, {tpic_large, tpic_large, tpic_dashed_ddot} }; TERM_PUBLIC void TPIC_options() { /* get size options */ struct value a; int ptsize, linewidth; double interval; if (!END_OF_COMMAND) { ptsize = (int) real(const_express(&a)); if (ptsize > 0) tpic_pointsize = ptsize; } if (!END_OF_COMMAND) { linewidth = (int) real(const_express(&a)); if (linewidth > 0) tpic_linewidth = linewidth; } if (!END_OF_COMMAND) { interval = (double) real(const_express(&a)); if (interval > 0) tpic_interval = interval; } sprintf(term_options, "%d %d %f", tpic_pointsize, tpic_linewidth, tpic_interval); } static unsigned int tpic_posx; /* current position */ static unsigned int tpic_posy; static int tpic_point_types; static int tpic_numlines; TERM_PUBLIC void TPIC_init() { static char GPFAR tpic1[] = "\ %% GNUPLOT: LaTeX picture using tpic \\specials\n\ %% with %d point types and %d line types\n\ %% Options: pointsize = %d, linewidth = %d, interval = %f\n\ %% To change above options, say:\n\ %% set terminal tpic pointsize_value linewidth_value interval_value\n\ %% (pointsize and linewidth - integers in milli-inches.\n\ %% interval - a float in inches. If zero is specified, \n\ %% the default value is chosen.)\n\ \\setlength{\\unitlength}{%fin}%%\n"; tpic_point_types = sizeof(tpic_point) / sizeof(tpic_point[0]); tpic_numlines = sizeof(tpic_line) / sizeof(tpic_line[0]); tpic_posx = tpic_posy = 0; TPIC_linetype(-1); fprintf(gpoutfile, tpic1, tpic_point_types, tpic_numlines - 2, tpic_pointsize, tpic_linewidth, tpic_interval, TPIC_UNIT); } TERM_PUBLIC void TPIC_reset() { tpic_endline(); tpic_posx = tpic_posy = 0; } TERM_PUBLIC void TPIC_text() { tpic_endline(); fputs("\\end{picture}\n", gpoutfile); } TERM_PUBLIC void TPIC_graphics() { register struct termentry *t = term; int left, right, top, bottom; /* margins */ static char GPFAR begin[] = "%s\\begin{picture}(%d,%d)(%d,%d)%% %s\n"; fprintf(gpoutfile, begin, "", t->xmax, t->ymax, 0, 0, ""); /* the following is dependent on boundary() function in graphics.c */ left = TPIC_HCHAR * 12; right = TPIC_HCHAR * 2 + TPIC_HTIC; bottom = TPIC_VCHAR * 7 / 2 + 1; top = TPIC_VCHAR * 5 / 2 - 1; fprintf(gpoutfile, begin, "%% ", t->xmax - left, t->ymax, left, 0, "trim left margin"); fprintf(gpoutfile, begin, "%% ", t->xmax - right, t->ymax, 0, 0, "trim right margin"); fprintf(gpoutfile, begin, "%% ", t->xmax - left - right, t->ymax, left, 0, "trim left & right margins"); fprintf(gpoutfile, begin, "%% ", t->xmax, t->ymax - top, 0, 0, "trim top margin"); fprintf(gpoutfile, begin, "%% ", t->xmax, t->ymax - bottom, 0, bottom, "trim bottom margin"); fprintf(gpoutfile, begin, "%% ", t->xmax, t->ymax - top - bottom, 0, bottom, "trim top & bottom margins"); fputs("\\footnotesize%\n", gpoutfile); } TERM_PUBLIC void TPIC_move(x, y) unsigned int x; unsigned int y; { tpic_endline(); tpic_posx = x; tpic_posy = y; } #define TPIC_LINEMAX 100 /* max value for linecount */ static TBOOLEAN tpic_inline = FALSE; /* are we in the middle of a line */ static int tpic_linecount = 0; /* number of points in line so far */ TERM_PUBLIC void TPIC_vector(ux, uy) unsigned int ux; unsigned int uy; { if (!tpic_inline) { tpic_startline(); } else if (tpic_linecount >= TPIC_LINEMAX) { /* Even though we are in middle of a path, we may start a new path command once in a while; if they are too long, latex will choke. */ tpic_endline(); tpic_startline(); } tpic_pushpath(ux, uy); tpic_posx = ux; tpic_posy = uy; } static int tpic_linetype; /* current line type */ static void tpic_startline() { /* private */ int thickness = 1; tpic_inline = TRUE; switch (tpic_line[tpic_linetype + 2].thickness) { case tpic_small: thickness = tpic_linewidth; break; case tpic_medium: thickness = (int) (tpic_linewidth * 3); break; case tpic_large: thickness = (int) (tpic_linewidth * 5); break; default: break; } tpic_pen(thickness); tpic_linecount = 0; tpic_pushpath(tpic_posx, tpic_posy); return; } static void tpic_endline() { /* private */ double interval = 1; if (tpic_inline) { tpic_scanpath(); /* draw actually */ switch (tpic_line[tpic_linetype + 2].interval) { case tpic_small: interval = tpic_interval; break; case tpic_medium: interval = tpic_interval * 2; break; case tpic_large: interval = tpic_interval * 3; break; case tpic_nosize: break; } switch (tpic_line[tpic_linetype + 2].linestyle) { case tpic_solid: tpic_flush(); break; case tpic_dotted: tpic_dottedflush(interval); break; case tpic_dashed: tpic_dashedflush(interval); break; case tpic_dashed_sdot: /* dashed with single dots in between */ tpic_dashedflush(interval); tpic_scanpath(); /* draw again */ tpic_dottedflush(interval / 2); break; case tpic_dashed_ddot: /* dashed with double dots in between */ tpic_dashedflush(interval); tpic_scanpath(); /* draw again */ tpic_dottedflush(interval / 3); break; } tpic_inline = FALSE; } return; } /* private: stack functions */ static unsigned int pathpoint[TPIC_LINEMAX][2]; /* point stack */ static void tpic_pushpath(x, y) unsigned int x; unsigned int y; /* private */ { if (tpic_linecount < TPIC_LINEMAX) { pathpoint[tpic_linecount][0] = x; pathpoint[tpic_linecount][1] = y; tpic_linecount++; } return; } static void tpic_scanpath() { int i; for (i = 0; i < tpic_linecount; i++) tpic_abspath(pathpoint[i][0], pathpoint[i][1]); return; } TERM_PUBLIC void TPIC_linetype(linetype) int linetype; { tpic_endline(); if (linetype >= tpic_numlines - 2) linetype %= (tpic_numlines - 2); tpic_linetype = linetype; } static int tpic_angle = 0; /* 0 = horizontal, 1 = vertical */ static enum JUSTIFY tpic_justify = LEFT; TERM_PUBLIC void TPIC_put_text(x, y, str) unsigned int x; unsigned int y; char *str; /* ref point and text */ { char *justify = NULL; tpic_endline(); fprintf(gpoutfile, "\\put(%d,%d)", x, y); if ((str[0] == '{') || (str[0] == '[')) { fprintf(gpoutfile, "{\\makebox(0,0)%s}\n", str); } else switch (tpic_angle) { case 0: /* horizontal */ switch (tpic_justify) { case LEFT: justify = "[l]"; break; case CENTRE: justify = ""; break; case RIGHT: justify = "[r]"; break; } fprintf(gpoutfile, "{\\makebox(0,0)%s{%s}}\n", justify, str); break; case 1: /* vertical */ /* we can't really write text vertically, but will put the ylabel centred at the left of the plot, and then we'll make a \shortstack */ switch (tpic_justify) { case LEFT: justify = "[lb]"; break; case CENTRE: justify = "[l]"; break; case RIGHT: justify = "[lt]"; break; } fprintf(gpoutfile, "{\\makebox(0,0)%s{\\shortstack{%s}}}\n", justify, str); break; } } TERM_PUBLIC int TPIC_text_angle(ang) int ang; { tpic_angle = ang; return (TRUE); } TERM_PUBLIC int TPIC_justify_text(mode) enum JUSTIFY mode; { tpic_justify = mode; return (TRUE); } TERM_PUBLIC void TPIC_point(x, y, number) unsigned int x; unsigned int y; int number; { int size = 0; TPIC_move(x, y); /* Print the character defined by 'number'; number < 0 means to use a dot, otherwise one of the defined points. */ fprintf(gpoutfile, "\\put(%d,%d){", x, y); /* start putting */ if (number < 0) { fprintf(gpoutfile, "\\rule{.1pt}{.1pt}"); /* tiny dot */ } else { number %= tpic_point_types; switch (tpic_point[number].shadestyle) { case tpic_white: tpic_pen(tpic_linewidth); /* set it thin */ tpic_shade(0.0); break; case tpic_gray: tpic_pen(tpic_linewidth); tpic_shade(0.5); break; case tpic_black: tpic_pen(tpic_linewidth); tpic_shade(1.0); break; case tpic_none: tpic_pen(tpic_linewidth * 3); /* set it thick */ break; } switch (tpic_point[number].size) { case tpic_small: size = tpic_pointsize; break; case tpic_medium: size = (int) (tpic_pointsize * 1.4142); break; case tpic_large: size = (int) (tpic_pointsize * 2.0); break; default: break; } (tpic_point[number].function) (size); } fputs("}%%\n", gpoutfile); /* end putting */ } TERM_PUBLIC void TPIC_arrow(sx, sy, ex, ey, head) unsigned int sx; unsigned int sy; unsigned int ex; unsigned int ey; TBOOLEAN head; { best_latex_arrow(sx, sy, ex, ey, 1, head); /* call latex routine */ tpic_posx = ex; tpic_posy = ey; } /* private: draw points with tpic commands */ void tpic_diamond(size) int size; { size = (int) (size * 1.4142); /* spread by sqrt(2) */ tpic_path(0, size); tpic_path(-size, 0); tpic_path(0, -size); tpic_path(size, 0); tpic_path(0, size); tpic_flush(); return; } void tpic_plus(size) int size; { tpic_path(0, size); tpic_path(0, -size); tpic_flush(); tpic_path(size, 0); tpic_path(-size, 0); tpic_flush(); return; } void tpic_box(size) int size; { tpic_path(size, size); tpic_path(-size, size); tpic_path(-size, -size); tpic_path(size, -size); tpic_path(size, size); tpic_flush(); return; } void tpic_times(size) int size; { size = (int) (size / 1.4142); /* reduce by sqrt(2) */ tpic_path(size, size); tpic_path(-size, -size); tpic_flush(); tpic_path(size, -size); tpic_path(-size, size); tpic_flush(); return; } void tpic_triangle(size) int size; { int x; size = (int) (size / 1.6119); /* reduce by sqrt(3 * sqrt(3) / 2) */ x = (int) (size * 1.7321); tpic_path(0, -size * 2); tpic_path(-x, size); tpic_path(x, size); tpic_path(0, -size * 2); tpic_flush(); return; } void tpic_star(size) int size; { int x; size = (int) (size / 2); /* reduce by 2 */ x = (int) (size * 1.7321); tpic_path(0, size * 2); tpic_path(0, -size * 2); tpic_flush(); tpic_path(x, size); tpic_path(-x, -size); tpic_flush(); tpic_path(x, -size); tpic_path(-x, size); tpic_flush(); return; } void tpic_hexagon(size) int size; { int x; size = (int) (size / 2); /* reduce by 2 */ x = (int) (size * 1.7321); tpic_path(0, size * 2); tpic_path(-x, size); tpic_path(-x, -size); tpic_path(0, -size * 2); tpic_path(x, -size); tpic_path(x, size); tpic_path(0, size * 2); tpic_flush(); return; } void tpic_circle(size) int size; { tpic_arc(size); return; } void tpic_doublecircle(size) int size; { tpic_arc(size); tpic_shade(0.0); tpic_arc(size / 2); return; } void tpic_vercircle(size) int size; /* circle with | */ { tpic_arc(size); tpic_path(0, size); tpic_path(0, -size); tpic_flush(); return; } void tpic_horcircle(size) int size; /* circle with - */ { tpic_arc(size); tpic_path(size, 0); tpic_path(-size, 0); tpic_flush(); return; } void tpic_pluscircle(size) int size; /* circle with + */ { tpic_arc(size); tpic_plus(size); return; } void tpic_timescircle(size) int size; /* circle with times */ { tpic_arc(size); tpic_times(size); return; } void tpic_starcircle(size) int size; /* circle with star */ { tpic_arc(size); tpic_star(size); return; } void tpic_dotcircle(size) int size; /* circle with dot (black circle) */ { tpic_arc(size); tpic_shade(1.0); tpic_arc(size / 2); return; } void tpic_diamondcircle(size) int size; /* not enough? circle with black diamond */ { tpic_arc(size); tpic_shade(1.0); tpic_diamond((int) (size / 1.5)); return; } void tpic_boxcircle(size) int size; /* need more? circle with black box */ { tpic_arc(size); tpic_shade(1.0); tpic_box((int) (size / 1.5)); return; } void tpic_trianglecircle(size) int size; /* circle with black triangle */ { tpic_arc(size); tpic_shade(1.0); tpic_triangle((int) (size / 1.5)); return; } void tpic_hexagoncircle(size) int size; /* how about circle with black hexagon? */ { tpic_arc(size); tpic_shade(1.0); tpic_hexagon((int) (size / 1.2)); return; } void tpic_plustimescircle(size) int size; /* no more idea ... with plus & times */ { tpic_arc(size); tpic_plus(size); tpic_times(size); return; } /* private: draw lines */ void tpic_abspath(x, y) unsigned int x; unsigned int y; /* absolute coord */ { fprintf(gpoutfile, "\\put(%u,%u){", x, y); /* start putting */ tpic_path(0, 0); fputs("}%\n", gpoutfile); /* end putting */ return; } /* private: tpic primitive functions */ void tpic_path(x, y) int x; int y; { fprintf(gpoutfile, "\\special{pa %d %d}", x, y); return; } void tpic_flush() { fputs("\\special{fp}%\n", gpoutfile); return; } void tpic_arc(radius) int radius; /* actually, draw a full circle */ { fprintf(gpoutfile, "\\special{ar 0 0 %d %d 0 7}", radius, radius); return; } void tpic_shade(grayscale) double grayscale; { fprintf(gpoutfile, "\\special{sh %f}", grayscale); return; } void tpic_pen(thickness) int thickness; { fprintf(gpoutfile, "\\special{pn %d}", thickness); return; } void tpic_dottedflush(interval) double interval; { fprintf(gpoutfile, "\\special{dt %f}%%\n", interval); return; } void tpic_dashedflush(interval) double interval; { fprintf(gpoutfile, "\\special{da %f}%%\n", interval); return; } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(tpic_driver) "tpic", "TPIC -- LaTeX picture environment with tpic \\specials", TPIC_XMAX, TPIC_YMAX, TPIC_VCHAR, TPIC_HCHAR, TPIC_VTIC, TPIC_HTIC, TPIC_options, TPIC_init, TPIC_reset, TPIC_text, null_scale, TPIC_graphics, TPIC_move, TPIC_vector, TPIC_linetype, TPIC_put_text, TPIC_text_angle, TPIC_justify_text, TPIC_point, TPIC_arrow, set_font_null TERM_TABLE_END(tpic_driver) #undef LAST_TERM #define LAST_TERM tpic_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(tpic) "1 tpic", "?commands set terminal tpic", "?set terminal tpic", "?set term tpic", "?terminal tpic", "?term tpic", "?tpic", " The `tpic` terminal driver supports the LaTeX picture environment with tpic", " \\specials. It is an alternative to the `latex` and `eepic` terminal drivers.", " Options are the point size, line width, and dot-dash interval.", "", " Syntax:", " set terminal tpic <pointsize> <linewidth> <interval>", "", " where `pointsize` and `linewidth` are integers in milli-inches and `interval`", " is a float in inches. If a non-positive value is specified, the default is", " chosen: pointsize = 40, linewidth = 6, interval = 0.1.", "", " All drivers for LaTeX offer a special way of controlling text positioning:", " If any text string begins with '{', you also need to include a '}' at the", " end of the text, and the whole text will be centered both horizontally", " and vertically by LaTeX. --- If the text string begins with '[', you need", " to continue it with: a position specification (up to two out of t,b,l,r),", " ']{', the text itself, and finally, '}'. The text itself may be anything", " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.", "", " Examples:", " About label positioning:", " Use gnuplot defaults (mostly sensible, but sometimes not really best):", " set title '\\LaTeX\\ -- $ \\gamma $'", " Force centering both horizontally and vertically:", " set label '{\\LaTeX\\ -- $ \\gamma $}' at 0,0", " Specify own positioning (top here):", " set xlabel '[t]{\\LaTeX\\ -- $ \\gamma $}'", " The other label -- account for long ticlabels:", " set ylabel '[r]{\\LaTeX\\ -- $ \\gamma $\\rule{7mm}{0pt}'" END_HELP(tpic) #endif /* TERM_TABLE */ /* * $Id: unixpc.trm,v 1.14 1998/04/14 00:18:12 drd Exp $ * */ /* GNUPLOT - unixpc.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Unix PC's (ATT 3b1) * * AUTHORS * John Campbell * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* >From: John Campbell (...!arizona!naucse!jdc) I originally ported gnuplot to the ATT 3b1 (ATT7300) on 12/4/88, and then added the minimal code needed to bring it up to 2.0 level on 1/28/90. The 3b1, as I view it, is a 720x300 bitmapped, monochrome display (often people don't use the top 12 scan lines and thus the effective size is 720x288). I tried to maximize the size of the graph area, by using these top 12 lines (normally reserved) and set up a signal handler to restore them upon exit, abort, etc. Line styles were "fudged" (they do not know the aspect ratio). The same line style may look different depending upon the slope of the curve. Due to this only 4 line styles were implemented. While more line types are possible, the current styles were chosen as distinguishable. The 3b1 has 4 "special" rows at the bottom that I could not use in graphics mode. It has been suggested that we use these lines for command prompting. Others have requested that we have a graphics window and a command window. My experience with gnuplot only includes relatively dumb graphics devices-- hence gnuplot "looks and feels" normal to me the way I implemented it. I welcome either of these changes from someone else, however. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(unixpc) #endif #ifdef TERM_PROTO TERM_PUBLIC void uPC_init __PROTO((void)); TERM_PUBLIC void uPC_graphics __PROTO((void)); TERM_PUBLIC void uPC_text __PROTO((void)); TERM_PUBLIC void uPC_linetype __PROTO((int linetype)); TERM_PUBLIC void uPC_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void uPC_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void uPC_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int uPC_text_angle __PROTO((int ang)); TERM_PUBLIC void uPC_reset __PROTO((void)); #define uPC_XMAX 720 #define uPC_YMAX 300 #define uPC_VCHAR FNT5X9_VCHAR #define uPC_HCHAR FNT5X9_HCHAR #define uPC_VTIC uPC_VCHAR/2 /* Was 8 */ #define uPC_HTIC uPC_HCHAR /* Was 12 */ #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void uPC_fixwind __PROTO((int signo)); void uPC_putc __PROTO((unsigned int x, unsigned int y, int c, int angle)); void uPC_plot_word __PROTO((unsigned short *a, unsigned short b)); #include <sys/window.h> /* Started with tam.h--too much trouble. */ #include <sys/signal.h> #include <errno.h> #define uPC_HIGH_BIT (0x8000) typedef unsigned short Scr_type; typedef unsigned char Scr_kluge; #define uPC_XSIZE 45 /* Short ints. */ #define uPC_YSIZE uPC_YMAX Scr_type uPC_display[uPC_YSIZE][uPC_XSIZE]; int uPC_width = 2 * uPC_XSIZE; int uPC_sx = 0, uPC_sy = 0; int uPC_cur_linetype = 0; int uPC_angle = 0; unsigned short uPC_raster_count = 0; static Scr_type lookup[] = { 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, }; #define uPC_XLAST (uPC_XMAX - 1) #define uPC_YLAST (uPC_YMAX - 1) static struct urdata uPC_ur = { (unsigned short *) uPC_display, 2 * uPC_XSIZE, 0, 0, 0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0 }; #define IfErrOut(e1,e2,s1,s2) if (e1 e2) {\ fprintf(stderr, "%s:: %s %s\n", sys_errlist[errno], s1, s2);\ uPC_fixwind(0);\ exit(-1);} TERM_PUBLIC void uPC_init() { /* This routine will ioctl to change 0 size */ int i; struct uwdata uw; int uPC_fixwind(); short gw; /* Check that we are on the bitmapped window. */ if (iswind() != 0) { fputs("Sorry--must run from the bitmapped terminal\n", stderr); exit(-1); } for (i = 1; i <= 16; i++) { if (i != SIGINT && i != SIGFPE) /* Two are caught in plot.c */ signal(i, uPC_fixwind); } /* Increase the screen size */ uw.uw_x = 0; uw.uw_y = 0; /* Leave room for top status line. */ uw.uw_width = uPC_XMAX; /* 720 */ uw.uw_height = uPC_YMAX; /* 288 normal--we clobber 12 (top row) */ uw.uw_uflags = 1; /* Creates with no border */ IfErrOut(ioctl(1, WIOCSETD, &uw), <0, "ioctl failed on", "WIOCSETD"); } TERM_PUBLIC void uPC_graphics() { /* This routine will clear the uPC_display buffer and window. */ register Scr_type *j; register int i; j = (Scr_type *) uPC_display; i = uPC_YSIZE * uPC_XSIZE + 1; while (--i) *j++ = 0; /* Position the cursor to the bottom of the screen so when we come back to * text mode we are just below the graph. */ fputs("\033[25;1H", stdout); uPC_ur.ur_dstop = DSTSRC; /* replace (clear screen). */ IfErrOut(ioctl(1, WIOCRASTOP, &uPC_ur), <0, "ioctl failed", "WIOCRASTOP"); uPC_ur.ur_dstop = DSTOR; /* Or in (show text) */ } TERM_PUBLIC void uPC_text() { /* This routine will flush the display. */ IfErrOut(ioctl(1, WIOCRASTOP, &uPC_ur), <0, "ioctl failed", "WIOCRASTOP"); } TERM_PUBLIC void uPC_linetype(linetype) int linetype; { /* This routine records the current linetype. */ if (uPC_cur_linetype != linetype) { uPC_raster_count = 0; uPC_cur_linetype = linetype; } } TERM_PUBLIC void uPC_move(x, y) unsigned int x, y; { /* This routine just records x and y in uPC_sx, uPC_sy */ uPC_sx = x; uPC_sy = y; } /* Was just (*(a)|=(b)) */ #define uPC_PLOT(a,b) (uPC_cur_linetype != 0 ? uPC_plot_word (a,b) :\ (*(a)|=(b))) void uPC_plot_word(a, b) Scr_type *a, b; /* Weak attempt to make line styles. The real problem is the aspect ratio. This routine is called only when a bit is to be turned on in a horizontal word. A better line style routine would know something about the slope of the line around the current point (in order to change weighting). This yields 3 working linetypes plus a usable axis line type. */ { /* Various line types */ switch (uPC_cur_linetype) { case -1: /* Distinguish between horizontal and vertical axis. */ if (uPC_sx > uPC_XMAX / 8 && uPC_sx < 7 * uPC_XMAX / 8) { /* Fuzzy tolerance because we don't know exactly where the y axis is */ if (++uPC_raster_count % 2 == 0) *(a) |= b; } else { /* Due to aspect ratio, take every other y pixel and every third x. */ *(a) |= (b & 0x9999); } break; case 1: case 5: /* Make a | |----| |----| type of line. */ if ((1 << uPC_raster_count) & 0xF0F0) *(a) |= b; if (++uPC_raster_count > 15) uPC_raster_count = 0; break; case 2: case 6: /* Make a |----|----|----|--- | | type of line. */ if ((1 << uPC_raster_count) & 0x0EFFF) *(a) |= b; if (++uPC_raster_count > 19) uPC_raster_count = 0; break; case 3: case 7: /* Make a | - | - | - | - | type of line. */ if ((1 << uPC_raster_count) & 0x4444) *(a) |= b; if (++uPC_raster_count > 15) uPC_raster_count = 0; break; case 4: case 8: default: *(a) |= b; break; } } TERM_PUBLIC void uPC_vector(x, y) unsigned int x, y; { /* This routine calls line with x,y */ int x1 = uPC_sx, y1 = uPC_sy, x2 = x, y2 = y; register int c, e, dx, dy, width; register Scr_type mask, *a; /* Record new sx, sy for next call to the vector routine. */ uPC_sx = x2; uPC_sy = y2; a = &uPC_display[(uPC_YSIZE - 1) - y1][x1 >> 4]; mask = lookup[x1 & 0x0f]; width = uPC_width; if ((dx = x2 - x1) > 0) { if ((dy = y2 - y1) > 0) { if (dx > dy) { /* dx > 0, dy > 0, dx > dy */ dy <<= 1; e = dy - dx; c = dx + 2; dx <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { (Scr_kluge *) a -= width; e -= dx; } if (mask & uPC_HIGH_BIT) { mask = 1; a++; } else mask <<= 1; e += dy; } } else { /* dx > 0, dy > 0, dx <= dy */ dx <<= 1; e = dx - dy; c = dy + 2; dy <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { if (mask & uPC_HIGH_BIT) { mask = 1; a++; } else mask <<= 1; e -= dy; } (Scr_kluge *) a -= width; e += dx; } } } else { dy = -dy; if (dx > dy) { /* dx > 0, dy <= 0, dx > dy */ dy <<= 1; e = dy - dx; c = dx + 2; dx <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { (Scr_kluge *) a += width; e -= dx; } if (mask & uPC_HIGH_BIT) { mask = 1; a++; } else mask <<= 1; e += dy; } } else { /* dx > 0, dy <= 0, dx <= dy */ dx <<= 1; e = dx - dy; c = dy + 2; dy <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { if (mask & uPC_HIGH_BIT) { mask = 1; a++; } else mask <<= 1; e -= dy; } (Scr_kluge *) a += width; e += dx; } } } } else { dx = -dx; if ((dy = y2 - y1) > 0) { if (dx > dy) { /* dx <= 0, dy > 0, dx > dy */ dy <<= 1; e = dy - dx; c = dx + 2; dx <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { (Scr_kluge *) a -= width; e -= dx; } if (mask & 1) { mask = uPC_HIGH_BIT; a--; } else mask >>= 1; e += dy; } } else { /* dx <= 0, dy > 0, dx <= dy */ dx <<= 1; e = dx - dy; c = dy + 2; dy <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { if (mask & 1) { mask = uPC_HIGH_BIT; a--; } else mask >>= 1; e -= dy; } (Scr_kluge *) a -= width; e += dx; } } } else { dy = -dy; if (dx > dy) { /* dx <= 0, dy <= 0, dx > dy */ dy <<= 1; e = dy - dx; c = dx + 2; dx <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { (Scr_kluge *) a += width; e -= dx; } if (mask & 1) { mask = uPC_HIGH_BIT; a--; } else mask >>= 1; e += dy; } } else { /* dx <= 0, dy <= 0, dx <= dy */ dx <<= 1; e = dx - dy; c = dy + 2; dy <<= 1; while (--c) { uPC_PLOT(a, mask); if (e >= 0) { if (mask & 1) { mask = uPC_HIGH_BIT; a--; } else mask >>= 1; e -= dy; } (Scr_kluge *) a += width; e += dx; } } } } } #ifdef uPC_NOT_USED /* Added by Russell Lang, eln272v@monu1.cc.monash.oz This placement to the nearest character cell worked, and I'm leaving it here so the calculations involved won't be lost! (jdc) */ TERM_PUBLIC void uPC_put_text(x, y, str) unsigned int x, y; char str[]; { /* This routine puts the text at the cursor location nearest to (x,y). Obviously the exact postion would look better */ /* Just use the ANSI escape sequence CUP (iswind said that was ok!) */ printf("\033[%d;%dH%s\033[25;1H", (int) (24 - (y - uPC_VCHAR / 2) * 25 / uPC_YMAX), (int) (x * 80 / uPC_XMAX), str); fflush(stdout); } #endif TERM_PUBLIC void uPC_put_text(x, y, str) unsigned int x, y; char str[]; { if (uPC_angle == 1) x += uPC_VCHAR / 2; else y -= uPC_VCHAR / 2; switch (uPC_angle) { case 0: for (; *str; ++str, x += uPC_HCHAR) uPC_putc(x, y, *str, uPC_angle); break; case 1: for (; *str; ++str, y += uPC_HCHAR) uPC_putc(x, y, *str, uPC_angle); break; } } void uPC_putc(x, y, c, angle) unsigned int x, y; int c, angle; /* Put a character at an x,y location in the bit map (using the fnt5x9 array. This is mostly just copied from the bitmap.c driver. */ { int i, j, k; register Scr_type mask, *a; char_row fc; unsigned int pixelon; i = c - ' '; for (j = 0; j < FNT5X9_VBITS; j++) { fc = fnt5x9[i][j]; for (k = 0; k < FNT5X9_HBITS; k++) { pixelon = ((unsigned int) (fc)) >> k & 1; if (pixelon) { switch (angle) { case 0: mask = lookup[x + k + 1 & 0x0f]; a = &uPC_display[(uPC_YSIZE - 1) - (y + j)][(x + k + 1) >> 4]; break; case 1: mask = lookup[x - j & 0x0f]; a = &uPC_display[(uPC_YSIZE - 1) - (y + k + 1)][(x - j) >> 4]; break; } *(a) |= (mask); /* see uPC_PLOT macro */ } } } } TERM_PUBLIC int uPC_text_angle(ang) int ang; { uPC_angle = ang; return TRUE; } TERM_PUBLIC void uPC_reset() { /* Reset window to normal size. */ uPC_fixwind(0); } void uPC_fixwind(signo) int signo; { static struct uwdata wreset = {0, 12, 720, 288, 0x1}; struct utdata ut; /* Reset the window to the right size. */ ioctl(1, WIOCSETD, &wreset); /* 0, not wncur here! */ /* Scroll the screen once. (avoids typing over the same line) */ putc('\n', stderr); if (signo) { if (signo == SIGILL || signo == SIGTRAP || signo == SIGPWR) signal(signo, SIG_DFL); kill(0, signo); /* Redo the signal (as if we never trapped it). */ } } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(unixpc_driver) "unixpc", "AT&T 3b1 or AT&T 7300 Unix PC", uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR, uPC_VTIC, uPC_HTIC, options_null, uPC_init, uPC_reset, uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector, uPC_linetype, uPC_put_text, uPC_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(unixpc_driver) #undef LAST_TERM #define LAST_TERM unixpc_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(unixpc) "1 unixpc", "?commands set terminal unixpc", "?set terminal unixpc", "?set term unixpc", "?terminal unixpc", "?term unixpc", "?unixpc", " The `unixpc` terminal driver supports AT&T 3b1 and AT&T 7300 Unix PC. It has", " no options." END_HELP(unixpc) #endif /* TERM_HELP */ /* * $Id: unixplot.trm,v 1.13 1998/04/14 00:18:13 drd Exp $ * */ /* GNUPLOT -- unixplot.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Unix plot(5) graphics language * * AUTHORS * Colin Kelley, Thomas Williams, Russell Lang * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * Unixplot library writes to stdout. A fix was put in place by * ..!arizona!naucse!jdc to let set term and set output redirect * stdout. All other terminals write to gpoutfile. */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(unixplot) #endif #ifdef TERM_PROTO TERM_PUBLIC void UP_init __PROTO((void)); TERM_PUBLIC void UP_graphics __PROTO((void)); TERM_PUBLIC void UP_text __PROTO((void)); TERM_PUBLIC void UP_linetype __PROTO((int linetype)); TERM_PUBLIC void UP_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void UP_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void UP_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void UP_reset __PROTO((void)); #define UP_XMAX 4096 #define UP_YMAX 4096 #define UP_XLAST (UP_XMAX - 1) #define UP_YLAST (UP_YMAX - 1) #define UP_VCHAR (UP_YMAX/30) /* just a guess--no way to know this! */ #define UP_HCHAR (UP_XMAX/60) /* just a guess--no way to know this! */ #define UP_VTIC (UP_YMAX/80) #define UP_HTIC (UP_XMAX/80) #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY TERM_PUBLIC void UP_init() { openpl(); space(0, 0, UP_XMAX, UP_YMAX); } TERM_PUBLIC void UP_graphics() { erase(); } TERM_PUBLIC void UP_text() { /* empty */ } TERM_PUBLIC void UP_linetype(linetype) int linetype; { static char *lt[2 + 5] = {"solid", "longdashed", "solid", "dotted", "shortdashed", "dotdashed", "longdashed"}; if (linetype >= 5) linetype %= 5; linemod(lt[linetype + 2]); } TERM_PUBLIC void UP_move(x, y) unsigned int x, y; { move(x, y); } TERM_PUBLIC void UP_vector(x, y) unsigned int x, y; { cont(x, y); } TERM_PUBLIC void UP_put_text(x, y, str) unsigned int x, y; char str[]; { UP_move(x + UP_HCHAR / 2, y + UP_VCHAR / 5); label(str); } TERM_PUBLIC void UP_reset() { closepl(); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(unixplot_driver) "unixplot", "Unix plotting standard (see plot(1))", UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset, UP_text, null_scale, UP_graphics, UP_move, UP_vector, UP_linetype, UP_put_text, null_text_angle, null_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(unixplot_driver) #undef LAST_TERM #define LAST_TERM unixplot_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(unixplot) "1 unixplot", "?comands set terminal unixplot", "?set terminal unixplot", "?set term unixplot", "?terminal unixplot", "?term unixplot", "?unixplot", " The `unixplot` terminal driver generates output in the Unix \"plot\" graphics", " language. It has no options.", "", " This terminal cannot be compiled if the GNU version of plot is to be used;", " in that case, use the `gnugraph` terminal instead." END_HELP(unixplot) #endif /* * $Id: v384.trm,v 1.13 1998/04/14 00:18:13 drd Exp $ * */ /* GNUPLOT - v384.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * Vectrix 384 - works with tandy color printer as well * * AUTHORS * roland@moncskermit.OZ (Roland Yap) * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * Vectrix 384 driver - works with tandy color printer as well * in reverse printing 8 color mode. * This doesn't work on Vectrix 128 because it redefines the * color table. It can be hacked to work on the 128 by changing * the colours but then it will probably not print best. The color * table is purposely designed so that it will print well * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(vx384) #endif #ifdef TERM_PROTO TERM_PUBLIC void V384_init __PROTO((void)); TERM_PUBLIC void V384_graphics __PROTO((void)); TERM_PUBLIC void V384_text __PROTO((void)); TERM_PUBLIC void V384_linetype __PROTO((int linetype)); TERM_PUBLIC void V384_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void V384_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void V384_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC void V384_reset __PROTO((void)); #define V384_XMAX 630 #define V384_YMAX 480 #define V384_XLAST (V384_XMAX - 1) #define V384_YLAST (V384_YMAX - 1) #define V384_VCHAR 12 #define V384_HCHAR 7 #define V384_VTIC 8 #define V384_HTIC 7 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY TERM_PUBLIC void V384_init() { fprintf(gpoutfile, "%c%c G0 \n\ Q 0 8\n\ 0 0 0\n\ 255 0 0\n\ 0 255 0\n\ 0 0 255\n\ 0 255 255\n\ 255 0 255\n\ 255 255 0\n\ 255 255 255\n", 27, 18); } TERM_PUBLIC void V384_graphics() { fprintf(gpoutfile, "%c%c E0 RE N 65535\n", 27, 18); } TERM_PUBLIC void V384_text() { fprintf(gpoutfile, "%c%c\n", 27, 17); } TERM_PUBLIC void V384_linetype(linetype) int linetype; { static int color[] = { 1 /* red */ , 2 /* green */ , 3 /* blue */ , 4 /* cyan */ , 5 /* magenta */ , 6 /* yellow */ , /* not a good color so not in use at the moment */ 7 /* white */ }; if (linetype < 0) linetype = 6; else linetype %= 5; fprintf(gpoutfile, "C %d\n", color[linetype]); } TERM_PUBLIC void V384_move(x, y) unsigned int x, y; { fprintf(gpoutfile, "M %d %d\n", x + 20, y); } TERM_PUBLIC void V384_vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "L %d %d\n", x + 20, y); } TERM_PUBLIC void V384_put_text(x, y, str) unsigned int x, y; char str[]; { V384_move(x, y + V384_VCHAR / 2); fprintf(gpoutfile, "$%s\n", str); } TERM_PUBLIC void V384_reset() { } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(vx384_driver) "vx384", "Vectrix 384 and Tandy color printer", V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset, V384_text, null_scale, V384_graphics, V384_move, V384_vector, V384_linetype, V384_put_text, null_text_angle, null_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(vx384_driver) #undef LAST_TERM #define LAST_TERM vx384_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(vx384) "1 vx384", "?commands set terminal vx384", "?set terminal vx384", "?set term vx384", "?terminal vx384", "?term vx384", "?vx384", " The `vx384` terminal driver supports the Vectrix 384 and Tandy color", " printers. It has no options." END_HELP(vx384) #endif /* * $Id: vws.trm,v 1.14 1998/04/14 00:18:14 drd Exp $ * */ /* GNUPLOT - vws.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This file is included by ../term.c. * * This terminal driver supports: * IRIS terminals * * AUTHORS * Walter Speth * BITNET: SPETH@DBNPIB5 * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) * adapted to VAX VMS 4.7, VAX C 2.4 and activated the INTENSITY and COLOR * monitor features (Lucas P. Hart, June 1997) */ #include "driver.h" #ifdef TERM_REGISTER register_term(vws) #endif #ifdef TERM_PROTO TERM_PUBLIC void VWS_init __PROTO((void)); TERM_PUBLIC void VWS_reset __PROTO((void)); TERM_PUBLIC int VWS_scale __PROTO((double xs, double ys)); TERM_PUBLIC void VWS_graphics __PROTO((void)); TERM_PUBLIC void VWS_text __PROTO((void)); TERM_PUBLIC void VWS_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void VWS_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void VWS_linetype __PROTO((int lt)); TERM_PUBLIC void VWS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int VWS_text_angle __PROTO((int ang)); TERM_PUBLIC int VWS_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void VWS_point __PROTO((unsigned int x, unsigned int y, int point)); TERM_PUBLIC void VWS_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head)); #define VWS_XMAX 1024 #define VWS_YMAX 780 /* VAXstation 2000 is 864 */ #define VWS_VCHAR 25 #define VWS_HCHAR 15 #define VWS_VTIC 10 #define VWS_HTIC 10 #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY void VWS_resize_ast __PROTO((void)); #include <ssdef.h> /* */ #include <descrip.h> #include <uisentry.h> #include <uisusrdef.h> #define DEFAULT_ATTR 0 #define OVER_ATTR 1 #define ERAS_ATTR 2 #define BIS_ATTR 3 #define COLOR_ATTR 4 #define TEXT_ATTR 5 #define LINE_ATTR 6 #define BACK_ATTR 7 float current_x, current_y; int vd_id, wd_id; int vcm_id, ws_type; static $DESCRIPTOR(ws_devname, "SYS$WORKSTATION"); static $DESCRIPTOR(vd_title, "gnuplot"); static float x0, y0, xsiz, ysiz, wc_xmin_new, wc_ymin_new, wc_xmax_new, wc_ymax_new, wc_xmin, wc_ymin, wc_xmax, wc_ymax, vd_width, vd_height; void VWS_resize_ast() { extern void replotrequest(); /* in command.c */ uis$resize_window(&vd_id, &wd_id, &x0, &y0, &xsiz, &ysiz, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax); replotrequest(); } /****************************************************************************/ TERM_PUBLIC void VWS_init() { int i; int cattr; $DESCRIPTOR(a_font, "DTABER0003WK00PG0001UZZZZ02A000"); const int i0 = 0, i1 = 1, i2 = 2, i3 = 3, i4 = 4, i5 = 5, i6 = 6, i7 = 7, i8 = 8; const float p0 = 0.0, p1 = 0.1, p2 = 0.2, p3 = 0.3, p4 = 0.4; const float p5 = 0.5, p6 = 0.6, p7 = 0.7, p8 = 0.8, p9 = 0.9; const int n1 = 0xFFFFFFFF; const int uis$c_mode_over = UIS$C_MODE_OVER; const int uis$c_mode_eras = UIS$C_MODE_ERAS; const int uis$c_mode_bis = UIS$C_MODE_BIS; const float vws_hchar = (float) VWS_HCHAR; const float vws_vchar = (float) VWS_VCHAR; const int default_attr = DEFAULT_ATTR; const int over_attr = OVER_ATTR; const int eras_attr = ERAS_ATTR; const int bis_attr = BIS_ATTR; const int color_attr = COLOR_ATTR; const int text_attr = TEXT_ATTR; const int line_attr = LINE_ATTR; const int back_attr = BACK_ATTR; /* lph: the similar notation may lead to some confusion * attributes are grouped in "attribute block" data structures * which are referenced by block number * attribute block 0 contains default attribute settings * * To customize settings, a function will read the source * attribute block, set the particular attribute, and * write to the destination attribute block. * Both the block number and attribute are integers, so it * is easy to confuse an attribute and an attribute blcok */ /* lph: Color map corresponding to an example in * MicroVMS Graphics Progamming Guide (V3.0) */ const float r_map[8] = { 0.40, 0.50, 0.50, 0.00, 0.25, 0.90, 0.80, 0.35 }; const float g_map[8] = { 0.30, 0.50, 0.25, 0.70, 0.25, 0.50, 0.30, 0.65 }; const float b_map[8] = { 0.00, 0.50, 0.50, 0.30, 0.90, 0.00, 0.00, 0.95 }; /* the array format is easier to customize */ vd_width = 14; vd_height = 10; /* aspect sqrt(2) as DIN A paper */ wc_xmin = 0.0; wc_ymin = 0.0; wc_xmax = (float) VWS_XMAX; wc_ymax = (float) VWS_YMAX; vcm_id = uis$create_color_map(&i8); vd_id = uis$create_display(&wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax, &vd_width, &vd_height, &vcm_id); uis$get_hw_color_info(&ws_devname, &ws_type); /* lph: ws's color table for monochrome */ /* by default, color table index 0 is backgound, and 1 is foregound */ /* a color {index into the color table} is assigned to the active line */ /* in VWS_linetype */ if (ws_type == UIS$C_DEV_MONO) { uis$set_color(&vd_id, &i0, &p5, &p5, &p5); uis$set_color(&vd_id, &i1, &p0, &p0, &p0); uis$set_color(&vd_id, &i2, &p0, &p0, &p0); uis$set_color(&vd_id, &i3, &p0, &p0, &p0); uis$set_color(&vd_id, &i4, &p0, &p0, &p0); uis$set_color(&vd_id, &i5, &p0, &p0, &p0); uis$set_color(&vd_id, &i6, &p0, &p0, &p0); uis$set_color(&vd_id, &i7, &p0, &p0, &p0); } else if (ws_type == UIS$C_DEV_INTENSITY) { /* Intensity scale, untested */ uis$set_color(&vd_id, &i2, &p2, &p2, &p2); uis$set_color(&vd_id, &i3, &p3, &p3, &p3); uis$set_color(&vd_id, &i4, &p4, &p4, &p4); uis$set_color(&vd_id, &i5, &p5, &p5, &p5); uis$set_color(&vd_id, &i6, &p6, &p6, &p6); uis$set_color(&vd_id, &i7, &p7, &p7, &p7); } /* ws: perhaps better for color terms (which I do not have) */ else if (ws_type == UIS$C_DEV_COLOR) { /* */ uis$set_color(&vd_id, &i0, &p0, &p0, &p0); uis$set_color(&vd_id, &i1, &p9, &p0, &p0); uis$set_color(&vd_id, &i2, &p0, &p9, &p0); uis$set_color(&vd_id, &i3, &p9, &p9, &p0); uis$set_color(&vd_id, &i4, &p0, &p0, &p9); uis$set_color(&vd_id, &i5, &p9, &p0, &p9); uis$set_color(&vd_id, &i6, &p0, &p9, &p9); uis$set_color(&vd_id, &i7, &p9, &p9, &p9); /* * lph: Another way to set up the color table is to use arrays, * which simplifies customizing the appearance. * uis$set_colors(&vd_id, &i0, &i8, &r_map, &g_map, &b_map); */ } uis$disable_display_list(&vd_id); wd_id = uis$create_window(&vd_id, &ws_devname, &vd_title, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax, &vd_width, &vd_height); uis$set_resize_ast(&vd_id, &wd_id, &VWS_resize_ast, &i0, &x0, &y0, &xsiz, &ysiz, &wc_xmin_new, &wc_ymin_new, &wc_xmax_new, &wc_ymax_new); /* * lph: This sets up three different attribute blocks, each having a different * mode, but they are never utilized and it is not clear when they might * be of use. * The attribute blocks used for writing are line_attr, text_attr. * uis$set_writing_mode(&vd_id, &default_attr, &over_attr, &uis$c_mode_over); uis$set_writing_mode(&vd_id, &default_attr, &eras_attr, &uis$c_mode_eras); uis$set_writing_mode(&vd_id, &default_attr, &bis_attr, &uis$c_mode_bis); */ /* lph: this was commented out; it changes the COLOR_ATTR BLOCK and * the following BLOCKS * if (ws_type >= UIS$C_DEV_INTENSITY) { for (i=0; i<8; i++) { cattr = COLOR_ATTR+i; uis$set_writing_index(&vd_id, &default_attr, &cattr, &i); } } * */ /* lph: default value for the background index into the virtual color /* table is 0, and the back_attr block is never used * uis$set_background_index(&vd_id, &default_attr, &back_attr, &i0); * * the rest look OK, setting up the two attribute blocks */ uis$set_writing_mode(&vd_id, &default_attr, &text_attr, &uis$c_mode_over); uis$set_font(&vd_id, &text_attr, &text_attr, &a_font); uis$set_char_size(&vd_id, &text_attr, &text_attr, &i0, &vws_hchar, &vws_vchar); uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1); } /****************************************************************************/ TERM_PUBLIC void VWS_reset() { uis$delete_display(&vd_id); } /****************************************************************************/ TERM_PUBLIC int VWS_scale(xs, ys) double xs, ys; { return FALSE; } /****************************************************************************/ TERM_PUBLIC void VWS_graphics() { uis$erase(&vd_id, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax); } /****************************************************************************/ TERM_PUBLIC void VWS_text() { } /****************************************************************************/ TERM_PUBLIC void VWS_move(x, y) unsigned int x, y; { current_x = (float) (x); current_y = (float) (y); } /****************************************************************************/ TERM_PUBLIC void VWS_vector(x, y) unsigned int x, y; { int col; int line_attr = LINE_ATTR; float fx, fy; fx = (float) x; fy = (float) y; uis$line(&vd_id, &line_attr, ¤t_x, ¤t_y, &fx, &fy); VWS_move(x, y); } /****************************************************************************/ TERM_PUBLIC void VWS_linetype(lt) int lt; { const int n1 = 0xFFFFFFFF; /* indices into the color map */ const int i[8] = {0, 1, 2, 3, 4, 5, 6, 7}; const float p15 = 2.0, p20 = 3.0, p10 = 1.0; long int lstyle[9] = {0xffffffff, 0Xff00ff00, 0xffffff00, 0xffff0000, 0xf0f0f0f0, 0Xfff0fff0, 0xf000f000, 0xa5a5a5af, 0xf00f00f0 }; int line_attr = LINE_ATTR; /* use multiplier of normal line width; default is width in pixels */ const int uis$c_width_world = UIS$C_WIDTH_WORLD; if (lt < 0) { switch (lt) { case -1: /* used for axis */ uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1); uis$set_line_width(&vd_id, &line_attr, &line_attr, &p15, &uis$c_width_world); if (ws_type >= UIS$C_DEV_INTENSITY) { uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]); } break; case -2: /* the borders */ uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1); uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20, &uis$c_width_world); if (ws_type >= UIS$C_DEV_INTENSITY) { uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]); } break; default: /* else a thick line ? */ uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1); uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20, &uis$c_width_world); if (ws_type >= UIS$C_DEV_INTENSITY) { uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1 + ((-lt) % 7)]); } break; } } else { /* assign the color index (excluding the background index, 0*/ if (ws_type >= UIS$C_DEV_INTENSITY) { uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1 + lt % 7]); } /* assign the line style uis$set_line_style(&vd_id,&line_attr,&line_attr,&lstyle[lt % 8]); * ws: makes part of curve disappear on my workstation * lph: also observed w/ VS2000 and 4 plane graphics coprocesssor; line * types change appropriately, but has problems as pixels/line segment * decreases. Better with full screen display and "set samples" smaller * but start out with only solid lines */ uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1); uis$set_line_width(&vd_id, &line_attr, &line_attr, &p10, &uis$c_width_world); } } /****************************************************************************/ static int justify_mode = CENTRE, up; TERM_PUBLIC void VWS_put_text(x, y, str) unsigned int x, y; char *str; { float fx, fy, thih, twid; int text_attr = TEXT_ATTR; /* uis$text parameter is descriptor string not character string */ struct dsc$descriptor_s textline = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, ""}; textline.dsc$a_pointer = str; textline.dsc$w_length = strlen(textline.dsc$a_pointer); uis$measure_text(&vd_id, &text_attr, &textline, &twid, &thih); fx = (float) x; fy = (float) y; switch (justify_mode) { case LEFT: fy += thih / 2.; break; case RIGHT: fy += thih / 2.; fx -= twid; break; case CENTRE: fy += thih / 2.; fx -= twid / 2; break; }; uis$text(&vd_id, &text_attr, &textline, &fx, &fy); /* write to Example Viewport window */ } /****************************************************************************/ TERM_PUBLIC int VWS_text_angle(ang) int ang; { float degrees; int text_attr = TEXT_ATTR; degrees = 90. * (up = ang); uis$set_text_slope(&vd_id, &text_attr, &text_attr, °rees); return TRUE; } /****************************************************************************/ TERM_PUBLIC int VWS_justify_text(mode) enum JUSTIFY mode; { justify_mode = mode; return TRUE; } /****************************************************************************/ TERM_PUBLIC void VWS_point(x, y, point) unsigned int x, y; int point; { do_point(x, y, point); } /****************************************************************************/ TERM_PUBLIC void VWS_arrow(sx, sy, ex, ey, head) unsigned int sx, sy, ex, ey; int head; { do_arrow(sx, sy, ex, ey, head); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(vws_driver) "VWS", "VAX Windowing System (UIS)", VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR, VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset, VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector, VWS_linetype, VWS_put_text, VWS_text_angle, VWS_justify_text, do_point, do_arrow, set_font_null TERM_TABLE_END(vws_driver) #undef LAST_TERM #define LAST_TERM vws_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(VWS) "1 VWS", "?commands set terminal VWS", "?set terminal VWS", "?set term VWS", "?terminal VWS", "?term VWS", "?VWS", " The `VWS` terminal driver supports the VAX Windowing System. It has", " no options. It will sense the display type (monochrome, gray scale,", " or color.) All line styles are plotted as solid lines." END_HELP(VWS) #endif /* TERM_HELP */ /* * $Id: $ */ /* GNUPLOT - win.trm */ /*[ * Copyright 1992 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * * AUTHORS * * Gnuplot for Windows: * Maurice Castro, Russell Lang * * There is a mailing list for gnuplot users. Note, however, that the * newsgroup * comp.graphics.apps.gnuplot * is identical to the mailing list (they * both carry the same set of messages). We prefer that you read the * messages through that newsgroup, to subscribing to the mailing list. * (If you can read that newsgroup, and are already on the mailing list, * please send a message to majordomo@dartmouth.edu, asking to be * removed from the mailing list.) * * The address for mailing to list members is * info-gnuplot@dartmouth.edu * and for mailing administrative requests is * majordomo@dartmouth.edu * The mailing list for bug reports is * bug-gnuplot@dartmouth.edu * The list of those interested in beta-test versions is * info-gnuplot-beta@dartmouth.edu */ /* This file implements the terminal and printer display for gnuplot */ /* under Microsoft Windows. The code currently compiles only with the */ /* Borland C++ 3.1 compiler. */ /* */ /* The modifications to allow Gnuplot to run under Windows were made */ /* by Maurice Castro (maurice@bruce.cs.monash.edu.au) */ /* and Russell Lang (rjl@monu1.cc.monash.edu.au) 19 Nov 1992 */ /* */ /* Edit this file with tabstop=4 (vi :se ts=4) */ /* * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(windows) #endif #ifdef TERM_PROTO TERM_PUBLIC void WIN_options __PROTO((void)); TERM_PUBLIC int WIN_scale __PROTO((void)); TERM_PUBLIC void WIN_init __PROTO((void)); TERM_PUBLIC void WIN_reset __PROTO((void)); TERM_PUBLIC void WIN_text __PROTO((void)); TERM_PUBLIC void WIN_graphics __PROTO((void)); TERM_PUBLIC void WIN_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void WIN_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void WIN_linetype __PROTO((int lt)); TERM_PUBLIC void WIN_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int WIN_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC int WIN_text_angle __PROTO((int ang)); TERM_PUBLIC void WIN_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void WIN_resume __PROTO((void)); TERM_PUBLIC void WIN_set_pointsize __PROTO((double)); /* Initialization values - Guess Now Scale later */ #define WIN_XMAX (24000) #define WIN_YMAX (18000) #define WIN_HCHAR (WIN_XMAX/75) #define WIN_VCHAR (WIN_YMAX/25) #define WIN_HTIC (WIN_XMAX/160) #define WIN_VTIC WIN_HTIC #endif /* TERM_PROTO */ #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY #include <windows.h> #include "../win/wgnuplib.h" #ifdef __MSC__ #include <io.h> /* for mktemp() */ #endif extern GW graphwin; #define WIN_POINT_TYPES 12 /* Interface routines - create list of actions for Windows */ TERM_PUBLIC void WIN_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token, "d$efault")) { graphwin.color = TRUE; strcpy(graphwin.fontname, WINFONT); graphwin.fontsize = WINFONTSIZE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token, "m$onochrome")) { graphwin.color = FALSE; c_token++; } else if (almost_equals(c_token, "c$olor") || almost_equals(c_token, "c$olour")) { graphwin.color = TRUE; c_token++; } } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(graphwin.fontname, c_token, MAX_ID_LEN); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; graphwin.fontsize = (int) real(const_express(&a)); } if (graphwin.fontname[0] == '\0') sprintf(term_options, "%s", graphwin.color ? "color" : "monochrome"); else sprintf(term_options, "%s \"%s\" %d", graphwin.color ? "color" : "monochrome", graphwin.fontname, graphwin.fontsize); if (IsWindow(graphwin.hWndGraph) && IsIconic(graphwin.hWndGraph)) { ShowWindow(graphwin.hWndGraph, SW_SHOWNORMAL); } GraphRedraw(&graphwin); } /* We don't actually do scaling, but we need to fix up the text size * if the user has resized the window */ int WIN_scale() { term->h_char = graphwin.hchar; term->v_char = graphwin.vchar; term->h_tic = graphwin.htic; term->v_tic = graphwin.vtic; sprintf(term_options, "%s \"%s\" %d", graphwin.color ? "color" : "monochrome", graphwin.fontname, graphwin.fontsize); return FALSE; /* can't be done */ } TERM_PUBLIC void WIN_init() { if (!graphwin.hWndGraph) { graphwin.xmax = WIN_XMAX; graphwin.ymax = WIN_YMAX; graphwin.htic = WIN_HTIC; graphwin.vtic = WIN_VTIC; GraphInit(&graphwin); #ifdef WIN32 SetClassLong(graphwin.hWndGraph, GCL_HICON, (LONG) LoadIcon(graphwin.hInstance, "GRPICON")); #else SetClassWord(graphwin.hWndGraph, GCW_HICON, LoadIcon(graphwin.hInstance, "GRPICON")); #endif graphwin.resized = FALSE; } } TERM_PUBLIC void WIN_reset() { } TERM_PUBLIC void WIN_text() { GraphEnd(&graphwin); } TERM_PUBLIC void WIN_graphics() { GraphStart(&graphwin, pointsize); } TERM_PUBLIC void WIN_move(x, y) unsigned int x, y; { GraphOp(&graphwin, W_move, x, y, NULL); } TERM_PUBLIC void WIN_vector(x, y) unsigned int x, y; { GraphOp(&graphwin, W_vect, x, y, NULL); } TERM_PUBLIC void WIN_linetype(lt) int lt; { GraphOp(&graphwin, W_line_type, lt, 0, NULL); } TERM_PUBLIC void WIN_put_text(x, y, str) unsigned int x, y; char *str; { GraphOp(&graphwin, W_put_text, x, y, str); } TERM_PUBLIC int WIN_justify_text(mode) enum JUSTIFY mode; { GraphOp(&graphwin, W_justify, mode, 0, NULL); return (TRUE); } TERM_PUBLIC int WIN_text_angle(ang) int ang; { if (graphwin.rotate) GraphOp(&graphwin, W_text_angle, ang, 0, NULL); return graphwin.rotate; } TERM_PUBLIC void WIN_point(x, y, number) unsigned int x, y; int number; { /* draw point shapes later to save memory */ /* size of point symbols */ graphwin.htic = pointsize * term->h_tic / 2; graphwin.vtic = pointsize * term->v_tic / 2; if (number >= 0) number %= WIN_POINT_TYPES; number += 1; GraphOp(&graphwin, W_dot + number, x, y, NULL); } TERM_PUBLIC void WIN_resume(void) { GraphResume(&graphwin); } TERM_PUBLIC void WIN_set_pointsize(s) double s; { /* Save new pointsize as string */ char scale[30]; sprintf(scale, "%.15g", s); #if 1 /* HBB 980309: it seems passing it as a string is a bad idea * in Win16: it means the wgnuplot.dll has to parse the string * via sscanf(), leading to crash (by stack overflow?). Alternative: * pass it as a scaled-up integer. For the sake of compatibility, * pass the string as well. */ GraphOp(&graphwin, W_pointsize, (int) 100 * s, 0, scale); #else GraphOp(&graphwin, W_pointsize, 0, 0, scale); #endif } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(win_driver) "windows", "Microsoft Windows", WIN_XMAX, WIN_YMAX, WIN_VCHAR, WIN_HCHAR, WIN_VTIC, WIN_HTIC, WIN_options, WIN_init, WIN_reset, WIN_text, null_scale, WIN_graphics, WIN_move, WIN_vector, WIN_linetype, WIN_put_text, WIN_text_angle, WIN_justify_text, WIN_point, do_arrow, set_font_null, WIN_set_pointsize, TERM_CAN_MULTIPLOT, WIN_text /* suspend */ , WIN_resume, 0 /*boxfill */ TERM_TABLE_END(win_driver) #undef LAST_TERM #define LAST_TERM win_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(windows) "1 windows", "?commands set terminal windows", "?set terminal windows", "?set term windows", "?terminal windows", "?term windows", "?windows", " Three options may be set in the `windows` terminal driver.", "", " Syntax:", " set terminal windows {<color>} {\"<fontname>\"} {<fontsize>}", "", " where `<color>` is either `color` or `monochrome`, `\"<fontname>\"` is the", " name of a valid Windows font, and `<fontsize>` is the size of the font in", " points.", "", " Other options may be set with the graph-menu, the initialization file,", " and `set linestyle`.", /* Does this really belong here? If not, someone move it where it does. */ "", " The Windows version normally terminates immediately as soon as the end of", " any files given as command line arguments is reached (i.e. in non-interactive", " mode). It will also not show the text-window at all, in this mode, only", " the plot. By giving the optional argument", " `/noend` or `-noend`, you can disable this behaviour.", "2 graph-menu", "?commands set terminal windows graph-menu", "?set terminal windows graph-menu", "?set term windows graph-menu", "?windows graph-menu", "?graph-menu", " The `gnuplot graph` window has the following options on a pop-up menu", " accessed by pressing the right mouse button or selecting `Options` from the", " system menu:", "", " `Bring to Top` when checked brings the graph window to the top after every", " plot.", "", " `Color` when checked enables color linestyles. When unchecked it forces", " monochrome linestyles.", "", " `Copy to Clipboard` copies a bitmap and a Metafile picture.", "", " `Background...` sets the window background color.", "", " `Choose Font...` selects the font used in the graphics window.", "", " `Line Styles...` allows customization of the line colors and styles.", "", " `Print...` prints the graphics windows using a Windows printer driver and", " allows selection of the printer and scaling of the output. The output", " produced by `Print` is not as good as that from `gnuplot`'s own printer", " drivers.", "", " `Update wgnuplot.ini` saves the current window locations, window sizes, text", " window font, text window font size, graph window font, graph window font", " size, background color and linestyles to the initialization file", " `WGNUPLOT.INI`.", "2 printing", "?commands set terminal windows printing", "?set terminal windows printing", "?set term windows printing", "?windows printing", "?printing", " In order of preference, graphs may be be printed in the following ways.", "", " `1.` Use the `gnuplot` command `set terminal` to select a printer and `set", " output` to redirect output to a file.", "", " `2.` Select the `Print...` command from the `gnuplot graph` window. An extra", " command `screendump` does this from the text window.", "", " `3.` If `set output \"PRN\"` is used, output will go to a temporary file. When", " you exit from `gnuplot` or when you change the output with another `set", " output` command, a dialog box will appear for you to select a printer port.", " If you choose OK, the output will be printed on the selected port, passing", " unmodified through the print manager. It is possible to accidentally (or", " deliberately) send printer output meant for one printer to an incompatible", " printer.", "2 text-menu", "?commands set terminal windows text-menu", "?set terminal windows text-menu", "?set term windows text-menu", "?windows text-menu", "?text-menu", " The `gnuplot text` window has the following options on a pop-up menu accessed", " by pressing the right mouse button or selecting `Options` from the system", " menu:", "", " `Copy to Clipboard` copies marked text to the clipboard.", "", " `Paste` copies text from the clipboard as if typed by the user.", "", " `Choose Font...` selects the font used in the text window.", "", " `System Colors` when selected makes the text window honor the System Colors", " set using the Control Panel. When unselected, text is black or blue on a", " white background.", "", " `Update wgnuplot.ini` saves the current text window location, text window", " size, text window font and text window font size to the initialisation file", " `WGNUPLOT.INI`.", "", " `MENU BAR`", "", " If the menu file `WGNUPLOT.MNU` is found in the same directory as", " WGNUPLOT.EXE, then the menu specified in `WGNUPLOT.MNU` will be loaded.", " Menu commands:", "", " [Menu] starts a new menu with the name on the following line.", "", " [EndMenu] ends the current menu.", "", " [--] inserts a horizontal menu separator.", "", " [|] inserts a vertical menu separator.", "", " [Button] puts the next macro on a push button instead of a menu.", "", " Macros take two lines with the macro name (menu entry) on the first line and", " the macro on the second line. Leading spaces are ignored. Macro commands:", "", " [INPUT] --- Input string with prompt terminated by [EOS] or {ENTER}", "", " [EOS] --- End Of String terminator. Generates no output.", "", " [OPEN] --- Get name of file to open from list box, with title of list box", " terminated by [EOS], followed by default filename terminated by [EOS] or", " {ENTER}. This uses COMMDLG.DLL from Windows 3.1.", "", " [SAVE] --- Get name of file to save. Similar to [OPEN]", "", " Macro character substitutions:", "", " {ENTER} --- Carriage Return '\\r'", "", " {TAB} --- Tab '\\011'", "", " {ESC} --- Escape '\\033'", "", " {^A} --- '\\001'", "", " ...", "", " {^_} --- '\\031'", "", " Macros are limited to 256 characters after expansion.", "2 wgnuplot.ini", "?commands set terminal windows wgnuplot.ini", "?set terminal windows wgnuplot.ini", "?set term windows wgnuplot.ini", "?windows wgnuplot.ini", "?wgnuplot.ini", " Windows `gnuplot` will read some of its options from the `[WGNUPLOT]` section", " of `WGNUPLOT.INI` in the Windows directory. A sample `WGNUPLOT.INI` file:", "", " [WGNUPLOT]", " TextOrigin=0 0", " TextSize=640 150", " TextFont=Terminal,9", " GraphOrigin=0 150", " GraphSize=640 330", " GraphFont=Arial,10", " GraphColor=1", " GraphToTop=1", " GraphBackground=255 255 255", " Border=0 0 0 0 0", " Axis=192 192 192 2 2", " Line1=0 0 255 0 0", " Line2=0 255 0 0 1", " Line3=255 0 0 0 2", " Line4=255 0 255 0 3", " Line5=0 0 128 0 4", "", " The `GraphFont` entry specifies the font name and size in points. The five", " numbers given in the `Border`, `Axis` and `Line` entries are the `Red`", " intensity (0--255), `Green` intensity, `Blue` intensity, `Color Linestyle`", " and `Mono Linestyle`. `Linestyles` are 0=SOLID, 1=DASH, 2=DOT, 3=DASHDOT,", " 4=DASHDOTDOT. In the sample `WGNUPLOT.INI` file above, Line 2 is a green", " solid line in color mode, or a dashed line in monochrome mode. The default", " line width is 1 pixel. If `Linestyle` is negative, it specifies the width of", " a SOLID line in pixels. Line1 and any linestyle used with the `points` style", " must be SOLID with unit width.", "2 windows3.0", "?commands set terminal windows windows3.0", "?set terminal windows windows3.0", "?set term windows windows3.0", "?windows windows3.0", "?windows3.0", " Windows 3.1 is preferred, but WGNUPLOT will run under Windows 3.0 with the", " following restrictions:", " `1.` COMMDLG.DLL and SHELL.DLL (available with Windows 3.1 or Borland C++", " 3.1) must be in the windows directory.", "", " `2.` WGNUPLOT.HLP produced by Borland C++ 3.1 is in Windows 3.1 format.", " You need to use the WINHELP.EXE supplied with Borland C++ 3.1.", "", " `3.` It will not run in real mode due to lack of memory.", "", " `4.` TrueType fonts are not available in the graph window.", "", " `5.` Drag-drop does not work." END_HELP(windows) #endif /* TERM_HELP */ /* * $Id: x11.trm,v 1.35 1998/06/18 14:59:27 ddenholm Exp $ * */ /*[ * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * x11.trm --- inboard terminal driver for X11 */ #include "driver.h" #ifdef TERM_REGISTER register_term(x11) #endif #ifdef TERM_PROTO int X11_args __PROTO((int argc, char *argv[])); TERM_PUBLIC void X11_options __PROTO((void)); TERM_PUBLIC void X11_init __PROTO((void)); TERM_PUBLIC void X11_graphics __PROTO((void)); TERM_PUBLIC void X11_text __PROTO((void)); TERM_PUBLIC void X11_reset __PROTO((void)); TERM_PUBLIC void X11_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void X11_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void X11_linewidth __PROTO((double lw)); TERM_PUBLIC void X11_pointsize __PROTO((double ps)); TERM_PUBLIC void X11_linetype __PROTO((int lt)); TERM_PUBLIC void X11_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int X11_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void X11_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC void X11_fillbox __PROTO((int style, unsigned int x, unsigned y, unsigned int width, unsigned int height)); #define X11_XMAX 4096 #define X11_YMAX 4096 /* approximations for typical font/screen sizes */ #define X11_VCHAR (X11_YMAX/25) #define X11_HCHAR (X11_XMAX/100) #define X11_VTIC (X11_YMAX/100) #define X11_HTIC (X11_XMAX/150) #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY int X11_Display = 0; /* non-zero if '-display' found on command line */ /* sunos 4 uses on_exit() in place of atexit(). If both are missing, * we can probably survive since gnuplot_x11 should detect EOF on * the pipe. Unfortunately, the handlers take different parameters. */ #ifdef NO_ATEXIT # define HANDLER_PROTO __PROTO((int x, void *y)) # define HANDLER_DECL (x,y) int x; void *y; # define HANDLER_PARAMS (0,NULL) # ifdef HAVE_ON_EXIT # define atexit(x) on_exit(x, NULL) # else # define atexit(x) /* nowt */ # endif #else /* !NO_ATEXIT */ # define HANDLER_PROTO __PROTO((void)) # define HANDLER_DECL () # define HANDLER_PARAMS () #endif static void X11_atexit HANDLER_PROTO; static char X11_opts[][20] = { "-mono", "-gray", "-clear", "-tvtwm", "-pointsize", "-iconic", "-rv", "-reverse", "+rv", "-synchronous", "-display", "-geometry", "-bg", "-background", "-bd", "-bordercolor", "-bw", "-borderwidth", "-fg", "-foreground", "-fn", "-font", "-name", "-selectionTimeout", "-title", "-xnllanguage", "-xrm", "-raise", "-noraise", "-persist" }; #define X11_nopts (sizeof(X11_opts) / sizeof(X11_opts[0])) static int X11_optarg[X11_nopts] = { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 }; static FILE *X11_ipc; #ifdef OS2 static char X11_command[1024] = "gnuplot_x11.exe"; #else static char X11_command[1024] = "gnuplot_x11"; #endif /* X11_args - scan gnuplot command line for standard X Toolkit options * called from plot.c so must not be TERM_PUBLIC (which may be static) */ int X11_args(argc, argv) int argc; char *argv[]; { int nx11 = 0, n; while (++argv, --argc > 0) { for (n = 0; n < X11_nopts; n++) { if (!strcmp(*argv, X11_opts[n])) { strcat(X11_command, " "); strcat(X11_command, *argv); if (strcmp(*argv, "-display") == 0) X11_Display++; if (X11_optarg[n]) { if (--argc <= 0) return (nx11); strcat(X11_command, " \""); strcat(X11_command, *++argv); strcat(X11_command, "\""); nx11++; } nx11++; break; } } if (n == X11_nopts) break; } return (nx11); } static unsigned int X11_plot_number; TERM_PUBLIC void X11_options() { if (almost_equals(c_token, "res$et")) { X11_atexit HANDLER_PARAMS; /* tell gnuplot_x11 to shut down */ ++c_token; } if (!END_OF_COMMAND) { struct value a; X11_plot_number = (int) real(const_express(&a)); /* let gnuplot_x11 check range */ } sprintf(term_options, "%d", X11_plot_number); } /*----------------------------------------------------------------------------- * Three different versions of the remainder of the X11 terminal driver * are provided to support three different types of IPC with the * gnuplot_x11 outboard terminal driver: * * DEFAULT_X11: popen() pipe for most un*x platforms * * CRIPPLED_SELECT : file IPC for un*x platforms with incomplete or faulty * implementation of BSD select() * * VMS : mailbox/spawn IPC *---------------------------------------------------------------------------*/ #define DEFAULT_X11 #if defined(VMS) || defined(CRIPPLED_SELECT) #undef DEFAULT_X11 #endif #if defined(VMS) && defined(CRIPPLED_SELECT) Error.Incompatible options. #endif /* we do not want to have to duplicate all the code, so we * do most of it with macros. * PRINT0(format), PRINT1(format, p1), PRINT2(format, p1, p2) etc * also FLUSH0(format), etc, which do an additional flush */ #ifdef DEFAULT_X11 /*----------------------------------------------------------------------------- * DEFAULT_X11 popen() pipe IPC *---------------------------------------------------------------------------*/ static void X11_atexit HANDLER_DECL { if (X11_ipc) { fputs("R\n", X11_ipc); fclose(X11_ipc); /* dont wait(), since they might be -persist */ X11_ipc = NULL; } } TERM_PUBLIC void X11_init() { if (!X11_ipc) { /* first time through or after a reset */ #if defined(OSK) || defined(OS2) /* OS-9 popen() does not block on close for child to end, so * we can safely use it here */ X11_ipc = popen(X11_command, "w"); #else int fdes[2]; pipe(fdes); if (fork() == 0) { /* child */ close(fdes[1]); dup2(fdes[0], 0); /* stdin from pipe */ execl("/bin/sh", "sh", "-c", X11_command, NULL); /* if we get here, something went wrong */ perror("exec failed"); exit(1); } /* parent */ close(fdes[0]); /* read end of pipe */ X11_ipc = fdopen(fdes[1], "w"); #endif } { static int been_here = 0; if (!been_here) { atexit(X11_atexit); been_here = 1; } } } TERM_PUBLIC void X11_reset() { /* leave the pipe alone, until exit or set term x11 reset */ } #define PRINT0(fmt) fprintf(X11_ipc, fmt) #define PRINT1(fmt,p1) fprintf(X11_ipc, fmt,p1) #define PRINT2(fmt,p1,p2) fprintf(X11_ipc, fmt,p1,p2) #define PRINT3(fmt,p1,p2,p3) fprintf(X11_ipc, fmt,p1,p2,p3) #define PRINT4(fmt,p1,p2,p3,p4) fprintf(X11_ipc, fmt,p1,p2,p3,p4) #define PRINT5(fmt,p1,p2,p3,p4,p5) fprintf(X11_ipc, fmt,p1,p2,p3,p4,p5) #define FFLUSH() fflush(X11_ipc) #define BEFORE_GRAPHICS /* nowt */ #define AFTER_TEXT /* nowt */ #endif /* DEFAULT_X11 */ #ifdef CRIPPLED_SELECT /* PLEASE CAN SOMEONE CHECK THAT THIS STILL WORKS !!! */ /*----------------------------------------------------------------------------- * CRIPPLED_SELECT file IPC *---------------------------------------------------------------------------*/ static char X11_tmp[32], X11_tmp0[32], X11_shutdown[32]; static int X11_pid; TERM_PUBLIC void X11_init() { if (!(X11_pid = fork())) { execl("/bin/sh", "sh", "-c", X11_command, NULL); _exit(1); } sprintf(X11_tmp, "/tmp/Gnuplot_%d", X11_pid); sprintf(X11_tmp0, "%s-", X11_tmp); sprintf(X11_shutdown, "echo R >%s", X11_tmp); } TERM_PUBLIC void X11_reset() { system(X11_shutdown); } #define BEFORE_GRAPHICS \ if (!(X11_ipc = fopen(X11_tmp0, "w"))) { \ perror(X11_tmp0); system(X11_shutdown); exit(1); \ } #define AFTER_TEXT \ { fclose(X11_ipc); rename(X11_tmp0, X11_tmp); } #define PRINT0(fmt) fprintf(X11_ipc, fmt) #define PRINT1(fmt,p1) fprintf(X11_ipc, fmt,p1) #define PRINT2(fmt,p1,p2) fprintf(X11_ipc, fmt,p1,p2) #define PRINT3(fmt,p1,p2,p3) fprintf(X11_ipc, fmt,p1,p2,p3) #define PRINT4(fmt,p1,p2,p3,p4) fprintf(X11_ipc, fmt,p1,p2,p3,p4) #define PRINT5(fmt,p1,p2,p3,p4,p5) fprintf(X11_ipc, fmt,p1,p2,p3,p4,p5) #define FFLUSH() fflush(X11_ipc) static void X11_atexit HANDLER_DECL { /* WHAT SHOULD I DO ? */ } #endif /* CRIPPLED_SELECT */ #ifdef VMS /*----------------------------------------------------------------------------- * VMS mailbox/spawn IPC - Yehavi Bourvine - YEHAVI@VMS.HUJI.AC.IL *---------------------------------------------------------------------------*/ #include <iodef.h> #include <descrip.h> #include <dvidef.h> #ifdef __DECC #include <lib$routines.h> #include <starlet.h> #endif #ifdef __GNUC__ #include <errno.h> #else int vaxc$errno; #endif #define SS$_NORMAL 1 /* or include <ssdef.h> for all SS$_ def's */ #define MBXMXMSG 128 /* DEFMBXMXMSG is set by SYSGEN */ static short X11_channel; struct iosb { unsigned short stat; unsigned short count; unsigned long info; }; TERM_PUBLIC void X11_init() { struct iosb iosb; static char devnam_string[64]; static $DESCRIPTOR(devnam, devnam_string); struct { short int buf_len; short int item; char *buf_addr; unsigned short int *ret_len; int end; } item_list = { devnam.dsc$w_length, DVI$_DEVNAM, devnam.dsc$a_pointer, &devnam.dsc$w_length, 0 }; if (!X11_channel) { int one = 1; /* Create a descriptor for the command line that starts GNUPLOT_X11. $DESCRIP doesn't work in this context... */ struct dsc$descriptor_s pgmdsc = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; pgmdsc.dsc$w_length = strlen(X11_command); pgmdsc.dsc$a_pointer = X11_command; /* Create a mailbox which will be used as a pipe for commands to the subprocess. What we'll write to it will be read by the subprocess as its STDIN. Use an unnamed mailbox and refer to it by its device number */ vaxc$errno = sys$crembx(0, &X11_channel, MBXMXMSG, MBXMXMSG, 0, 0, 0, 0); if ((vaxc$errno & SS$_NORMAL) != SS$_NORMAL) { printf("SYS$CreMbx failed with status=%d\r\n", vaxc$errno); os_error("sys$crembx failed", NO_CARET); } vaxc$errno = sys$getdviw(0, X11_channel, 0, &item_list, &iosb, 0, 0, 0); if ((vaxc$errno & SS$_NORMAL) == SS$_NORMAL) vaxc$errno = iosb.stat; if ((vaxc$errno & SS$_NORMAL) != SS$_NORMAL) { printf("SYS$Getdviw failed with status=%d\r\n", vaxc$errno); sys$dassgn(X11_channel); X11_channel = 0; os_error("sys$getdviw failed", NO_CARET); } /* Create a subprocess whose input is this mailbox. */ vaxc$errno = lib$spawn(&pgmdsc, &devnam, 0, &one, 0, 0, 0, 0, 0, 0, 0, 0, 0); if ((vaxc$errno & SS$_NORMAL) != SS$_NORMAL) { printf("LIB$SPAWN failed with status=%d\r\n", vaxc$errno); sys$dassgn(X11_channel); X11_channel = 0; os_error("lib$spawn failed", NO_CARET); } } { static int been_here = 0; if (!been_here) { atexit(X11_atexit); been_here = 1; } } } /* We use $QIO in order to avoid buffering problems, although it might * work as well with simple Fprintf calls. */ #define GO(x) \ { \ char buffer[512]; int status; struct iosb iosb;\ sprintf x; \ if (strlen(buffer) >= MBXMXMSG ) { \ printf("buffer contents (%d char) catenated to mailbox size (%d bytes)\n", \ strlen(buffer), MBXMXMSG); \ buffer[MBXMXMSG-1] = '\0';\ printf("%s\n", buffer); \ } \ status = sys$qiow(0, X11_channel, IO$_WRITEVBLK, &iosb, 0, 0, buffer, strlen(buffer), 0, 0, 0, 0); \ if ((status & SS$_NORMAL) == SS$_NORMAL) status = iosb.stat; \ if((status & SS$_NORMAL) != SS$_NORMAL) exit(status); \ } #define PRINT0(fmt) GO( (buffer, fmt) ) #define PRINT1(fmt,p1) GO( (buffer, fmt,p1) ) #define PRINT2(fmt,p1,p2) GO( (buffer, fmt,p1,p2) ) #define PRINT3(fmt,p1,p2,p3) GO( (buffer, fmt,p1,p2,p3) ) #define PRINT4(fmt,p1,p2,p3,p4) GO( (buffer, fmt,p1,p2,p3,p4) ) #define PRINT5(fmt,p1,p2,p3,p4,p5) GO( (buffer, fmt,p1,p2,p3,p4,p5) ) #define FFLUSH() /* nowt */ #define BEFORE_GRAPHICS /* nowt */ #define AFTER_TEXT /* nowt */ static void X11_atexit HANDLER_DECL { if (X11_channel) { PRINT0("R\n"); sleep(2); /* Wait for subprocess to finish */ sys$dassgn(X11_channel); X11_channel = 0; } } TERM_PUBLIC void X11_reset() { /* do nothing until exit */ } #endif /* VMS */ /* common stuff, using macros defined above */ TERM_PUBLIC void X11_graphics() { BEFORE_GRAPHICS; /* kludge for crippled select */ PRINT1("G%d\n", X11_plot_number); /* for VMS sake, keep as separate prints */ #ifdef ULTRIX_KLUDGE fflush(X11_ipc); #endif } TERM_PUBLIC void X11_text() { PRINT0("E\n"); FFLUSH(); #ifdef ULTRIX_KLUDGE PRINT0("E\n"); FFLUSH(); #endif AFTER_TEXT; /* kludge for crippled select */ } TERM_PUBLIC void X11_move(x, y) unsigned int x, y; { PRINT2("M%04d%04d\n", x, y); } TERM_PUBLIC void X11_vector(x, y) unsigned int x, y; { PRINT2("V%04d%04d\n", x, y); } TERM_PUBLIC void X11_pointsize(ps) double ps; { PRINT2("P7%04d%04d\n", /* size of point symbols */ (int) (term->h_tic * ps * 0.5), (int) (term->v_tic * ps * 0.5)); } TERM_PUBLIC void X11_linewidth(lw) double lw; { PRINT1("W%04d\n", (int) lw); } TERM_PUBLIC void X11_linetype(lt) int lt; { PRINT1("L%04d\n", lt); } TERM_PUBLIC void X11_put_text(x, y, str) unsigned int x, y; char str[]; { /* badly outrange labels can overflow into text field */ if (x < 10000 && y < 10000) { PRINT3("T%04d%04d%s\n", x, y, str); } } TERM_PUBLIC int X11_justify_text(mode) enum JUSTIFY mode; { PRINT1("J%04d\n", mode); return (TRUE); } TERM_PUBLIC void X11_point(x, y, number) unsigned int x, y; int number; { if (number >= 0) number %= POINT_TYPES; number += 1; PRINT3("P%01d%04d%04d\n", number, x, y); } TERM_PUBLIC void X11_fillbox(style, x, y, w, h) int style; unsigned int x, y, w, h; { PRINT5("F%04d%04u%04u%04u%04u\n", style, x, y, w, h); } #endif /* TERM_BODY */ #ifdef TERM_TABLE TERM_TABLE_START(x11_driver) "x11", "X11 Window System", X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, X11_VTIC, X11_HTIC, X11_options, X11_init, X11_reset, X11_text, null_scale, X11_graphics, X11_move, X11_vector, X11_linetype, X11_put_text, null_text_angle, X11_justify_text, X11_point, do_arrow, set_font_null, X11_pointsize, TERM_CAN_MULTIPLOT, X11_text /* suspend can use same routine */ , 0 /* resume */ , X11_fillbox, X11_linewidth TERM_TABLE_END(x11_driver) #undef LAST_TERM #define LAST_TERM x11_driver TERM_TABLE_START(X11_driver) "X11", "X11 Window System (identical to x11)", X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, X11_VTIC, X11_HTIC, X11_options, X11_init, X11_reset, X11_text, null_scale, X11_graphics, X11_move, X11_vector, X11_linetype, X11_put_text, null_text_angle, X11_justify_text, X11_point, do_arrow, set_font_null, X11_pointsize, TERM_CAN_MULTIPLOT, X11_text /* suspend can use same routine */ , 0 /* resume */ , X11_fillbox, X11_linewidth TERM_TABLE_END(X11_driver) #undef LAST_TERM #define LAST_TERM x11_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(x11) "1 x11", "?commands set terminal x11", "?set terminal x11", "?set term x11", "?terminal x11", "?term x11", "?x11", "?X11", " `gnuplot` provides the `x11` terminal type for use with X servers. This", " terminal type is set automatically at startup if the `DISPLAY` environment", " variable is set, if the `TERM` environment variable is set to `xterm`, or", " if the `-display` command line option is used.", "", " Syntax:", " set terminal x11 {reset} {<n>}", "", " Multiple plot windows are supported: `set terminal x11 <n>` directs the", " output to plot window number n. If n>0, the terminal number will be", " appended to the window title and the icon will be labeled `gplt <n>`.", " The active window may distinguished by a change in cursor (from default", " to crosshair.)", "", " Plot windows remain open even when the `gnuplot` driver is changed to a", " different device. A plot window can be closed by pressing the letter q", " while that window has input focus, or by choosing `close` from a window", " manager menu. All plot windows can be closed by specifying `reset`, which", " actually terminates the subprocess which maintains the windows (unless", " `-persist` was specified).", "", " Plot windows will automatically be closed at the end of the session", " unless the `-persist` option was given.", "", " The size or aspect ratio of a plot may be changed by resizing the `gnuplot`", " window.", "", " Linewidths and pointsizes may be changed from within `gnuplot` with", " `set linestyle`.", "", " For terminal type `x11`, `gnuplot` accepts (when initialized) the standard", " X Toolkit options and resources such as geometry, font, and name from the", " command line arguments or a configuration file. See the X(1) man page", " (or its equivalent) for a description of such options.", "", " A number of other `gnuplot` options are available for the `x11` terminal.", " These may be specified either as command-line options when `gnuplot` is", " invoked or as resources in the configuration file \"/.Xdefaults\". They are", " set upon initialization and cannot be altered during a `gnuplot` session.", "2 command-line_options", "?commands set terminal x11 command-line-options", "?set terminal x11 command-line-options", "?set term x11 command-line-options", "?x11 command-line-options", "?command-line-options", " In addition to the X Toolkit options, the following options may be specified", " on the command line when starting `gnuplot` or as resources in your", " \".Xdefaults\" file:", "@start table - first is interactive cleartext form", " `-clear` requests that the window be cleared momentarily before a", " new plot is displayed.", " `-gray` requests grayscale rendering on grayscale or color displays.", " (Grayscale displays receive monochrome rendering by default.)", " `-mono` forces monochrome rendering on color displays.", " `-persist` plot windows survive after main gnuplot program exits", " `-raise` raise plot window after each plot", " `-noraise` do not raise plot window after each plot", " `-tvtwm` requests that geometry specifications for position of the", " window be made relative to the currently displayed portion", " of the virtual root.", "#\\begin{tabular}{|cl|} \\hline", "#`-mono` & forces monochrome rendering on color displays.\\\\", "#`-gray` & requests grayscale rendering on grayscale or color displays.\\\\", "# & (Grayscale displays receive monochrome rendering by default.) \\\\", "#`-clear` & requests that the window be cleared momentarily before a\\\\", "# & new plot is displayed. \\\\", "#`-tvtwm` & requests that geometry specifications for position of the\\\\", "# & window be made relative to the currently displayed portion\\\\", "# & of the virtual root. \\\\", "#`-raise` & raise plot window after each plot. \\\\", "#`-noraise` & do not raise plot window after each plot. \\\\", "#`-persist`&plot windows survive after main gnuplot program exits. \\\\", "%c l .", "%`-mono`@forces monochrome rendering on color displays.", "%`-gray`@requests grayscale rendering on grayscale or color displays.", "% @(Grayscale displays receive monochrome rendering by default.)", "%`-clear`@requests that the window be cleared momentarily before a", "% @new plot is displayed.", "%`-tvtwm`@requests that geometry specifications for position of the", "% @window be made relative to the currently displayed portion", "% @of the virtual root.", "%`-raise`@raise plot window after each plot", "%`-noraise`@do not raise plot window after each plot", "%`-persist`@plot windows survive after main gnuplot program exits", "@end table", " The options are shown above in their command-line syntax. When entered as", " resources in \".Xdefaults\", they require a different syntax.", "", " Example:", " gnuplot*gray: on", "", " `gnuplot` also provides a command line option (`-pointsize <v>`) and a", " resource, `gnuplot*pointsize: <v>`, to control the size of points plotted", " with the `points` plotting style. The value `v` is a real number (greater", " than 0 and less than or equal to ten) used as a scaling factor for point", " sizes. For example, `-pointsize 2` uses points twice the default size, and", " `-pointsize 0.5` uses points half the normal size.", "2 monochome_options", "?commands set terminal x11 monochrome_options", "?set terminal x11 monochrome_options", "?set term x11 monochrome_options", "?x11 monochrome_options", "?monochrome_options", " For monochrome displays, `gnuplot` does not honor foreground or background", " colors. The default is black-on-white. `-rv` or `gnuplot*reverseVideo: on`", " requests white-on-black.", "", "2 color_resources", "?commands set terminal x11 color_resources", "?set terminal x11 color_resources", "?set term x11 color_resources", "?x11 color_resources", "?color_resources", " For color displays, `gnuplot` honors the following resources (shown here", " with their default values) or the greyscale resources. The values may be", " color names as listed in the X11 rgb.txt file on your system, hexadecimal", " RGB color specifications (see X11 documentation), or a color name followed", " by a comma and an `intensity` value from 0 to 1. For example, `blue, 0.5`", " means a half intensity blue.", "@start table - first is interactive cleartext form", " gnuplot*background: white", " gnuplot*textColor: black", " gnuplot*borderColor: black", " gnuplot*axisColor: black", " gnuplot*line1Color: red", " gnuplot*line2Color: green", " gnuplot*line3Color: blue", " gnuplot*line4Color: magenta", " gnuplot*line5Color: cyan", " gnuplot*line6Color: sienna", " gnuplot*line7Color: orange", " gnuplot*line8Color: coral", "#\\begin{tabular}{|cl|} \\hline", "#&gnuplot*background: white\\\\", "#&gnuplot*textColor: black\\\\", "#&gnuplot*borderColor: black\\\\", "#&gnuplot*axisColor: black\\\\", "#&gnuplot*line1Color: red\\\\", "#&gnuplot*line2Color: green\\\\", "#&gnuplot*line3Color: blue\\\\", "#&gnuplot*line4Color: magenta\\\\", "#&gnuplot*line5Color: cyan\\\\", "#&gnuplot*line6Color: sienna\\\\", "#&gnuplot*line7Color: orange\\\\", "#&gnuplot*line8Color: coral\\\\", "%c l .", "%@gnuplot*background: white", "%@gnuplot*textColor: black", "%@gnuplot*borderColor: black", "%@gnuplot*axisColor: black", "%@gnuplot*line1Color: red", "%@gnuplot*line2Color: green", "%@gnuplot*line3Color: blue", "%@gnuplot*line4Color: magenta", "%@gnuplot*line5Color: cyan", "%@gnuplot*line6Color: sienna", "%@gnuplot*line7Color: orange", "%@gnuplot*line8Color: coral", "@end table", "", " The command-line syntax for these is, for example,", "", " Example:", " gnuplot -background coral", "", "2 grayscale_resources", "?commands set terminal x11 grayscale_resources", "?set terminal x11 grayscale_resources", "?set term x11 grayscale_resources", "?x11 grayscale_resources", "?grayscale_resources", " When `-gray` is selected, `gnuplot` honors the following resources for", " grayscale or color displays (shown here with their default values). Note", " that the default background is black.", "@start table - first is interactive cleartext form", " gnuplot*background: black", " gnuplot*textGray: white", " gnuplot*borderGray: gray50", " gnuplot*axisGray: gray50", " gnuplot*line1Gray: gray100", " gnuplot*line2Gray: gray60", " gnuplot*line3Gray: gray80", " gnuplot*line4Gray: gray40", " gnuplot*line5Gray: gray90", " gnuplot*line6Gray: gray50", " gnuplot*line7Gray: gray70", " gnuplot*line8Gray: gray30", "#\\begin{tabular}{|cl|} \\hline", "#&gnuplot*background: black\\\\", "#&gnuplot*textGray: white\\\\", "#&gnuplot*borderGray: gray50\\\\", "#&gnuplot*axisGray: gray50\\\\", "#&gnuplot*line1Gray: gray100\\\\", "#&gnuplot*line2Gray: gray60\\\\", "#&gnuplot*line3Gray: gray80\\\\", "#&gnuplot*line4Gray: gray40\\\\", "#&gnuplot*line5Gray: gray90\\\\", "#&gnuplot*line6Gray: gray50\\\\", "#&gnuplot*line7Gray: gray70\\\\", "#&gnuplot*line8Gray: gray30\\\\", "%c l .", "%@gnuplot*background: black", "%@gnuplot*textGray: white", "%@gnuplot*borderGray: gray50", "%@gnuplot*axisGray: gray50", "%@gnuplot*line1Gray: gray100", "%@gnuplot*line2Gray: gray60", "%@gnuplot*line3Gray: gray80", "%@gnuplot*line4Gray: gray40", "%@gnuplot*line5Gray: gray90", "%@gnuplot*line6Gray: gray50", "%@gnuplot*line7Gray: gray70", "%@gnuplot*line8Gray: gray30", "@end table", "", "2 line_resources", "?commands set terminal x11 line_resources", "?set terminal x11 line_resources", "?set term x11 line_resources", "?x11 line_resources", "?line_resources", " `gnuplot` honors the following resources for setting the width (in pixels) of", " plot lines (shown here with their default values.) 0 or 1 means a minimal", " width line of 1 pixel width. A value of 2 or 3 may improve the appearance of", " some plots.", "@start table - first is interactive cleartext form", " gnuplot*borderWidth: 2", " gnuplot*axisWidth: 0", " gnuplot*line1Width: 0", " gnuplot*line2Width: 0", " gnuplot*line3Width: 0", " gnuplot*line4Width: 0", " gnuplot*line5Width: 0", " gnuplot*line6Width: 0", " gnuplot*line7Width: 0", " gnuplot*line8Width: 0", "#\\begin{tabular}{|cl|} \\hline", "#&gnuplot*borderWidth: 2\\\\", "#&gnuplot*axisWidth: 0\\\\", "#&gnuplot*line1Width: 0\\\\", "#&gnuplot*line2Width: 0\\\\", "#&gnuplot*line3Width: 0\\\\", "#&gnuplot*line4Width: 0\\\\", "#&gnuplot*line5Width: 0\\\\", "#&gnuplot*line6Width: 0\\\\", "#&gnuplot*line7Width: 0\\\\", "#&gnuplot*line8Width: 0\\\\", "%c l .", "%@gnuplot*borderWidth: 2", "%@gnuplot*axisWidth: 0", "%@gnuplot*line1Width: 0", "%@gnuplot*line2Width: 0", "%@gnuplot*line3Width: 0", "%@gnuplot*line4Width: 0", "%@gnuplot*line5Width: 0", "%@gnuplot*line6Width: 0", "%@gnuplot*line7Width: 0", "%@gnuplot*line8Width: 0", "@end table", "", " `gnuplot` honors the following resources for setting the dash style used for", " plotting lines. 0 means a solid line. A two-digit number `jk` (`j` and `k`", " are >= 1 and <= 9) means a dashed line with a repeated pattern of `j` pixels", " on followed by `k` pixels off. For example, '16' is a \"dotted\" line with one", " pixel on followed by six pixels off. More elaborate on/off patterns can be", " specified with a four-digit value. For example, '4441' is four on, four off,", " four on, one off. The default values shown below are for monochrome displays", " or monochrome rendering on color or grayscale displays. For color displays,", " the default for each is 0 (solid line) except for `axisDashes` which defaults", " to a '16' dotted line.", "@start table - first is interactive cleartext form", " gnuplot*borderDashes: 0", " gnuplot*axisDashes: 16", " gnuplot*line1Dashes: 0", " gnuplot*line2Dashes: 42", " gnuplot*line3Dashes: 13", " gnuplot*line4Dashes: 44", " gnuplot*line5Dashes: 15", " gnuplot*line6Dashes: 4441", " gnuplot*line7Dashes: 42", " gnuplot*line8Dashes: 13", "#\\begin{tabular}{|cl|} \\hline", "#&gnuplot*borderDashes: 0\\\\", "#&gnuplot*axisDashes: 16\\\\", "#&gnuplot*line1Dashes: 0\\\\", "#&gnuplot*line2Dashes: 42\\\\", "#&gnuplot*line3Dashes: 13\\\\", "#&gnuplot*line4Dashes: 44\\\\", "#&gnuplot*line5Dashes: 15\\\\", "#&gnuplot*line6Dashes: 4441\\\\", "#&gnuplot*line7Dashes: 42\\\\", "#&gnuplot*line8Dashes: 13\\\\", "%c l .", "%@gnuplot*borderDashes: 0", "%@gnuplot*axisDashes: 16", "%@gnuplot*line1Dashes: 0", "%@gnuplot*line2Dashes: 42", "%@gnuplot*line3Dashes: 13", "%@gnuplot*line4Dashes: 44", "%@gnuplot*line5Dashes: 15", "%@gnuplot*line6Dashes: 4441", "%@gnuplot*line7Dashes: 42", "%@gnuplot*line8Dashes: 13", "@end table" END_HELP(x11) #endif /* TERM_HELP */ /* * $Id: xlib.trm,v 1.12 1998/04/14 00:18:16 drd Exp $ */ /* GNUPLOT - xlib.trm */ /*[ * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * xlib.trm - inboard terminal driver for X11 (dumps gnuplot_x11 commands) * * To be used with gnulib_x11. */ /* * adapted to new terminal layout by Stefan Bodewig (Dec. 1995) */ #include "driver.h" #ifdef TERM_REGISTER register_term(xlib) #endif #ifdef TERM_PROTO TERM_PUBLIC void Xlib_init __PROTO((void)); TERM_PUBLIC void Xlib_graphics __PROTO((void)); TERM_PUBLIC void Xlib_text __PROTO((void)); TERM_PUBLIC void Xlib_reset __PROTO((void)); TERM_PUBLIC void Xlib_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void Xlib_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void Xlib_linetype __PROTO((int lt)); TERM_PUBLIC void Xlib_put_text __PROTO((unsigned int x, unsigned int y, char str[])); TERM_PUBLIC int Xlib_justify_text __PROTO((enum JUSTIFY mode)); #define Xlib_XMAX 4096 #define Xlib_YMAX 4096 /* approximations for typical font/screen sizes */ #define Xlib_VCHAR (Xlib_YMAX/25) #define Xlib_HCHAR (Xlib_XMAX/100) #define Xlib_VTIC (Xlib_YMAX/100) #define Xlib_HTIC (Xlib_XMAX/150) #define GOT_XLIB_PROTO #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY TERM_PUBLIC void Xlib_init() { /* empty */ } TERM_PUBLIC void Xlib_graphics() { fputs("G\n", gpoutfile); } TERM_PUBLIC void Xlib_text() { fputs("E\n", gpoutfile); fflush(gpoutfile); #ifdef ULTRIX_KLUDGE fputs("E\n", gpoutfile); fflush(gpoutfile); #endif } TERM_PUBLIC void Xlib_reset() { fputs("R\n", gpoutfile); fflush(gpoutfile); } TERM_PUBLIC void Xlib_move(x, y) unsigned int x, y; { fprintf(gpoutfile, "M%04d%04d\n", x, y); } TERM_PUBLIC void Xlib_vector(x, y) unsigned int x, y; { fprintf(gpoutfile, "V%04d%04d\n", x, y); } TERM_PUBLIC void Xlib_linetype(lt) int lt; { fprintf(gpoutfile, "L%04d\n", lt); } TERM_PUBLIC void Xlib_put_text(x, y, str) unsigned int x, y; char str[]; { fprintf(gpoutfile, "T%04d%04d%s\n", x, y, str); } TERM_PUBLIC int Xlib_justify_text(mode) enum JUSTIFY mode; { fprintf(gpoutfile, "J%04d\n", mode); return (TRUE); } #endif #ifdef TERM_TABLE TERM_TABLE_START(xlib_driver) "xlib", "X11 Window System (gnulib_x11 dump)", Xlib_XMAX, Xlib_YMAX, Xlib_VCHAR, Xlib_HCHAR, Xlib_VTIC, Xlib_HTIC, options_null, Xlib_init, Xlib_reset, Xlib_text, null_scale, Xlib_graphics, Xlib_move, Xlib_vector, Xlib_linetype, Xlib_put_text, null_text_angle, Xlib_justify_text, line_and_point, do_arrow, set_font_null TERM_TABLE_END(xlib_driver) #undef LAST_TERM #define LAST_TERM xlib_driver #endif /* TERM_TABLE */ #endif /* TERM_PROTO_ONLY */ #ifdef TERM_HELP START_HELP(xlib) "1 xlib", "?commands set terminal xlib", "?set terminal xlib", "?set term xlib", "?terminal xlib", "?term xlib", "?xlib", " The `xlib` terminal driver supports the X11 Windows System. It generates", " gnulib_x11 commands. `set term x11` behaves similarly to `set terminal xlib;", " set output \"|gnuplot_x11\"`. `xlib` has no options, but see `x11`." END_HELP(xlib) #endif