annotate pads2gpcb/decals.c @ 47:8fa304e2b7e1

pads2gpcb: parsing of -w options implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 30 Jan 2016 08:23:35 +0000
parents bf1be6c97c28
children c977d637f038
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <stdio.h>
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdlib.h>
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <ctype.h>
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <string.h>
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <strings.h>
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "globals.h"
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include "struct.h"
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 extern long convert_input_dim();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 static struct part_decal *current_decal;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 static struct footprint_body fpbody;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 static struct footprint_pad *pins_array;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
14
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
15 #define SOLDERMASK_DELTA (600 * 254)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
16 #define CLEARANCE_SETTING (2000 * 254)
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 enter_decal()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 struct part_decal *p, **pp;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 char *name = input_line_fields[0];
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 for (pp = &part_decal_list; p = *pp; pp = &p->next)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 if (!strcmp(p->name, name)) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 fprintf(stderr,
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 "%s line %d: decal name \"%s\" already defined\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 input_filename, input_lineno, name);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 p = malloc(sizeof(struct part_decal) + strlen(name) + 1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 if (!p) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 perror("malloc of struct part_decal");
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 p->name = (char *)(p + 1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 strcpy(p->name, name);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 p->body = 0;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 p->next = 0;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
40 *pp = p;
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 current_decal = p;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 get_line_internal()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 if (!get_input_line()) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 fprintf(stderr,
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 "error: EOF in the middle of a part decal definition\n");
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 one_drawing_piece()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 int ncoord, i;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 /* just skip it for now */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 parse_input_line_fields();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 if (input_line_nfields < 2) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 fprintf(stderr,
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 "%s line %d: expected piece header line giving # of coords\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 input_filename, input_lineno);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 ncoord = atoi(input_line_fields[1]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 for (i = 0; i < ncoord; i++)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 one_text_item()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 /* just skip it for now */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 one_attr_label()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 /* just skip it for now */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
92 read_pindef_line(idx)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 get_line_internal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
95 if (input_line_buf[0] != 'T') {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
96 fprintf(stderr, "%s line %d: 'T' line expected\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
97 input_filename, input_lineno);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
98 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
99 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
100 parse_input_line_fields();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
101 if (input_line_nfields != 5) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
102 fprintf(stderr, "%s line %d: expected 5 fields in 'T' line\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
103 input_filename, input_lineno);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
104 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
105 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
106 input_line_fields[0]++;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
107
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
108 if (atoi(input_line_fields[4]) != idx + 1) {
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
109 fprintf(stderr,
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
110 "%s line %d: expected %d in the pin number field\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
111 input_filename, input_lineno);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
112 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
113 }
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
114 pins_array[idx].x1 = convert_input_dim(input_line_fields[0]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
115 pins_array[idx].y1 = -convert_input_dim(input_line_fields[1]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
116 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
117
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
118 static void
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
119 process_pad_shape(padptr)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
120 struct pad_shape_info *padptr;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
121 {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
122 padptr->short_dim = convert_input_dim(input_line_fields[1]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
123 if (padptr->short_dim <= 0) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
124 printf("line %d: pad short dim <= 0\n", input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
125 return;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
126 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
127 if (!strcmp(input_line_fields[2], "R")) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
128 padptr->rounded = 1;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
129 padptr->elongated = 0;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
130 } else if (!strcmp(input_line_fields[2], "S")) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
131 padptr->rounded = 0;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
132 padptr->elongated = 0;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
133 } else if (!strcmp(input_line_fields[2], "OF")) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
134 padptr->rounded = 1;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
135 padptr->elongated = 1;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
136 } else if (!strcmp(input_line_fields[2], "RF")) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
137 padptr->rounded = 0;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
138 padptr->elongated = 1;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
139 } else {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
140 printf("line %d: unsupported pad shape %s\n", input_lineno,
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
141 input_line_fields[2]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
142 return;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
143 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
144 if (padptr->elongated) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
145 if (input_line_nfields < 6) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
146 fprintf(stderr,
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
147 "%s line %d: too few fields in OF/RF pad stack line\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
148 input_filename, input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
149 exit(1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
150 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
151 padptr->angle = parse_input_angle_90s(input_line_fields[3]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
152 if (padptr->angle != 0 && padptr->angle != 90) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
153 printf("line %d: unsupported OF/RF angle\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
154 input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
155 return;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
156 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
157 padptr->long_dim = convert_input_dim(input_line_fields[4]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
158 if (strcmp(input_line_fields[5], "0")) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
159 printf("line %d: unsupported nonzero finoffset\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
160 input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
161 return;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
162 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
163 if (padptr->long_dim <= padptr->short_dim) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
164 printf("line %d: OF/RF long dim <= short dim\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
165 input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
166 return;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
167 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
168 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
169 padptr->valid = 1;
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
170 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
171
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
172 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
173 one_padstack_def()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
174 {
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
175 int pinno, stacklines, i;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
176 struct pad_shape_info *padptr;
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
177
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
178 get_line_internal();
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
179 parse_input_line_fields();
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
180 if (input_line_nfields != 3 || strcmp(input_line_fields[0], "PAD")) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
181 fprintf(stderr, "%s line %d: expected PAD header line\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
182 input_filename, input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
183 exit(1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
184 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
185 pinno = atoi(input_line_fields[1]);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
186 stacklines = atoi(input_line_fields[2]);
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
187
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
188 if (pinno < 0 || pinno > fpbody.npins) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
189 fprintf(stderr, "%s line %d: PAD pinno field invalid\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
190 input_filename, input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
191 exit(1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
192 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
193 if (pinno)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
194 padptr = &pins_array[pinno-1].shape;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
195 else
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
196 padptr = &fpbody.default_pad;
43
4a50888d09ce pads2gpcb: handle error cases when the default pad is defined, but failed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 41
diff changeset
197 padptr->defined = 1;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
198
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
199 for (i = 0; i < stacklines; i++) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
200 get_line_internal();
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
201 parse_input_line_fields();
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
202 if (input_line_nfields < 3) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
203 fprintf(stderr,
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
204 "%s line %d: too few fields in pad stack line\n",
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
205 input_filename, input_lineno);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
206 exit(1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
207 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
208 if (!strcmp(input_line_fields[0], "-2"))
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
209 process_pad_shape(padptr);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
210 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
211 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
212
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
213 static void
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
214 apply_default_padstack()
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
215 {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
216 int i;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
217
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
218 if (!fpbody.default_pad.valid)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
219 return;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
220 for (i = 0; i < fpbody.npins; i++)
43
4a50888d09ce pads2gpcb: handle error cases when the default pad is defined, but failed
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 41
diff changeset
221 if (!pins_array[i].shape.defined)
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
222 pins_array[i].shape = fpbody.default_pad;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
223 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
224
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
225 static
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
226 convert_pad_to_gpcb(pinidx)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
227 {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
228 struct footprint_pad *pin = pins_array + pinidx;
44
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
229 long long_minus_short, delta;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
230
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
231 if (!pin->shape.valid) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
232 printf("error: no pad shape for pin #%d\n", pinidx + 1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
233 return(-1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
234 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
235 pin->thickness = pin->shape.short_dim;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
236 pin->clearance = CLEARANCE_SETTING;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
237 pin->mask = pin->thickness + SOLDERMASK_DELTA;
44
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
238 pin->x2 = pin->x1;
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
239 pin->y2 = pin->y1;
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
240 if (!pin->shape.elongated)
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
241 return(0);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
242 long_minus_short = pin->shape.long_dim - pin->shape.short_dim;
44
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
243 delta = long_minus_short / 2;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
244 switch (pin->shape.angle) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
245 case 0:
44
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
246 pin->x1 -= delta;
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
247 pin->x2 += delta;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
248 return(0);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
249 case 90:
44
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
250 pin->y1 -= delta;
bf1be6c97c28 pads2gpcb: fixed conversion of elongated pads
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 43
diff changeset
251 pin->y2 += delta;
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
252 return(0);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
253 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
254 return(-1);
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
255 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
256
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
257 static void
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
258 process_one_decal()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
259 {
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
260 int num_drawing_pieces, num_padstack_defs;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
261 int num_text_items, num_attr_labels;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
262 int i, valid;
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
263
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
264 if (input_line_nfields < 7 || input_line_nfields > 9) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
265 fprintf(stderr,
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
266 "%s line %d: expected beginning of part decal definition, wrong # of fields\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
267 input_filename, input_lineno);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
268 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
269 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
270 enter_decal();
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
271 printf("Processing decal %s\n", current_decal->name);
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
272 bzero(&fpbody, sizeof fpbody);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
273 if (input_line_fields[1][0] != 'I' && input_line_fields[1][0] != 'M'
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
274 || input_line_fields[1][1]) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
275 fprintf(stderr, "%s line %d: expected 'I' or 'M' in field 1\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
276 input_filename, input_lineno);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
277 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
278 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
279 fpbody.src_units = input_line_fields[1][0];
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
280 if (input_units_global == 'B')
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
281 input_units_current = 'B';
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
282 else
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
283 input_units_current = fpbody.src_units;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
284 fpbody.mark_x = convert_input_dim(input_line_fields[2]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
285 fpbody.mark_y = -convert_input_dim(input_line_fields[3]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
286 num_drawing_pieces = atoi(input_line_fields[4]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
287 fpbody.npins = atoi(input_line_fields[5]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
288 num_padstack_defs = atoi(input_line_fields[6]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
289 if (input_line_nfields > 7)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
290 num_text_items = atoi(input_line_fields[7]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
291 else
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
292 num_text_items = 0;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
293 if (input_line_nfields > 8)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
294 num_attr_labels = atoi(input_line_fields[8]);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
295 else
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
296 num_attr_labels = 0;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
297
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
298 /* sanity checks */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
299 if (fpbody.npins < 1) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
300 fprintf(stderr, "%s line %d: # of terminals %d < 1\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
301 input_filename, input_lineno, fpbody.npins);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
302 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
303 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
304 if (num_padstack_defs < 1) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
305 fprintf(stderr, "%s line %d: # of pad stack defs %d < 1\n",
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
306 input_filename, input_lineno, num_padstack_defs);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
307 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
308 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
309
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
310 /* done parsing the header line, initialize some misc */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
311 fpbody.refdes_scale = 100;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
312
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
313 /* read and process the miscellany */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
314 for (i = 0; i < num_drawing_pieces; i++)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
315 one_drawing_piece();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
316 for (i = 0; i < num_text_items; i++)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
317 one_text_item();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
318 for (i = 0; i < num_attr_labels; i++)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
319 one_attr_label();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
320
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
321 /* the meat: allocate and fill the pins array */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
322 pins_array = malloc(sizeof(struct footprint_pad) * fpbody.npins);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
323 if (!pins_array) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
324 perror("malloc of the pins array");
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
325 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
326 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
327 fpbody.pins = pins_array;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
328 bzero(pins_array, sizeof(struct footprint_pad) * fpbody.npins);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
329 for (i = 0; i < fpbody.npins; i++)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
330 read_pindef_line(i);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
331 /* read and process the pad stack definitions */
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
332 for (i = 0; i < num_padstack_defs; i++)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
333 one_padstack_def();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
334
41
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
335 /* post-processing */
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
336 apply_default_padstack();
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
337 valid = 1;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
338 for (i = 0; i < fpbody.npins; i++)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
339 if (convert_pad_to_gpcb(i) < 0)
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
340 valid = 0;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
341 if (valid) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
342 /* good, save it */
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
343 current_decal->body = malloc(sizeof(struct footprint_body));
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
344 if (!current_decal->body) {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
345 perror("malloc to save footprint body");
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
346 exit(1);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
347 }
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
348 *current_decal->body = fpbody;
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
349 /* optional file output will go here */
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
350 } else {
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
351 printf("decal to gpcb fp conversion FAILED\n");
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
352 free(pins_array);
a2d304ec3817 pads2gpcb: decal processing code compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 40
diff changeset
353 }
40
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
354 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
355
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
356 process_partdecal_section()
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
357 {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
358 for (;;) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
359 if (!get_input_line()) {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
360 fprintf(stderr, "error: EOF in PARTDECAL section\n");
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
361 exit(1);
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
362 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
363 if (input_line_buf[0] == '*') {
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
364 parse_starline();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
365 if (strcmp(input_line_starkw, "REMARK"))
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
366 break;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
367 else
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
368 continue;
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
369 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
370 parse_input_line_fields();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
371 if (input_line_nfields)
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
372 process_one_decal();
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
373 }
1c37bec20596 pads2gpcb: slowly working on the decal processing logic
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
374 }