1 /*!
2  * \file src/hid_draw.h
3  *
4  * \brief Human Interface Device - Drawing.
5  * <hr>
6  *
7  * <h1><b>Copyright.</b></h1>\n
8  *
9  * PCB, interactive printed circuit board design
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * Contact addresses for paper mail and Email:
26  * harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA
27  * haceaton@aplcomm.jhuapl.edu
28  */
29 
30 
31 /*!
32  * \brief Mask modes.
33  */
34 enum mask_mode
35 {
36   HID_MASK_OFF    = 0, /*!< Flush the buffer and return to non-mask operation. */
37   HID_MASK_BEFORE = 1, /*!< Polygons being drawn before clears.                */
38   HID_MASK_CLEAR  = 2, /*!< Clearances being drawn.                            */
39   HID_MASK_AFTER  = 3, /*!< Polygons being drawn after clears.                 */
40 };
41 
42 
43 /*!
44  * \brief Low level drawing API Drawing Functions.
45  *
46  * Coordinates and distances are ALWAYS in PCB's default coordinates
47  * (1 nm at the time this comment was written).
48  *
49  * Angles are always in degrees, with 0 being "right" (positive X) and
50  * 90 being "up" (positive Y).
51  */
52 struct hid_draw_st
53 {
54   hidGC (*make_gc) (void); /*!< Make an empty graphics context.  */
55   void (*destroy_gc) (hidGC gc);
56   void (*use_mask) (enum mask_mode mode);
57 
58   void (*set_color) (hidGC gc, const char *name);
59     /*!< Set a color.  Names can be like "red" or "#rrggbb" or special
60      * names like "erase".
61      * *Always* use the "erase" color for removing ink (like polygon
62      * reliefs or thermals), as you cannot rely on knowing the background
63      * color or special needs of the HID.
64      * Always use the "drill" color to draw holes.
65      * You may assume this is cheap enough to call inside the redraw
66      * callback, but not cheap enough to call for each item drawn.
67      */
68 
69   void (*set_line_cap) (hidGC gc, EndCapStyle style);
70     /*!< Set the line style.  While calling this is cheap, calling it with
71      * different values each time may be expensive, so grouping items by
72      * line style is helpful.
73      */
74   void (*set_line_width) (hidGC gc, Coord width);
75   void (*set_draw_xor) (hidGC gc, int xor_);
76 
77   void (*set_draw_faded) (hidGC gc, int faded);
78     /*!< Blends 20% or so color with 80% background.
79      * Only used for assembly drawings so far.
80      */
81 
82   /* The usual drawing functions.  "draw" means to use segments of the
83      given width, whereas "fill" means to fill to a zero-width
84      outline.  */
85   void (*draw_line)    (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2);
86   void (*draw_arc)     (hidGC gc, Coord cx, Coord cy, Coord xradius, Coord yradius, Angle start_angle, Angle delta_angle);
87   void (*draw_rect)    (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2);
88   void (*fill_circle)  (hidGC gc, Coord cx, Coord cy, Coord radius);
89   void (*fill_polygon) (hidGC gc, int n_coords, Coord *x, Coord *y);
90   void (*fill_rect)    (hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2);
91 
92   /* draw the grid in the specified region */
93   void (*draw_grid)    (BoxType * box);
94 
95   /* The following APIs render using PCB data-structures, not immediate parameters */
96 
97   void (*draw_pcb_line) (hidGC gc, LineType *line);
98   void (*draw_pcb_arc) (hidGC gc, ArcType *arc);
99   void (*draw_pcb_text) (hidGC gc, TextType *, Coord);
100   void (*draw_pcb_polygon) (hidGC gc, PolygonType *poly, const BoxType *clip_box);
101 
102   void (*fill_pcb_polygon) (hidGC gc, PolygonType *poly, const BoxType *clip_box);
103   void (*thindraw_pcb_polygon) (hidGC gc, PolygonType *poly, const BoxType *clip_box);
104   void (*fill_pcb_pad) (hidGC gc, PadType *pad, bool clip, bool mask);
105   void (*thindraw_pcb_pad) (hidGC gc, PadType *pad, bool clip, bool mask);
106   void (*fill_pcb_pv) (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask);
107   void (*thindraw_pcb_pv) (hidGC fg_gc, hidGC bg_gc, PinType *pv, bool drawHole, bool mask);
108 
109 };
110