KiCad PCB EDA Suite
altium_parser_pcb.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Thomas Pointhuber <thomas.pointhuber@gmx.at>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef ALTIUM_PARSER_PCB_H
25 #define ALTIUM_PARSER_PCB_H
26 
27 #include <cstdint>
28 #include <cstring>
29 #include <memory>
30 #include <vector>
31 
32 #include <class_module.h>
33 #include <wx/gdicmn.h>
34 
35 // tthis constant specifies an unconnected net
36 const uint16_t ALTIUM_NET_UNCONNECTED = std::numeric_limits<uint16_t>::max();
37 
38 // this constant specifies a item which is not inside an component
39 const uint16_t ALTIUM_COMPONENT_NONE = std::numeric_limits<uint16_t>::max();
40 
41 // this constant specifies a item which does not define a polygon
42 const uint16_t ALTIUM_POLYGON_NONE = std::numeric_limits<uint16_t>::max();
43 
44 
45 enum class ALTIUM_UNIT
46 {
47  UNKNOWN = 0,
48 
49  INCHES = 1,
50  MILS = 2,
51  MILLIMETERS = 3,
52  CENTIMETER = 4
53 };
54 
56 {
57  UNKNOWN = -1,
58 
59  NET_CLASS = 0,
61  FROM_TO = 2,
62  PAD_CLASS = 3,
63  LAYER_CLASS = 4,
64  UNKNOWN_CLASS = 5,
65  DIFF_PAIR_CLASS = 6,
66  POLYGON_CLASS = 7
67 };
68 
70 {
71  UNKNOWN = 0,
72 
73  LINEAR = 1,
74  ANGULAR = 2,
75  RADIAL = 3,
76  LEADER = 4,
77  DATUM = 5,
78  BASELINE = 6,
79  CENTER = 7,
80  LINEAR_DIAMETER = 8,
81  RADIAL_DIAMETER = 9
82 };
83 
85 {
86  UNKNOWN = -1,
87 
88  COPPER = 0, // KIND=0
89  POLYGON_CUTOUT = 1, // KIND=1
90  BOARD_CUTOUT = 2, // KIND=0 AND ISBOARDCUTOUT=TRUE
91  CAVITY_DEFINITION = 3, // KIND=4
92 };
93 
94 enum class ALTIUM_RULE_KIND
95 {
96  UNKNOWN = 0,
97 
98  CLEARANCE = 1,
100  HEIGHT = 3,
101  HOLE_SIZE = 4,
103  WIDTH = 6,
105  PLANE_CLEARANCE = 8,
106  POLYGON_CONNECT = 9,
107 };
108 
110 {
111  UNKNOWN = 0,
112  DIRECT = 1,
113  RELIEF = 2,
114  NONE = 3
115 };
116 
117 enum class ALTIUM_RECORD
118 {
119  ARC = 1,
120  PAD = 2,
121  VIA = 3,
122  TRACK = 4,
123  TEXT = 5,
124  FILL = 6,
125  REGION = 11,
126  MODEL = 12
127 };
128 
130 {
131  UNKNOWN = 0,
132  CIRCLE = 1,
133  RECT = 2,
134  OCTAGONAL = 3
135 };
136 
138 {
139  UNKNOWN = 0,
140  CIRCLE = 1,
141  RECT = 2, // TODO: valid?
142  OCTAGONAL = 3, // TODO: valid?
143  ROUNDRECT = 9
144 };
145 
147 {
148  UNKNOWN = -1,
149  ROUND = 0,
150  SQUARE = 1,
151  SLOT = 2
152 };
153 
154 enum class ALTIUM_PAD_MODE
155 {
156  SIMPLE = 0,
157  TOP_MIDDLE_BOTTOM = 1,
158  FULL_STACK = 2
159 };
160 
161 enum class ALTIUM_PAD_RULE
162 {
163  UNKNOWN = 0,
164  RULE = 1,
165  MANUAL = 2
166 };
167 
169 {
170  UNKNOWN = 0,
171 
172  SOLID = 1,
173  DEGREE_45 = 2,
174  DEGREE_90 = 3,
175  HORIZONTAL = 4,
176  VERTICAL = 5,
177  NONE = 6
178 };
179 
181 {
182  MANUAL = 0, // only relevant for NAMEAUTOPOSITION and COMMENTAUTOPOSITION
183  LEFT_TOP = 1,
184  LEFT_CENTER = 2,
185  LEFT_BOTTOM = 3,
186  CENTER_TOP = 4,
187  CENTER_CENTER = 5,
188  CENTER_BOTTOM = 6,
189  RIGHT_TOP = 7,
190  RIGHT_CENTER = 8,
191  RIGHT_BOTTOM = 9
192 };
193 
195 {
196  UNKNOWN = -1,
197 
198  STROKE = 0,
199  TRUETYPE = 1,
200  BARCODE = 2
201 };
202 
204 {
205  const bool isRound;
206  const int32_t radius;
207  const double startangle;
208  const double endangle;
211 
212  explicit ALTIUM_VERTICE( const wxPoint aPosition )
213  : isRound( false ),
214  radius( 0 ),
215  startangle( 0. ),
216  endangle( 0. ),
217  position( aPosition ),
218  center( wxPoint( 0, 0 ) )
219  {
220  }
221 
222  explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
223  const wxPoint aPosition, const wxPoint aCenter )
224  : isRound( aIsRound ),
225  radius( aRadius ),
226  startangle( aStartAngle ),
227  endangle( aEndAngle ),
228  position( aPosition ),
229  center( aCenter )
230  {
231  }
232 };
233 
234 enum class ALTIUM_LAYER
235 {
236  UNKNOWN = 0,
237 
238  TOP_LAYER = 1,
239  MID_LAYER_1 = 2,
240  MID_LAYER_2 = 3,
241  MID_LAYER_3 = 4,
242  MID_LAYER_4 = 5,
243  MID_LAYER_5 = 6,
244  MID_LAYER_6 = 7,
245  MID_LAYER_7 = 8,
246  MID_LAYER_8 = 9,
247  MID_LAYER_9 = 10,
248  MID_LAYER_10 = 11,
249  MID_LAYER_11 = 12,
250  MID_LAYER_12 = 13,
251  MID_LAYER_13 = 14,
252  MID_LAYER_14 = 15,
253  MID_LAYER_15 = 16,
254  MID_LAYER_16 = 17,
255  MID_LAYER_17 = 18,
256  MID_LAYER_18 = 19,
257  MID_LAYER_19 = 20,
258  MID_LAYER_20 = 21,
259  MID_LAYER_21 = 22,
260  MID_LAYER_22 = 23,
261  MID_LAYER_23 = 24,
262  MID_LAYER_24 = 25,
263  MID_LAYER_25 = 26,
264  MID_LAYER_26 = 27,
265  MID_LAYER_27 = 28,
266  MID_LAYER_28 = 29,
267  MID_LAYER_29 = 30,
268  MID_LAYER_30 = 31,
269  BOTTOM_LAYER = 32,
270 
271  TOP_OVERLAY = 33,
272  BOTTOM_OVERLAY = 34,
273  TOP_PASTE = 35,
274  BOTTOM_PASTE = 36,
275  TOP_SOLDER = 37,
276  BOTTOM_SOLDER = 38,
277 
278  INTERNAL_PLANE_1 = 39,
279  INTERNAL_PLANE_2 = 40,
280  INTERNAL_PLANE_3 = 41,
281  INTERNAL_PLANE_4 = 42,
282  INTERNAL_PLANE_5 = 43,
283  INTERNAL_PLANE_6 = 44,
284  INTERNAL_PLANE_7 = 45,
285  INTERNAL_PLANE_8 = 46,
286  INTERNAL_PLANE_9 = 47,
287  INTERNAL_PLANE_10 = 48,
288  INTERNAL_PLANE_11 = 49,
289  INTERNAL_PLANE_12 = 50,
290  INTERNAL_PLANE_13 = 51,
291  INTERNAL_PLANE_14 = 52,
292  INTERNAL_PLANE_15 = 53,
293  INTERNAL_PLANE_16 = 54,
294 
295  DRILL_GUIDE = 55,
296  KEEP_OUT_LAYER = 56,
297 
298  MECHANICAL_1 = 57,
299  MECHANICAL_2 = 58,
300  MECHANICAL_3 = 59,
301  MECHANICAL_4 = 60,
302  MECHANICAL_5 = 61,
303  MECHANICAL_6 = 62,
304  MECHANICAL_7 = 63,
305  MECHANICAL_8 = 64,
306  MECHANICAL_9 = 65,
307  MECHANICAL_10 = 66,
308  MECHANICAL_11 = 67,
309  MECHANICAL_12 = 68,
310  MECHANICAL_13 = 69,
311  MECHANICAL_14 = 70,
312  MECHANICAL_15 = 71,
313  MECHANICAL_16 = 72,
314 
315  DRILL_DRAWING = 73,
316  MULTI_LAYER = 74,
317  CONNECTIONS = 75,
318  BACKGROUND = 76,
319  DRC_ERROR_MARKERS = 77,
320  SELECTIONS = 78,
321  VISIBLE_GRID_1 = 79,
322  VISIBLE_GRID_2 = 80,
323  PAD_HOLES = 81,
324  VIA_HOLES = 82,
325 };
326 
327 class ALTIUM_PARSER;
328 
330 {
331  wxString name;
332 
333  size_t nextId;
334  size_t prevId;
335 
336  int32_t copperthick;
337 
341 };
342 
343 struct ABOARD6
344 {
346  wxSize sheetsize;
347 
349  std::vector<ABOARD6_LAYER_STACKUP> stackup;
350 
351  std::vector<ALTIUM_VERTICE> board_vertices;
352 
353  explicit ABOARD6( ALTIUM_PARSER& aReader );
354 };
355 
356 struct ACLASS6
357 {
358  wxString name;
359  wxString uniqueid;
360 
362 
363  std::vector<wxString> names;
364 
365  explicit ACLASS6( ALTIUM_PARSER& aReader );
366 };
367 
369 {
372  double rotation;
373  bool locked;
374  bool nameon;
375  bool commenton;
380 
383 
384  explicit ACOMPONENT6( ALTIUM_PARSER& aReader );
385 };
386 
388 {
391 
392  wxString textformat;
393 
394  int32_t height;
395  double angle;
396 
397  uint32_t linewidth;
398  uint32_t textheight;
399  uint32_t textlinewidth;
400  int32_t textprecission;
401  bool textbold;
403 
404  int32_t arrowsize;
405 
407 
409 
410  std::vector<wxPoint> referencePoint;
411  std::vector<wxPoint> textPoint;
412 
413  explicit ADIMENSION6( ALTIUM_PARSER& aReader );
414 };
415 
416 struct AMODEL
417 {
418  wxString name;
419  wxString id;
421 
423 
424  explicit AMODEL( ALTIUM_PARSER& aReader );
425 };
426 
427 struct ANET6
428 {
429  wxString name;
430 
431  explicit ANET6( ALTIUM_PARSER& aReader );
432 };
433 
434 struct APOLYGON6
435 {
437  uint16_t net;
438  bool locked;
439 
441 
442  int32_t gridsize;
443  int32_t trackwidth;
444  int32_t minprimlength;
446 
447  // Note: Altium pour index is the opposite of KiCad zone priority!
448  int32_t pourindex;
449 
450  std::vector<ALTIUM_VERTICE> vertices;
451 
452  explicit APOLYGON6( ALTIUM_PARSER& aReader );
453 };
454 
455 
456 struct ARULE6
457 {
458  wxString name;
459  int priority;
460 
462 
463  wxString scope1expr;
464  wxString scope2expr;
465 
466  // ALTIUM_RULE_KIND::CLEARANCE
468 
469  // ALTIUM_RULE_KIND::PLANE_CLEARANCE
471 
472  // ALTIUM_RULE_KIND::POLYGON_CONNECT
477 
478  // TODO: implement different types of rules we need to parse
479 
480  explicit ARULE6( ALTIUM_PARSER& aReader );
481 };
482 
483 struct AREGION6
484 {
485  bool is_locked;
487 
489 
491  uint16_t net;
492  uint16_t component;
493  uint16_t subpolyindex;
494 
495  ALTIUM_REGION_KIND kind; // I asume this means if normal or keepout?
496 
497  std::vector<ALTIUM_VERTICE> vertices;
498 
499  explicit AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices );
500 };
501 
502 struct AARC6
503 {
504  bool is_locked;
507 
509  uint16_t net;
510  uint16_t component;
511  uint16_t subpolyindex;
512 
514  uint32_t radius;
515  double startangle;
516  double endangle;
517  uint32_t width;
518 
519  explicit AARC6( ALTIUM_PARSER& aReader );
520 };
521 
523 {
524  uint16_t component;
525 
526  wxString modelName;
527  wxString modelId;
529 
532  double rotation;
533  double bodyOpacity;
534 
535  explicit ACOMPONENTBODY6( ALTIUM_PARSER& aReader );
536 };
537 
539 {
541  uint32_t slotsize;
542  double slotrotation;
543 
544  wxSize inner_size[29];
548  uint8_t cornerradius[32];
549 };
550 
551 struct APAD6
552 {
553  bool is_locked;
558 
559  wxString name;
560 
562  uint16_t net;
563  uint16_t component;
564 
566  wxSize topsize;
567  wxSize midsize;
568  wxSize botsize;
569  uint32_t holesize;
570 
574 
576 
577  double direction;
578  bool plated;
583  double holerotation;
584 
587 
588  std::unique_ptr<APAD6_SIZE_AND_SHAPE> sizeAndShape;
589 
590  explicit APAD6( ALTIUM_PARSER& aReader );
591 };
592 
593 struct AVIA6
594 {
595  bool is_locked;
600 
601  uint16_t net;
602 
604  uint32_t diameter;
605  uint32_t holesize;
606 
610 
611  explicit AVIA6( ALTIUM_PARSER& aReader );
612 };
613 
614 struct ATRACK6
615 {
616  bool is_locked;
619 
621  uint16_t net;
622  uint16_t component;
623  uint16_t subpolyindex;
624 
627  uint32_t width;
628 
629  explicit ATRACK6( ALTIUM_PARSER& aReader );
630 };
631 
632 struct ATEXT6
633 {
635  uint16_t component;
636 
638  uint32_t height;
639  double rotation;
640  uint32_t strokewidth;
642 
643  bool isBold;
644  bool isItalic;
647 
648  bool isComment;
650 
652 
653  wxString text;
654 
655  explicit ATEXT6( ALTIUM_PARSER& aReader );
656 };
657 
658 struct AFILL6
659 {
660  bool is_locked;
662 
664  uint16_t component;
665  uint16_t net;
666 
669  double rotation;
670 
671  explicit AFILL6( ALTIUM_PARSER& aReader );
672 };
673 
674 
675 #endif //ALTIUM_PARSER_PCB_H
AREGION6(ALTIUM_PARSER &aReader, bool aExtendedVertices)
ADIMENSION6(ALTIUM_PARSER &aReader)
Text placement is manually set by the user.
uint32_t textlinewidth
uint32_t linewidth
ALTIUM_LAYER tolayer
int32_t soldermaskexpansionmanual
ALTIUM_RULE_KIND kind
double rotation
uint32_t holesize
uint32_t width
std::vector< ALTIUM_VERTICE > vertices
int planeclearanceClearance
wxString name
bool isDesignator
bool is_locked
ALTIUM_TEXT_POSITION nameautoposition
ALTIUM_PAD_SHAPE topshape
wxPoint pos1
ALTIUM_LAYER layer
ALTIUM_DIMENSION_KIND
AMODEL(ALTIUM_PARSER &aReader)
wxPoint start
wxSize topsize
ALTIUM_LAYER layer
ALTIUM_DIMENSION_KIND kind
int32_t textprecission
ARULE6(ALTIUM_PARSER &aReader)
ALTIUM_REGION_KIND kind
wxPoint position
double startangle
uint16_t component
bool is_test_fab_bottom
ALTIUM_TEXT_TYPE
ALTIUM_POLYGON_HATCHSTYLE
int32_t polygonconnectAirgapwidth
wxPoint center
ALTIUM_LAYER layer
wxString sourcedesignator
const uint16_t ALTIUM_POLYGON_NONE
ALTIUM_LAYER layer
ALTIUM_RECORD
ALTIUM_LAYER layer_end
ALTIUM_PAD_SHAPE
ALTIUM_PAD_RULE soldermaskexpansionmode
ALTIUM_PAD_HOLE_SHAPE
ALTIUM_REGION_KIND
ALTIUM_LAYER layer
MODULE_3D_SETTINGS::VECTOR3D modelRotation
uint16_t net
wxString sourcefootprintlibrary
AVIA6(ALTIUM_PARSER &aReader)
const double startangle
wxString name
MODULE_3D_SETTINGS::VECTOR3D modelPosition
wxString sourcelibreference
wxString text
wxSize sheetsize
wxString scope2expr
bool is_tent_bottom
bool is_polygonoutline
ATEXT6(ALTIUM_PARSER &aReader)
uint32_t height
ALTIUM_PAD_SHAPE_ALT
ALTIUM_CONNECT_STYLE polygonconnectStyle
MODULE_3D_SETTINGS::VECTOR3D rotation
ALTIUM_PAD_SHAPE_ALT alt_shape[32]
std::vector< wxString > names
int32_t trackwidth
std::vector< wxPoint > textPoint
wxString textformat
wxString sourcecomponentlibrary
uint16_t subpolyindex
uint16_t net
ALTIUM_CLASS_KIND
APAD6(ALTIUM_PARSER &aReader)
ALTIUM_VERTICE(bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle, const wxPoint aPosition, const wxPoint aCenter)
wxSize botsize
ALTIUM_PAD_RULE pastemaskexpansionmode
wxPoint position
uint16_t subpolyindex
double direction
ALTIUM_RULE_KIND
double endangle
wxString id
const wxPoint position
A leader is a dimension-like object pointing to a specific point.
ALTIUM_CLASS_KIND kind
ALTIUM_LAYER layer
const uint16_t ALTIUM_NET_UNCONNECTED
wxSize midsize
ALTIUM_PAD_MODE
wxString name
uint16_t component
ALTIUM_PAD_SHAPE inner_shape[29]
uint32_t holesize
bool is_test_fab_top
ACOMPONENTBODY6(ALTIUM_PARSER &aReader)
wxPoint sheetpos
ALTIUM_VERTICE(const wxPoint aPosition)
ABOARD6(ALTIUM_PARSER &aReader)
const int32_t radius
uint16_t net
bool is_test_fab_bottom
bool is_keepout
const wxPoint center
ALTIUM_UNIT
bool is_locked
double rotation
bool is_polygonoutline
AFILL6(ALTIUM_PARSER &aReader)
bool is_tent_bottom
uint16_t subpolyindex
ACLASS6(ALTIUM_PARSER &aReader)
wxString uniqueid
ALTIUM_PAD_SHAPE botshape
std::vector< ALTIUM_VERTICE > vertices
ANET6(ALTIUM_PARSER &aReader)
uint32_t width
ALTIUM_TEXT_POSITION textposition
ALTIUM_LAYER layer
uint16_t net
ALTIUM_LAYER layer_start
bool is_test_fab_top
ALTIUM_CONNECT_STYLE
ALTIUM_PAD_HOLE_SHAPE holeshape
bool is_tent_top
ATRACK6(ALTIUM_PARSER &aReader)
uint32_t radius
wxPoint position
ALTIUM_PAD_MODE viamode
int32_t pastemaskexpansionmanual
wxString name
APOLYGON6(ALTIUM_PARSER &aReader)
ALTIUM_TEXT_POSITION
uint16_t net
uint16_t component
ALTIUM_LAYER
ALTIUM_PAD_MODE padmode
ALTIUM_LAYER layer
std::unique_ptr< APAD6_SIZE_AND_SHAPE > sizeAndShape
const double endangle
uint16_t component
std::vector< ALTIUM_VERTICE > board_vertices
ALTIUM_UNIT textunit
ALTIUM_LAYER layer
ALTIUM_TEXT_POSITION commentautoposition
uint16_t component
ALTIUM_PAD_SHAPE midshape
std::vector< wxPoint > referencePoint
std::vector< ABOARD6_LAYER_STACKUP > stackup
uint32_t strokewidth
const uint16_t ALTIUM_COMPONENT_NONE
bool is_tent_top
int32_t minprimlength
int32_t gridsize
ACOMPONENT6(ALTIUM_PARSER &aReader)
uint32_t textheight
ALTIUM_PAD_RULE
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
uint16_t component
ALTIUM_TEXT_TYPE fonttype
wxPoint pos2
uint32_t diameter
AARC6(ALTIUM_PARSER &aReader)
double holerotation
bool is_locked
ALTIUM_LAYER fromlayer
wxString name
uint16_t net
wxString scope1expr
int32_t polygonconnectReliefconductorwidth
int32_t pourindex
int polygonconnectReliefentries