t_point.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* The internal point-drawing function, which point() is a wrapper around.
  16. It draws a point at the current location. There is no standard
  17. definition of `point', so any Plotter is free to implement this as it
  18. sees fit. */
  19. /* TekPlotter objects display a point as a zero-length line segment. */
  20. #include "sys-defines.h"
  21. #include "extern.h"
  22. void
  23. _pl_t_paint_point (S___(Plotter *_plotter))
  24. {
  25. double xx, yy;
  26. int ixx, iyy;
  27. if (_plotter->drawstate->pen_type != 0)
  28. /* have a pen to draw with */
  29. {
  30. /* convert point to floating-point device coordinates */
  31. xx = XD(_plotter->drawstate->pos.x, _plotter->drawstate->pos.y);
  32. yy = YD(_plotter->drawstate->pos.x, _plotter->drawstate->pos.y);
  33. /* do nothing if point is outside device clipping rectangle */
  34. if ((xx < TEK_DEVICE_X_MIN_CLIP)
  35. || (xx > TEK_DEVICE_X_MAX_CLIP)
  36. || (yy < TEK_DEVICE_Y_MIN_CLIP)
  37. || (yy > TEK_DEVICE_Y_MAX_CLIP))
  38. return;
  39. /* round to integer device (Tektronix) coordinates */
  40. ixx = IROUND(xx);
  41. iyy = IROUND(yy);
  42. /* emit an escape sequence if necessary, to switch to POINT mode */
  43. _pl_t_tek_mode (R___(_plotter) TEK_MODE_POINT);
  44. /* sync Tek's color too (significant only for kermit Tek emulator) */
  45. _pl_t_set_pen_color (S___(_plotter));
  46. /* Output the point. If in fact we were already in POINT mode, this
  47. is slightly suboptimal because we can't call
  48. _pl_t_tek_vector_compressed() to save (potentially) a few bytes,
  49. because we don't know what the last-plotted point was. Unlike
  50. when incrementally drawing a polyline, when plotting points we
  51. don't keep track of "where we last were". */
  52. _pl_t_tek_vector (R___(_plotter) ixx, iyy);
  53. /* update our notion of Tek's notion of position */
  54. _plotter->tek_pos.x = ixx;
  55. _plotter->tek_pos.y = iyy;
  56. }
  57. }