Blame term/grass.trm

Packit 0986c0
/* Hello, Emacs, this is -*-C-*- */
Packit 0986c0
/*[
Packit 0986c0
 * GNUPLOT - grass.trm
Packit 0986c0
 * $Id:
Packit 0986c0
 *-
Packit 0986c0
 * Copyright (C) 1992-1995, 1999, 2004 James Darrell McCauley
Packit 0986c0
 *
Packit 0986c0
 * Permission to use, copy, and distribute this software and its
Packit 0986c0
 * documentation for any purpose with or without fee is hereby granted,
Packit 0986c0
 * provided that the above copyright notice appear in all copies and
Packit 0986c0
 * that both that copyright notice and this permission notice appear
Packit 0986c0
 * in supporting documentation.
Packit 0986c0
 *
Packit 0986c0
 * Permission to modify the software is granted, but not the right to
Packit 0986c0
 * distribute the complete modified source code.  Modifications are to
Packit 0986c0
 * be distributed as patches to the released version.  Permission to
Packit 0986c0
 * distribute binaries produced by compiling modified sources is granted,
Packit 0986c0
 * provided you
Packit 0986c0
 *   1. distribute the corresponding source modifications from the
Packit 0986c0
 *    released version in the form of a patch file along with the binaries,
Packit 0986c0
 *   2. add special version identification to distinguish your version
Packit 0986c0
 *    in addition to the base release version number,
Packit 0986c0
 *   3. provide your name and address as the primary contact for the
Packit 0986c0
 *    support of your modified version, and
Packit 0986c0
 *   4. retain our contact information in regard to use of the base
Packit 0986c0
 *    software.
Packit 0986c0
 * Permission to distribute the released version of the source code along
Packit 0986c0
 * with corresponding source modifications in the form of a patch file is
Packit 0986c0
 * granted with same provisions 2 through 4 for binary distributions.
Packit 0986c0
 *
Packit 0986c0
 * This software is provided "as is" without express or implied warranty
Packit 0986c0
 * to the extent permitted by applicable law.
Packit 0986c0
 *
Packit 0986c0
 * This software  is provided "as is" without express or implied warranty.
Packit 0986c0
 *
Packit 0986c0
 * This file is included by ../term.c.
Packit 0986c0
 *
Packit 0986c0
 * This terminal driver supports:
Packit 0986c0
 *  GRASS graphics driver
Packit 0986c0
 *
Packit 0986c0
 * AUTHOR
Packit 0986c0
 * James Darrell McCauley, PhD        http://soils.ecn.purdue.edu/~mccauley/
Packit 0986c0
 * Dept of Agricultural Engineering   mccauley@ecn.purdue.edu
Packit 0986c0
 * Purdue University                  tel: 317.494.1198 fax: 317.496.1115
Packit 0986c0
 *
Packit 0986c0
 * 05 Apr 1995 - cleaned up code by adding explicit function declarations.
Packit 0986c0
 *               compiles clean with 'gcc -Wall'
Packit 0986c0
 * 14 Apr 1995 - adapted for new layout, added font selection
Packit 0986c0
 *
Packit 0986c0
 * 13 Jan 1999 - Copyright statement changed to new gnuplot copyright
Packit 0986c0
 *               Permission given by orig author in private email (lh)
Packit 0986c0
 *
Packit 0986c0
 * send your comments or suggestions to (grassp-list@moon.cecer.army.mil).
Packit 0986c0
 *
Packit 0986c0
]*/
Packit 0986c0
Packit 0986c0
#include "driver.h"
Packit 0986c0
Packit 0986c0
#ifdef TERM_REGISTER
Packit 0986c0
register_term(grass)
Packit 0986c0
#endif
Packit 0986c0
Packit 0986c0
Packit 0986c0
#ifdef TERM_PROTO
Packit 0986c0
TERM_PUBLIC void GRASS_move __PROTO((unsigned int x, unsigned int y));
Packit 0986c0
TERM_PUBLIC void GRASS_options __PROTO((void));
Packit 0986c0
TERM_PUBLIC void GRASS_init __PROTO((void));
Packit 0986c0
TERM_PUBLIC void GRASS_reset __PROTO((void));
Packit 0986c0
TERM_PUBLIC void GRASS_graphics __PROTO((void));
Packit 0986c0
TERM_PUBLIC void GRASS_text __PROTO((void));
Packit 0986c0
TERM_PUBLIC void GRASS_vector __PROTO((unsigned int x, unsigned int y));
Packit 0986c0
TERM_PUBLIC void GRASS_linetype __PROTO((int lt));
Packit 0986c0
TERM_PUBLIC void GRASS_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
Packit 0986c0
TERM_PUBLIC int GRASS_text_angle __PROTO((int ang));
Packit 0986c0
TERM_PUBLIC int GRASS_justify_text __PROTO((enum JUSTIFY mode));
Packit 0986c0
TERM_PUBLIC void GRASS_point __PROTO((unsigned int x, unsigned int y, int point));
Packit 0986c0
TERM_PUBLIC int GRASS_set_font __PROTO((const char *font));
Packit 0986c0
/* TERM_PUBLIC void GRASS_set_pointsize __PROTO((double size)); */
Packit 0986c0
TERM_PUBLIC void GRASS_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
Packit 0986c0
#endif /* TERM_PROTO */
Packit 0986c0
Packit 0986c0
#ifndef TERM_PROTO_ONLY
Packit 0986c0
#ifdef TERM_BODY
Packit 0986c0
Packit 0986c0
#include <stdio.h>
Packit 0986c0
#include <string.h>
Packit 0986c0
/* #include "gis.h" */ /* this causes conflicts with things in term.c */
Packit 0986c0
Packit 0986c0
#define GRASS_XMAX 1000
Packit 0986c0
#define GRASS_YMAX 1000
Packit 0986c0
#define GRASS_VCHAR 5
Packit 0986c0
#define GRASS_HCHAR 5
Packit 0986c0
#define GRASS_VTIC 3
Packit 0986c0
#define GRASS_HTIC 3
Packit 0986c0
Packit 0986c0
#define PNT_SIZE 3
Packit 0986c0
#define TYPE_DOT  -1
Packit 0986c0
#define TYPE_X  0
Packit 0986c0
#define TYPE_PLUS   1
Packit 0986c0
#define TYPE_BOX    2
Packit 0986c0
#define TYPE_DIAMOND    3	/* need type 4 and 5 */
Packit 0986c0
#define TYPE_TRIANGLE 4
Packit 0986c0
#define TYPE_OCTO 5
Packit 0986c0
#define TYPE_ITRIANGLE 6
Packit 0986c0
#define TYPE_FBOX 7
Packit 0986c0
#define TYPE_FTRIANGLE 8
Packit 0986c0
#define TYPE_FITRIANGLE 9
Packit 0986c0
#define TYPE_FOCTO 10
Packit 0986c0
Packit 0986c0
static void cont_abs __PROTO((int x, int y));
Packit 0986c0
static void draw_points_dot __PROTO((int x, int y));
Packit 0986c0
static void draw_points_diamond __PROTO((int x, int y));
Packit 0986c0
static void draw_points_box __PROTO((int x, int y));
Packit 0986c0
static void draw_points_fbox __PROTO((int x, int y));
Packit 0986c0
static void draw_points_itriangle __PROTO((int x, int y));
Packit 0986c0
static void draw_points_fitriangle __PROTO((int x, int y));
Packit 0986c0
static void draw_points_triangle __PROTO((int x, int y));
Packit 0986c0
static void draw_points_ftriangle __PROTO((int x, int y));
Packit 0986c0
static void draw_points_plus __PROTO((int x, int y));
Packit 0986c0
static void draw_points_octo __PROTO((int x, int y));
Packit 0986c0
static void draw_points_focto __PROTO((int x, int y));
Packit 0986c0
static void draw_points_x __PROTO((int x, int y));
Packit 0986c0
Packit 0986c0
static int R__curx, R__cury;
Packit 0986c0
Packit 0986c0
static int grass_yoffset;
Packit 0986c0
static int grass_xoffset;
Packit 0986c0
static int y_max;
Packit 0986c0
static int points_buf_x[PNT_SIZE*PNT_SIZE]; /* for filled point types */
Packit 0986c0
static int points_buf_y[PNT_SIZE*PNT_SIZE];
Packit 0986c0
Packit 0986c0
extern int R_move_abs ();
Packit 0986c0
extern int R_cont_abs ();
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_move(unsigned int x, unsigned int y)
Packit 0986c0
{
Packit 0986c0
  /* R_move_abs (grass_xoffset+x, grass_yoffset-y + y_max); */
Packit 0986c0
  R_move_abs (grass_xoffset+x, grass_yoffset-y);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
cont_abs(int x, int y)
Packit 0986c0
{
Packit 0986c0
  /* R_cont_abs (grass_xoffset+x, grass_xoffset-y + y_max); */
Packit 0986c0
  R_cont_abs (grass_xoffset+x, grass_yoffset-y);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_options()
Packit 0986c0
{
Packit 0986c0
  options_null ();		/* no options to begin with */
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_init()
Packit 0986c0
{
Packit 0986c0
    /* char buff[128]; */
Packit 0986c0
    char window_name[64];
Packit 0986c0
    float size = 3.0;
Packit 0986c0
    /* int backcolor; */
Packit 0986c0
    int dots_per_line;
Packit 0986c0
    int top, b, l, r;
Packit 0986c0
    /* int textcolor; */
Packit 0986c0
    struct termentry *t = term;
Packit 0986c0
Packit 0986c0
    extern int G_gisinit();
Packit 0986c0
    extern int R_open_driver();
Packit 0986c0
    extern int D_setup();
Packit 0986c0
    extern int D_get_cur_wind();
Packit 0986c0
    extern int G_fatal_error();
Packit 0986c0
    extern int D_set_cur_wind();
Packit 0986c0
    extern int D_get_screen_window();
Packit 0986c0
    extern int R_set_window();
Packit 0986c0
    extern int R_text_size();
Packit 0986c0
    extern int R_font();
Packit 0986c0
    extern int R_screen_top();
Packit 0986c0
    extern int R_screen_bot();
Packit 0986c0
    extern int D_erase_window();
Packit 0986c0
Packit 0986c0
    G_gisinit ("g.gnuplot");
Packit 0986c0
Packit 0986c0
    R_open_driver ();
Packit 0986c0
Packit 0986c0
    D_setup (0);
Packit 0986c0
Packit 0986c0
    if (D_get_cur_wind (window_name))
Packit 0986c0
	G_fatal_error ("No current window");
Packit 0986c0
Packit 0986c0
    if (D_set_cur_wind (window_name))
Packit 0986c0
	G_fatal_error ("Current window not available");
Packit 0986c0
Packit 0986c0
    /* Set up the screen, conversions, and graphics */
Packit 0986c0
    D_get_screen_window (&top, &b, &l, &r);
Packit 0986c0
    /* D_set_overlay_mode (1); */
Packit 0986c0
Packit 0986c0
    /* Figure out where to put text */
Packit 0986c0
Packit 0986c0
    R_set_window (top, b, l, r);
Packit 0986c0
    t->xmax = r-l;
Packit 0986c0
    t->ymax = b-top;
Packit 0986c0
    grass_xoffset=l;
Packit 0986c0
    grass_yoffset=b;
Packit 0986c0
Packit 0986c0
    dots_per_line = (int) (size / 100.0 * (float) (t->ymax));
Packit 0986c0
    t->v_char = t->h_char = (int) (.8 * (float) dots_per_line);
Packit 0986c0
    R_text_size (t->h_char, t->v_char);
Packit 0986c0
    R_font("romans");
Packit 0986c0
Packit 0986c0
    t->v_tic = t->h_tic = 4;
Packit 0986c0
Packit 0986c0
    y_max = t->ymax; /* kludge? */
Packit 0986c0
Packit 0986c0
    R__curx = R_screen_top ();
Packit 0986c0
    R__cury = R_screen_bot () + grass_yoffset;
Packit 0986c0
Packit 0986c0
    D_erase_window();
Packit 0986c0
Packit 0986c0
    fprintf(stderr,"**********************************************\n");
Packit 0986c0
    fprintf(stderr,"DIAGNOSTIC TERMINAL SETUP\n");
Packit 0986c0
    fprintf(stderr,"top = %d\tb = %d\tl = %d\tr = %d\n", top,b,l,r);
Packit 0986c0
    fprintf(stderr,"name = %s\n", t->name);
Packit 0986c0
    fprintf(stderr,"description = %s\n", t->description);
Packit 0986c0
    fprintf(stderr,"xmax = %d\t", (int)t->xmax);
Packit 0986c0
    fprintf(stderr,"ymax = %d\n", (int)t->ymax);
Packit 0986c0
    fprintf(stderr,"v_char = %d\t", (int)t->v_char);
Packit 0986c0
    fprintf(stderr,"h_char = %d\n", (int)t->h_char);
Packit 0986c0
    fprintf(stderr,"v_tic = %d\t", (int)t->v_tic);
Packit 0986c0
    fprintf(stderr,"h_tic = %d\n", (int)t->h_tic);
Packit 0986c0
    fprintf(stderr,"**********************************************\n\n");
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_reset ()
Packit 0986c0
{
Packit 0986c0
    extern int R_standard_color();
Packit 0986c0
    extern int D_translate_color();
Packit 0986c0
    extern int R_flush();
Packit 0986c0
    extern int R_stabilize();
Packit 0986c0
    extern int R_close_driver();
Packit 0986c0
Packit 0986c0
    R_standard_color (D_translate_color ("black"));
Packit 0986c0
    /* D_erase_window(); .* don't clear after g.gnuplot is finished */
Packit 0986c0
    R_flush ();
Packit 0986c0
    R_stabilize ();
Packit 0986c0
    R_close_driver ();
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_graphics ()
Packit 0986c0
{
Packit 0986c0
    extern int D_erase_window();
Packit 0986c0
    extern int R_flush();
Packit 0986c0
    extern int R_stabilize();
Packit 0986c0
    extern int R_standard_color();
Packit 0986c0
    extern int D_translate_color();
Packit 0986c0
Packit 0986c0
    R_flush ();
Packit 0986c0
    R_stabilize ();
Packit 0986c0
    R_standard_color (D_translate_color ("black"));
Packit 0986c0
    D_erase_window();
Packit 0986c0
    return;
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_text ()
Packit 0986c0
{
Packit 0986c0
    extern int R_flush ();
Packit 0986c0
    extern int R_stabilize ();
Packit 0986c0
Packit 0986c0
    R_flush ();
Packit 0986c0
    R_stabilize ();
Packit 0986c0
    return;			/* device can't be used as a terminal */
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_vector(unsigned int x, unsigned int y)
Packit 0986c0
{
Packit 0986c0
    extern int R_flush ();
Packit 0986c0
    extern int R_stabilize ();
Packit 0986c0
Packit 0986c0
    cont_abs (x, y);
Packit 0986c0
    R_flush ();
Packit 0986c0
    R_stabilize ();
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_linetype(int lt)
Packit 0986c0
{
Packit 0986c0
    extern int R_standard_color();
Packit 0986c0
    extern int D_translate_color();
Packit 0986c0
    extern int R_flush ();
Packit 0986c0
    extern int R_stabilize ();
Packit 0986c0
Packit 0986c0
    while (lt > 10) lt-=10;
Packit 0986c0
Packit 0986c0
    if (lt <= LT_BLACK)
Packit 0986c0
	R_standard_color (D_translate_color ("gray"));
Packit 0986c0
    else if (lt == LT_AXIS)
Packit 0986c0
	R_standard_color (D_translate_color ("white"));
Packit 0986c0
    else if (lt == 0)
Packit 0986c0
	R_standard_color (D_translate_color ("red"));
Packit 0986c0
    else if (lt == 1)
Packit 0986c0
	R_standard_color (D_translate_color ("green"));
Packit 0986c0
    else if (lt == 2)
Packit 0986c0
	R_standard_color (D_translate_color ("magenta"));
Packit 0986c0
    else if (lt == 3)
Packit 0986c0
	R_standard_color (D_translate_color ("brown"));
Packit 0986c0
    else if (lt == 4)
Packit 0986c0
	R_standard_color (D_translate_color ("orange"));
Packit 0986c0
    else if (lt == 5)
Packit 0986c0
	R_standard_color (D_translate_color ("yellow"));
Packit 0986c0
    else if (lt == 6)
Packit 0986c0
	R_standard_color (D_translate_color ("blue"));
Packit 0986c0
    else if (lt == 7)
Packit 0986c0
	R_standard_color (D_translate_color ("violet"));
Packit 0986c0
    else if (lt == 8)
Packit 0986c0
	R_standard_color (D_translate_color ("indigo"));
Packit 0986c0
    else if (lt == 9)
Packit 0986c0
	R_standard_color (D_translate_color ("gray"));
Packit 0986c0
    else /* if (lt == 10) */
Packit 0986c0
	R_standard_color (D_translate_color ("white"));
Packit 0986c0
    R_flush ();
Packit 0986c0
    R_stabilize ();
Packit 0986c0
    return;
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
/* originally /usr/grass4/src/display/d.label/cmd/label.c */
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_put_text(unsigned int x, unsigned int y, const char *str)
Packit 0986c0
{
Packit 0986c0
    extern int R_text();
Packit 0986c0
    extern int R_flush ();
Packit 0986c0
    extern int R_stabilize ();
Packit 0986c0
Packit 0986c0
    if (strlen (str) == 0)
Packit 0986c0
	return;
Packit 0986c0
Packit 0986c0
    GRASS_move (x, y);
Packit 0986c0
    /* R_standard_color (D_translate_color ("white")); */
Packit 0986c0
    R_text (str);
Packit 0986c0
    R_flush ();
Packit 0986c0
    R_stabilize ();
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC int
Packit 0986c0
GRASS_text_angle (int ang)
Packit 0986c0
{
Packit 0986c0
  extern int R_text_rotation();
Packit 0986c0
Packit 0986c0
  R_text_rotation((float)ang);
Packit 0986c0
  return TRUE;			/* GRASS can (?) rotate text */
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC int
Packit 0986c0
GRASS_justify_text (enum JUSTIFY mode)
Packit 0986c0
{
Packit 0986c0
    return (FALSE);		/* don't mess with this now */
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_point (unsigned int x, unsigned y, int point)
Packit 0986c0
{
Packit 0986c0
    switch (point) {
Packit 0986c0
    case TYPE_DOT:
Packit 0986c0
	draw_points_dot (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_X:
Packit 0986c0
	draw_points_x (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_PLUS:
Packit 0986c0
	draw_points_plus (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_BOX:
Packit 0986c0
	draw_points_box (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_DIAMOND:
Packit 0986c0
	draw_points_diamond (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_TRIANGLE:
Packit 0986c0
	draw_points_triangle (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_OCTO:
Packit 0986c0
	draw_points_octo (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_ITRIANGLE:
Packit 0986c0
	draw_points_itriangle (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_FBOX:
Packit 0986c0
	draw_points_fbox (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_FTRIANGLE:
Packit 0986c0
	draw_points_ftriangle (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_FITRIANGLE:
Packit 0986c0
	draw_points_fitriangle (x, y);
Packit 0986c0
	break;
Packit 0986c0
    case TYPE_FOCTO:
Packit 0986c0
	draw_points_focto (x, y);
Packit 0986c0
	break;
Packit 0986c0
    }
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
/* modified from /usr/grass4/src/display/d.points/cmd/main.c */
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_dot(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x, y);
Packit 0986c0
  cont_abs (x, y);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_diamond(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x, y + PNT_SIZE);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y);
Packit 0986c0
  GRASS_vector (x, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y);
Packit 0986c0
  GRASS_vector (x, y + PNT_SIZE);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_box(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x - PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_fbox(int x, int y)
Packit 0986c0
{
Packit 0986c0
  int R_polygon_abs();
Packit 0986c0
  points_buf_x[0] = grass_xoffset + x - PNT_SIZE;
Packit 0986c0
  points_buf_y[0]= grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  points_buf_x[1] = grass_xoffset + x + PNT_SIZE;
Packit 0986c0
  points_buf_y[1]= grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  points_buf_x[2] = grass_xoffset + x + PNT_SIZE;
Packit 0986c0
  points_buf_y[2]= grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  points_buf_x[3] = grass_xoffset + x - PNT_SIZE;
Packit 0986c0
  points_buf_y[3]= grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  R_polygon_abs(points_buf_x, points_buf_y, 4 );
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_itriangle(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x - PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
  GRASS_vector (x , y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_fitriangle(int x, int y)
Packit 0986c0
{
Packit 0986c0
  int R_polygon_abs();
Packit 0986c0
Packit 0986c0
  points_buf_x[0] = grass_xoffset + x + PNT_SIZE;
Packit 0986c0
  points_buf_y[0] = grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  points_buf_x[1] = grass_xoffset + x ;
Packit 0986c0
  points_buf_y[1] = grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  points_buf_x[2] = grass_xoffset + x - PNT_SIZE;
Packit 0986c0
  points_buf_y[2] = grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  R_polygon_abs(points_buf_x, points_buf_y, 3 );
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_triangle(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x - PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x , y + PNT_SIZE);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_ftriangle(int x, int y)
Packit 0986c0
{
Packit 0986c0
  int R_polygon_abs();
Packit 0986c0
Packit 0986c0
  points_buf_x[0] = grass_xoffset + x;
Packit 0986c0
  points_buf_y[0]= grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  points_buf_x[1] = grass_xoffset + x + PNT_SIZE;
Packit 0986c0
  points_buf_y[1]= grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  points_buf_x[2] = grass_xoffset + x - PNT_SIZE;
Packit 0986c0
  points_buf_y[2]= grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  R_polygon_abs(points_buf_x, points_buf_y, 3 );
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_plus(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x - PNT_SIZE, y);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y);
Packit 0986c0
  GRASS_move (x, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x, y + PNT_SIZE);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
/* depends on PNT_SIZE */
Packit 0986c0
static void
Packit 0986c0
draw_points_octo(int x, int y)
Packit 0986c0
{
Packit 0986c0
  /* CCW */
Packit 0986c0
  GRASS_move (x - (int) (PNT_SIZE/3), y - PNT_SIZE);   /* 1 */
Packit 0986c0
  GRASS_vector (x + (int) (PNT_SIZE/3), y - PNT_SIZE); /* 2 */
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y - (int) (PNT_SIZE/3)); /* 3 */
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y + (int) (PNT_SIZE/3)); /* 4 */
Packit 0986c0
  GRASS_vector (x + (int) (PNT_SIZE/3), y + PNT_SIZE); /* 5 */
Packit 0986c0
  GRASS_vector (x - (int) (PNT_SIZE/3), y + PNT_SIZE); /* 6 */
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y + (int) (PNT_SIZE/3)); /* 7 */
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y - (int) (PNT_SIZE/3)); /* 8 */
Packit 0986c0
  GRASS_vector (x - (int) (PNT_SIZE/3), y - PNT_SIZE); /* 1 */
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
/* depends on PNT_SIZE */
Packit 0986c0
static void
Packit 0986c0
draw_points_focto(int x, int y)
Packit 0986c0
{
Packit 0986c0
  int R_polygon_abs();
Packit 0986c0
Packit 0986c0
  /* CCW */
Packit 0986c0
  points_buf_x[0] = grass_xoffset + x + (int) (PNT_SIZE/3);
Packit 0986c0
  points_buf_y[0] = grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  points_buf_x[1] = grass_xoffset + x + PNT_SIZE;
Packit 0986c0
  points_buf_y[1] = grass_yoffset - (y - (int) (PNT_SIZE/3));
Packit 0986c0
  points_buf_x[2] = grass_xoffset + x + PNT_SIZE;
Packit 0986c0
  points_buf_y[2] = grass_yoffset - (y + (int) (PNT_SIZE/3));
Packit 0986c0
  points_buf_x[3] = grass_xoffset + x + (int) (PNT_SIZE/3);
Packit 0986c0
  points_buf_y[3] = grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  points_buf_x[4] = grass_xoffset + x - (int) (PNT_SIZE/3);
Packit 0986c0
  points_buf_y[4] = grass_yoffset - (y + PNT_SIZE);
Packit 0986c0
  points_buf_x[5] = grass_xoffset + x - PNT_SIZE;
Packit 0986c0
  points_buf_y[5] = grass_yoffset - (y + (int) (PNT_SIZE/3));
Packit 0986c0
  points_buf_x[6] = grass_xoffset + x - PNT_SIZE;
Packit 0986c0
  points_buf_y[6] = grass_yoffset - (y - (int) (PNT_SIZE/3));
Packit 0986c0
  points_buf_x[7] = grass_xoffset + x - (int) (PNT_SIZE/3);
Packit 0986c0
  points_buf_y[7] = grass_yoffset - (y - PNT_SIZE);
Packit 0986c0
  R_polygon_abs(points_buf_x, points_buf_y, 8 );
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
static void
Packit 0986c0
draw_points_x(int x, int y)
Packit 0986c0
{
Packit 0986c0
  GRASS_move (x - PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x + PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
  GRASS_move (x + PNT_SIZE, y - PNT_SIZE);
Packit 0986c0
  GRASS_vector (x - PNT_SIZE, y + PNT_SIZE);
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
TERM_PUBLIC int
Packit 0986c0
GRASS_set_font(const char *font)
Packit 0986c0
{
Packit 0986c0
  char name[32];
Packit 0986c0
  int size,sep, R_font();
Packit 0986c0
  struct termentry *t = term;
Packit 0986c0
  int R_text_size (), dots_per_line;
Packit 0986c0
Packit 0986c0
  /* G_warning(font); */
Packit 0986c0
Packit 0986c0
  sep=strcspn(font,",");
Packit 0986c0
  strncpy(name,font,sep); name[sep]=NUL;
Packit 0986c0
  sscanf (&(font[sep+1]),"%d",&size);
Packit 0986c0
Packit 0986c0
  if (size==0)
Packit 0986c0
    size=3;
Packit 0986c0
  dots_per_line = (int) (size / 100.0 * (float) (t->ymax));
Packit 0986c0
  t->v_char = t->h_char = (int) (.8 * (float) dots_per_line);
Packit 0986c0
  R_text_size (t->h_char, t->v_char);
Packit 0986c0
/* cyrilc,gothgbt,gothgrt,gothitt,greekc,greekcs,greekp,
Packit 0986c0
greeks,italicc,italiccs,italict,romanc,romancs,romand,
Packit 0986c0
romans,romant,scriptc,scripts */
Packit 0986c0
Packit 0986c0
  if (strlen(name) > 5 )
Packit 0986c0
    R_font(name);
Packit 0986c0
  else
Packit 0986c0
    R_font("romans");
Packit 0986c0
  return TRUE;
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
#ifdef GRASS_POINTSIZE
Packit 0986c0
/* HBB FIXME 20040619: argument type wrong, but luckily unused anyway... */
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_set_pointsize(double *size)
Packit 0986c0
{
Packit 0986c0
  return;
Packit 0986c0
}
Packit 0986c0
#endif /* GRASS_POINTSIZE */
Packit 0986c0
Packit 0986c0
/* need to fix */
Packit 0986c0
TERM_PUBLIC void
Packit 0986c0
GRASS_arrow(
Packit 0986c0
    unsigned int sx, unsigned int sy,
Packit 0986c0
    unsigned int ex, unsigned int ey,
Packit 0986c0
    int head)
Packit 0986c0
{
Packit 0986c0
  do_arrow (sx, sy, ex, ey, 1);
Packit 0986c0
  return;
Packit 0986c0
}
Packit 0986c0
Packit 0986c0
#endif /* TERM_BODY */
Packit 0986c0
Packit 0986c0
#ifdef TERM_TABLE
Packit 0986c0
TERM_TABLE_START(grass_driver)
Packit 0986c0
    "grass", "GRASS Graphics Monitor",
Packit 0986c0
    GRASS_XMAX, GRASS_YMAX, GRASS_VCHAR, GRASS_HCHAR,
Packit 0986c0
    GRASS_VTIC, GRASS_HTIC, GRASS_options, GRASS_init, GRASS_reset,
Packit 0986c0
    GRASS_text, null_scale, GRASS_graphics, GRASS_move, GRASS_vector,
Packit 0986c0
    GRASS_linetype, GRASS_put_text, GRASS_text_angle,
Packit 0986c0
    GRASS_justify_text, GRASS_point, GRASS_arrow, GRASS_set_font
Packit 0986c0
TERM_TABLE_END(grass_driver)
Packit 0986c0
Packit 0986c0
Packit 0986c0
#undef LAST_TERM
Packit 0986c0
#define LAST_TERM grass_driver
Packit 0986c0
#endif /* TERM_TABLE */
Packit 0986c0
#endif /* TERM_PROTO_ONLY */
Packit 0986c0
Packit 0986c0
Packit 0986c0
#ifdef TERM_HELP
Packit 0986c0
START_HELP(grass)
Packit 0986c0
"1 grass",
Packit 0986c0
"?commands set terminal grass",
Packit 0986c0
"?set terminal grass",
Packit 0986c0
"?set term grass",
Packit 0986c0
"?terminal grass",
Packit 0986c0
"?term grass",
Packit 0986c0
"?grass",
Packit 0986c0
" Note: legacy terminal.",
Packit 0986c0
" The `grass` terminal driver gives `gnuplot` capabilities to users of the ",
Packit 0986c0
" GRASS geographic information system.  Contact grassp-list@moon.cecer.army.mil",
Packit 0986c0
" for more information.  Pages are written to the current frame of the GRASS",
Packit 0986c0
" Graphics Window.  There are no options."
Packit 0986c0
END_HELP(grass)
Packit 0986c0
#endif