h_closepl.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /* This version is for both HPGLPlotters and PCLPlotters.
  16. For HPGL Plotter objects, we output all plotted objects, which we have
  17. saved in a resizable outbuf structure for the current page. An HP-GL or
  18. HP-GL/2 prologue and epilogue are included. We then flush the output
  19. stream, and reset all datastructures. */
  20. #include "sys-defines.h"
  21. #include "extern.h"
  22. bool
  23. _pl_h_end_page (S___(Plotter *_plotter))
  24. {
  25. /* output HP-GL epilogue to page buffer */
  26. if (_plotter->hpgl_pendown == true)
  27. /* lift pen */
  28. {
  29. sprintf (_plotter->data->page->point, "PU;");
  30. _update_buffer (_plotter->data->page);
  31. }
  32. /* move to lower left hand corner */
  33. sprintf (_plotter->data->page->point, "PA0,0;");
  34. _update_buffer (_plotter->data->page);
  35. /* select pen zero, i.e. return pen to carousel */
  36. if (_plotter->hpgl_pen != 0)
  37. {
  38. sprintf (_plotter->data->page->point, "SP0;");
  39. _update_buffer (_plotter->data->page);
  40. }
  41. if (_plotter->hpgl_version >= 1)
  42. /* have a `page advance' command, so use it */
  43. {
  44. sprintf (_plotter->data->page->point, "PG0;");
  45. _update_buffer (_plotter->data->page);
  46. }
  47. /* add newline at end */
  48. sprintf (_plotter->data->page->point, "\n");
  49. _update_buffer (_plotter->data->page);
  50. /* if a PCL Plotter, switch back from HP-GL/2 mode to PCL mode */
  51. _maybe_switch_from_hpgl (S___(_plotter));
  52. /* set this, so that no drawing on the next page will take place without
  53. a pen advance */
  54. _plotter->hpgl_position_is_unknown = true;
  55. _plotter->hpgl_pendown = false; /* be on the safe side */
  56. return true;
  57. }
  58. void
  59. _pl_h_maybe_switch_from_hpgl (S___(Plotter *_plotter))
  60. {
  61. }
  62. void
  63. _pl_q_maybe_switch_from_hpgl (S___(Plotter *_plotter))
  64. {
  65. /* switch back from HP-GL/2 to PCL 5 mode */
  66. strcpy (_plotter->data->page->point, "\033%0A");
  67. _update_buffer (_plotter->data->page);
  68. }