17 #include "../hidint.h"
18 #include "pcb-printf.h"
20 #include "hid/common/draw_helpers.h"
21 #include "hid/common/hidnogui.h"
22 #include "hid/common/actions.h"
23 #include "hid/common/hidinit.h"
25 #ifdef HAVE_LIBDMALLOC
29 /* This is a text-line "batch" HID, which exists for scripting and
33 static HID_Attribute
*
34 batch_get_export_options (int *n_ret
)
39 /* ----------------------------------------------------------------------------- */
41 static char *prompt
= "pcb";
44 nop (int argc
, char **argv
, Coord x
, Coord y
)
50 PCBChanged (int argc
, char **argv
, Coord x
, Coord y
)
52 if (PCB
&& PCB
->Filename
)
54 prompt
= strrchr(PCB
->Filename
, '/');
58 prompt
= PCB
->Filename
;
66 help (int argc
, char **argv
, Coord x
, Coord y
)
73 info (int argc
, char **argv
, Coord x
, Coord y
)
76 int top_group
, bottom_group
;
77 if (!PCB
|| !PCB
->Data
|| !PCB
->Filename
)
79 printf("No PCB loaded.\n");
82 printf("Filename: %s\n", PCB
->Filename
);
83 pcb_printf("Size: %ml x %ml mils, %mm x %mm mm\n",
84 PCB
->MaxWidth
, PCB
->MaxHeight
,
85 PCB
->MaxWidth
, PCB
->MaxHeight
);
86 top_group
= GetLayerGroupNumberBySide (TOP_SIDE
);
87 bottom_group
= GetLayerGroupNumberBySide (BOTTOM_SIDE
);
88 for (i
=0; i
<MAX_LAYER
; i
++)
91 int lg
= GetLayerGroupNumberByNumber (i
);
92 for (j
= 0; j
< MAX_GROUP
; j
++)
93 putchar(j
==lg
? '#' : '-');
94 printf(" %c %s\n", lg
== top_group
? 'c' : lg
== bottom_group
? 's' : '-',
95 PCB
->Data
->Layer
[i
].Name
);
101 HID_Action batch_action_list
[] = {
102 {"PCBChanged", 0, PCBChanged
},
103 {"RouteStylesChanged", 0, nop
},
104 {"NetlistChanged", 0, nop
},
105 {"LayersChanged", 0, nop
},
106 {"LibraryChanged", 0, nop
},
112 REGISTER_ACTIONS (batch_action_list
)
115 /* ----------------------------------------------------------------------------- */
118 batch_do_export (HID_Attr_Val
* options
)
130 printf("Entering %s version %s batch mode.\n", PACKAGE
, VERSION
);
131 printf("See http://pcb.geda-project.org for project information\n");
137 printf("%s> ", prompt
);
140 if (fgets(line
, sizeof(line
)-1, stdin
) == NULL
)
142 hid_parse_command (line
);
147 batch_parse_arguments (int *argc
, char ***argv
)
149 hid_parse_command_line (argc
, argv
);
153 batch_invalidate_lr (int l
, int r
, int t
, int b
)
158 batch_invalidate_all (void)
163 batch_set_layer (const char *name
, int idx
, int empty
)
175 batch_destroy_gc (hidGC gc
)
180 batch_use_mask (enum mask_mode mode
)
185 batch_set_color (hidGC gc
, const char *name
)
190 batch_set_line_cap (hidGC gc
, EndCapStyle style
)
195 batch_set_line_width (hidGC gc
, Coord width
)
200 batch_set_draw_xor (hidGC gc
, int xor_set
)
205 batch_draw_line (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
210 batch_draw_arc (hidGC gc
, Coord cx
, Coord cy
, Coord width
, Coord height
,
211 Angle start_angle
, Angle end_angle
)
216 batch_draw_rect (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
221 batch_fill_circle (hidGC gc
, Coord cx
, Coord cy
, Coord radius
)
226 batch_fill_polygon (hidGC gc
, int n_coords
, Coord
*x
, Coord
*y
)
231 batch_fill_rect (hidGC gc
, Coord x1
, Coord y1
, Coord x2
, Coord y2
)
236 batch_calibrate (double xval
, double yval
)
241 batch_shift_is_pressed (void)
247 batch_control_is_pressed (void)
253 batch_mod1_is_pressed (void)
259 batch_get_coords (const char *msg
, Coord
*x
, Coord
*y
)
264 batch_set_crosshair (int x
, int y
, int action
)
269 batch_add_timer (void (*func
) (hidval user_data
),
270 unsigned long milliseconds
, hidval user_data
)
278 batch_stop_timer (hidval timer
)
283 batch_watch_file (int fd
, unsigned int condition
, void (*func
) (hidval watch
, int fd
, unsigned int condition
, hidval user_data
),
292 batch_unwatch_file (hidval data
)
297 batch_add_block_hook (void (*func
) (hidval data
), hidval user_data
)
305 batch_stop_block_hook (hidval mlpoll
)
310 batch_attribute_dialog (HID_Attribute
* attrs_
,
311 int n_attrs_
, HID_Attr_Val
* results_
,
312 const char *title_
, const char *descr_
)
318 batch_show_item (void *item
)
324 static HID batch_hid
;
325 static HID_DRAW batch_graphics
;
326 static HID_DRAW_CLASS batch_graphics_class
;
331 memset (&batch_hid
, 0, sizeof (HID
));
332 memset (&batch_graphics
, 0, sizeof (HID_DRAW
));
333 memset (&batch_graphics_class
, 0, sizeof (HID_DRAW_CLASS
));
335 common_nogui_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
.calibrate
= batch_calibrate
;
348 batch_hid
.shift_is_pressed
= batch_shift_is_pressed
;
349 batch_hid
.control_is_pressed
= batch_control_is_pressed
;
350 batch_hid
.mod1_is_pressed
= batch_mod1_is_pressed
;
351 batch_hid
.get_coords
= batch_get_coords
;
352 batch_hid
.set_crosshair
= batch_set_crosshair
;
353 batch_hid
.add_timer
= batch_add_timer
;
354 batch_hid
.stop_timer
= batch_stop_timer
;
355 batch_hid
.watch_file
= batch_watch_file
;
356 batch_hid
.unwatch_file
= batch_unwatch_file
;
357 batch_hid
.add_block_hook
= batch_add_block_hook
;
358 batch_hid
.stop_block_hook
= batch_stop_block_hook
;
359 batch_hid
.attribute_dialog
= batch_attribute_dialog
;
360 batch_hid
.show_item
= batch_show_item
;
362 common_nogui_graphics_class_init (&batch_graphics_class
);
363 common_draw_helpers_class_init (&batch_graphics_class
);
365 batch_graphics_class
.set_layer
= batch_set_layer
;
366 batch_graphics_class
.make_gc
= batch_make_gc
;
367 batch_graphics_class
.destroy_gc
= batch_destroy_gc
;
368 batch_graphics_class
.use_mask
= batch_use_mask
;
369 batch_graphics_class
.set_color
= batch_set_color
;
370 batch_graphics_class
.set_line_cap
= batch_set_line_cap
;
371 batch_graphics_class
.set_line_width
= batch_set_line_width
;
372 batch_graphics_class
.set_draw_xor
= batch_set_draw_xor
;
373 batch_graphics_class
.draw_line
= batch_draw_line
;
374 batch_graphics_class
.draw_arc
= batch_draw_arc
;
375 batch_graphics_class
.draw_rect
= batch_draw_rect
;
376 batch_graphics_class
.fill_circle
= batch_fill_circle
;
377 batch_graphics_class
.fill_polygon
= batch_fill_polygon
;
378 batch_graphics_class
.fill_rect
= batch_fill_rect
;
380 batch_graphics
.klass
= &batch_graphics_class
;
381 common_nogui_graphics_init (&batch_graphics
);
382 common_draw_helpers_init (&batch_graphics
);
384 hid_register_hid (&batch_hid
);
385 #include "batch_lists.h"