File: [local] / OpenXM_contrib / gnuplot / term / Attic / gnugraph.trm (download)
Revision 1.1.1.2 (vendor branch), Sat Jan 22 14:16:23 2000 UTC (24 years, 7 months ago) by maekawa
Branch: GNUPLOT
CVS Tags: maekawa-ipv6, VERSION_3_7_1, RELEASE_20000124, RELEASE_1_2_2, RELEASE_1_2_1, RELEASE_1_1_3, RELEASE_1_1_2 Changes since 1.1.1.1: +5 -1
lines
Import gnuplot 3.7.1
|
/*
* $Id: gnugraph.trm,v 1.8.2.1 1999/08/19 14:17:45 lhecking Exp $
*/
/* 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"
#if defined (HAVE_PLOTCOMPAT_H)
# include <plotcompat.h>
#endif
#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 {\"<fontname>\"} {<fontsize>}",
"",
" 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