16 #include "../hidint.h"
17 #include "hid/common/draw_helpers.h"
19 #ifdef HAVE_LIBDMALLOC
26 #define MAXINT (((unsigned int)(~0))>>1)
32 typedef struct hid_gc_struct
38 extents_set_layer (const char *name
, int group
, int empty
)
41 if (idx
>= 0 && idx
< max_layer
)
43 idx
= PCB
->LayerGroups
.Entries
[idx
][0];
45 if (idx
>= 0 && idx
< max_layer
+ 2)
49 switch (SL_TYPE (idx
))
65 extents_make_gc (void)
67 hidGC rv
= malloc (sizeof (hid_gc_struct
));
68 memset (rv
, 0, sizeof (hid_gc_struct
));
73 extents_destroy_gc (hidGC gc
)
79 extents_use_mask (int use_it
)
84 extents_set_color (hidGC gc
, const char *name
)
89 extents_set_line_cap (hidGC gc
, EndCapStyle style
)
94 extents_set_line_width (hidGC gc
, int width
)
100 extents_set_draw_xor (hidGC gc
, int xor)
105 extents_set_draw_faded (hidGC gc
, int faded
)
110 extents_set_line_cap_angle (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
114 #define PEX(x,w) if (box.X1 > (x)-(w)) box.X1 = (x)-(w); \
115 if (box.X2 < (x)+(w)) box.X2 = (x)+(w)
116 #define PEY(y,w) if (box.Y1 > (y)-(w)) box.Y1 = (y)-(w); \
117 if (box.Y2 < (y)+(w)) box.Y2 = (y)+(w)
120 extents_draw_line (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
129 extents_draw_arc (hidGC gc
, int cx
, int cy
, int width
, int height
,
130 int start_angle
, int end_angle
)
132 /* Naive but good enough. */
133 PEX (cx
, width
+ gc
->width
);
134 PEY (cy
, height
+ gc
->width
);
138 extents_draw_rect (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
147 extents_fill_circle (hidGC gc
, int cx
, int cy
, int radius
)
154 extents_fill_polygon (hidGC gc
, int n_coords
, int *x
, int *y
)
157 for (i
= 0; i
< n_coords
; i
++)
165 extents_fill_rect (hidGC gc
, int x1
, int y1
, int x2
, int y2
)
173 static HID extents_hid
= {
176 "used to calculate extents",
184 0 /* extents_get_export_options */ ,
185 0 /* extents_do_export */ ,
186 0 /* extents_parse_arguments */ ,
188 0 /* extents_invalidate_wh */ ,
189 0 /* extents_invalidate_lr */ ,
190 0 /* extents_invalidate_all */ ,
196 extents_set_line_cap
,
197 extents_set_line_width
,
198 extents_set_draw_xor
,
199 extents_set_draw_faded
,
200 extents_set_line_cap_angle
,
205 extents_fill_polygon
,
206 common_fill_pcb_polygon
,
207 0 /* extents_thindraw_pcb_polygon */,
210 0 /* extents_calibrate */ ,
211 0 /* extents_shift_is_pressed */ ,
212 0 /* extents_control_is_pressed */ ,
213 0 /* extents_get_coords */ ,
214 0 /* extents_set_crosshair */ ,
215 0 /* extents_add_timer */ ,
216 0 /* extents_stop_timer */ ,
217 0 /* extents_watch_file */ ,
218 0 /* extents_unwatch_file */ ,
219 0 /* extents_add_block_hook */ ,
220 0 /* extents_stop_block_hook */ ,
222 0 /* extents_log */ ,
223 0 /* extents_logv */ ,
224 0 /* extents_confirm_dialog */ ,
225 0 /* extents_close_confirm_dialog */ ,
226 0 /* extents_report_dialog */ ,
227 0 /* extents_prompt_for */ ,
228 0 /* extents_attribute_dialog */ ,
229 0 /* extents_show_item */ ,
234 hid_get_extents (void *item
)
247 hid_expose_callback (&extents_hid
, ®ion
, item
);