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 The 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{
52
53 INCH = 1,
54 MILS = 2,
55 MM = 3,
56 CM = 4
57};
58
72
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
117
119{
124};
125
127{
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{
144 RECT = 2,
146};
147
149{
152 RECT = 2, // TODO: valid?
153 OCTAGONAL = 3, // TODO: valid?
155};
156
158{
160 ROUND = 0,
163};
164
171
172enum class ALTIUM_MODE
173{
175 NONE = 0, // TODO: correct ID?
176 RULE = 1,
178};
179
191
193{
194 MANUAL = 0, // only relevant for NAMEAUTOPOSITION and COMMENTAUTOPOSITION
204};
205
207{
209
213};
214
216{
219};
220
222{
223 const bool isRound;
224 const int32_t radius;
225 const double startangle;
226 const double endangle;
229
230 explicit ALTIUM_VERTICE( const VECTOR2I& aPosition )
231 : isRound( false ),
232 radius( 0 ),
233 startangle( 0. ),
234 endangle( 0. ),
235 position( aPosition ),
236 center( VECTOR2I( 0, 0 ) )
237 {
238 }
239
240 explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
241 const VECTOR2I aPosition, const VECTOR2I aCenter )
242 : isRound( aIsRound ),
243 radius( aRadius ),
244 startangle( aStartAngle ),
245 endangle( aEndAngle ),
246 position( aPosition ),
247 center( aCenter )
248 {
249 }
250};
251
252enum class ALTIUM_LAYER
253{
255
288
295
312
315
332
343};
344
346
353
369
371{
372 wxString name;
373
374 size_t nextId;
375 size_t prevId;
376
377 int32_t copperthick;
378
382};
383
385{
387 wxSize sheetsize;
388
390 std::vector<ABOARD6_LAYER_STACKUP> stackup;
391 std::set<wxString> layerNames;
392
393 std::vector<ALTIUM_VERTICE> board_vertices;
394
395 explicit ABOARD6( ALTIUM_BINARY_PARSER& aReader );
396};
397
399{
400 wxString name;
401 wxString uniqueid;
402
404
405 std::vector<wxString> names;
406
407 explicit ACLASS6( ALTIUM_BINARY_PARSER& aReader );
408};
409
431
433{
436
437 wxString textformat;
438 wxString textprefix;
439 wxString textsuffix;
440
441 int32_t height;
442 double angle;
443
444 uint32_t linewidth;
445 uint32_t textheight;
448 uint32_t textgap;
451
452 int32_t arrowsize;
453
455
457
458 std::vector<VECTOR2I> referencePoint;
459 std::vector<VECTOR2I> textPoint;
460
461 explicit ADIMENSION6( ALTIUM_BINARY_PARSER& aReader );
462};
463
464struct AMODEL
465{
466 wxString name;
467 wxString id;
469
471 double z_offset;
472 int32_t checksum;
473
474 explicit AMODEL( ALTIUM_BINARY_PARSER& aReader );
475};
476
477struct ANET6
478{
479 wxString name;
480
481 explicit ANET6( ALTIUM_BINARY_PARSER& aReader );
482};
483
485{
487 uint16_t net;
488 bool locked;
489
491
492 int32_t gridsize;
493 int32_t trackwidth;
496
497 // Note: Altium pour index is the opposite of KiCad zone priority!
498 int32_t pourindex;
499
500 std::vector<ALTIUM_VERTICE> vertices;
501
502 explicit APOLYGON6( ALTIUM_BINARY_PARSER& aReader );
503};
504
505
506struct ARULE6
507{
508 wxString name;
509 int priority = 0;
510
512
513 wxString scope1expr;
514 wxString scope2expr;
515
516 // ALTIUM_RULE_KIND::CLEARANCE
517 // ALTIUM_RULE_KIND::HOLE_TO_HOLE_CLEARANCE
519
520 // ALTIUM_RULE_KIND::WIDTH
521 // ALTIUM_RULE_KIND::HOLE_SIZE
522 int minLimit = 0;
523 int maxLimit = 0;
524
525 // ALTIUM_RULE_KIND::WIDTH
527
528 // ALTIUM_RULE_KIND::ROUTING_VIAS
529 int width = 0;
530 int minWidth = 0;
531 int maxWidth = 0;
532 int holeWidth = 0;
535
536 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
538
539 // ALTIUM_RULE_KIND::SOLDER_MASK_EXPANSION
541
542 // ALTIUM_RULE_KIND::PASTE_MASK_EXPANSION
544
545 // ALTIUM_RULE_KIND::POLYGON_CONNECT
550
551 // TODO: implement different types of rules we need to parse
552
553 explicit ARULE6( ALTIUM_BINARY_PARSER& aReader );
554};
555
557{
560
562
564 uint16_t net;
565 uint16_t component;
566 uint16_t polygon;
567 uint16_t subpolyindex;
569 uint16_t holecount;
570
571 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
572
573 std::vector<ALTIUM_VERTICE> outline;
574 std::vector<std::vector<ALTIUM_VERTICE>> holes;
575
576 explicit AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices );
577};
578
579struct AARC6
580{
584
586 uint16_t net;
587 uint16_t component;
588 uint16_t polygon;
589 uint16_t subpolyindex;
591
593 uint32_t radius;
595 double endangle;
596 uint32_t width;
597
598 explicit AARC6( ALTIUM_BINARY_PARSER& aReader );
599};
600
602{
603 uint16_t component = 0;
604
605 wxString body_name;
606 int kind = 0;
608 int unionindex = 0;
610 bool is_shape_based = false;
616 double body_opacity_3d = 0.0;
617 wxString identifier;
618 wxString texture;
624
625 wxString modelId;
627 bool modelIsEmbedded = false;
628 wxString modelName;
629 int modelType = 0;
630 int modelSource = 0;
632
635 double rotation = 0.0;
636
637 explicit ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader );
638};
639
652
697
698struct AVIA6
699{
700 bool is_locked = false;
701 bool is_tent_top = false;
702 bool is_tent_bottom = false;
703 bool is_test_fab_top = false;
704 bool is_test_fab_bottom = false;
705
706 uint16_t net = 0;
707
709 uint32_t pos_tolerance = 2147483640; // 2147483640 is N/A
710 uint32_t neg_tolerance = 2147483640; // 2147483640 is N/A
711 uint32_t diameter = 0;
712 uint32_t holesize = 0;
713
717
722
726
727 // In PAD_MODE::SIMPLE, this is the same as the diameter
728 // In PAD_MODE::TOP_MIDDLE_BOTTOM, layer 0 is top, layer 1 is middle, layer 31 is bottom
729 // In PAD_MODE::FULL_STACK, layers correspond to the layer number
730 uint32_t diameter_by_layer[32];
731
732 explicit AVIA6( ALTIUM_BINARY_PARSER& aReader );
733};
734
736{
740
742 uint16_t net;
743 uint16_t component;
744 uint16_t polygon;
745 uint16_t subpolyindex;
747
750 uint32_t width;
751
752 explicit ATRACK6( ALTIUM_BINARY_PARSER& aReader );
753};
754
755struct ATEXT6
756{
758 {
762 };
763
764
766 uint16_t component = 0;
767
769 uint32_t height = 0;
770 double rotation = 0.0;
771 uint32_t strokewidth = 0;
773
774 bool isBold = false;
775 bool isItalic = false;
776 bool isMirrored = false;
777 bool isInverted = false;
778 bool isInvertedRect = false;
779 bool isFrame = false;
780 bool isOffsetBorder = false;
782
784 uint32_t textbox_rect_width = 0;
786 uint32_t text_offset_width = 0;
787
788 // Justification only applies when there is a text box size specified
789 // Then, the text is justified within the box
791
792 uint32_t widestring_index = 0;
793
794 bool isComment = false;
795 bool isDesignator = false;
796
798 wxString fontname;
800
801 // Barcode specific parameters
804 bool barcode_inverted = false;
805 wxString barcode_name;
806 bool barcode_show_text = false;
807
808 wxString text;
809
810 explicit ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
811};
812
813struct AFILL6
814{
817
819 uint16_t component;
820 uint16_t net;
822
825 double rotation;
826
827 explicit AFILL6( ALTIUM_BINARY_PARSER& aReader );
828};
829
830
831#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_BARCODE_TYPE
ALTIUM_DIMENSION_KIND
ALTIUM_PAD_HOLE_SHAPE
const uint16_t ALTIUM_NET_UNCONNECTED
ALTIUM_CLASS_KIND
const uint16_t ALTIUM_POLYGON_NONE
AEXTENDED_PRIMITIVE_INFORMATION_TYPE
const uint16_t ALTIUM_POLYGON_BOARD
ALTIUM_RECORD
const int ALTIUM_COMPONENT_NONE
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
@ SOLID
Definition eda_shape.h:70
@ NONE
Definition eda_shape.h:69
@ DIRECT
Unconstrained point-to-point.
@ MANUAL
Text placement is manually set by the user.
#define MASK(x)
@ VIA
Normal via.
@ INCH
Definition rs274x.cpp:62
double startangle
uint16_t component
uint32_t width
ALTIUM_LAYER layer
AARC6(ALTIUM_BINARY_PARSER &aReader)
uint8_t keepoutrestrictions
uint16_t polygon
VECTOR2I center
uint32_t radius
uint16_t net
bool is_polygonoutline
double endangle
uint16_t subpolyindex
VECTOR2I sheetpos
std::set< wxString > layerNames
ABOARD6(ALTIUM_BINARY_PARSER &aReader)
std::vector< ABOARD6_LAYER_STACKUP > stackup
std::vector< ALTIUM_VERTICE > board_vertices
wxString uniqueid
std::vector< wxString > names
ALTIUM_CLASS_KIND kind
wxString name
ACLASS6(ALTIUM_BINARY_PARSER &aReader)
wxString sourceHierachicalPath
ALTIUM_TEXT_POSITION commentautoposition
ALTIUM_TEXT_POSITION nameautoposition
ACOMPONENT6(ALTIUM_BINARY_PARSER &aReader)
wxString sourcefootprintlibrary
ALTIUM_LAYER layer
wxString sourcelibreference
wxString sourcedesignator
wxString sourceUniqueID
wxString sourcecomponentlibrary
ACOMPONENTBODY6(ALTIUM_BINARY_PARSER &aReader)
ALTIUM_UNIT textunit
uint32_t textlinewidth
ALTIUM_LAYER layer
std::vector< VECTOR2I > textPoint
ALTIUM_DIMENSION_KIND kind
ADIMENSION6(ALTIUM_BINARY_PARSER &aReader)
std::vector< VECTOR2I > referencePoint
AEXTENDED_PRIMITIVE_INFORMATION_TYPE type
AEXTENDED_PRIMITIVE_INFORMATION(ALTIUM_BINARY_PARSER &aReader)
VECTOR2I pos2
ALTIUM_LAYER layer
uint16_t net
VECTOR2I pos1
double rotation
uint8_t keepoutrestrictions
AFILL6(ALTIUM_BINARY_PARSER &aReader)
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
AMODEL(ALTIUM_BINARY_PARSER &aReader)
ANET6(ALTIUM_BINARY_PARSER &aReader)
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
APAD6(ALTIUM_BINARY_PARSER &aReader)
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
int32_t pad_to_die_delay
bool is_tent_bottom
VECTOR2I botsize
ALTIUM_PAD_SHAPE botshape
uint16_t component
VECTOR2I midsize
ALTIUM_PAD_SHAPE midshape
int32_t pastemaskexpansionmanual
ALTIUM_LAYER fromlayer
VECTOR2I position
VECTOR2I topsize
bool is_test_fab_top
int32_t pad_to_die_length
int32_t minprimlength
std::vector< ALTIUM_VERTICE > vertices
APOLYGON6(ALTIUM_BINARY_PARSER &aReader)
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
ALTIUM_LAYER layer
uint8_t keepoutrestrictions
ALTIUM_LAYER layer
AREGION6(ALTIUM_BINARY_PARSER &aReader, bool aExtendedVertices)
uint16_t holecount
std::vector< ALTIUM_VERTICE > outline
uint16_t subpolyindex
std::vector< std::vector< ALTIUM_VERTICE > > holes
uint16_t component
uint16_t polygon
ALTIUM_REGION_KIND kind
ALTIUM_RULE_KIND kind
ALTIUM_CONNECT_STYLE polygonconnectStyle
wxString scope1expr
wxString name
int planeclearanceClearance
int32_t polygonconnectReliefconductorwidth
int pastemaskExpansion
wxString scope2expr
int soldermaskExpansion
ARULE6(ALTIUM_BINARY_PARSER &aReader)
int32_t polygonconnectAirgapwidth
int polygonconnectReliefentries
uint32_t text_offset_width
VECTOR2I barcode_margin
uint32_t textbox_rect_height
uint16_t component
bool barcode_show_text
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_BARCODE_TYPE barcode_type
ALTIUM_LAYER layer
VECTOR2I position
ALTIUM_TEXT_TYPE fonttype
STROKE_FONT_TYPE strokefonttype
wxString barcode_fontname
bool isOffsetBorder
ATEXT6(ALTIUM_BINARY_PARSER &aReader, std::map< uint32_t, wxString > &aStringTable)
bool barcode_inverted
wxString barcode_name
uint32_t strokewidth
ATRACK6(ALTIUM_BINARY_PARSER &aReader)
uint32_t width
bool is_polygonoutline
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_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
AVIA6(ALTIUM_BINARY_PARSER &aReader)
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
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR3< double > VECTOR3D
Definition vector3.h:230