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 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
46enum class ALTIUM_UNIT
47{
48 UNKNOWN = 0,
49
50 INCHES = 1,
51 MILS = 2,
52 MILLIMETERS = 3,
53 CENTIMETER = 4
54};
55
57{
58 UNKNOWN = -1,
59
60 NET_CLASS = 0,
62 FROM_TO = 2,
63 PAD_CLASS = 3,
64 LAYER_CLASS = 4,
65 UNKNOWN_CLASS = 5,
68};
69
71{
72 UNKNOWN = 0,
73
74 LINEAR = 1,
75 ANGULAR = 2,
76 RADIAL = 3,
77 LEADER = 4,
78 DATUM = 5,
79 BASELINE = 6,
80 CENTER = 7,
83};
84
86{
87 UNKNOWN = -1,
88
89 COPPER = 0, // KIND=0
90 POLYGON_CUTOUT = 1, // KIND=1
91 UNKNOWN_2 = 2, // KIND=2
92 UNKNOWN_3 = 3, // KIND=3
93 CAVITY_DEFINITION = 4, // KIND=4
94 BOARD_CUTOUT = 5, // KIND=0 AND ISBOARDCUTOUT=TRUE
95};
96
98{
99 UNKNOWN = 0,
100
101 CLEARANCE = 1,
103 HEIGHT = 3,
104 HOLE_SIZE = 4,
106 WIDTH = 6,
108 PLANE_CLEARANCE = 8,
109 POLYGON_CONNECT = 9,
110};
111
113{
114 UNKNOWN = 0,
115 DIRECT = 1,
116 RELIEF = 2,
117 NONE = 3
118};
119
121{
122 UNKNOWN = -1,
123
124 ARC = 1,
125 PAD = 2,
126 VIA = 3,
127 TRACK = 4,
128 TEXT = 5,
129 FILL = 6,
130 REGION = 11,
131 MODEL = 12
132};
133
135{
136 UNKNOWN = 0,
137 CIRCLE = 1,
138 RECT = 2,
139 OCTAGONAL = 3
140};
141
143{
144 UNKNOWN = 0,
145 CIRCLE = 1,
146 RECT = 2, // TODO: valid?
147 OCTAGONAL = 3, // TODO: valid?
148 ROUNDRECT = 9
149};
150
152{
153 UNKNOWN = -1,
154 ROUND = 0,
155 SQUARE = 1,
156 SLOT = 2
157};
158
160{
161 SIMPLE = 0,
163 FULL_STACK = 2
164};
165
166enum class ALTIUM_MODE
167{
168 UNKNOWN = -1,
169 NONE = 0, // TODO: correct ID?
170 RULE = 1,
171 MANUAL = 2
172};
173
175{
176 UNKNOWN = 0,
177
178 SOLID = 1,
179 DEGREE_45 = 2,
180 DEGREE_90 = 3,
181 HORIZONTAL = 4,
182 VERTICAL = 5,
183 NONE = 6
184};
185
187{
188 MANUAL = 0, // only relevant for NAMEAUTOPOSITION and COMMENTAUTOPOSITION
189 LEFT_TOP = 1,
190 LEFT_CENTER = 2,
191 LEFT_BOTTOM = 3,
192 CENTER_TOP = 4,
193 CENTER_CENTER = 5,
194 CENTER_BOTTOM = 6,
195 RIGHT_TOP = 7,
196 RIGHT_CENTER = 8,
197 RIGHT_BOTTOM = 9
198};
199
201{
202 UNKNOWN = -1,
203
204 STROKE = 0,
205 TRUETYPE = 1,
206 BARCODE = 2
207};
208
210{
211 const bool isRound;
212 const int32_t radius;
213 const double startangle;
214 const double endangle;
217
218 explicit ALTIUM_VERTICE( const VECTOR2I& aPosition )
219 : isRound( false ),
220 radius( 0 ),
221 startangle( 0. ),
222 endangle( 0. ),
223 position( aPosition ),
224 center( VECTOR2I( 0, 0 ) )
225 {
226 }
227
228 explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
229 const VECTOR2I aPosition, const VECTOR2I aCenter )
230 : isRound( aIsRound ),
231 radius( aRadius ),
232 startangle( aStartAngle ),
233 endangle( aEndAngle ),
234 position( aPosition ),
235 center( aCenter )
236 {
237 }
238};
239
240enum class ALTIUM_LAYER
241{
242 UNKNOWN = 0,
243
244 TOP_LAYER = 1,
245 MID_LAYER_1 = 2,
246 MID_LAYER_2 = 3,
247 MID_LAYER_3 = 4,
248 MID_LAYER_4 = 5,
249 MID_LAYER_5 = 6,
250 MID_LAYER_6 = 7,
251 MID_LAYER_7 = 8,
252 MID_LAYER_8 = 9,
253 MID_LAYER_9 = 10,
254 MID_LAYER_10 = 11,
255 MID_LAYER_11 = 12,
256 MID_LAYER_12 = 13,
257 MID_LAYER_13 = 14,
258 MID_LAYER_14 = 15,
259 MID_LAYER_15 = 16,
260 MID_LAYER_16 = 17,
261 MID_LAYER_17 = 18,
262 MID_LAYER_18 = 19,
263 MID_LAYER_19 = 20,
264 MID_LAYER_20 = 21,
265 MID_LAYER_21 = 22,
266 MID_LAYER_22 = 23,
267 MID_LAYER_23 = 24,
268 MID_LAYER_24 = 25,
269 MID_LAYER_25 = 26,
270 MID_LAYER_26 = 27,
271 MID_LAYER_27 = 28,
272 MID_LAYER_28 = 29,
273 MID_LAYER_29 = 30,
274 MID_LAYER_30 = 31,
275 BOTTOM_LAYER = 32,
276
277 TOP_OVERLAY = 33,
278 BOTTOM_OVERLAY = 34,
279 TOP_PASTE = 35,
280 BOTTOM_PASTE = 36,
281 TOP_SOLDER = 37,
282 BOTTOM_SOLDER = 38,
283
284 INTERNAL_PLANE_1 = 39,
285 INTERNAL_PLANE_2 = 40,
286 INTERNAL_PLANE_3 = 41,
287 INTERNAL_PLANE_4 = 42,
288 INTERNAL_PLANE_5 = 43,
289 INTERNAL_PLANE_6 = 44,
290 INTERNAL_PLANE_7 = 45,
291 INTERNAL_PLANE_8 = 46,
292 INTERNAL_PLANE_9 = 47,
300
301 DRILL_GUIDE = 55,
302 KEEP_OUT_LAYER = 56,
303
304 MECHANICAL_1 = 57,
305 MECHANICAL_2 = 58,
306 MECHANICAL_3 = 59,
307 MECHANICAL_4 = 60,
308 MECHANICAL_5 = 61,
309 MECHANICAL_6 = 62,
310 MECHANICAL_7 = 63,
311 MECHANICAL_8 = 64,
312 MECHANICAL_9 = 65,
313 MECHANICAL_10 = 66,
314 MECHANICAL_11 = 67,
315 MECHANICAL_12 = 68,
316 MECHANICAL_13 = 69,
317 MECHANICAL_14 = 70,
318 MECHANICAL_15 = 71,
319 MECHANICAL_16 = 72,
320
321 DRILL_DRAWING = 73,
322 MULTI_LAYER = 74,
323 CONNECTIONS = 75,
324 BACKGROUND = 76,
326 SELECTIONS = 78,
327 VISIBLE_GRID_1 = 79,
328 VISIBLE_GRID_2 = 80,
329 PAD_HOLES = 81,
330 VIA_HOLES = 82,
331};
332
333class ALTIUM_PARSER;
334
336{
337 UNKNOWN = -1,
338
339 MASK
340};
341
343{
346
348
349 // Type == Mask
354
356};
357
359{
360 wxString name;
361
362 size_t nextId;
363 size_t prevId;
364
365 int32_t copperthick;
366
370};
371
373{
375 wxSize sheetsize;
376
378 std::vector<ABOARD6_LAYER_STACKUP> stackup;
379
380 std::vector<ALTIUM_VERTICE> board_vertices;
381
382 explicit ABOARD6( ALTIUM_PARSER& aReader );
383};
384
386{
387 wxString name;
388 wxString uniqueid;
389
391
392 std::vector<wxString> names;
393
394 explicit ACLASS6( ALTIUM_PARSER& aReader );
395};
396
398{
401 double rotation;
402 bool locked;
403 bool nameon;
407 wxString pattern;
410
413
414 explicit ACOMPONENT6( ALTIUM_PARSER& aReader );
415};
416
418{
421
422 wxString textformat;
423 wxString textprefix;
424 wxString textsuffix;
425
426 int32_t height;
427 double angle;
428
429 uint32_t linewidth;
430 uint32_t textheight;
433 uint32_t textgap;
436
437 int32_t arrowsize;
438
440
442
443 std::vector<VECTOR2I> referencePoint;
444 std::vector<VECTOR2I> textPoint;
445
446 explicit ADIMENSION6( ALTIUM_PARSER& aReader );
447};
448
449struct AMODEL
450{
451 wxString name;
452 wxString id;
454
456
457 explicit AMODEL( ALTIUM_PARSER& aReader );
458};
459
460struct ANET6
461{
462 wxString name;
463
464 explicit ANET6( ALTIUM_PARSER& aReader );
465};
466
468{
470 uint16_t net;
471 bool locked;
472
474
475 int32_t gridsize;
476 int32_t trackwidth;
479
480 // Note: Altium pour index is the opposite of KiCad zone priority!
481 int32_t pourindex;
482
483 std::vector<ALTIUM_VERTICE> vertices;
484
485 explicit APOLYGON6( ALTIUM_PARSER& aReader );
486};
487
488
489struct ARULE6
490{
491 wxString name;
493
495
496 wxString scope1expr;
497 wxString scope2expr;
498
499 // ALTIUM_RULE_KIND::CLEARANCE
501
502 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
504
505 // ALTIUM_RULE_KIND::POLYGON_CONNECT
510
511 // TODO: implement different types of rules we need to parse
512
513 explicit ARULE6( ALTIUM_PARSER& aReader );
514};
515
517{
520
522
524 uint16_t net;
525 uint16_t component;
526 uint16_t subpolyindex;
528 uint16_t holecount;
529
530 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
531
532 std::vector<ALTIUM_VERTICE> outline;
533 std::vector<std::vector<ALTIUM_VERTICE>> holes;
534
535 explicit AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices );
536};
537
538struct AARC6
539{
543
545 uint16_t net;
546 uint16_t component;
547 uint16_t subpolyindex;
549
551 uint32_t radius;
553 double endangle;
554 uint32_t width;
555
556 explicit AARC6( ALTIUM_PARSER& aReader );
557};
558
560{
561 uint16_t component;
562
563 wxString modelName;
564 wxString modelId;
566
569 double rotation;
571
572 explicit ACOMPONENTBODY6( ALTIUM_PARSER& aReader );
573};
574
576{
578 uint32_t slotsize;
580
581 wxSize inner_size[29];
585 uint8_t cornerradius[32];
586};
587
588struct APAD6
589{
595
596 wxString name;
597
599 uint16_t net;
600 uint16_t component;
601
606 uint32_t holesize;
607
611
613
614 double direction;
615 bool plated;
621
624
625 std::unique_ptr<APAD6_SIZE_AND_SHAPE> sizeAndShape;
626
627 explicit APAD6( ALTIUM_PARSER& aReader );
628};
629
630struct AVIA6
631{
637
638 uint16_t net;
639
641 uint32_t diameter;
642 uint32_t holesize;
643
647
648 explicit AVIA6( ALTIUM_PARSER& aReader );
649};
650
652{
656
658 uint16_t net;
659 uint16_t component;
660 uint16_t subpolyindex;
662
665 uint32_t width;
666
667 explicit ATRACK6( ALTIUM_PARSER& aReader );
668};
669
670struct ATEXT6
671{
673 uint16_t component;
674
676 uint32_t height;
677 double rotation;
678 uint32_t strokewidth;
680
681 bool isBold;
685
688
690
691 wxString text;
692
693 explicit ATEXT6( ALTIUM_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
694};
695
696struct AFILL6
697{
700
702 uint16_t component;
703 uint16_t net;
705
708 double rotation;
709
710 explicit AFILL6( ALTIUM_PARSER& aReader );
711};
712
713
714#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
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
VECTOR2I center
uint32_t radius
uint16_t net
bool is_locked
bool is_polygonoutline
double endangle
uint16_t subpolyindex
VECTOR2I sheetpos
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
ALTIUM_REGION_KIND kind
ALTIUM_RULE_KIND kind
ALTIUM_CONNECT_STYLE polygonconnectStyle
wxString scope1expr
wxString name
int planeclearanceClearance
int32_t polygonconnectReliefconductorwidth
wxString scope2expr
int32_t polygonconnectAirgapwidth
int polygonconnectReliefentries
ALTIUM_TEXT_POSITION textposition
uint16_t component
wxString text
double rotation
uint32_t height
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 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