16 #include "../hidint.h"
17 #include "pcb-printf.h"
19 #include "hid/common/draw_helpers.h"
20 #include "hid/common/hidnogui.h"
21 #include "hid/common/actions.h"
22 #include "hid/common/hidinit.h"
24 #ifdef HAVE_LIBDMALLOC
28 /* This is a text-line "batch" HID, which exists for scripting and
31 typedef struct hid_gc_struct
33 int nothing_interesting_here
;
36 static HID_Attribute
*
37 batch_get_export_options (int *n_ret
)
42 /* ----------------------------------------------------------------------------- */
44 static char *prompt
= "pcb";
47 nop (int argc
, char **argv
, Coord x
, Coord y
)
53 PCBChanged (int argc
, char **argv
, Coord x
, Coord y
)
55 if (PCB
&& PCB
->Filename
)
57 prompt
= strrchr(PCB
->Filename
, '/');
61 prompt
= PCB
->Filename
;
69 help (int argc
, char **argv
, Coord x
, Coord y
)
76 info (int argc
, char **argv
, Coord x
, Coord y
)
80 if (!PCB
|| !PCB
->Data
|| !PCB
->Filename
)
82 printf("No PCB loaded.\n");
85 printf("Filename: %s\n", PCB
->Filename
);
86 pcb_printf("Size: %ml x %ml mils, %mm x %mm mm\n",
87 PCB
->MaxWidth
, PCB
->MaxHeight
,
88 PCB
->MaxWidth
, PCB
->MaxHeight
);
89 cg
= GetLayerGroupNumberByNumber (component_silk_layer
);
90 sg
= GetLayerGroupNumberByNumber (solder_silk_layer
);
91 for (i
=0; i
<MAX_LAYER
; i
++)
94 int lg
= GetLayerGroupNumberByNumber (i
);
95 for (j
=0; j
<MAX_LAYER
; j
++)
96 putchar(j
==lg
? '#' : '-');
97 printf(" %c %s\n", lg
==cg
? 'c' : lg
==sg
? 's' : '-',
98 PCB
->Data
->Layer
[i
].Name
);
104 HID_Action batch_action_list
[] = {
105 {"PCBChanged", 0, PCBChanged
},
106 {"RouteStylesChanged", 0, nop
},
107 {"NetlistChanged", 0, nop
},
108 {"LayersChanged", 0, nop
},
109 {"LibraryChanged", 0, nop
},
115 REGISTER_ACTIONS (batch_action_list
)
118 /* ----------------------------------------------------------------------------- */
121 batch_do_export (HID_Attr_Val
* options
)
133 printf("Entering %s version %s batch mode.\n", PACKAGE
, VERSION
);
134 printf("See http://pcb.geda-project.org for project information\n");
140 printf("%s> ", prompt
);
143 if (fgets(line
, sizeof(line
)-1, stdin
) == NULL
)
145 hid_parse_command (line
);
150 batch_parse_arguments (int *argc
, char ***argv
)
152 hid_parse_command_line (argc
, argv
);
156 batch_invalidate_lr (int l
, int r
, int t
, int b
)
161 batch_invalidate_all (void)
166 batch_set_layer (const char *name
, int idx
, int empty
)
178 batch_destroy_gc (hidGC gc
)
183 batch_use_mask (int use_it
)
188 batch_set_color (hidGC gc
, const char *name
)
193 batch_set_line_cap (hidGC gc
, EndCapStyle style
)
198 batch_set_line_width (hidGC gc
, Coord width
)
203 batch_set_draw_xor (hidGC gc
, int xor_set
)
208 batch_draw_line (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
213 batch_draw_arc (hidGC gc
, Coord cx
, Coord cy
, Coord width
, Coord height
,
214 Angle start_angle
, Angle end_angle
)
219 batch_draw_rect (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
224 batch_fill_circle (hidGC gc
, Coord cx
, Coord cy
, Coord radius
)
229 batch_fill_polygon (hidGC gc
, int n_coords
, Coord
*x
, Coord
*y
)
234 batch_fill_rect (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
239 batch_calibrate (double xval
, double yval
)
244 batch_shift_is_pressed (void)
250 batch_control_is_pressed (void)
256 batch_mod1_is_pressed (void)
262 batch_get_coords (const char *msg
, Coord
*x
, Coord
*y
)
267 batch_set_crosshair (int x
, int y
, int action
)
272 batch_add_timer (void (*func
) (hidval user_data
),
273 unsigned long milliseconds
, hidval user_data
)
281 batch_stop_timer (hidval timer
)
286 batch_watch_file (int fd
, unsigned int condition
, void (*func
) (hidval watch
, int fd
, unsigned int condition
, hidval user_data
),
295 batch_unwatch_file (hidval data
)
300 batch_add_block_hook (void (*func
) (hidval data
), hidval user_data
)
308 batch_stop_block_hook (hidval mlpoll
)
313 batch_attribute_dialog (HID_Attribute
* attrs_
,
314 int n_attrs_
, HID_Attr_Val
* results_
,
315 const char *title_
, const char *descr_
)
321 batch_show_item (void *item
)
327 static HID batch_hid
;
332 memset (&batch_hid
, 0, sizeof (HID
));
334 common_nogui_init (&batch_hid
);
335 common_draw_helpers_init (&batch_hid
);
337 batch_hid
.struct_size
= sizeof (HID
);
338 batch_hid
.name
= "batch";
339 batch_hid
.description
= "Batch-mode GUI for non-interactive use.";
342 batch_hid
.get_export_options
= batch_get_export_options
;
343 batch_hid
.do_export
= batch_do_export
;
344 batch_hid
.parse_arguments
= batch_parse_arguments
;
345 batch_hid
.invalidate_lr
= batch_invalidate_lr
;
346 batch_hid
.invalidate_all
= batch_invalidate_all
;
347 batch_hid
.set_layer
= batch_set_layer
;
348 batch_hid
.make_gc
= batch_make_gc
;
349 batch_hid
.destroy_gc
= batch_destroy_gc
;
350 batch_hid
.use_mask
= batch_use_mask
;
351 batch_hid
.set_color
= batch_set_color
;
352 batch_hid
.set_line_cap
= batch_set_line_cap
;
353 batch_hid
.set_line_width
= batch_set_line_width
;
354 batch_hid
.set_draw_xor
= batch_set_draw_xor
;
355 batch_hid
.draw_line
= batch_draw_line
;
356 batch_hid
.draw_arc
= batch_draw_arc
;
357 batch_hid
.draw_rect
= batch_draw_rect
;
358 batch_hid
.fill_circle
= batch_fill_circle
;
359 batch_hid
.fill_polygon
= batch_fill_polygon
;
360 batch_hid
.fill_rect
= batch_fill_rect
;
361 batch_hid
.calibrate
= batch_calibrate
;
362 batch_hid
.shift_is_pressed
= batch_shift_is_pressed
;
363 batch_hid
.control_is_pressed
= batch_control_is_pressed
;
364 batch_hid
.mod1_is_pressed
= batch_mod1_is_pressed
;
365 batch_hid
.get_coords
= batch_get_coords
;
366 batch_hid
.set_crosshair
= batch_set_crosshair
;
367 batch_hid
.add_timer
= batch_add_timer
;
368 batch_hid
.stop_timer
= batch_stop_timer
;
369 batch_hid
.watch_file
= batch_watch_file
;
370 batch_hid
.unwatch_file
= batch_unwatch_file
;
371 batch_hid
.add_block_hook
= batch_add_block_hook
;
372 batch_hid
.stop_block_hook
= batch_stop_block_hook
;
373 batch_hid
.attribute_dialog
= batch_attribute_dialog
;
374 batch_hid
.show_item
= batch_show_item
;
376 hid_register_hid (&batch_hid
);
377 #include "batch_lists.h"