14 #include "../hidint.h"
15 #include "hid/common/draw_helpers.h"
17 #ifdef HAVE_LIBDMALLOC
22 #define MAXINT (((unsigned int)(~0))>>1)
27 typedef struct hid_gc_struct
33 extents_set_layer (const char *name
, int group
, int empty
)
36 if (idx
>= 0 && idx
< max_group
)
38 idx
= PCB
->LayerGroups
.Entries
[idx
][0];
40 if (idx
>= 0 && idx
< max_copper_layer
+ 2)
44 switch (SL_TYPE (idx
))
60 extents_make_gc (void)
62 hidGC rv
= (hidGC
)malloc (sizeof (hid_gc_struct
));
63 memset (rv
, 0, sizeof (hid_gc_struct
));
68 extents_destroy_gc (hidGC gc
)
74 extents_use_mask (enum mask_mode mode
)
79 extents_set_color (hidGC gc
, const char *name
)
84 extents_set_line_cap (hidGC gc
, EndCapStyle style
)
89 extents_set_line_width (hidGC gc
, Coord width
)
95 extents_set_draw_xor (hidGC gc
, int xor_
)
99 #define PEX(x,w) if (box.X1 > (x)-(w)) box.X1 = (x)-(w); \
100 if (box.X2 < (x)+(w)) box.X2 = (x)+(w)
101 #define PEY(y,w) if (box.Y1 > (y)-(w)) box.Y1 = (y)-(w); \
102 if (box.Y2 < (y)+(w)) box.Y2 = (y)+(w)
105 extents_draw_line (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
114 extents_draw_arc (hidGC gc
, Coord cx
, Coord cy
, Coord width
, Coord height
,
115 Angle start_angle
, Angle end_angle
)
117 /* Naive but good enough. */
118 PEX (cx
, width
+ gc
->width
);
119 PEY (cy
, height
+ gc
->width
);
123 extents_draw_rect (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
132 extents_fill_circle (hidGC gc
, Coord cx
, Coord cy
, Coord radius
)
139 extents_fill_polygon (hidGC gc
, int n_coords
, Coord
*x
, Coord
*y
)
142 for (i
= 0; i
< n_coords
; i
++)
150 extents_fill_rect (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
158 static HID extents_hid
;
161 hid_extents_init (void)
163 static bool initialised
= false;
168 memset (&extents_hid
, 0, sizeof (HID
));
170 common_draw_helpers_init (&extents_hid
);
172 extents_hid
.struct_size
= sizeof (HID
);
173 extents_hid
.name
= "extents-extents";
174 extents_hid
.description
= "used to calculate extents";
175 extents_hid
.poly_before
= 1;
177 extents_hid
.set_layer
= extents_set_layer
;
178 extents_hid
.make_gc
= extents_make_gc
;
179 extents_hid
.destroy_gc
= extents_destroy_gc
;
180 extents_hid
.use_mask
= extents_use_mask
;
181 extents_hid
.set_color
= extents_set_color
;
182 extents_hid
.set_line_cap
= extents_set_line_cap
;
183 extents_hid
.set_line_width
= extents_set_line_width
;
184 extents_hid
.set_draw_xor
= extents_set_draw_xor
;
185 extents_hid
.draw_line
= extents_draw_line
;
186 extents_hid
.draw_arc
= extents_draw_arc
;
187 extents_hid
.draw_rect
= extents_draw_rect
;
188 extents_hid
.fill_circle
= extents_fill_circle
;
189 extents_hid
.fill_polygon
= extents_fill_polygon
;
190 extents_hid
.fill_rect
= extents_fill_rect
;
196 hid_get_extents (void *item
)
200 /* As this isn't a real "HID", we need to ensure we are initialised. */
212 hid_expose_callback (&extents_hid
, ®ion
, item
);