KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
5 * Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef ALTIUM_PARSER_PCB_H
26#define ALTIUM_PARSER_PCB_H
27
28#include <cstdint>
29#include <cstring>
30#include <memory>
31#include <vector>
32
33#include <footprint.h>
34#include <wx/gdicmn.h>
35
36// tthis constant specifies an unconnected net
37const uint16_t ALTIUM_NET_UNCONNECTED = std::numeric_limits<uint16_t>::max();
38
39// this constant specifies a item which is not inside an component
40const uint16_t ALTIUM_COMPONENT_NONE = std::numeric_limits<uint16_t>::max();
41
42// this constant specifies a item which does not define a polygon
43const uint16_t ALTIUM_POLYGON_NONE = std::numeric_limits<uint16_t>::max();
44
45// 65534 seems to be belonging to board outline
46const uint16_t ALTIUM_POLYGON_BOARD = std::numeric_limits<uint16_t>::max() - 1;
47
48
49enum class ALTIUM_UNIT
50{
51 UNKNOWN = 0,
52
53 INCHES = 1,
54 MILS = 2,
55 MILLIMETERS = 3,
56 CENTIMETER = 4
57};
58
60{
61 UNKNOWN = -1,
62
63 NET_CLASS = 0,
65 FROM_TO = 2,
66 PAD_CLASS = 3,
67 LAYER_CLASS = 4,
68 UNKNOWN_CLASS = 5,
71};
72
74{
75 UNKNOWN = 0,
76
77 LINEAR = 1,
78 ANGULAR = 2,
79 RADIAL = 3,
80 LEADER = 4,
81 DATUM = 5,
82 BASELINE = 6,
83 CENTER = 7,
84 UNKNOWN_2 = 8,
87};
88
90{
91 UNKNOWN = -1,
92
93 COPPER = 0, // KIND=0
94 POLYGON_CUTOUT = 1, // KIND=1
95 DASHED_OUTLINE = 2, // KIND=2
96 UNKNOWN_3 = 3, // KIND=3
97 CAVITY_DEFINITION = 4, // KIND=4
98 BOARD_CUTOUT = 5, // KIND=0 AND ISBOARDCUTOUT=TRUE
99};
100
102{
103 UNKNOWN = 0,
104
105 CLEARANCE = 1,
107 HEIGHT = 3,
108 HOLE_SIZE = 4,
110 WIDTH = 6,
113 PLANE_CLEARANCE = 9,
114 POLYGON_CONNECT = 10,
115 ROUTING_VIAS = 11
116};
117
119{
120 UNKNOWN = 0,
121 DIRECT = 1,
122 RELIEF = 2,
123 NONE = 3
124};
125
127{
128 UNKNOWN = -1,
129
130 ARC = 1,
131 PAD = 2,
132 VIA = 3,
133 TRACK = 4,
134 TEXT = 5,
135 FILL = 6,
136 REGION = 11,
137 MODEL = 12
138};
139
141{
142 UNKNOWN = 0,
143 CIRCLE = 1,
144 RECT = 2,
145 OCTAGONAL = 3
146};
147
149{
150 UNKNOWN = 0,
151 CIRCLE = 1,
152 RECT = 2, // TODO: valid?
153 OCTAGONAL = 3, // TODO: valid?
154 ROUNDRECT = 9
155};
156
158{
159 UNKNOWN = -1,
160 ROUND = 0,
161 SQUARE = 1,
162 SLOT = 2
163};
164
166{
167 SIMPLE = 0,
169 FULL_STACK = 2
170};
171
172enum class ALTIUM_MODE
173{
174 UNKNOWN = -1,
175 NONE = 0, // TODO: correct ID?
176 RULE = 1,
177 MANUAL = 2
178};
179
181{
182 UNKNOWN = 0,
183
184 SOLID = 1,
185 DEGREE_45 = 2,
186 DEGREE_90 = 3,
187 HORIZONTAL = 4,
188 VERTICAL = 5,
189 NONE = 6
190};
191
193{
194 MANUAL = 0, // only relevant for NAMEAUTOPOSITION and COMMENTAUTOPOSITION
195 LEFT_TOP = 1,
196 LEFT_CENTER = 2,
197 LEFT_BOTTOM = 3,
198 CENTER_TOP = 4,
199 CENTER_CENTER = 5,
200 CENTER_BOTTOM = 6,
201 RIGHT_TOP = 7,
202 RIGHT_CENTER = 8,
203 RIGHT_BOTTOM = 9
204};
205
207{
208 UNKNOWN = -1,
209
210 STROKE = 0,
211 TRUETYPE = 1,
212 BARCODE = 2
213};
214
216{
217 const bool isRound;
218 const int32_t radius;
219 const double startangle;
220 const double endangle;
223
224 explicit ALTIUM_VERTICE( const VECTOR2I& aPosition )
225 : isRound( false ),
226 radius( 0 ),
227 startangle( 0. ),
228 endangle( 0. ),
229 position( aPosition ),
230 center( VECTOR2I( 0, 0 ) )
231 {
232 }
233
234 explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
235 const VECTOR2I aPosition, const VECTOR2I aCenter )
236 : isRound( aIsRound ),
237 radius( aRadius ),
238 startangle( aStartAngle ),
239 endangle( aEndAngle ),
240 position( aPosition ),
241 center( aCenter )
242 {
243 }
244};
245
246enum class ALTIUM_LAYER
247{
248 UNKNOWN = 0,
249
250 TOP_LAYER = 1,
251 MID_LAYER_1 = 2,
252 MID_LAYER_2 = 3,
253 MID_LAYER_3 = 4,
254 MID_LAYER_4 = 5,
255 MID_LAYER_5 = 6,
256 MID_LAYER_6 = 7,
257 MID_LAYER_7 = 8,
258 MID_LAYER_8 = 9,
259 MID_LAYER_9 = 10,
260 MID_LAYER_10 = 11,
261 MID_LAYER_11 = 12,
262 MID_LAYER_12 = 13,
263 MID_LAYER_13 = 14,
264 MID_LAYER_14 = 15,
265 MID_LAYER_15 = 16,
266 MID_LAYER_16 = 17,
267 MID_LAYER_17 = 18,
268 MID_LAYER_18 = 19,
269 MID_LAYER_19 = 20,
270 MID_LAYER_20 = 21,
271 MID_LAYER_21 = 22,
272 MID_LAYER_22 = 23,
273 MID_LAYER_23 = 24,
274 MID_LAYER_24 = 25,
275 MID_LAYER_25 = 26,
276 MID_LAYER_26 = 27,
277 MID_LAYER_27 = 28,
278 MID_LAYER_28 = 29,
279 MID_LAYER_29 = 30,
280 MID_LAYER_30 = 31,
281 BOTTOM_LAYER = 32,
282
283 TOP_OVERLAY = 33,
284 BOTTOM_OVERLAY = 34,
285 TOP_PASTE = 35,
286 BOTTOM_PASTE = 36,
287 TOP_SOLDER = 37,
288 BOTTOM_SOLDER = 38,
289
290 INTERNAL_PLANE_1 = 39,
291 INTERNAL_PLANE_2 = 40,
292 INTERNAL_PLANE_3 = 41,
293 INTERNAL_PLANE_4 = 42,
294 INTERNAL_PLANE_5 = 43,
295 INTERNAL_PLANE_6 = 44,
296 INTERNAL_PLANE_7 = 45,
297 INTERNAL_PLANE_8 = 46,
298 INTERNAL_PLANE_9 = 47,
306
307 DRILL_GUIDE = 55,
308 KEEP_OUT_LAYER = 56,
309
310 MECHANICAL_1 = 57,
311 MECHANICAL_2 = 58,
312 MECHANICAL_3 = 59,
313 MECHANICAL_4 = 60,
314 MECHANICAL_5 = 61,
315 MECHANICAL_6 = 62,
316 MECHANICAL_7 = 63,
317 MECHANICAL_8 = 64,
318 MECHANICAL_9 = 65,
319 MECHANICAL_10 = 66,
320 MECHANICAL_11 = 67,
321 MECHANICAL_12 = 68,
322 MECHANICAL_13 = 69,
323 MECHANICAL_14 = 70,
324 MECHANICAL_15 = 71,
325 MECHANICAL_16 = 72,
326
327 DRILL_DRAWING = 73,
328 MULTI_LAYER = 74,
329 CONNECTIONS = 75,
330 BACKGROUND = 76,
332 SELECTIONS = 78,
333 VISIBLE_GRID_1 = 79,
334 VISIBLE_GRID_2 = 80,
335 PAD_HOLES = 81,
336 VIA_HOLES = 82,
337};
338
340
342{
343 UNKNOWN = -1,
344
345 MASK
346};
347
349{
352
354
355 // Type == Mask
360
362};
363
365{
366 wxString name;
367
368 size_t nextId;
369 size_t prevId;
370
371 int32_t copperthick;
372
376};
377
379{
381 wxSize sheetsize;
382
384 std::vector<ABOARD6_LAYER_STACKUP> stackup;
385 std::set<wxString> layerNames;
386
387 std::vector<ALTIUM_VERTICE> board_vertices;
388
389 explicit ABOARD6( ALTIUM_BINARY_PARSER& aReader );
390};
391
393{
394 wxString name;
395 wxString uniqueid;
396
398
399 std::vector<wxString> names;
400
401 explicit ACLASS6( ALTIUM_BINARY_PARSER& aReader );
402};
403
405{
408 double rotation;
409 bool locked;
410 bool nameon;
414 wxString pattern;
417
420
421 explicit ACOMPONENT6( ALTIUM_BINARY_PARSER& aReader );
422};
423
425{
428
429 wxString textformat;
430 wxString textprefix;
431 wxString textsuffix;
432
433 int32_t height;
434 double angle;
435
436 uint32_t linewidth;
437 uint32_t textheight;
440 uint32_t textgap;
443
444 int32_t arrowsize;
445
447
449
450 std::vector<VECTOR2I> referencePoint;
451 std::vector<VECTOR2I> textPoint;
452
453 explicit ADIMENSION6( ALTIUM_BINARY_PARSER& aReader );
454};
455
456struct AMODEL
457{
458 wxString name;
459 wxString id;
461
463 double z_offset;
464 int32_t checksum;
465
466 explicit AMODEL( ALTIUM_BINARY_PARSER& aReader );
467};
468
469struct ANET6
470{
471 wxString name;
472
473 explicit ANET6( ALTIUM_BINARY_PARSER& aReader );
474};
475
477{
479 uint16_t net;
480 bool locked;
481
483
484 int32_t gridsize;
485 int32_t trackwidth;
488
489 // Note: Altium pour index is the opposite of KiCad zone priority!
490 int32_t pourindex;
491
492 std::vector<ALTIUM_VERTICE> vertices;
493
494 explicit APOLYGON6( ALTIUM_BINARY_PARSER& aReader );
495};
496
497
498struct ARULE6
499{
500 wxString name;
502
504
505 wxString scope1expr;
506 wxString scope2expr;
507
508 // ALTIUM_RULE_KIND::CLEARANCE
509 // ALTIUM_RULE_KIND::HOLE_TO_HOLE_CLEARANCE
511
512 // ALTIUM_RULE_KIND::WIDTH
513 // ALTIUM_RULE_KIND::HOLE_SIZE
516
517 // ALTIUM_RULE_KIND::WIDTH
519
520 // ALTIUM_RULE_KIND::ROUTING_VIAS
521 int width;
527
528 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
530
531 // ALTIUM_RULE_KIND::SOLDER_MASK_EXPANSION
533
534 // ALTIUM_RULE_KIND::PASTE_MASK_EXPANSION
536
537 // ALTIUM_RULE_KIND::POLYGON_CONNECT
542
543 // TODO: implement different types of rules we need to parse
544
545 explicit ARULE6( ALTIUM_BINARY_PARSER& aReader );
546};
547
549{
552
554
556 uint16_t net;
557 uint16_t component;
558 uint16_t polygon;
559 uint16_t subpolyindex;
561 uint16_t holecount;
562
563 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
564
565 std::vector<ALTIUM_VERTICE> outline;
566 std::vector<std::vector<ALTIUM_VERTICE>> holes;
567
568 explicit AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices );
569};
570
571struct AARC6
572{
576
578 uint16_t net;
579 uint16_t component;
580 uint16_t polygon;
581 uint16_t subpolyindex;
583
585 uint32_t radius;
587 double endangle;
588 uint32_t width;
589
590 explicit AARC6( ALTIUM_BINARY_PARSER& aReader );
591};
592
594{
595 uint16_t component;
596
597 wxString body_name;
598 int kind;
609 wxString identifier;
610 wxString texture;
616
617 wxString modelId;
620 wxString modelName;
624
627 double rotation;
628
629 explicit ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader );
630};
631
633{
635 uint32_t slotsize;
637
638 wxSize inner_size[29];
642 uint8_t cornerradius[32];
643};
644
645struct APAD6
646{
652
653 wxString name;
654
656 uint16_t net;
657 uint16_t component;
658
663 uint32_t holesize;
664
668
670
671 double direction;
672 bool plated;
678
681
682 std::unique_ptr<APAD6_SIZE_AND_SHAPE> sizeAndShape;
683
684 explicit APAD6( ALTIUM_BINARY_PARSER& aReader );
685};
686
687struct AVIA6
688{
694
695 uint16_t net;
696
698 uint32_t pos_tolerance; // 2147483640 is N/A
699 uint32_t neg_tolerance; // 2147483640 is N/A
700 uint32_t diameter;
701 uint32_t holesize;
702
706
711
715
716 // In PAD_MODE::SIMPLE, this is the same as the diameter
717 // In PAD_MODE::TOP_MIDDLE_BOTTOM, layer 0 is top, layer 1 is middle, layer 31 is bottom
718 // In PAD_MODE::FULL_STACK, layers correspond to the layer number
719 uint32_t diameter_by_layer[32];
720
721 explicit AVIA6( ALTIUM_BINARY_PARSER& aReader );
722};
723
725{
729
731 uint16_t net;
732 uint16_t component;
733 uint16_t polygon;
734 uint16_t subpolyindex;
736
739 uint32_t width;
740
741 explicit ATRACK6( ALTIUM_BINARY_PARSER& aReader );
742};
743
744struct ATEXT6
745{
747 {
748 DEFAULT = 1,
749 SANSSERIF = 2,
750 SERIF = 3
751 };
752
753
755 uint16_t component;
756
758 uint32_t height;
759 double rotation;
760 uint32_t strokewidth;
762
763 bool isBold;
771
776
777 // Justification only applies when there is a text box size specified
778 // Then, the text is justified within the box
780
782
785
787 wxString fontname;
788
789 wxString text;
790
791 explicit ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
792};
793
794struct AFILL6
795{
798
800 uint16_t component;
801 uint16_t net;
803
806 double rotation;
807
808 explicit AFILL6( ALTIUM_BINARY_PARSER& aReader );
809};
810
811
812#endif //ALTIUM_PARSER_PCB_H
ALTIUM_REGION_KIND
ALTIUM_PAD_SHAPE_ALT
ALTIUM_TEXT_POSITION
ALTIUM_CONNECT_STYLE
ALTIUM_POLYGON_HATCHSTYLE
ALTIUM_PAD_MODE
ALTIUM_UNIT
ALTIUM_TEXT_TYPE
ALTIUM_RULE_KIND
ALTIUM_PAD_SHAPE
ALTIUM_DIMENSION_KIND
ALTIUM_PAD_HOLE_SHAPE
const uint16_t ALTIUM_NET_UNCONNECTED
ALTIUM_CLASS_KIND
ALTIUM_MODE
const uint16_t ALTIUM_POLYGON_NONE
const uint16_t ALTIUM_COMPONENT_NONE
ALTIUM_LAYER
AEXTENDED_PRIMITIVE_INFORMATION_TYPE
const uint16_t ALTIUM_POLYGON_BOARD
ALTIUM_RECORD
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:33
Definition: pad.h:54
A round rectangle shape, based on a rectangle and a radius.
Definition: roundrect.h:36
double startangle
uint16_t component
bool is_keepout
uint32_t width
ALTIUM_LAYER layer
uint8_t keepoutrestrictions
uint16_t polygon
VECTOR2I center
uint32_t radius
uint16_t net
bool is_locked
bool is_polygonoutline
double endangle
uint16_t subpolyindex
VECTOR2I sheetpos
std::set< wxString > layerNames
wxSize sheetsize
std::vector< ABOARD6_LAYER_STACKUP > stackup
std::vector< ALTIUM_VERTICE > board_vertices
wxString uniqueid
std::vector< wxString > names
ALTIUM_CLASS_KIND kind
wxString name
ALTIUM_TEXT_POSITION commentautoposition
ALTIUM_TEXT_POSITION nameautoposition
wxString sourcefootprintlibrary
ALTIUM_LAYER layer
wxString sourcelibreference
wxString sourcedesignator
wxString sourcecomponentlibrary
int32_t textprecision
ALTIUM_UNIT textunit
wxString textsuffix
uint32_t textlinewidth
wxString textformat
ALTIUM_LAYER layer
std::vector< VECTOR2I > textPoint
wxString textprefix
uint32_t linewidth
ALTIUM_DIMENSION_KIND kind
uint32_t textheight
std::vector< VECTOR2I > referencePoint
AEXTENDED_PRIMITIVE_INFORMATION_TYPE type
VECTOR2I pos2
ALTIUM_LAYER layer
uint16_t net
VECTOR2I pos1
double rotation
uint8_t keepoutrestrictions
uint16_t component
ALTIUM_VERTICE(const VECTOR2I &aPosition)
const int32_t radius
const VECTOR2I center
const VECTOR2I position
const double endangle
const double startangle
ALTIUM_VERTICE(bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle, const VECTOR2I aPosition, const VECTOR2I aCenter)
double z_offset
wxString id
int32_t checksum
wxString name
VECTOR3D rotation
wxString name
ALTIUM_PAD_SHAPE inner_shape[29]
ALTIUM_PAD_HOLE_SHAPE holeshape
ALTIUM_PAD_SHAPE_ALT alt_shape[32]
double holerotation
int32_t soldermaskexpansionmanual
uint16_t net
ALTIUM_LAYER layer
std::unique_ptr< APAD6_SIZE_AND_SHAPE > sizeAndShape
ALTIUM_LAYER tolayer
ALTIUM_PAD_SHAPE topshape
ALTIUM_PAD_MODE padmode
ALTIUM_MODE pastemaskexpansionmode
uint32_t holesize
double direction
ALTIUM_MODE soldermaskexpansionmode
wxString name
bool is_test_fab_bottom
bool is_tent_bottom
VECTOR2I botsize
ALTIUM_PAD_SHAPE botshape
uint16_t component
VECTOR2I midsize
ALTIUM_PAD_SHAPE midshape
int32_t pastemaskexpansionmanual
bool is_tent_top
ALTIUM_LAYER fromlayer
VECTOR2I position
bool is_locked
VECTOR2I topsize
bool is_test_fab_top
int32_t minprimlength
std::vector< ALTIUM_VERTICE > vertices
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
int32_t pourindex
int32_t trackwidth
ALTIUM_LAYER layer
int32_t gridsize
uint8_t keepoutrestrictions
ALTIUM_LAYER layer
uint16_t holecount
std::vector< ALTIUM_VERTICE > outline
uint16_t subpolyindex
std::vector< std::vector< ALTIUM_VERTICE > > holes
uint16_t component
uint16_t net
uint16_t polygon
ALTIUM_REGION_KIND kind
ALTIUM_RULE_KIND kind
ALTIUM_CONNECT_STYLE polygonconnectStyle
wxString scope1expr
int preferredWidth
wxString name
int planeclearanceClearance
int32_t polygonconnectReliefconductorwidth
int pastemaskExpansion
wxString scope2expr
int soldermaskExpansion
int32_t polygonconnectAirgapwidth
int polygonconnectReliefentries
uint32_t text_offset_width
uint32_t textbox_rect_height
uint16_t component
ALTIUM_TEXT_POSITION textbox_rect_justification
bool isInvertedRect
wxString text
uint32_t widestring_index
uint32_t textbox_rect_width
double rotation
uint32_t margin_border_width
uint32_t height
wxString fontname
bool isJustificationValid
ALTIUM_LAYER layer
VECTOR2I position
ALTIUM_TEXT_TYPE fonttype
STROKE_FONT_TYPE strokefonttype
bool isDesignator
bool isOffsetBorder
uint32_t strokewidth
VECTOR2I end
uint32_t width
bool is_polygonoutline
uint16_t net
uint16_t polygon
uint16_t subpolyindex
uint8_t keepoutrestrictions
VECTOR2I start
ALTIUM_LAYER layer
uint16_t component
bool soldermask_expansion_linked
uint32_t thermal_relief_conductorcount
uint32_t diameter
uint32_t neg_tolerance
uint16_t net
VECTOR2I position
int32_t thermal_relief_airgap
bool is_locked
bool is_tent_top
bool is_test_fab_top
int32_t soldermask_expansion_front
uint32_t pos_tolerance
bool is_tent_bottom
bool is_test_fab_bottom
bool soldermask_expansion_manual
ALTIUM_PAD_MODE viamode
uint32_t thermal_relief_conductorwidth
int32_t soldermask_expansion_back
uint32_t diameter_by_layer[32]
ALTIUM_LAYER layer_start
ALTIUM_LAYER layer_end
uint32_t holesize