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
4 The GNU plotutils package is free software. You may redistribute it
5 and/or modify it under the terms of the GNU General Public License as
6 published by the Free Software foundation; either version 2, or (at your
7 option) any later version.
8
9 The GNU plotutils package is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with the GNU plotutils package; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17 Boston, MA 02110-1301, USA. */
18
19 /* The internal point-drawing function, which point() is a wrapper around.
20 It draws a point at the current location. There is no standard
21 definition of `point', so any Plotter is free to implement this as it
22 sees fit. */
23
24 #include "sys-defines.h"
25 #include "extern.h"
26
27 /* size of a `point' as fraction of diagonal distance between scaling
28 points P1 and P2, i.e. as fraction of distance between opposite corners
29 of the viewport */
30 #define POINT_HPGL_SIZE 0.0001
31
32 void
_pl_h_paint_point(S___ (Plotter * _plotter))33 _pl_h_paint_point (S___(Plotter *_plotter))
34 {
35 int saved_join_type, saved_cap_type;
36
37 if (_plotter->drawstate->pen_type != 0)
38 /* have a pen to draw with */
39 {
40 /* Sync pen color. This may set the _plotter->hpgl_bad_pen flag (if
41 optimal pen is #0 [white] and we're not allowed to use pen #0 to
42 draw with). So we test _plotter->hpgl_bad_pen before drawing the
43 point (see below). */
44 _pl_h_set_pen_color (R___(_plotter) HPGL_OBJECT_PATH);
45
46 /* temporarily store line attributes */
47 saved_join_type = _plotter->drawstate->join_type;
48 saved_cap_type = _plotter->drawstate->cap_type;
49 _plotter->drawstate->join_type = PL_JOIN_ROUND;
50 _plotter->drawstate->cap_type = PL_CAP_ROUND;
51
52 /* sync line attributes and pen position */
53 _pl_h_set_attributes (S___(_plotter));
54 _pl_h_set_position (S___(_plotter));
55
56 /* we wish to set a pen width in terms of HP-GL coordinates, which
57 _pl_h_set_attributes can't do; so we do it specially */
58 if (_plotter->hpgl_version == 2)
59 {
60 if (_plotter->hpgl_pen_width != POINT_HPGL_SIZE)
61 {
62 sprintf (_plotter->data->page->point, "PW%.4f;",
63 100.0 * POINT_HPGL_SIZE);
64 _update_buffer (_plotter->data->page);
65 _plotter->hpgl_pen_width = POINT_HPGL_SIZE;
66 }
67 }
68
69 if (_plotter->hpgl_bad_pen == false)
70 /* no problems with nonexistent pen */
71 {
72 if (_plotter->hpgl_pendown == false)
73 /* N.B. if pen were down, point would be invisible */
74 {
75 strcpy (_plotter->data->page->point, "PD;");
76 _update_buffer (_plotter->data->page);
77 _plotter->hpgl_pendown = true;
78 }
79 strcpy (_plotter->data->page->point, "PU;");
80 _update_buffer (_plotter->data->page);
81 _plotter->hpgl_pendown = false;
82 }
83
84 /* restore line attributes */
85 _plotter->drawstate->join_type = saved_join_type;
86 _plotter->drawstate->cap_type = saved_cap_type;
87 }
88 }
89