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,
86};
87
89{
90 UNKNOWN = -1,
91
92 COPPER = 0, // KIND=0
93 POLYGON_CUTOUT = 1, // KIND=1
94 DASHED_OUTLINE = 2, // KIND=2
95 UNKNOWN_3 = 3, // KIND=3
96 CAVITY_DEFINITION = 4, // KIND=4
97 BOARD_CUTOUT = 5, // KIND=0 AND ISBOARDCUTOUT=TRUE
98};
99
101{
102 UNKNOWN = 0,
103
104 CLEARANCE = 1,
106 HEIGHT = 3,
107 HOLE_SIZE = 4,
109 WIDTH = 6,
112 PLANE_CLEARANCE = 9,
113 POLYGON_CONNECT = 10,
114 ROUTING_VIAS = 11
115};
116
118{
119 UNKNOWN = 0,
120 DIRECT = 1,
121 RELIEF = 2,
122 NONE = 3
123};
124
126{
127 UNKNOWN = -1,
128
129 ARC = 1,
130 PAD = 2,
131 VIA = 3,
132 TRACK = 4,
133 TEXT = 5,
134 FILL = 6,
135 REGION = 11,
136 MODEL = 12
137};
138
140{
141 UNKNOWN = 0,
142 CIRCLE = 1,
143 RECT = 2,
144 OCTAGONAL = 3
145};
146
148{
149 UNKNOWN = 0,
150 CIRCLE = 1,
151 RECT = 2, // TODO: valid?
152 OCTAGONAL = 3, // TODO: valid?
153 ROUNDRECT = 9
154};
155
157{
158 UNKNOWN = -1,
159 ROUND = 0,
160 SQUARE = 1,
161 SLOT = 2
162};
163
165{
166 SIMPLE = 0,
168 FULL_STACK = 2
169};
170
171enum class ALTIUM_MODE
172{
173 UNKNOWN = -1,
174 NONE = 0, // TODO: correct ID?
175 RULE = 1,
176 MANUAL = 2
177};
178
180{
181 UNKNOWN = 0,
182
183 SOLID = 1,
184 DEGREE_45 = 2,
185 DEGREE_90 = 3,
186 HORIZONTAL = 4,
187 VERTICAL = 5,
188 NONE = 6
189};
190
192{
193 MANUAL = 0, // only relevant for NAMEAUTOPOSITION and COMMENTAUTOPOSITION
194 LEFT_TOP = 1,
195 LEFT_CENTER = 2,
196 LEFT_BOTTOM = 3,
197 CENTER_TOP = 4,
198 CENTER_CENTER = 5,
199 CENTER_BOTTOM = 6,
200 RIGHT_TOP = 7,
201 RIGHT_CENTER = 8,
202 RIGHT_BOTTOM = 9
203};
204
206{
207 UNKNOWN = -1,
208
209 STROKE = 0,
210 TRUETYPE = 1,
211 BARCODE = 2
212};
213
215{
216 const bool isRound;
217 const int32_t radius;
218 const double startangle;
219 const double endangle;
222
223 explicit ALTIUM_VERTICE( const VECTOR2I& aPosition )
224 : isRound( false ),
225 radius( 0 ),
226 startangle( 0. ),
227 endangle( 0. ),
228 position( aPosition ),
229 center( VECTOR2I( 0, 0 ) )
230 {
231 }
232
233 explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
234 const VECTOR2I aPosition, const VECTOR2I aCenter )
235 : isRound( aIsRound ),
236 radius( aRadius ),
237 startangle( aStartAngle ),
238 endangle( aEndAngle ),
239 position( aPosition ),
240 center( aCenter )
241 {
242 }
243};
244
245enum class ALTIUM_LAYER
246{
247 UNKNOWN = 0,
248
249 TOP_LAYER = 1,
250 MID_LAYER_1 = 2,
251 MID_LAYER_2 = 3,
252 MID_LAYER_3 = 4,
253 MID_LAYER_4 = 5,
254 MID_LAYER_5 = 6,
255 MID_LAYER_6 = 7,
256 MID_LAYER_7 = 8,
257 MID_LAYER_8 = 9,
258 MID_LAYER_9 = 10,
259 MID_LAYER_10 = 11,
260 MID_LAYER_11 = 12,
261 MID_LAYER_12 = 13,
262 MID_LAYER_13 = 14,
263 MID_LAYER_14 = 15,
264 MID_LAYER_15 = 16,
265 MID_LAYER_16 = 17,
266 MID_LAYER_17 = 18,
267 MID_LAYER_18 = 19,
268 MID_LAYER_19 = 20,
269 MID_LAYER_20 = 21,
270 MID_LAYER_21 = 22,
271 MID_LAYER_22 = 23,
272 MID_LAYER_23 = 24,
273 MID_LAYER_24 = 25,
274 MID_LAYER_25 = 26,
275 MID_LAYER_26 = 27,
276 MID_LAYER_27 = 28,
277 MID_LAYER_28 = 29,
278 MID_LAYER_29 = 30,
279 MID_LAYER_30 = 31,
280 BOTTOM_LAYER = 32,
281
282 TOP_OVERLAY = 33,
283 BOTTOM_OVERLAY = 34,
284 TOP_PASTE = 35,
285 BOTTOM_PASTE = 36,
286 TOP_SOLDER = 37,
287 BOTTOM_SOLDER = 38,
288
289 INTERNAL_PLANE_1 = 39,
290 INTERNAL_PLANE_2 = 40,
291 INTERNAL_PLANE_3 = 41,
292 INTERNAL_PLANE_4 = 42,
293 INTERNAL_PLANE_5 = 43,
294 INTERNAL_PLANE_6 = 44,
295 INTERNAL_PLANE_7 = 45,
296 INTERNAL_PLANE_8 = 46,
297 INTERNAL_PLANE_9 = 47,
305
306 DRILL_GUIDE = 55,
307 KEEP_OUT_LAYER = 56,
308
309 MECHANICAL_1 = 57,
310 MECHANICAL_2 = 58,
311 MECHANICAL_3 = 59,
312 MECHANICAL_4 = 60,
313 MECHANICAL_5 = 61,
314 MECHANICAL_6 = 62,
315 MECHANICAL_7 = 63,
316 MECHANICAL_8 = 64,
317 MECHANICAL_9 = 65,
318 MECHANICAL_10 = 66,
319 MECHANICAL_11 = 67,
320 MECHANICAL_12 = 68,
321 MECHANICAL_13 = 69,
322 MECHANICAL_14 = 70,
323 MECHANICAL_15 = 71,
324 MECHANICAL_16 = 72,
325
326 DRILL_DRAWING = 73,
327 MULTI_LAYER = 74,
328 CONNECTIONS = 75,
329 BACKGROUND = 76,
331 SELECTIONS = 78,
332 VISIBLE_GRID_1 = 79,
333 VISIBLE_GRID_2 = 80,
334 PAD_HOLES = 81,
335 VIA_HOLES = 82,
336};
337
339
341{
342 UNKNOWN = -1,
343
344 MASK
345};
346
348{
351
353
354 // Type == Mask
359
361};
362
364{
365 wxString name;
366
367 size_t nextId;
368 size_t prevId;
369
370 int32_t copperthick;
371
375};
376
378{
380 wxSize sheetsize;
381
383 std::vector<ABOARD6_LAYER_STACKUP> stackup;
384 std::set<wxString> layerNames;
385
386 std::vector<ALTIUM_VERTICE> board_vertices;
387
388 explicit ABOARD6( ALTIUM_BINARY_PARSER& aReader );
389};
390
392{
393 wxString name;
394 wxString uniqueid;
395
397
398 std::vector<wxString> names;
399
400 explicit ACLASS6( ALTIUM_BINARY_PARSER& aReader );
401};
402
404{
407 double rotation;
408 bool locked;
409 bool nameon;
413 wxString pattern;
416
419
420 explicit ACOMPONENT6( ALTIUM_BINARY_PARSER& aReader );
421};
422
424{
427
428 wxString textformat;
429 wxString textprefix;
430 wxString textsuffix;
431
432 int32_t height;
433 double angle;
434
435 uint32_t linewidth;
436 uint32_t textheight;
439 uint32_t textgap;
442
443 int32_t arrowsize;
444
446
448
449 std::vector<VECTOR2I> referencePoint;
450 std::vector<VECTOR2I> textPoint;
451
452 explicit ADIMENSION6( ALTIUM_BINARY_PARSER& aReader );
453};
454
455struct AMODEL
456{
457 wxString name;
458 wxString id;
460
462
463 explicit AMODEL( ALTIUM_BINARY_PARSER& aReader );
464};
465
466struct ANET6
467{
468 wxString name;
469
470 explicit ANET6( ALTIUM_BINARY_PARSER& aReader );
471};
472
474{
476 uint16_t net;
477 bool locked;
478
480
481 int32_t gridsize;
482 int32_t trackwidth;
485
486 // Note: Altium pour index is the opposite of KiCad zone priority!
487 int32_t pourindex;
488
489 std::vector<ALTIUM_VERTICE> vertices;
490
491 explicit APOLYGON6( ALTIUM_BINARY_PARSER& aReader );
492};
493
494
495struct ARULE6
496{
497 wxString name;
499
501
502 wxString scope1expr;
503 wxString scope2expr;
504
505 // ALTIUM_RULE_KIND::CLEARANCE
506 // ALTIUM_RULE_KIND::HOLE_TO_HOLE_CLEARANCE
508
509 // ALTIUM_RULE_KIND::WIDTH
510 // ALTIUM_RULE_KIND::HOLE_SIZE
513
514 // ALTIUM_RULE_KIND::WIDTH
516
517 // ALTIUM_RULE_KIND::ROUTING_VIAS
518 int width;
524
525 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
527
528 // ALTIUM_RULE_KIND::SOLDER_MASK_EXPANSION
530
531 // ALTIUM_RULE_KIND::PASTE_MASK_EXPANSION
533
534 // ALTIUM_RULE_KIND::POLYGON_CONNECT
539
540 // TODO: implement different types of rules we need to parse
541
542 explicit ARULE6( ALTIUM_BINARY_PARSER& aReader );
543};
544
546{
549
551
553 uint16_t net;
554 uint16_t component;
555 uint16_t polygon;
556 uint16_t subpolyindex;
558 uint16_t holecount;
559
560 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
561
562 std::vector<ALTIUM_VERTICE> outline;
563 std::vector<std::vector<ALTIUM_VERTICE>> holes;
564
565 explicit AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices );
566};
567
568struct AARC6
569{
573
575 uint16_t net;
576 uint16_t component;
577 uint16_t polygon;
578 uint16_t subpolyindex;
580
582 uint32_t radius;
584 double endangle;
585 uint32_t width;
586
587 explicit AARC6( ALTIUM_BINARY_PARSER& aReader );
588};
589
591{
592 uint16_t component;
593
594 wxString modelName;
595 wxString modelId;
597
600 double rotation;
602
603 explicit ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader );
604};
605
607{
609 uint32_t slotsize;
611
612 wxSize inner_size[29];
616 uint8_t cornerradius[32];
617};
618
619struct APAD6
620{
626
627 wxString name;
628
630 uint16_t net;
631 uint16_t component;
632
637 uint32_t holesize;
638
642
644
645 double direction;
646 bool plated;
652
655
656 std::unique_ptr<APAD6_SIZE_AND_SHAPE> sizeAndShape;
657
658 explicit APAD6( ALTIUM_BINARY_PARSER& aReader );
659};
660
661struct AVIA6
662{
668
669 uint16_t net;
670
672 uint32_t diameter;
673 uint32_t holesize;
674
678
679 explicit AVIA6( ALTIUM_BINARY_PARSER& aReader );
680};
681
683{
687
689 uint16_t net;
690 uint16_t component;
691 uint16_t polygon;
692 uint16_t subpolyindex;
694
697 uint32_t width;
698
699 explicit ATRACK6( ALTIUM_BINARY_PARSER& aReader );
700};
701
702struct ATEXT6
703{
705 uint16_t component;
706
708 uint32_t height;
709 double rotation;
710 uint32_t strokewidth;
712
713 bool isBold;
717
720
722 wxString fontname;
723
724 wxString text;
725
726 explicit ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
727};
728
729struct AFILL6
730{
733
735 uint16_t component;
736 uint16_t net;
738
741 double rotation;
742
743 explicit AFILL6( ALTIUM_BINARY_PARSER& aReader );
744};
745
746
747#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:59
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)
wxString id
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
ALTIUM_TEXT_POSITION textposition
uint16_t component
wxString text
double rotation
uint32_t height
wxString fontname
ALTIUM_LAYER layer
VECTOR2I position
ALTIUM_TEXT_TYPE fonttype
bool isDesignator
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
uint32_t diameter
uint16_t net
VECTOR2I position
bool is_locked
bool is_tent_top
bool is_test_fab_top
bool is_tent_bottom
bool is_test_fab_bottom
ALTIUM_PAD_MODE viamode
ALTIUM_LAYER layer_start
ALTIUM_LAYER layer_end
uint32_t holesize