rowcol.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _ROWCOL_H
  2. #define _ROWCOL_H
  3. /* these defines work with modeling coordinates only */
  4. /* view resolutions */
  5. #define VXRES(gs) (gs->x_mod * gs->xres)
  6. #define VYRES(gs) (gs->y_mod * gs->yres)
  7. /* number of viewres rows/cols */
  8. #define VROWS(gs) (int)((gs->rows -1)/gs->y_mod)
  9. #define VCOLS(gs) (int)((gs->cols -1)/gs->x_mod)
  10. /* data row & col to offset */
  11. #define DRC2OFF(gs, drow, dcol) (int)((dcol) + (drow) * gs->cols)
  12. /* ycoord/xcoord to data row/col */
  13. #define Y2DROW(gs,py) (int)((gs->yrange - (py))/gs->yres)
  14. #define X2DCOL(gs,px) (int)((px)/gs->xres)
  15. /* ycoord/xcoord to offset */
  16. #define XY2OFF(gs, px, py) (int)DRC2OFF(gs, Y2DROW(gs,py), X2DCOL(gs,px))
  17. /* ycoord/xcoord to viewres row/col */
  18. #define Y2VROW(gs,py) (int)((gs->yrange - (py))/(gs->yres * gs->y_mod))
  19. #define X2VCOL(gs,px) (int)((px)/(gs->xres * gs->x_mod))
  20. /* viewres row/col to data row/col */
  21. #define VROW2DROW(gs,vrow) (int)(gs->y_mod * (vrow))
  22. #define VCOL2DCOL(gs,vcol) (int)(gs->x_mod * (vcol))
  23. /* data row/col to ycoord/xcoord */
  24. #define DROW2Y(gs,drow) (gs->yrange - ((drow) * gs->yres))
  25. #define DCOL2X(gs,dcol) ((dcol) * gs->xres)
  26. /* viewres row/col to ycoord/xcoord */
  27. #define VROW2Y(gs,vrow) (gs->yrange - ((vrow) * gs->yres * gs->y_mod))
  28. #define VCOL2X(gs,vcol) ((vcol) * gs->xres * gs->x_mod)
  29. #endif /* _ROWCOL_H */