h_point.c 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include "sys-defines.h"
  20. #include "extern.h"
  21. /* size of a `point' as fraction of diagonal distance between scaling
  22. points P1 and P2, i.e. as fraction of distance between opposite corners
  23. of the viewport */
  24. #define POINT_HPGL_SIZE 0.0001
  25. void
  26. _pl_h_paint_point (S___(Plotter *_plotter))
  27. {
  28. int saved_join_type, saved_cap_type;
  29. if (_plotter->drawstate->pen_type != 0)
  30. /* have a pen to draw with */
  31. {
  32. /* Sync pen color. This may set the _plotter->hpgl_bad_pen flag (if
  33. optimal pen is #0 [white] and we're not allowed to use pen #0 to
  34. draw with). So we test _plotter->hpgl_bad_pen before drawing the
  35. point (see below). */
  36. _pl_h_set_pen_color (R___(_plotter) HPGL_OBJECT_PATH);
  37. /* temporarily store line attributes */
  38. saved_join_type = _plotter->drawstate->join_type;
  39. saved_cap_type = _plotter->drawstate->cap_type;
  40. _plotter->drawstate->join_type = PL_JOIN_ROUND;
  41. _plotter->drawstate->cap_type = PL_CAP_ROUND;
  42. /* sync line attributes and pen position */
  43. _pl_h_set_attributes (S___(_plotter));
  44. _pl_h_set_position (S___(_plotter));
  45. /* we wish to set a pen width in terms of HP-GL coordinates, which
  46. _pl_h_set_attributes can't do; so we do it specially */
  47. if (_plotter->hpgl_version == 2)
  48. {
  49. if (_plotter->hpgl_pen_width != POINT_HPGL_SIZE)
  50. {
  51. sprintf (_plotter->data->page->point, "PW%.4f;",
  52. 100.0 * POINT_HPGL_SIZE);
  53. _update_buffer (_plotter->data->page);
  54. _plotter->hpgl_pen_width = POINT_HPGL_SIZE;
  55. }
  56. }
  57. if (_plotter->hpgl_bad_pen == false)
  58. /* no problems with nonexistent pen */
  59. {
  60. if (_plotter->hpgl_pendown == false)
  61. /* N.B. if pen were down, point would be invisible */
  62. {
  63. strcpy (_plotter->data->page->point, "PD;");
  64. _update_buffer (_plotter->data->page);
  65. _plotter->hpgl_pendown = true;
  66. }
  67. strcpy (_plotter->data->page->point, "PU;");
  68. _update_buffer (_plotter->data->page);
  69. _plotter->hpgl_pendown = false;
  70. }
  71. /* restore line attributes */
  72. _plotter->drawstate->join_type = saved_join_type;
  73. _plotter->drawstate->cap_type = saved_cap_type;
  74. }
  75. }