GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rowcol.h
Go to the documentation of this file.
1 #ifndef _ROWCOL_H
2 #define _ROWCOL_H
3 
4 /* these defines work with modeling coordinates only */
5 
6 /* view resolutions */
7 #define VXRES(gs) (gs->x_mod * gs->xres)
8 #define VYRES(gs) (gs->y_mod * gs->yres)
9 
10 /* number of viewres rows/cols */
11 #define VROWS(gs) (int)((gs->rows -1)/gs->y_mod)
12 #define VCOLS(gs) (int)((gs->cols -1)/gs->x_mod)
13 
14 /* data row & col to offset */
15 #define DRC2OFF(gs, drow, dcol) (int)((dcol) + (drow) * gs->cols)
16 
17 /* ycoord/xcoord to data row/col */
18 #define Y2DROW(gs,py) (int)((gs->yrange - (py))/gs->yres)
19 #define X2DCOL(gs,px) (int)((px)/gs->xres)
20 
21 /* ycoord/xcoord to offset */
22 #define XY2OFF(gs, px, py) (int)DRC2OFF(gs, Y2DROW(gs,py), X2DCOL(gs,px))
23 
24 /* ycoord/xcoord to viewres row/col */
25 #define Y2VROW(gs,py) (int)((gs->yrange - (py))/(gs->yres * gs->y_mod))
26 #define X2VCOL(gs,px) (int)((px)/(gs->xres * gs->x_mod))
27 
28 /* viewres row/col to data row/col */
29 #define VROW2DROW(gs,vrow) (int)(gs->y_mod * (vrow))
30 #define VCOL2DCOL(gs,vcol) (int)(gs->x_mod * (vcol))
31 
32 /* data row/col to ycoord/xcoord */
33 #define DROW2Y(gs,drow) (gs->yrange - ((drow) * gs->yres))
34 #define DCOL2X(gs,dcol) ((dcol) * gs->xres)
35 
36 /* viewres row/col to ycoord/xcoord */
37 #define VROW2Y(gs,vrow) (gs->yrange - ((vrow) * gs->yres * gs->y_mod))
38 #define VCOL2X(gs,vcol) ((vcol) * gs->xres * gs->x_mod)
39 
40 #endif /* _ROWCOL_H */