47 #include <sys/types.h>
62 #define DPRINTF(...) do { if (DEBUG) printf(__VA_ARGS__); } while (0)
65 #define DRILL_READ_DOUBLE_SIZE 32
68 DRILL_NONE, DRILL_HEADER, DRILL_DATA
69 } drill_file_section_t;
72 DRILL_MODE_ABSOLUTE, DRILL_MODE_INCREMENTAL
73 } drill_coordinate_mode_t;
83 typedef struct drill_pattern_entry {
90 } drill_pattern_entry_t;
92 typedef struct drill_state {
96 drill_file_section_t curr_section;
97 drill_coordinate_mode_t coordinate_mode;
107 number_fmt_t number_format, header_number_format;
109 number_fmt_t backup_number_format;
128 drill_g_code_t route_mode;
137 gboolean found_arc_radius;
141 GArray *pattern_buffer;
151 static drill_g_code_t drill_parse_G_code(gerb_file_t *fd,
153 static drill_m_code_t drill_parse_M_code(gerb_file_t *fd, drill_state_t *state,
155 static int drill_parse_T_code(gerb_file_t *fd, drill_state_t *state,
157 static int drill_parse_header_is_metric(gerb_file_t *fd, drill_state_t *state,
159 static int drill_parse_header_is_metric_comment(gerb_file_t *fd, drill_state_t *state,
161 static int drill_parse_header_is_inch(gerb_file_t *fd, drill_state_t *state,
163 static int drill_parse_header_is_ici(gerb_file_t *fd, drill_state_t *state,
165 static void drill_parse_coordinate(gerb_file_t *fd,
char firstchar,
167 unsigned int file_line);
168 static drill_state_t *new_state(drill_state_t *state);
170 drill_state_t *state,
173 double prev_x,
double prev_y);
175 drill_state_t *state,
178 double prev_x,
double prev_y);
179 static double read_double(gerb_file_t *fd, number_fmt_t fmt,
181 static void eat_line(gerb_file_t *fd);
182 static void eat_whitespace(gerb_file_t *fd);
183 static char *get_line(gerb_file_t *fd);
184 static int file_check_str(gerb_file_t *fd,
const char *str);
197 static const char *suppression_list[] = {
204 static const char *units_list[] = {
220 static gerbv_HID_Attribute drill_attribute_list[] = {
222 {N_(
"autodetect"), N_(
"Try to autodetect the file format"),
223 HID_Boolean, 0, 0, {1, 0, 0}, 0, 0, 0},
225 {N_(
"zero_suppression"), N_(
"Zero suppression"),
226 HID_Enum, 0, 0, {0, 0, 0}, suppression_list, 0, 0},
228 {N_(
"units"), N_(
"Length units"),
229 HID_Enum, 0, 0, {0, 0, 0}, units_list, 0, 0},
231 {N_(
"digits"), N_(
"Number of digits. For trailing zero suppression,"
232 " this is the number of digits before the decimal point. "
233 "Otherwise this is the number of digits after the decimal point."),
234 HID_Integer, 0, 20, {5, 0, 0}, 0, 0, 0},
237 {
"tool_units",
"Tool size units",
238 HID_Enum, 0, 0, {0, 0, 0}, units_list, 0, 0},
243 drill_attribute_merge (gerbv_HID_Attribute *dest,
int ndest, gerbv_HID_Attribute *src,
int nsrc)
252 for (i = 0 ; i < nsrc ; i++) {
255 while (j < ndest && strcmp (src[i].name, dest[j].name) != 0)
259 if (j < ndest && src[i].type == dest[j].type) {
260 dest[j].default_val = src[i].default_val;
262 GERB_MESSAGE(
"Ignoring \"%s\" attribute for drill file", src[i].name);
271 info->min_x = MIN(info->min_x, bbox->
left);
272 info->min_y = MIN(info->min_y, bbox->
bottom);
273 info->max_x = MAX(info->max_x, bbox->
right);
274 info->max_y = MAX(info->max_y, bbox->
top);
281 drill_add_drill_hole (
gerbv_image_t *image, drill_state_t *state,
288 drill_stats_increment_drill_counter(image->
drill_stats->drill_list,
289 state->current_tool);
292 if (curr_net->
next == NULL) {
293 GERB_FATAL_ERROR(
"malloc curr_net->next failed in %s()",
297 curr_net = curr_net->
next;
300 curr_net->
start_x = state->curr_x;
301 curr_net->
start_y = state->curr_y;
314 curr_net->
aperture = state->current_tool;
319 if(image->
aperture[state->current_tool] == NULL) {
324 r = image->
aperture[state->current_tool]->parameter[0] / 2;
332 drill_update_image_info_min_max_from_bbox(image->
info, bbox);
343 drill_add_route_segment(
gerbv_image_t *image, drill_state_t *state,
345 double prev_x,
double prev_y)
349 double start_x, start_y, stop_x, stop_y;
352 if (curr_net->
next == NULL) {
353 GERB_FATAL_ERROR(
"malloc curr_net->next failed in %s()",
357 curr_net = curr_net->
next;
363 stop_x = state->curr_x;
364 stop_y = state->curr_y;
377 curr_net->
stop_x = stop_x;
378 curr_net->
stop_y = stop_y;
379 curr_net->
aperture = state->current_tool;
385 if (image->
aperture[state->current_tool] == NULL) {
390 r = image->
aperture[state->current_tool]->parameter[0] / 2;
393 bbox->
left = MIN(start_x, stop_x) - r;
394 bbox->
right = MAX(start_x, stop_x) + r;
395 bbox->
bottom = MIN(start_y, stop_y) - r;
396 bbox->
top = MAX(start_y, stop_y) + r;
398 drill_update_image_info_min_max_from_bbox(image->
info, bbox);
407 drill_add_arc_segment(
gerbv_image_t *image, drill_state_t *state,
409 double prev_x,
double prev_y)
413 double start_x, start_y, stop_x, stop_y;
414 double delta_cp_x, delta_cp_y;
418 if (curr_net->
next == NULL)
419 GERB_FATAL_ERROR(
"malloc curr_net->next failed in %s()",
422 curr_net = curr_net->
next;
428 stop_x = state->curr_x;
429 stop_y = state->curr_y;
430 delta_cp_x = state->delta_cp_x;
431 delta_cp_y = state->delta_cp_y;
444 cw = (state->route_mode == DRILL_G_CWMOVE);
446 if (state->found_arc_radius) {
450 double radius = state->arc_radius;
451 double dx, dy, d, h, mx, my, px, py, sign, cp_x, cp_y;
456 dx = stop_x - start_x;
457 dy = stop_y - start_y;
460 if (d < DBL_EPSILON) {
464 delta_cp_y = fabs(radius);
465 }
else if (d > 2.0 * fabs(radius)) {
470 _(
"Arc radius %.4f too small for chord %.4f; "
471 "clamping to semicircle"),
473 delta_cp_x = dx / 2.0;
474 delta_cp_y = dy / 2.0;
476 h = sqrt(radius * radius - (d / 2.0) * (d / 2.0));
477 mx = (start_x + stop_x) / 2.0;
478 my = (start_y + stop_y) / 2.0;
486 sign = cw ? -1.0 : 1.0;
488 cp_x = mx + sign * h * px;
489 cp_y = my + sign * h * py;
491 delta_cp_x = cp_x - start_x;
492 delta_cp_y = cp_y - start_y;
495 state->found_arc_radius = FALSE;
500 curr_net->
stop_x = stop_x;
501 curr_net->
stop_y = stop_y;
502 curr_net->
aperture = state->current_tool;
508 curr_net->
cirseg = g_new0(gerbv_cirseg_t, 1);
509 if (curr_net->
cirseg == NULL)
510 GERB_FATAL_ERROR(
"malloc cirseg failed in %s()", __FUNCTION__);
512 calc_cirseg_mq(curr_net, cw, delta_cp_x, delta_cp_y);
515 if (image->
aperture[state->current_tool] == NULL)
520 r = image->
aperture[state->current_tool]->parameter[0] / 2;
523 double ang1, ang2, step_pi_2, x, y;
525 ang1 = DEG2RAD(MIN(curr_net->
cirseg->angle1,
526 curr_net->
cirseg->angle2));
527 ang2 = DEG2RAD(MAX(curr_net->
cirseg->angle1,
528 curr_net->
cirseg->angle2));
531 x = curr_net->
cirseg->cp_x +
532 curr_net->
cirseg->width * cos(ang1) / 2;
533 y = curr_net->
cirseg->cp_y +
534 curr_net->
cirseg->width * sin(ang1) / 2;
541 for (step_pi_2 = (floor(ang1 / M_PI_2) + 1) * M_PI_2;
542 step_pi_2 < MIN(ang2, ang1 + 2 * M_PI);
543 step_pi_2 += M_PI_2) {
544 x = curr_net->
cirseg->cp_x +
545 curr_net->
cirseg->width * cos(step_pi_2) / 2;
546 y = curr_net->
cirseg->cp_y +
547 curr_net->
cirseg->width * sin(step_pi_2) / 2;
548 bbox->
left = MIN(bbox->
left, x - r);
551 bbox->
top = MAX(bbox->
top, y + r);
555 x = curr_net->
cirseg->cp_x +
556 curr_net->
cirseg->width * cos(ang2) / 2;
557 y = curr_net->
cirseg->cp_y +
558 curr_net->
cirseg->width * sin(ang2) / 2;
559 bbox->
left = MIN(bbox->
left, x - r);
562 bbox->
top = MAX(bbox->
top, y + r);
565 drill_update_image_info_min_max_from_bbox(image->
info, bbox);
572 parse_drillfile(gerb_file_t *fd, gerbv_HID_Attribute *attr_list,
int n_attr,
int reload)
574 drill_state_t *state = NULL;
577 gerbv_HID_Attribute *hid_attrs;
579 gboolean parsing_done = FALSE;
582 unsigned int file_line = 1;
589 setlocale(LC_NUMERIC,
"C" );
592 DPRINTF(
"In parse_drillfile, about to create image for this layer\n");
596 GERB_FATAL_ERROR(
"malloc image failed in %s()", __FUNCTION__);
599 if (reload && attr_list != NULL) {
603 image->
info->n_attr = n_attr;
604 image->
info->attr_list = gerbv_attribute_dup(attr_list, n_attr);
611 image->
info->n_attr =
sizeof (drill_attribute_list) /
sizeof (drill_attribute_list[0]);
612 image->
info->attr_list = gerbv_attribute_dup (drill_attribute_list, image->
info->n_attr);
615 drill_attribute_merge (image->
info->attr_list, image->
info->n_attr,
625 GERB_FATAL_ERROR(
"malloc stats failed in %s()", __FUNCTION__);
630 state = new_state(state);
632 GERB_FATAL_ERROR(
"malloc state failed in %s()", __FUNCTION__);
636 if (image->
format == NULL) {
637 GERB_FATAL_ERROR(
"malloc format failed in %s()", __FUNCTION__);
642 hid_attrs = image->
info->attr_list;
644 if (!hid_attrs[HA_auto].default_val.int_value) {
646 state->number_format = FMT_USER;
647 state->decimals = hid_attrs[HA_digits].default_val.int_value;
649 if (
GERBV_UNIT_MM == hid_attrs[HA_xy_units].default_val.int_value) {
653 switch (hid_attrs[HA_suppression].default_val.int_value) {
668 DPRINTF(
"%s(): Starting parsing of drill file \"%s\"\n",
669 __FUNCTION__, fd->filename);
671 while (!parsing_done && (read = gerb_fgetc(fd)) != EOF) {
673 switch ((
char) read) {
677 if (drill_parse_header_is_metric_comment(fd, state, image, file_line)) {
682 _(
"Comment \"%s\" at line %u in file \"%s\""),
683 tmps, file_line, fd->filename);
684 DPRINTF(
" Comment with ';' \"%s\" at line %u\n",
695 if (strcmp(tmps,
"ATC,ON") == 0 ||
696 strcmp(tmps,
"ATC,OFF") == 0) {
698 _(
"Ignoring ATC command \"%s\" "
699 "at line %u in file \"%s\""),
700 tmps, file_line, fd->filename);
703 _(
"Undefined code \"%s\" "
704 "at line %u in file \"%s\""),
705 tmps, file_line, fd->filename);
712 tmps = get_line (fd);
713 if (strcmp (tmps,
"DETECT,ON") == 0 ||
714 strcmp (tmps,
"DETECT,OFF") == 0) {
717 if (strcmp (tmps,
"DETECT,ON") == 0) {
725 tmps2 = g_strdup_printf (
"%s\n%s", stats->detect, tmps3);
726 g_free (stats->detect);
728 tmps2 = g_strdup_printf (
"%s", tmps3);
730 stats->detect = tmps2;
733 _(
"Unrecognised string \"%s\" in header "
734 "at line %u in file \"%s\""),
735 tmps, file_line, fd->filename);
742 tmps = get_line (fd);
745 if (0 == strcmp (tmps,
"FMAT,2")) {
750 if (0 == strcmp (tmps,
"FMAT,1")) {
751 gerbv_stats_printf(stats->error_list,
753 _(
"File in unsupported format 1 "
754 "at line %u in file \"%s\""),
755 file_line, fd->filename);
763 gerbv_stats_printf(stats->error_list,
765 _(
"Unrecognised string \"%s\" in header "
766 "at line %u in file \"%s\""),
767 tmps, file_line, fd->filename);
774 drill_g_code_t g_code;
776 switch (g_code = drill_parse_G_code(fd, image, file_line)) {
780 state->route_mode = DRILL_G_DRILL;
781 state->tool_down = FALSE;
785 state->route_mode = DRILL_G_ROUT;
787 case DRILL_G_LINEARMOVE :
788 state->route_mode = DRILL_G_LINEARMOVE;
790 case DRILL_G_CWMOVE :
791 state->route_mode = DRILL_G_CWMOVE;
793 case DRILL_G_CCWMOVE :
794 state->route_mode = DRILL_G_CCWMOVE;
797 case DRILL_G_SLOT : {
802 if (EOF == (read = gerb_fgetc(fd))) {
803 gerbv_stats_printf(stats->error_list,
805 _(
"Unexpected EOF found in file \"%s\""),
810 drill_parse_coordinate(fd, read, image, state, file_line);
813 curr_net->
stop_x = state->curr_x;
814 curr_net->
stop_y = state->curr_y;
822 r = image->
aperture[state->current_tool]->parameter[0]/2;
830 drill_update_image_info_min_max_from_bbox(image->
info, bbox);
837 case DRILL_G_ROUTSLOT : {
840 double prev_x = state->curr_x;
841 double prev_y = state->curr_y;
843 if (EOF == (read = gerb_fgetc(fd))) {
844 gerbv_stats_printf(stats->error_list,
846 _(
"Unexpected EOF found in file \"%s\""),
851 drill_parse_coordinate(fd, read, image, state, file_line);
853 curr_net = drill_add_route_segment(image, state, stats,
854 curr_net, prev_x, prev_y);
858 case DRILL_G_ABSOLUTE :
859 state->coordinate_mode = DRILL_MODE_ABSOLUTE;
862 case DRILL_G_INCREMENTAL :
863 state->coordinate_mode = DRILL_MODE_INCREMENTAL;
866 case DRILL_G_ZEROSET :
867 if (EOF == (read = gerb_fgetc(fd))) {
868 gerbv_stats_printf(stats->error_list,
870 _(
"Unexpected EOF found in file \"%s\""),
875 drill_parse_coordinate(fd, (
char)read, image,
877 state->origin_x = state->curr_x;
878 state->origin_y = state->curr_y;
881 case DRILL_G_UNKNOWN:
883 gerbv_stats_printf(stats->error_list,
885 _(
"Unrecognized string \"%s\" found "
886 "at line %u in file \"%s\""),
887 tmps, file_line, fd->filename);
891 case DRILL_G_OVERRIDETOOLSPEED:
892 case DRILL_G_VISTOOL:
893 case DRILL_G_VISSINGLEPOINTOFFSET:
894 case DRILL_G_VISMULTIPOINTTRANS:
895 case DRILL_G_VISCANCEL:
896 case DRILL_G_VISCORRHOLEDRILL:
897 case DRILL_G_VISAUTOCALIBRATION:
898 case DRILL_G_CUTTERCOMPOFF:
899 case DRILL_G_CUTTERCOMPLEFT:
900 case DRILL_G_CUTTERCOMPRIGHT:
901 case DRILL_G_VISSINGLEPOINTOFFSETREL:
902 case DRILL_G_VISMULTIPOINTTRANSREL:
903 case DRILL_G_VISCANCELREL:
904 case DRILL_G_VISCORRHOLEDRILLREL:
905 case DRILL_G_PACKDIP2:
906 case DRILL_G_PACKDIP:
907 case DRILL_G_PACK8PINL:
910 gerbv_stats_printf(stats->error_list,
912 _(
"Ignoring machine-only G%02d (%s) "
913 "at line %u in file \"%s\""),
915 file_line, fd->filename);
921 _(
"Unsupported G%02d (%s) code "
922 "at line %u in file \"%s\""),
924 file_line, fd->filename);
934 if (drill_parse_header_is_inch(fd, state, image, file_line)) {
938 if (drill_parse_header_is_ici(fd, state, image, file_line)) {
943 gerbv_stats_printf(stats->error_list,
945 _(
"Unrecognized string \"%s\" found "
946 "at line %u in file \"%s\""),
947 tmps, file_line, fd->filename);
955 switch (m_code = drill_parse_M_code(fd, state, image, file_line)) {
956 case DRILL_M_HEADER :
957 state->curr_section = DRILL_HEADER;
959 case DRILL_M_HEADEREND :
960 state->curr_section = DRILL_DATA;
971 gerbv_stats_printf(stats->error_list,
973 _(
"End of Excellon header reached "
974 "but no leading/trailing zero "
975 "handling specified "
976 "at line %u in file \"%s\""),
977 file_line, fd->filename);
978 gerbv_stats_printf(stats->error_list,
980 _(
"Assuming leading zeros in file \"%s\""),
985 case DRILL_M_METRIC :
987 && state->curr_section != DRILL_HEADER) {
990 gerbv_stats_printf(stats->error_list,
992 _(
"M71 code found but no METRIC "
993 "specification in header "
994 "at line %u in file \"%s\""),
995 file_line, fd->filename);
996 gerbv_stats_printf(stats->error_list,
998 _(
"Assuming all tool sizes are MM in file \"%s\""),
1002 for (
int tool_num = TOOL_MIN; tool_num < TOOL_MAX;
1007 size = image->
aperture[tool_num]->parameter[0];
1008 drill_stats_modify_drill_list(stats->drill_list,
1015 image->
aperture[tool_num]->parameter[0] /= 25.4;
1020 state->number_format = state->backup_number_format;
1024 case DRILL_M_IMPERIAL :
1026 if (state->number_format != FMT_00_0000) {
1028 state->backup_number_format = state->number_format;
1030 state->number_format = FMT_00_0000;
1031 state->decimals = 4;
1036 case DRILL_M_CANNEDTEXTX :
1037 case DRILL_M_CANNEDTEXTY :
1038 tmps = get_line(fd);
1040 _(
"Canned text \"%s\" "
1041 "at line %u in drill file \"%s\""),
1042 tmps, file_line, fd->filename);
1045 case DRILL_M_MESSAGELONG :
1046 case DRILL_M_MESSAGE :
1047 tmps = get_line(fd);
1049 _(
"Message \"%s\" embedded "
1050 "at line %u in drill file \"%s\""),
1051 tmps, file_line, fd->filename);
1054 case DRILL_M_PATTERN:
1055 state->in_pattern = TRUE;
1056 if (state->pattern_buffer) {
1057 g_array_set_size(state->pattern_buffer, 0);
1059 state->pattern_buffer = g_array_new(FALSE, FALSE,
1060 sizeof(drill_pattern_entry_t));
1064 case DRILL_M_PATTERNEND:
1065 state->in_pattern = FALSE;
1068 case DRILL_M_REPEATPATTERNOFFSET: {
1069 double offset_x = 0.0, offset_y = 0.0;
1075 offset_x = read_double(fd, state->number_format,
1076 image->
format->omit_zeros, state->decimals);
1080 offset_y = read_double(fd, state->number_format,
1081 image->
format->omit_zeros, state->decimals);
1087 if (state->pattern_buffer && state->pattern_buffer->len > 0) {
1088 double save_x = state->curr_x;
1089 double save_y = state->curr_y;
1090 saved_tool = state->current_tool;
1092 for (guint i = 0; i < state->pattern_buffer->len; i++) {
1093 drill_pattern_entry_t *e = &g_array_index(
1094 state->pattern_buffer,
1095 drill_pattern_entry_t, i);
1096 state->current_tool = e->tool;
1097 state->curr_x = e->x + offset_x;
1098 state->curr_y = e->y + offset_y;
1101 curr_net = drill_add_route_segment(image, state,
1103 e->prev_x + offset_x,
1104 e->prev_y + offset_y);
1106 curr_net = drill_add_drill_hole(image, state,
1111 state->curr_x = save_x;
1112 state->curr_y = save_y;
1113 state->current_tool = saved_tool;
1118 case DRILL_M_TOOLTIPCHECK:
1121 case DRILL_M_ZAXISROUTEPOSITIONDEPTHCTRL:
1122 case DRILL_M_ZAXISROUTEPOSITION:
1123 state->tool_down = TRUE;
1125 case DRILL_M_RETRACTCLAMPING:
1126 case DRILL_M_RETRACTNOCLAMPING:
1127 state->tool_down = FALSE;
1130 case DRILL_M_SWAPAXIS:
1131 state->swap_axis = !state->swap_axis;
1133 case DRILL_M_MIRRORX:
1134 state->mirror_x = !state->mirror_x;
1136 case DRILL_M_MIRRORY:
1137 state->mirror_y = !state->mirror_y;
1146 case DRILL_M_ENDREWIND :
1147 parsing_done = TRUE;
1150 case DRILL_M_UNKNOWN:
1153 if (drill_parse_header_is_metric(fd, state, image, file_line)) {
1158 tmps = get_line(fd);
1159 gerbv_stats_printf(stats->error_list,
1161 _(
"Unrecognized string \"%s\" found "
1162 "at line %u in file \"%s\""),
1163 tmps, file_line, fd->filename);
1168 case DRILL_M_STOPOPTIONAL:
1169 case DRILL_M_SANDREND:
1170 case DRILL_M_STOPINSPECTION:
1171 case DRILL_M_VISANDRPATTERN:
1172 case DRILL_M_VISANDRPATTERNREWIND:
1173 case DRILL_M_VISANDRPATTERNOFFSETCOUNTERCTRL:
1174 case DRILL_M_REFSCALING:
1175 case DRILL_M_REFSCALINGEND:
1176 case DRILL_M_PECKDRILLING:
1177 case DRILL_M_PECKDRILLINGEND:
1179 gerbv_stats_printf(stats->error_list,
1181 _(
"Ignoring machine-only M%02d (%s) "
1182 "at line %u in file \"%s\""),
1184 file_line, fd->filename);
1190 _(
"Unsupported M%02d (%s) code found "
1191 "at line %u in file \"%s\""),
1193 file_line, fd->filename);
1201 if (state->curr_section == DRILL_HEADER) {
1204 _(
"Not allowed 'R' code in the header "
1205 "at line %u in file \"%s\""),
1206 file_line, fd->filename);
1208 double start_x, start_y;
1209 double step_x, step_y;
1225 start_x = state->curr_x;
1226 start_y = state->curr_y;
1229 c = gerb_fgetc (fd);
1231 while (
'0' <= c && c <=
'9') {
1232 rcnt = 10*rcnt + (c -
'0');
1233 c = gerb_fgetc (fd);
1235 DPRINTF(
"working on R code (repeat) with a number of reps equal to %d\n", rcnt);
1239 step_x = read_double(fd, state->number_format, image->
format->omit_zeros, state->decimals);
1240 c = gerb_fgetc (fd);
1245 step_y = read_double(fd, state->number_format, image->
format->omit_zeros, state->decimals);
1250 DPRINTF(
"Getting ready to repeat the drill %d times with delta_x = %g, delta_y = %g\n", rcnt, step_x, step_y);
1253 for (c = 1 ; c <= rcnt ; c++) {
1254 state->curr_x = start_x + c*step_x;
1255 state->curr_y = start_y + c*step_y;
1256 DPRINTF(
" Repeat #%d - new location is (%g, %g)\n", c, state->curr_x, state->curr_y);
1257 curr_net = drill_add_drill_hole (image, state, stats, curr_net);
1258 if (state->in_pattern) {
1259 drill_pattern_entry_t entry = {
1260 state->curr_x, state->curr_y,
1261 0, 0, state->current_tool, FALSE
1263 g_array_append_val(state->pattern_buffer, entry);
1272 _(
"Ignoring setting spindle speed "
1273 "at line %u in drill file \"%s\""),
1274 file_line, fd->filename);
1278 drill_parse_T_code(fd, state, image, file_line);
1279 state->route_mode = DRILL_G_DRILL;
1280 state->tool_down = FALSE;
1281 state->delta_cp_x = 0;
1282 state->delta_cp_y = 0;
1286 tmps = get_line (fd);
1288 if (0 != strcmp (tmps,
"VER,1")) {
1290 _(
"Undefined string \"%s\" in header "
1291 "at line %u in file \"%s\""),
1292 tmps, file_line, fd->filename);
1299 double prev_x = state->curr_x;
1300 double prev_y = state->curr_y;
1303 drill_parse_coordinate(fd, read, image, state, file_line);
1305 if ((state->route_mode == DRILL_G_ROUT ||
1306 state->route_mode == DRILL_G_LINEARMOVE ||
1307 state->route_mode == DRILL_G_CWMOVE ||
1308 state->route_mode == DRILL_G_CCWMOVE) && !state->tool_down) {
1310 state->delta_cp_x = 0;
1311 state->delta_cp_y = 0;
1312 state->found_arc_radius = FALSE;
1316 if ((state->route_mode == DRILL_G_CWMOVE ||
1317 state->route_mode == DRILL_G_CCWMOVE) && state->tool_down) {
1319 curr_net = drill_add_arc_segment(image, state, stats,
1320 curr_net, prev_x, prev_y);
1321 state->delta_cp_x = 0;
1322 state->delta_cp_y = 0;
1323 state->found_arc_radius = FALSE;
1324 }
else if ((state->route_mode == DRILL_G_LINEARMOVE ||
1325 state->route_mode == DRILL_G_ROUT) && state->tool_down) {
1327 curr_net = drill_add_route_segment(image, state, stats,
1328 curr_net, prev_x, prev_y);
1329 if (state->in_pattern) {
1330 drill_pattern_entry_t entry = {
1331 state->curr_x, state->curr_y,
1332 prev_x, prev_y, state->current_tool, TRUE
1334 g_array_append_val(state->pattern_buffer, entry);
1338 curr_net = drill_add_drill_hole(image, state, stats, curr_net);
1339 if (state->in_pattern) {
1340 drill_pattern_entry_t entry = {
1341 state->curr_x, state->curr_y,
1342 0, 0, state->current_tool, FALSE
1344 g_array_append_val(state->pattern_buffer, entry);
1351 state->curr_section = DRILL_DATA;
1358 read = gerb_fgetc(fd);
1359 if (read !=
'\r' && read != EOF) {
1368 read = gerb_fgetc(fd);
1369 if (read !=
'\n' && read != EOF) {
1381 if (DRILL_HEADER == state->curr_section) {
1383 _(
"Undefined code '%s' (0x%x) found in header "
1384 "at line %u in file \"%s\""),
1385 gerbv_escape_char(read), read,
1386 file_line, fd->filename);
1390 tmps = get_line(fd);
1392 _(
"Unrecognised string \"%s\" in header "
1393 "at line %u in file \"%s\""),
1394 tmps, file_line, fd->filename);
1398 _(
"Ignoring undefined character '%s' (0x%x) "
1399 "found inside data at line %u in file \"%s\""),
1400 gerbv_escape_char(read), read, file_line, fd->filename);
1405 if (!parsing_done) {
1407 _(
"No EOF found in drill file \"%s\""), fd->filename);
1410 DPRINTF(
"%s(): Populating file attributes\n", __FUNCTION__);
1412 hid_attrs = image->
info->attr_list;
1414 switch (state->unit) {
1416 hid_attrs[HA_xy_units].default_val.int_value =
GERBV_UNIT_MM;
1424 switch (state->number_format) {
1427 hid_attrs[HA_digits].default_val.int_value = 2;
1431 hid_attrs[HA_digits].default_val.int_value = 3;
1435 hid_attrs[HA_digits].default_val.int_value = 4;
1439 DPRINTF(
"%s(): Keeping user specified number of decimal places (%d)\n",
1441 hid_attrs[HA_digits].default_val.int_value);
1448 switch (image->
format->omit_zeros) {
1450 hid_attrs[HA_suppression].default_val.int_value = SUP_LEAD;
1454 hid_attrs[HA_suppression].default_val.int_value = SUP_TRAIL;
1458 hid_attrs[HA_suppression].default_val.int_value = SUP_NONE;
1462 if (state->pattern_buffer)
1463 g_array_free(state->pattern_buffer, TRUE);
1476 drill_file_p(gerb_file_t *fd, gboolean *returnFoundBinary)
1478 char *buf=NULL, *tbuf;
1485 gboolean found_binary = FALSE;
1486 gboolean found_M48 = FALSE;
1487 gboolean found_M30 = FALSE;
1488 gboolean found_percent = FALSE;
1489 gboolean found_T = FALSE;
1490 gboolean found_X = FALSE;
1491 gboolean found_Y = FALSE;
1492 gboolean end_comments=FALSE;
1494 tbuf = g_malloc(MAXL);
1497 "malloc buf failed while checking for drill file in %s()",
1501 while (fgets(tbuf, MAXL, fd->fd) != NULL) {
1506 if(g_strstr_len(buf, len,
";")!=NULL){
1507 for (i = 0; i < len-1; ++i) {
1511 && buf[i+1] !=
'\n') {
1512 end_comments = TRUE;
1530 for (i = 0; i < len; i++) {
1531 ascii = (int) buf[i];
1532 if ((ascii > 128) || (ascii < 0)) {
1533 found_binary = TRUE;
1538 if (g_strstr_len(buf, len,
"M48")) {
1543 if (g_strstr_len(buf, len,
"M30")) {
1544 if (found_percent) {
1550 if ((letter = g_strstr_len(buf, len,
"%")) != NULL) {
1551 if ((letter[1] ==
'\r') || (letter[1] ==
'\n')) {
1552 found_percent = TRUE;
1557 if ((letter = g_strstr_len(buf, len,
"T")) != NULL) {
1558 if (!found_T && (found_X || found_Y)) {
1561 if (isdigit( (
int) letter[1])) {
1568 if ((letter = g_strstr_len(buf, len,
"X")) != NULL) {
1569 ascii = (int) letter[1];
1570 if ((ascii >= zero) && (ascii <= nine)) {
1574 if ((letter = g_strstr_len(buf, len,
"Y")) != NULL) {
1575 ascii = (int) letter[1];
1576 if ((ascii >= zero) && (ascii <= nine)) {
1584 *returnFoundBinary = found_binary;
1587 if ( ((found_X || found_Y) && found_T) &&
1588 (found_M48 || (found_percent && found_M30)) ) {
1590 }
else if (found_M48 && found_percent && found_M30) {
1605 drill_parse_T_code(gerb_file_t *fd, drill_state_t *state,
1609 gboolean done = FALSE;
1613 gerbv_aperture_t *apert;
1617 DPRINTF(
"---> entering %s()...\n", __FUNCTION__);
1621 temp = gerb_fgetc(fd);
1622 DPRINTF(
" Found a char '%s' (0x%02x) after the T\n",
1623 gerbv_escape_char(temp), temp);
1626 if((temp ==
'C') && ((fd->ptr + 2) < fd->datalen)){
1627 if(gerb_fgetc(fd) ==
'S'){
1628 if (gerb_fgetc(fd) ==
'T' ){
1630 tmps = get_line(fd++);
1632 _(
"Tool change stop switch found \"%s\" "
1633 "at line %u in file \"%s\""),
1634 tmps, file_line, fd->filename);
1644 if( !(isdigit(temp) != 0 || temp ==
'+' || temp ==
'-') ) {
1647 _(
"OrCAD bug: Junk text found in place of tool definition"));
1648 tmps = get_line(fd);
1650 _(
"Junk text \"%s\" "
1651 "at line %u in file \"%s\""),
1652 tmps, file_line, fd->filename);
1655 _(
"Ignoring junk text"));
1661 tool_num = (int) gerb_fgetint(fd, NULL);
1662 DPRINTF(
" Handling tool T%d at line %u\n", tool_num, file_line);
1664 if (tool_num == 0) {
1669 temp = gerb_fgetc(fd);
1670 while (temp != EOF && temp !=
'\n' && temp !=
'\r') {
1672 read_double(fd, state->header_number_format,
1674 }
else if (temp ==
'F' || temp ==
'S') {
1675 gerb_fgetint(fd, NULL);
1680 temp = gerb_fgetc(fd);
1682 if (temp ==
'\n' || temp ==
'\r')
1687 if (tool_num < TOOL_MIN || tool_num >= TOOL_MAX) {
1689 _(
"Out of bounds drill number %d "
1690 "at line %u in file \"%s\""),
1691 tool_num, file_line, fd->filename);
1696 state->current_tool = tool_num;
1700 temp = gerb_fgetc(fd);
1705 switch((
char)temp) {
1708 DPRINTF(
" Read a size of %g\n", size);
1712 }
else if(size >= 4.0) {
1720 _(
"Read a drill of diameter %g inches "
1721 "at line %u in file \"%s\""),
1722 size, file_line, fd->filename);
1724 _(
"Assuming units are mils"));
1728 if (size <= 0. || size >= 10000.) {
1730 _(
"Unreasonable drill size %g found for drill %d "
1731 "at line %u in file \"%s\""),
1732 size, tool_num, file_line, fd->filename);
1734 if (apert != NULL) {
1739 if (apert->parameter[0] != size
1741 || apert->nuf_parameters != 1
1744 gerbv_stats_printf(stats->error_list,
1746 _(
"Found redefinition of drill %d "
1747 "at line %u in file \"%s\""),
1748 tool_num, file_line, fd->filename);
1751 apert = image->
aperture[tool_num] =
1752 g_new0(gerbv_aperture_t, 1);
1753 if (apert == NULL) {
1754 GERB_FATAL_ERROR(
"malloc tool failed in %s()",
1761 apert->parameter[0] = size;
1763 apert->nuf_parameters = 1;
1771 string = g_strdup_printf(
"%s", (state->unit ==
GERBV_UNIT_MM ? _(
"mm") : _(
"inch")));
1772 drill_stats_add_to_drill_list(stats->drill_list,
1782 gerb_fgetint(fd, NULL);
1793 temp = gerb_fgetc(fd);
1796 _(
"Unexpected EOF encountered in header of "
1797 "drill file \"%s\""), fd->filename);
1800 if (
'\n' == temp ||
'\r' == temp) {
1808 if (apert == NULL) {
1811 apert = image->
aperture[tool_num] = g_new0(gerbv_aperture_t, 1);
1812 if (apert == NULL) {
1813 GERB_FATAL_ERROR(
"malloc tool failed in %s()", __FUNCTION__);
1817 dia = gerbv_get_tool_diameter(tool_num);
1823 dia = (double)(16 + 8 * tool_num) / 1000;
1829 if (tool_num != 0) {
1831 _(
"Tool %02d used without being defined "
1832 "at line %u in file \"%s\""),
1833 tool_num, file_line, fd->filename);
1835 _(
"Setting a default size of %g\""), dia);
1840 apert->nuf_parameters = 1;
1841 apert->parameter[0] = dia;
1845 if (tool_num != 0) {
1848 string = g_strdup_printf(
"%s",
1850 drill_stats_add_to_drill_list(stats->drill_list,
1858 DPRINTF(
"<---- ...leaving %s()\n", __FUNCTION__);
1865 static drill_m_code_t
1866 drill_parse_M_code(gerb_file_t *fd, drill_state_t *state,
1870 drill_m_code_t m_code;
1873 DPRINTF(
"---> entering %s() ...\n", __FUNCTION__);
1875 op[0] = gerb_fgetc(fd);
1876 op[1] = gerb_fgetc(fd);
1882 _(
"Unexpected EOF found while parsing M-code in file \"%s\""),
1885 return DRILL_M_UNKNOWN;
1888 DPRINTF(
" Compare M-code \"%s\" at line %u\n", op, file_line);
1890 switch (m_code = atoi(op)) {
1893 if (0 != strncmp(op,
"00", 2)) {
1894 m_code = DRILL_M_UNKNOWN;
1958 case 50:
case 51:
case 52:
1959 case 60:
case 61:
case 62:
case 63:
1960 stats->M_machine_only++;
1964 case DRILL_M_UNKNOWN:
1969 DPRINTF(
"<---- ...leaving %s()\n", __FUNCTION__);
1976 drill_parse_header_is_metric(gerb_file_t *fd, drill_state_t *state,
1982 DPRINTF(
" %s(): entering\n", __FUNCTION__);
1991 if (DRILL_HEADER != state->curr_section) {
1995 switch (file_check_str(fd,
"METRIC")) {
1998 _(
"Unexpected EOF found while parsing \"%s\" string "
1999 "in file \"%s\""),
"METRIC", fd->filename);
2007 gboolean found_junk = FALSE;
2009 if (
',' != gerb_fgetc(fd)) {
2016 switch (c = gerb_fgetc(fd)) {
2019 if (
'Z' != gerb_fgetc(fd)) {
2025 DPRINTF(
" %s(): Detected a file that probably has "
2026 "trailing zero suppression\n", __FUNCTION__);
2029 DPRINTF(
" %s(): Detected a file that probably has "
2030 "leading zero suppression\n", __FUNCTION__);
2034 if (!state->autod && state->number_format == FMT_USER
2035 && state->digits_before > 0 && c ==
'L') {
2038 state->decimals = state->digits_before;
2041 if (state->autod && state->number_format != FMT_USER) {
2050 state->header_number_format =
2051 state->number_format = FMT_000_000;
2052 state->decimals = 3;
2055 if (
',' == gerb_fgetc(fd)) {
2064 if (
'0' != gerb_fgetc(fd)
2065 ||
'0' != gerb_fgetc(fd)) {
2072 op[0] = gerb_fgetc(fd);
2073 op[1] = gerb_fgetc(fd);
2081 if (0 == strcmp(op,
"0.")) {
2084 if (
'0' != gerb_fgetc(fd)
2085 ||
'0' != gerb_fgetc(fd)) {
2093 state->number_format = FMT_0000_00;
2094 state->decimals = 2;
2099 if (0 != strcmp(op,
".0")) {
2106 if (
'0' != gerb_fgetc(fd)) {
2115 int last_char = gerb_fgetc(fd);
2116 if (last_char ==
'0') {
2118 state->number_format = FMT_000_000;
2119 state->decimals = 3;
2122 if (last_char != EOF) {
2126 state->number_format = FMT_000_00;
2127 state->decimals = 2;
2144 gerbv_stats_printf(stats->error_list,
2146 _(
"Found junk after METRIC command "
2147 "at line %u in file \"%s\""),
2148 file_line, fd->filename);
2167 drill_parse_header_is_metric_comment(gerb_file_t *fd, drill_state_t *state,
2171 DPRINTF(
" %s(): entering\n", __FUNCTION__);
2173 if (DRILL_HEADER != state->curr_section) {
2177 switch (file_check_str(fd,
"FILE_FORMAT")) {
2180 _(
"Unexpected EOF found while parsing \"%s\" string "
2181 "in file \"%s\" on line %u"),
2182 "FILE_FORMAT", fd->filename, file_line);
2189 if (file_check_str(fd,
"=") != 1) {
2191 _(
"Expected '=' while parsing \"%s\" string "
2192 "in file \"%s\" on line %u"),
2193 "FILE_FORMAT", fd->filename, file_line);
2198 int digits_before = gerb_fgetint(fd, &len);
2203 _(
"Expected integer after '=' while parsing \"%s\" string "
2204 "in file \"%s\" on line %u"),
2205 "FILE_FORMAT", fd->filename, file_line);
2209 if (file_check_str(fd,
":") != 1) {
2211 _(
"Expected ':' while parsing \"%s\" string "
2212 "in file \"%s\" on line %u"),
2213 "FILE_FORMAT", fd->filename, file_line);
2218 int digits_after = gerb_fgetint(fd, &len);
2222 _(
"Expected integer after ':' while parsing \"%s\" string "
2223 "in file \"%s\" on line %u"),
2224 "FILE_FORMAT", fd->filename, file_line);
2228 state->header_number_format = state->number_format = FMT_USER;
2229 state->decimals = digits_after;
2230 state->digits_before = digits_before;
2237 drill_parse_header_is_inch(gerb_file_t *fd, drill_state_t *state,
2243 DPRINTF(
" %s(): entering\n", __FUNCTION__);
2245 if (DRILL_HEADER != state->curr_section) {
2249 switch (file_check_str(fd,
"INCH")) {
2252 _(
"Unexpected EOF found while parsing \"%s\" string "
2253 "in file \"%s\""),
"INCH", fd->filename);
2261 if (
',' != gerb_fgetc(fd)) {
2266 if (c != EOF &&
'Z' == gerb_fgetc(fd)) {
2271 state->header_number_format =
2272 state->number_format = FMT_00_0000;
2273 state->decimals = 4;
2274 }
else if (state->number_format == FMT_USER
2275 && state->digits_before > 0) {
2278 state->decimals = state->digits_before;
2285 state->header_number_format =
2286 state->number_format = FMT_00_0000;
2287 state->decimals = 4;
2294 gerbv_stats_printf(stats->error_list,
2296 _(
"Found junk '%s' after "
2298 "at line %u in file \"%s\""),
2299 gerbv_escape_char(c),
2300 file_line, fd->filename);
2304 gerbv_stats_printf(stats->error_list,
2306 _(
"Found junk '%s' after INCH command "
2307 "at line %u in file \"%s\""),
2308 gerbv_escape_char(c),
2309 file_line, fd->filename);
2323 drill_parse_header_is_ici(gerb_file_t *fd, drill_state_t *state,
2328 switch (file_check_str(fd,
"ICI,ON")) {
2331 _(
"Unexpected EOF found while parsing \"%s\" string "
2332 "in file \"%s\""),
"ICI,ON", fd->filename);
2336 state->coordinate_mode = DRILL_MODE_INCREMENTAL;
2340 switch (file_check_str(fd,
"ICI,OFF")) {
2343 _(
"Unexpected EOF found while parsing \"%s\" string "
2344 "in file \"%s\""),
"ICI,OFF", fd->filename);
2348 state->coordinate_mode = DRILL_MODE_ABSOLUTE;
2356 static drill_g_code_t
2357 drill_parse_G_code(gerb_file_t *fd,
gerbv_image_t *image,
unsigned int file_line)
2360 drill_g_code_t g_code;
2363 DPRINTF(
"---> entering %s()...\n", __FUNCTION__);
2365 op[0] = gerb_fgetc(fd);
2366 op[1] = gerb_fgetc(fd);
2372 _(
"Unexpected EOF found while parsing G-code in file \"%s\""),
2374 return DRILL_G_UNKNOWN;
2377 DPRINTF(
" Compare G-code \"%s\" at line %u\n", op, file_line);
2379 switch (g_code = atoi(op)) {
2382 if (0 != strncmp(op,
"00", 2)) {
2383 g_code = DRILL_G_UNKNOWN;
2419 case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
2420 case 40:
case 41:
case 42:
2421 case 45:
case 46:
case 47:
case 48:
2422 case 81:
case 82:
case 83:
case 84:
2423 stats->G_machine_only++;
2426 case DRILL_G_UNKNOWN:
2432 DPRINTF(
"<---- ...leaving %s()\n", __FUNCTION__);
2442 drill_parse_coordinate(gerb_file_t *fd,
char firstchar,
2444 unsigned int file_line)
2449 gboolean found_x = FALSE;
2451 gboolean found_y = FALSE;
2453 gboolean found_i = FALSE;
2455 gboolean found_j = FALSE;
2459 if (firstchar ==
'X') {
2460 x = read_double(fd, state->number_format, image->
format->omit_zeros, state->decimals);
2462 }
else if (firstchar ==
'Y') {
2463 y = read_double(fd, state->number_format, image->
format->omit_zeros, state->decimals);
2465 }
else if (firstchar ==
'I') {
2466 i_val = read_double(fd, state->number_format, image->
format->omit_zeros, state->decimals);
2468 }
else if (firstchar ==
'J') {
2469 j_val = read_double(fd, state->number_format, image->
format->omit_zeros, state->decimals);
2471 }
else if (firstchar ==
'A') {
2472 state->arc_radius = read_double(fd, state->number_format,
2473 image->
format->omit_zeros, state->decimals);
2474 state->found_arc_radius = TRUE;
2480 firstchar = gerb_fgetc(fd);
2483 if (state->swap_axis) {
2484 double tmp = x; x = y; y = tmp;
2485 gboolean ftmp = found_x; found_x = found_y; found_y = ftmp;
2487 if (state->mirror_x && found_x)
2489 if (state->mirror_y && found_y)
2492 if(state->coordinate_mode == DRILL_MODE_ABSOLUTE) {
2499 }
else if(state->coordinate_mode == DRILL_MODE_INCREMENTAL) {
2508 _(
"Coordinate mode is not absolute and not incremental "
2509 "at line %u in file \"%s\""),
2510 file_line, fd->filename);
2515 state->delta_cp_x = i_val;
2517 state->delta_cp_y = j_val;
2523 static drill_state_t *
2524 new_state(drill_state_t *state)
2526 state = g_new0(drill_state_t, 1);
2527 if (state != NULL) {
2529 state->curr_section = DRILL_NONE;
2530 state->coordinate_mode = DRILL_MODE_ABSOLUTE;
2531 state->origin_x = 0.0;
2532 state->origin_y = 0.0;
2534 state->backup_number_format = FMT_000_000;
2535 state->header_number_format = state->number_format = FMT_00_0000;
2537 state->decimals = 4;
2538 state->route_mode = DRILL_G_DRILL;
2539 state->tool_down = FALSE;
2550 read_double(gerb_file_t *fd, number_fmt_t fmt,
gerbv_omit_zeros_t omit_zeros,
int decimals)
2553 char temp[DRILL_READ_DOUBLE_SIZE];
2556 gboolean decimal_point = FALSE;
2557 gboolean sign_prepend = FALSE;
2559 memset(temp, 0,
sizeof(temp));
2561 read = gerb_fgetc(fd);
2562 while(read != EOF && i < (DRILL_READ_DOUBLE_SIZE -1) &&
2563 (isdigit(read) || read ==
'.' || read ==
',' || read ==
'+' || read ==
'-')) {
2564 if(read ==
',' || read ==
'.') decimal_point = TRUE;
2574 if(read ==
'-' || read ==
'+') {
2575 sign_prepend = TRUE;
2578 temp[i++] = (char)read;
2579 read = gerb_fgetc(fd);
2585 if (decimal_point) {
2586 result = strtod(temp, NULL);
2588 unsigned int wantdigits;
2590 char tmp2[DRILL_READ_DOUBLE_SIZE];
2592 memset(tmp2, 0,
sizeof(tmp2));
2615 wantdigits = decimals;
2620 fprintf(stderr, _(
"%s(): omit_zeros == GERBV_OMIT_ZEROS_TRAILING but fmt = %d.\n"
2621 "This should never have happened\n"), __FUNCTION__, fmt);
2635 if (wantdigits >
sizeof(tmp2) - 2) {
2636 fprintf(stderr, _(
"%s(): wantdigits = %d which exceeds the maximum allowed size\n"),
2637 __FUNCTION__, wantdigits);
2646 DPRINTF(
"%s(): wantdigits = %d, strlen(\"%s\") = %ld\n",
2647 __FUNCTION__, wantdigits, temp, (
long) strlen(temp));
2648 for (i = 0 ; i < wantdigits && i < strlen(temp) ; i++) {
2651 for ( ; i < wantdigits ; i++) {
2655 for ( ; i <= strlen(temp) ; i++) {
2656 tmp2[i] = temp[i-1];
2658 DPRINTF(
"%s(): After dealing with trailing zero suppression, convert \"%s\"\n", __FUNCTION__, tmp2);
2661 for (i = 0 ; i <= strlen(tmp2) && i <
sizeof (temp) ; i++) {
2686 scale = pow (10.0, -1.0*decimals);
2691 fprintf (stderr, _(
"%s(): Unhandled fmt ` %d\n"), __FUNCTION__, fmt);
2696 result = strtod(temp, NULL) * scale;
2699 DPRINTF(
" %s()=%f: fmt=%d, omit_zeros=%d, decimals=%d \n",
2700 __FUNCTION__, result, fmt, omit_zeros, decimals);
2709 eat_line(gerb_file_t *fd)
2714 read = gerb_fgetc(fd);
2715 }
while (read !=
'\n' && read !=
'\r' && read != EOF);
2726 eat_whitespace(gerb_file_t *fd)
2731 read = gerb_fgetc(fd);
2732 }
while ((read ==
' ' || read ==
'\t') && read != EOF);
2742 get_line(gerb_file_t *fd)
2746 gchar *tmps=g_strdup(
"");
2748 read = gerb_fgetc(fd);
2749 while (read !=
'\n' && read !=
'\r' && read != EOF) {
2750 retstring = g_strdup_printf(
"%s%c", tmps, read);
2758 read = gerb_fgetc(fd);
2776 file_check_str(gerb_file_t *fd,
const char *str)
2780 for (
int i = 0; str[i] !=
'\0'; i++) {
2807 return N_(
"rout mode");
2808 case DRILL_G_LINEARMOVE:
2809 return N_(
"linear mode");
2810 case DRILL_G_CWMOVE:
2811 return N_(
"circular CW mode");
2812 case DRILL_G_CCWMOVE:
2813 return N_(
"circular CCW mode");
2814 case DRILL_G_VARIABLEDWELL:
2815 return N_(
"variable dwell");
2817 return N_(
"drill mode");
2818 case DRILL_G_OVERRIDETOOLSPEED:
2819 return N_(
"override tool feed or speed");
2820 case DRILL_G_ROUTCIRCLE:
2821 return N_(
"routed CW circle");
2822 case DRILL_G_ROUTCIRCLECCW:
2823 return N_(
"routed CCW circle");
2824 case DRILL_G_VISTOOL:
2825 return N_(
"select vision tool");
2826 case DRILL_G_VISSINGLEPOINTOFFSET:
2827 return N_(
"single point vision offset");
2828 case DRILL_G_VISMULTIPOINTTRANS:
2829 return N_(
"multipoint vision translation");
2830 case DRILL_G_VISCANCEL:
2831 return N_(
"cancel vision translation or offset");
2832 case DRILL_G_VISCORRHOLEDRILL:
2833 return N_(
"vision corrected single hole drilling");
2834 case DRILL_G_VISAUTOCALIBRATION:
2835 return N_(
"vision system autocalibration");
2836 case DRILL_G_CUTTERCOMPOFF:
2837 return N_(
"cutter compensation off");
2838 case DRILL_G_CUTTERCOMPLEFT:
2839 return N_(
"cutter compensation left");
2840 case DRILL_G_CUTTERCOMPRIGHT:
2841 return N_(
"cutter compensation right");
2842 case DRILL_G_VISSINGLEPOINTOFFSETREL:
2843 return N_(
"single point vision relative offset");
2844 case DRILL_G_VISMULTIPOINTTRANSREL:
2845 return N_(
"multipoint vision relative translation");
2846 case DRILL_G_VISCANCELREL:
2847 return N_(
"cancel vision relative translation or offset");
2848 case DRILL_G_VISCORRHOLEDRILLREL:
2849 return N_(
"vision corrected single hole relative drilling");
2850 case DRILL_G_PACKDIP2:
2851 return N_(
"dual in line package");
2852 case DRILL_G_PACKDIP:
2853 return N_(
"dual in line package");
2854 case DRILL_G_PACK8PINL:
2855 return N_(
"eight pin L package");
2857 return N_(
"canned circle");
2859 return N_(
"canned slot");
2860 case DRILL_G_ROUTSLOT:
2861 return N_(
"routed step slot");
2862 case DRILL_G_ABSOLUTE:
2863 return N_(
"absolute input mode");
2864 case DRILL_G_INCREMENTAL:
2865 return N_(
"incremental input mode");
2866 case DRILL_G_ZEROSET:
2867 return N_(
"zero set");
2869 case DRILL_G_UNKNOWN:
2871 return N_(
"unknown G-code");
2881 return N_(
"end of program");
2882 case DRILL_M_PATTERNEND:
2883 return N_(
"pattern end");
2884 case DRILL_M_REPEATPATTERNOFFSET:
2885 return N_(
"repeat pattern offset");
2886 case DRILL_M_STOPOPTIONAL:
2887 return N_(
"stop optional");
2888 case DRILL_M_SANDREND:
2889 return N_(
"step and repeat end");
2890 case DRILL_M_STOPINSPECTION:
2891 return N_(
"stop for inspection");
2892 case DRILL_M_ZAXISROUTEPOSITIONDEPTHCTRL:
2893 return N_(
"Z-axis rout position with depth control");
2894 case DRILL_M_ZAXISROUTEPOSITION:
2895 return N_(
"Z-axis rout position");
2896 case DRILL_M_RETRACTCLAMPING:
2897 return N_(
"retract with clamping");
2898 case DRILL_M_RETRACTNOCLAMPING:
2899 return N_(
"retract without clamping");
2900 case DRILL_M_TOOLTIPCHECK:
2901 return N_(
"tool tip check");
2902 case DRILL_M_PATTERN:
2903 return N_(
"pattern start");
2904 case DRILL_M_ENDREWIND:
2905 return N_(
"end of program with rewind");
2906 case DRILL_M_MESSAGELONG:
2907 return N_(
"long operator message");
2908 case DRILL_M_MESSAGE:
2909 return N_(
"operator message");
2910 case DRILL_M_HEADER:
2911 return N_(
"header start");
2912 case DRILL_M_VISANDRPATTERN:
2913 return N_(
"vision step and repeat pattern start");
2914 case DRILL_M_VISANDRPATTERNREWIND:
2915 return N_(
"vision step and repeat rewind");
2916 case DRILL_M_VISANDRPATTERNOFFSETCOUNTERCTRL:
2917 return N_(
"vision step and repeat offset counter control");
2918 case DRILL_M_REFSCALING:
2919 return N_(
"reference scaling on");
2920 case DRILL_M_REFSCALINGEND:
2921 return N_(
"reference scaling off");
2922 case DRILL_M_PECKDRILLING:
2923 return N_(
"peck drilling on");
2924 case DRILL_M_PECKDRILLINGEND:
2925 return N_(
"peck drilling off");
2926 case DRILL_M_SWAPAXIS:
2927 return N_(
"swap axes");
2928 case DRILL_M_METRIC:
2929 return N_(
"metric measuring mode");
2930 case DRILL_M_IMPERIAL:
2931 return N_(
"inch measuring mode");
2932 case DRILL_M_MIRRORX:
2933 return N_(
"mirror image X-axis");
2934 case DRILL_M_MIRRORY:
2935 return N_(
"mirror image Y-axis");
2936 case DRILL_M_HEADEREND:
2937 return N_(
"header end");
2938 case DRILL_M_CANNEDTEXTX:
2939 return N_(
"canned text along X-axis");
2940 case DRILL_M_CANNEDTEXTY:
2941 return N_(
"canned text along Y-axis");
2942 case DRILL_M_USERDEFPATTERN:
2943 return N_(
"user defined stored pattern");
2945 case DRILL_M_UNKNOWN:
2947 return N_(
"unknown M-code");
Dynamic GUI window creation header info.
const char * drill_g_code_name(drill_g_code_t g_code)
Return drill G-code name by code number.
const char * drill_m_code_name(drill_m_code_t m_code)
Return drill M-code name by code number.
Header info for the Excellon drill parsing functions.
gerbv_drill_stats_t * gerbv_drill_stats_new(void)
Allocates a new drill_stats structure.
Header info to the statistics generating functions for Excellon drill files.
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
gerbv_image_t * gerbv_create_image(gerbv_image_t *image, const gchar *type)
Allocate a new gerbv_image structure.
Header info for the RS274X parsing functions.
The main header file for the libgerbv library.
@ GERBV_APERTURE_STATE_ON
@ GERBV_APERTURE_STATE_FLASH
@ GERBV_OMIT_ZEROS_TRAILING
@ GERBV_OMIT_ZEROS_EXPLICIT
@ GERBV_OMIT_ZEROS_LEADING
@ GERBV_OMIT_ZEROS_UNSPECIFIED
@ GERBV_INTERPOLATION_CW_CIRCULAR
@ GERBV_INTERPOLATION_CCW_CIRCULAR
@ GERBV_INTERPOLATION_LINEARx1
gerbv_layertype_t layertype
gerbv_drill_stats_t * drill_stats
gerbv_aperture_t * aperture[APERTURE_MAX]
gerbv_netstate_t * states
gerbv_image_info_t * info
gerbv_render_size_t boundingBox
gerbv_aperture_state_t aperture_state
gerbv_interpolation_t interpolation