GRASS Programmer's Manual 6.4.1(2011)
plot.c File Reference
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
Include dependency graph for plot.c:

Go to the source code of this file.

Defines

#define POINT   struct point
#define X(e)   (left + xconv * ((e) - window.west))
#define Y(n)   (top + yconv * (window.north - (n)))
#define EAST(x)   (window.west + ((x)-left)/xconv)
#define NORTH(y)   (window.north - ((y)-top)/yconv)
#define OK   0
#define TOO_FEW_EDGES   2
#define NO_MEMORY   1
#define OUT_OF_SYNC   -1

Functions

int G_setup_plot (double t, double b, double l, double r, int(*Move)(int, int), int(*Cont)(int, int))
 returns east larger than west
int G_setup_fill (int gap)
 set row_fill routine to row_solid_fill or row_dotted_fill
int G_plot_where_xy (double east, double north, int *x, int *y)
 east,north to x,y
int G_plot_where_en (int x, int y, double *east, double *north)
 x,y to east,north
int G_plot_point (double east, double north)
int G_plot_line (double east1, double north1, double east2, double north2)
 plot line between latlon coordinates
int G_plot_line2 (double east1, double north1, double east2, double north2)
int G_plot_polygon (const double *x, const double *y, int n)
 plot filled polygon with n vertices
int G_plot_area (double *const *xs, double *const *ys, int *rpnts, int rings)
 plot multiple polygons
int G_plot_fx (double(*f)(double), double east1, double east2)
 plot f(east1) to f(east2)

Variables

static double yconv
static double right
static double top
static double bottom
static int ymax

Define Documentation

#define EAST (   x)    (window.west + ((x)-left)/xconv)

Definition at line 151 of file plot.c.

Referenced by G_plot_where_en().

#define NO_MEMORY   1

Definition at line 386 of file plot.c.

Referenced by G_plot_area(), and G_plot_polygon().

#define NORTH (   y)    (window.north - ((y)-top)/yconv)

Definition at line 152 of file plot.c.

Referenced by G_plot_where_en().

#define OK   0

Definition at line 384 of file plot.c.

Referenced by G_plot_area(), and G_plot_polygon().

#define OUT_OF_SYNC   -1

Definition at line 387 of file plot.c.

Referenced by G_plot_area(), and G_plot_polygon().

#define POINT   struct point

Definition at line 31 of file plot.c.

Referenced by G_plot_area(), and G_plot_polygon().

#define TOO_FEW_EDGES   2

Definition at line 385 of file plot.c.

Referenced by G_plot_area(), and G_plot_polygon().

#define X (   e)    (left + xconv * ((e) - window.west))

Definition at line 148 of file plot.c.

Referenced by G_plot_area(), G_plot_polygon(), and G_plot_where_xy().

#define Y (   n)    (top + yconv * (window.north - (n)))

Definition at line 149 of file plot.c.

Referenced by G_plot_area(), G_plot_polygon(), and G_plot_where_xy().


Function Documentation

int G_plot_area ( double *const *  xs,
double *const *  ys,
int *  rpnts,
int  rings 
)

plot multiple polygons

Like G_plot_polygon, except it takes a set of polygons, each with {npts[i]} vertices, where the number of polygons is specified with the rings argument. It is especially useful for plotting vector areas with interior islands.

Parameters:
xs
ys
npts
rings
Returns:
int

Definition at line 542 of file plot.c.

References G_free(), L, NO_MEMORY, NULL, OK, OUT_OF_SYNC, POINT, TOO_FEW_EDGES, X, and Y.

int G_plot_fx ( double(*)(double)  f,
double  east1,
double  east2 
)

plot f(east1) to f(east2)

The function f(east) is plotted from east1 to east2. The function f(east) must return the map northing coordinate associated with east.

Parameters:
~
Returns:
int

Definition at line 811 of file plot.c.

References G_plot_line().

int G_plot_line ( double  east1,
double  north1,
double  east2,
double  north2 
)

plot line between latlon coordinates

A line from east1,north1 to east2,north2 is plotted in output x,y coordinates (e.g. pixels for graphics.) This routine handles global wrap-around for latitude-longitude databases.

Parameters:
east1
north1
east2
north2
Returns:
int

Definition at line 230 of file plot.c.

Referenced by G_plot_fx(), and G_plot_icon().

int G_plot_line2 ( double  east1,
double  north1,
double  east2,
double  north2 
)

Definition at line 235 of file plot.c.

int G_plot_point ( double  east,
double  north 
)

Definition at line 198 of file plot.c.

References G_plot_where_xy().

int G_plot_polygon ( const double *  x,
const double *  y,
int  n 
)

plot filled polygon with n vertices

The polygon, described by the n vertices east,north, is plotted in the output x,y space as a filled polygon.

Parameters:
east
north
n
Returns:
int

Definition at line 412 of file plot.c.

References L, NO_MEMORY, OK, OUT_OF_SYNC, POINT, TOO_FEW_EDGES, X, and Y.

int G_plot_where_en ( int  x,
int  y,
double *  east,
double *  north 
)

x,y to east,north

The pixel coordinates x,y are converted to map coordinates east,north.

Parameters:
x
y
east
north
Returns:
int

Definition at line 190 of file plot.c.

References EAST, G_adjust_easting(), and NORTH.

int G_plot_where_xy ( double  east,
double  north,
int *  x,
int *  y 
)

east,north to x,y

The map coordinates east,north are converted to pixel coordinates x,y.

Parameters:
east
north
x
y
Returns:
int

Definition at line 168 of file plot.c.

References G_adjust_easting(), X, and Y.

Referenced by G_plot_point().

int G_setup_fill ( int  gap)

set row_fill routine to row_solid_fill or row_dotted_fill

After calling this function, G_plot_polygon() and G_plot_area() fill shapes with solid or dotted lines. If gap is greater than zero, this value will be used for row_dotted_fill. Otherwise, row_solid_fill is used.

Parameters:
int
Returns:
int

Definition at line 136 of file plot.c.

int G_setup_plot ( double  t,
double  b,
double  l,
double  r,
int(*)(int, int)  Move,
int(*)(int, int)  Cont 
)

returns east larger than west

If the region projection is PROJECTION_LL, then this routine returns an equivalent east that is larger, but no more than 360 degrees larger, than the coordinate for the western edge of the region. Otherwise no adjustment is made and the original east is returned.

Parameters:
east
region
Returns:
double

initialize plotting routines

Initializes the plotting capability. This routine must be called once before calling the G_plot_*(~) routines described below. The parameters t, b, l, r are the top, bottom, left, and right of the output x,y coordinate space. They are not integers, but doubles to allow for subpixel registration of the input and output coordinate spaces. The input coordinate space is assumed to be the current GRASS region, and the routines supports both planimetric and latitude- longitude coordinate systems. Move and Cont are subroutines that will draw lines in x,y space. They will be called as follows: Move(x, y) move to x,y (no draw) Cont(x, y) draw from previous position to x,y. Cont(~) is responsible for clipping

Parameters:
~
Returns:
int

Definition at line 97 of file plot.c.

References b, bottom, G_get_set_window(), r, right, top, yconv, and ymax.


Variable Documentation

double bottom

Definition at line 21 of file plot.c.

Referenced by G_setup_plot().

double right

Definition at line 21 of file plot.c.

Referenced by G_setup_plot().

double top

Definition at line 21 of file plot.c.

Referenced by G_setup_plot().

double yconv

Definition at line 20 of file plot.c.

Referenced by G_setup_plot().

int ymax

Definition at line 22 of file plot.c.

Referenced by G_setup_plot().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines