31static void fastline(
double,
double,
double,
double);
32static void slowline(
double,
double,
double,
double);
33static void plot_line(
double,
double,
double,
double,
34 void (*)(
double,
double,
double,
double));
35static double wrap_east(
double,
double);
36static int edge(
double,
double,
double,
double);
37static int edge_point(
double,
int);
39static int edge_order(
const void *,
const void *);
40static void row_solid_fill(
int,
double,
double);
41static void row_dotted_fill(
int,
double,
double);
42static int ifloor(
double);
43static int iceil(
double);
50#define POINT struct point
55 double left, right, top, bottom;
71#define TOO_FEW_EDGES 2
98 int (*Cont)(
int,
int))
107 st->xconv = (
st->right -
st->left) / (
st->window.east -
st->window.west);
108 st->yconv = (
st->bottom -
st->top) / (
st->window.north -
st->window.south);
110 if (
st->top <
st->bottom) {
111 st->ymin = iceil(
st->top);
112 st->ymax = ifloor(
st->bottom);
115 st->ymin = iceil(
st->bottom);
116 st->ymax = ifloor(
st->top);
136 st->row_fill = row_dotted_fill;
137 st->dotted_fill_gap =
gap + 1;
140 st->row_fill = row_solid_fill;
143#define X(e) (st->left + st->xconv * ((e) - st->window.west))
144#define Y(n) (st->top + st->yconv * (st->window.north - (n)))
146#define EAST(x) (st->window.west + ((x) - st->left) / st->xconv)
147#define NORTH(y) (st->window.north - ((y) - st->top) / st->yconv)
163 *y = ifloor(
Y(north) + 0.5);
231static void fastline(
double x1,
double y1,
double x2,
double y2)
233 st->move(ifloor(x1 + 0.5), ifloor(y1 + 0.5));
234 st->cont(ifloor(x2 + 0.5), ifloor(y2 + 0.5));
242static void slowline(
double x1,
double y1,
double x2,
double y2)
257 xstop = ifloor(x1 + 0.5);
261 xstop = ifloor(x2 + 0.5);
281 ystop = ifloor(y1 + 0.5);
285 ystop = ifloor(y2 + 0.5);
299 void (*line)(
double,
double,
double,
double))
301 double x1, x2, y1, y2;
313 while (
east1 >
st->window.east) {
324 line(x1, y1, x2, y2);
327 while (
east2 >
st->window.east) {
337 line(x1, y1, x2, y2);
343 line(x1, y1, x2, y2);
347static double wrap_east(
double e0,
double e1)
349 while (
e0 - e1 > 180)
351 while (e1 -
e0 > 180)
378 double shift, E,
W = 0L;
383 st->row_fill = row_solid_fill;
409 for (i = 0; i < n; i++) {
410 e1 = wrap_east(
e0,
x[i]);
419 if (!edge(x0,
y0, x1, y1))
430 while (E + shift >
st->window.east)
440 for (i = 0; i < n; i++) {
443 if (!edge(x0,
y0, x1, y1))
452 G_warning(
"Weird internal error: perimeter has odd number of points");
460 for (i = 1; i <
st->np; i += 2) {
461 if (
st->P[i].y !=
st->P[i - 1].y) {
462 G_warning(
"Weird internal error: edge leaves row");
471 while (
W + shift >
st->window.east)
475 for (i = 1; i <
st->np; i += 2) {
508 double shift, E,
W = 0L;
513 st->row_fill = row_solid_fill;
545 for (i = 0; i < n; i++) {
546 e1 = wrap_east(
e0,
x[i]);
555 if (!edge(x0,
y0, x1, y1))
566 while (E + shift >
st->window.east)
576 for (i = 0; i < n; i++) {
579 if (!edge(x0,
y0, x1, y1))
589 G_warning(
"Weird internal error: perimeter has odd number of points");
598 for (i = 1; i <
st->np; i += 2) {
599 if (
st->P[i].y !=
st->P[i - 1].y) {
600 G_warning(
"Weird internal error: edge leaves row");
614 while (
W + shift >
st->window.east)
618 for (i = 1; i <
st->np; i += 2) {
629static int edge(
double x0,
double y0,
double x1,
double y1)
668 m = (x0 - x1) / (
y0 - y1);
671 if (!edge_point(x,
ystart++))
679static int edge_point(
double x,
int y)
684 if (
st->np >=
st->npalloc) {
685 if (
st->npalloc > 0) {
699 st->P[
st->np++].y = y;
703static int edge_order(
const void *
aa,
const void *
bb)
705 const struct point *a =
aa, *
b =
bb;
720static void row_solid_fill(
int y,
double x1,
double x2)
732static void row_dotted_fill(
int y,
double x1,
double x2)
736 if (y != iceil(y /
st->dotted_fill_gap) *
st->dotted_fill_gap)
739 i1 = iceil(x1 /
st->dotted_fill_gap) *
st->dotted_fill_gap;
742 for (i =
i1; i <=
i2; i +=
st->dotted_fill_gap) {
749static int ifloor(
double x)
759static int iceil(
double x)
782 double east, north,
north1;
785 incr =
fabs(1.0 /
st->xconv);
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
double G_adjust_easting(double, const struct Cell_head *)
Returns east not smaller than west.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
int G_plot_area(double *const *xs, double *const *ys, int *rpnts, int rings)
Plot multiple polygons.
void G_plot_line2(double east1, double north1, double east2, double north2)
Plot line between latlon coordinates (slowline)
int G_plot_polygon(const double *x, const double *y, int n)
Plot filled polygon with n vertices.
void G_plot_where_en(int x, int y, double *east, double *north)
Converts x,y to east,north.
void G_plot_where_xy(double east, double north, int *x, int *y)
Converts east,north to x,y.
void G_setup_fill(int gap)
Set row_fill routine to row_solid_fill or row_dotted_fill.
void G_setup_plot(double t, double b, double l, double r, int(*Move)(int, int), int(*Cont)(int, int))
Initialize plotting routines.
void G_plot_fx(double(*f)(double), double east1, double east2)
Plot f(east1) to f(east2)
void G_plot_line(double east1, double north1, double east2, double north2)
Plot line between latlon coordinates (fastline)
void G_plot_point(double east, double north)
Plot point.
2D/3D raster map header (used also for region)