Term-Gnuplot

 view release on metacpan or  search on metacpan

gnuterm/term/hpgl.trm  view on Meta::CPAN

 */

#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.
 */

#define HPGL2_BASE64 1

#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 {
    const char *compare, *name;
    int symbol_set, spacing;
    double pitch, height;
    int posture, stroke_weight, typeface;
};

struct PCL_mode_str {
    const 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.
 */

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},
    {"cg_t$imes", "cg_times", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4101},
    {"z$apf_dingbats", "zapf_dingbats", 364, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4141},
    {"an$tique_olive", "antique_olive", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4168},
    {"ar$ial", "arial", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 16602},
    {"cou$rier", "courier", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4099},
    {"g$aramond_antigua", "garamond_antigua", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4197},
    {"l$etter_gothic", "letter_gothic", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4102},
    {"cg_o$mega", "cg_omega", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4113},
    {"al$bertus", "albertus", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 1, 4362},
    {"ti$mes_new_roman", "times_new_roman", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 16901},
    {"cl$arendon", "clarendon", 277, 1, 0.0, HPGL2_DEF_POINT, 4, 3, 4140},
    {"cor$onet", "coronet", 277, 1, 0.0, HPGL2_DEF_POINT, 1, 0, 4116},
    {"m$arigold", "marigold", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4297},
    {"tr$uetype_symbols", "truetype_symbols", 621, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 16686},
    {"w$ingdings", "wingdings", 18540, 1, 0.0, HPGL2_DEF_POINT, 1, 0, 31402}
};

#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 in monochrome
 */

static const char *HPGL2_lt[] = { "", ",2", ",2", ",2", ",2", ",2", ",2", ",2" },
		  *HPGL2_pw[] = { ".24", ".16", ".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",

gnuterm/term/hpgl.trm  view on Meta::CPAN

    HPGL2_SIZE, HPGL2_NOPSPOINTS, HPGL2_PSPOINTS,
    HPGL2_INVALID
};

static struct gen_table HPGL2_opts[] =
{
    { "mono$chrome", HPGL2_MONOCHROME },
    { "col$or", HPGL2_COLOR },
    { "col$our", HPGL2_COLOR },
    { "sol$id", HPGL2_SOLID },
    { "das$hed", HPGL2_DASHED },
    { "f$ont", HPGL2_FONT },
    { "s$ize", HPGL2_SIZE },
    { "n$opspoints", HPGL2_NOPSPOINTS },
    { "p$spoints", HPGL2_PSPOINTS },
    { NULL, HPGL2_INVALID }
};

TERM_PUBLIC void
HPGL2_options()
{
    struct termentry *t = term;
    int i;

    while (!END_OF_COMMAND) {
	switch(lookup_table(&HPGL2_opts[0],c_token)) {
	case HPGL2_MONOCHROME:
	    HPGL2_color = 0;
	    c_token++;
	    break;
	case HPGL2_COLOR:
	    HPGL2_color = 1;
	    c_token++;
	    if (!END_OF_COMMAND && isanumber(c_token)) {
		HPGL2_numpen = (int) real(&token[c_token].l_val);
		if (HPGL2_numpen <= 0) {
		    HPGL2_numpen = 6;
		    int_error(c_token, "Number of pens must be a positive");
		}
	    c_token++;
	    }
	    break;
	case HPGL2_SOLID:
	    HPGL2_solid = 1;
	    c_token++;
	    break;
	case HPGL2_DASHED:
	    HPGL2_solid = 0;
	    c_token++;
	    break;
	case HPGL2_FONT:
	    c_token++;
	    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];
		    HPGL2_font_num = i;
		    HPGL2_font_num_current = HPGL2_font_num;
		} else
		    int_error(c_token,
			      "expecting font: stick, cg_times, univers, zapf_dingbats, antique_olive,\narial, courier, garamond_antigua, letter_gothic, cg_omega, albertus,\ntimes_new_roman, clarendon, coronet, marigold, truetype_symbols, or wingdings");
		c_token++;
	    } else
		int_error(c_token,
			  "expecting font: stick, cg_times, univers, zapf_dingbats, antique_olive,\narial, courier, garamond_antigua, letter_gothic, cg_omega, albertus,\ntimes_new_roman, clarendon, coronet, marigold, truetype_symbols, or wingdings");
	    break;
	case HPGL2_SIZE:
	    c_token++;
	    if (!END_OF_COMMAND) {
		if ((HPGL2_point_size = real(&token[c_token].l_val)) > 0.0) {
		    HPGL2_point_size_current = HPGL2_point_size;
		    t->v_char = (int) HPGL_PUPI *HPGL2_point_size / 72;
		    t->h_char = t->v_char * 2 / 3;
		    if (HPGL2_font->spacing)
			HPGL2_font->height = HPGL2_point_size;
		    else
			HPGL2_font->pitch = 72 * 3 / (HPGL2_point_size * 2);
		} else
		    int_error(c_token, "expecting point size: real number");
		c_token++;
	    } else
		int_error(c_token, "expecting point size: real number");
	    break;
	case HPGL2_NOPSPOINTS:
	    c_token++;
	    pspointset = 0;
	    break;
	case  HPGL2_PSPOINTS:
	    c_token++;
	    pspointset = 1;
	    break;
	case HPGL2_INVALID:
	    c_token++;
	default:
	    break;
	}
    }

    sprintf(term_options+strlen(term_options)," %s %d %s \\\n"
					      "   %s %s %f %s",
	    HPGL2_color ? "color" : "monochrome",
	    HPGL2_color == 1 ? HPGL2_numpen : 1,
	    HPGL2_solid ? "solid" : "dashed",
	    HPGL2_font->name,
	    HPGL2_font->spacing ? "height" : "pitch",
	    HPGL2_font->spacing ? HPGL2_font->height : HPGL2_font->pitch,
	    pspointset ? "pspoints" : "nopspoints");
}

#if 0
/* Unused for now */

enum PCL_id {
    PCL_MODE, PCL_EXTENDED, PCL_EXTENDED, PCL_LEGAL, PCL_LETTER,
    PCL_INVALID
};

static struct gen_table PCL_opts[] =
{
    { "m$ode", PCL_MODE },
    { "ext$ended", PCL_EXTENDED },
    { "noext$ended", PCL_NOEXTENDED },
    { "leg$al", PCL_LEGAL },
    { "let$ter", PCL_LETTER },
    { NULL, PCL_INVALID }

gnuterm/term/hpgl.trm  view on Meta::CPAN

#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 {<number_of_pens>} {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 plotters such as the Hewlett-Packard Designjet",
" 750C, the Hewlett-Packard Laserjet III, and the Hewlett-Packard Laserjet IV.",
" It actually uses HPGL-2, but there is a name conflict among the terminal",
" devices.  It has several options which must be specified in the order",
" indicated below:",
"",
" Syntax:",
"       set terminal pcl5 {mode <mode>} {<plotsize>}",
"           {{color {<number_of_pens>}} | monochrome} {solid | dashed}",
"           {font <font>} {size <fontsize>} {pspoints | nopspoints}",
"",
" <mode> is `landscape` or `portrait`. <plotsize> is the physical",
" plotting size of the plot, which is one of the following: `letter` for",
" standard (8 1/2\" X 11\") displays, `legal` for (8 1/2\" X 14\") displays,",
" `noextended` for (36\" X 48\") displays (a letter size ratio) or,",
" `extended` for (36\" X 55\") displays (almost a legal size ratio).",
" `color` is for multi-pen (i.e. color) plots, and <number_of_pens> is",
" the number of pens (i.e. colors) used in color plots. `monochrome` is for",
" one (e.g. black) pen plots. `solid` draws all lines as solid lines, or",
" 'dashed' will draw lines with different dashed and dotted line patterns.",
" <font> is `stick`, `univers`, `cg_times`, `zapf_dingbats`, `antique_olive`,",
" `arial`, `courier`, `garamond_antigua`, `letter_gothic`, `cg_omega`,",
" `albertus`, `times_new_roman`, `clarendon`, `coronet`, `marigold`,",
" `truetype_symbols`, or `wingdings`. <fontsize> is the font size in points.",
" The point type selection can be the standard default set by specifying",
" nopspoints, or the same set of point types found in the postscript terminal",
" by specifying pspoints.",
"",
" Note that built-in support of some of these options is printer device",
" dependent. For instance, all the fonts are supposedly supported by the HP",
" Laserjet IV, but only a few (e.g. univers, stick) may be supported by the HP",
" Laserjet III and the Designjet 750C. Also, color obviously won't work on the",
" the laserjets since they are monochrome devices.",
"",
" Defaults: landscape, noextended, color (6 pens), solid, univers, 12 point,",
"           and nopspoints.",
"",
" 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 */



( run in 0.606 second using v1.01-cache-2.11-cpan-df04353d9ac )