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 : uint32_t
253{
255
288
295
312
315
332
343
344 // V7 format layers
345 V7_START = 0x01000000,
346
347 V7_COPPER_BASE = 0x01000000,
350
351 V7_MECHANICAL_BASE = 0x01020000,
355
356 // V8 format layers
357 V8_OTHER_BASE = 0x01030000,
379};
380
381// Specifies values from LayerKindMapping
383{
385
388
390 BOARD = 0x04,
391
394
397
400
403
406
410
411 FAB_NOTES = 0x12,
412
415
418
419 VALUE_TOP = 0x17,
420 VALUE_BOT = 0x18,
421
422 V_CUT = 0x19,
423
426
428 SHEET = 0x1D,
430};
431
433
440
456
458{
459 uint32_t layerId = 0;
460 wxString name;
461
462 size_t nextId;
463 size_t prevId;
464
465 int32_t copperthick;
466
470
471 bool mechenabled = false;
473
474 explicit ABOARD6_LAYER_STACKUP( const std::map<wxString, wxString>& aProps, const wxString& aPrefix,
475 uint32_t aLayerIdFallback );
476};
477
479{
481 std::vector<ABOARD6_LAYER_STACKUP> stackup;
482 std::set<wxString> layerNames;
483
484 explicit ALIBRARY( ALTIUM_BINARY_PARSER& aReader );
485};
486
488{
490 wxSize sheetsize;
491
493 std::vector<ABOARD6_LAYER_STACKUP> stackup;
494 std::set<wxString> layerNames;
495
496 std::vector<ALTIUM_VERTICE> board_vertices;
497
498 explicit ABOARD6( ALTIUM_BINARY_PARSER& aReader );
499};
500
502{
503 wxString name;
504 wxString uniqueid;
505
507
508 std::vector<wxString> names;
509
510 explicit ACLASS6( ALTIUM_BINARY_PARSER& aReader );
511};
512
534
568
569struct AMODEL
570{
571 wxString name;
572 wxString id;
574
576 double z_offset;
577 int32_t checksum;
578
579 explicit AMODEL( ALTIUM_BINARY_PARSER& aReader );
580};
581
582struct ANET6
583{
584 wxString name;
585
586 explicit ANET6( ALTIUM_BINARY_PARSER& aReader );
587};
588
590{
594 uint16_t net;
595 bool locked;
596
598
599 int32_t gridsize;
600 int32_t trackwidth;
603
604 // Note: Altium pour index is the opposite of KiCad zone priority!
605 int32_t pourindex;
606
607 std::vector<ALTIUM_VERTICE> vertices;
608
609 explicit APOLYGON6( ALTIUM_BINARY_PARSER& aReader );
610};
611
612
613struct ARULE6
614{
615 wxString name;
616 int priority = 0;
617
619
620 wxString scope1expr;
621 wxString scope2expr;
622
623 // ALTIUM_RULE_KIND::CLEARANCE
624 // ALTIUM_RULE_KIND::HOLE_TO_HOLE_CLEARANCE
626
627 // ALTIUM_RULE_KIND::WIDTH
628 // ALTIUM_RULE_KIND::HOLE_SIZE
629 int minLimit = 0;
630 int maxLimit = 0;
631
632 // ALTIUM_RULE_KIND::WIDTH
634
635 // ALTIUM_RULE_KIND::ROUTING_VIAS
636 int width = 0;
637 int minWidth = 0;
638 int maxWidth = 0;
639 int holeWidth = 0;
642
643 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
645
646 // ALTIUM_RULE_KIND::SOLDER_MASK_EXPANSION
648
649 // ALTIUM_RULE_KIND::PASTE_MASK_EXPANSION
651
652 // ALTIUM_RULE_KIND::POLYGON_CONNECT
657
658 // TODO: implement different types of rules we need to parse
659
660 explicit ARULE6( ALTIUM_BINARY_PARSER& aReader );
661};
662
664{
668
670
674 uint16_t net;
675 uint16_t component;
676 uint16_t polygon;
677 uint16_t subpolyindex;
679 uint16_t holecount;
680
681 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
682
683 std::vector<ALTIUM_VERTICE> outline;
684 std::vector<std::vector<ALTIUM_VERTICE>> holes;
685
686 explicit AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices );
687};
688
712
714{
715 uint16_t component = 0;
716
717 wxString body_name;
718 int kind = 0;
720 int unionindex = 0;
722 bool is_shape_based = false;
728 double body_opacity_3d = 0.0;
729 wxString identifier;
730 wxString texture;
736
737 wxString modelId;
739 bool modelIsEmbedded = false;
740 wxString modelName;
741 int modelType = 0;
742 int modelSource = 0;
744
747 double rotation = 0.0;
748
749 explicit ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader );
750};
751
764
811
812struct AVIA6
813{
814 bool is_locked = false;
815 bool is_tent_top = false;
816 bool is_tent_bottom = false;
817 bool is_test_fab_top = false;
818 bool is_test_fab_bottom = false;
819
820 uint16_t net = 0;
821
823 uint32_t pos_tolerance = 2147483640; // 2147483640 is N/A
824 uint32_t neg_tolerance = 2147483640; // 2147483640 is N/A
825 uint32_t diameter = 0;
826 uint32_t holesize = 0;
827
831
836
840
841 // In PAD_MODE::SIMPLE, this is the same as the diameter
842 // In PAD_MODE::TOP_MIDDLE_BOTTOM, layer 0 is top, layer 1 is middle, layer 31 is bottom
843 // In PAD_MODE::FULL_STACK, layers correspond to the layer number
844 uint32_t diameter_by_layer[32]{ 0 };
845
846 explicit AVIA6( ALTIUM_BINARY_PARSER& aReader );
847};
848
870
871struct ATEXT6
872{
874 {
878 };
879
880
884 uint16_t component = 0;
885
887 uint32_t height = 0;
888 double rotation = 0.0;
889 uint32_t strokewidth = 0;
891
892 bool isBold = false;
893 bool isItalic = false;
894 bool isMirrored = false;
895 bool isInverted = false;
896 bool isInvertedRect = false;
897 bool isFrame = false;
898 bool isOffsetBorder = false;
900
902 uint32_t textbox_rect_width = 0;
904 uint32_t text_offset_width = 0;
905
906 // Justification only applies when there is a text box size specified
907 // Then, the text is justified within the box
909
910 uint32_t widestring_index = 0;
911
912 bool isComment = false;
913 bool isDesignator = false;
914
916 wxString fontname;
918
919 // Barcode specific parameters
922 bool barcode_inverted = false;
923 wxString barcode_name;
924 bool barcode_show_text = false;
925
926 wxString text;
927
928 explicit ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
929};
930
949
950
951#endif //ALTIUM_PARSER_PCB_H
ALTIUM_REGION_KIND
ALTIUM_PAD_SHAPE_ALT
ALTIUM_TEXT_POSITION
ALTIUM_CONNECT_STYLE
ALTIUM_MECHKIND
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
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
Represent basic circle geometry with utility geometry functions.
Definition circle.h:33
Definition pad.h:55
A round rectangle shape, based on a rectangle and a radius.
Definition roundrect.h:36
@ HOLE_TO_HOLE_CLEARANCE
@ 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
ALTIUM_LAYER layer_v6
ALTIUM_LAYER layer_v7
bool is_polygonoutline
double endangle
uint16_t subpolyindex
ABOARD6_LAYER_STACKUP(const std::map< wxString, wxString > &aProps, const wxString &aPrefix, uint32_t aLayerIdFallback)
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
ALTIUM_LAYER layer_v6
std::vector< VECTOR2I > textPoint
ALTIUM_DIMENSION_KIND kind
ALTIUM_LAYER layer_v7
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)
ALTIUM_LAYER layer_v6
uint16_t component
ALTIUM_LAYER layer_v7
std::set< wxString > layerNames
std::vector< ABOARD6_LAYER_STACKUP > stackup
ALIBRARY(ALTIUM_BINARY_PARSER &aReader)
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 layer_v7
ALTIUM_LAYER tolayer
ALTIUM_PAD_SHAPE topshape
ALTIUM_LAYER layer_v6
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
ALTIUM_LAYER layer_v6
int32_t minprimlength
std::vector< ALTIUM_VERTICE > vertices
APOLYGON6(ALTIUM_BINARY_PARSER &aReader)
ALTIUM_LAYER layer_v7
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
ALTIUM_LAYER layer
uint8_t keepoutrestrictions
ALTIUM_LAYER layer
AREGION6(ALTIUM_BINARY_PARSER &aReader, bool aExtendedVertices)
ALTIUM_LAYER layer_v7
uint16_t holecount
ALTIUM_LAYER layer_v6
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_LAYER layer_v6
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_LAYER layer_v7
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
ALTIUM_LAYER layer_v6
ATRACK6(ALTIUM_BINARY_PARSER &aReader)
uint32_t width
bool is_polygonoutline
ALTIUM_LAYER layer_v7
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