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 <limits>
31#include <map>
32#include <memory>
33#include <set>
34#include <vector>
35
36#include <wx/gdicmn.h>
37
38#include <math/vector2d.h>
39#include <math/vector3.h>
40
41
42// tthis constant specifies an unconnected net
43const uint16_t ALTIUM_NET_UNCONNECTED = std::numeric_limits<uint16_t>::max();
44
45// this constant specifies a item which is not inside an component
46const uint16_t ALTIUM_COMPONENT_NONE = std::numeric_limits<uint16_t>::max();
47
48// this constant specifies a item which does not define a polygon
49const uint16_t ALTIUM_POLYGON_NONE = std::numeric_limits<uint16_t>::max();
50
51// 65534 seems to be belonging to board outline
52const uint16_t ALTIUM_POLYGON_BOARD = std::numeric_limits<uint16_t>::max() - 1;
53
54
55enum class ALTIUM_UNIT
56{
58
59 INCH = 1,
60 MILS = 2,
61 MM = 3,
62 CM = 4
63};
64
78
94
96{
97 UNKNOWN = -1,
98
99 COPPER = 0, // KIND=0
100 POLYGON_CUTOUT = 1, // KIND=1
101 DASHED_OUTLINE = 2, // KIND=2
102 UNKNOWN_3 = 3, // KIND=3
103 CAVITY_DEFINITION = 4, // KIND=4
104 BOARD_CUTOUT = 5, // KIND=0 AND ISBOARDCUTOUT=TRUE
105};
106
123
125{
130};
131
133{
135
136 ARC = 1,
137 PAD = 2,
138 VIA = 3,
139 TRACK = 4,
140 TEXT = 5,
141 FILL = 6,
142 REGION = 11,
143 MODEL = 12
144};
145
147{
150 RECT = 2,
152};
153
155{
158 RECT = 2, // TODO: valid?
159 OCTAGONAL = 3, // TODO: valid?
161};
162
164{
166 ROUND = 0,
169};
170
177
178enum class ALTIUM_MODE
179{
181 NONE = 0, // TODO: correct ID?
182 RULE = 1,
184};
185
197
199{
200 MANUAL = 0, // only relevant for NAMEAUTOPOSITION and COMMENTAUTOPOSITION
210};
211
213{
215
219};
220
222{
225};
226
228{
229 const bool isRound;
230 const int32_t radius;
231 const double startangle;
232 const double endangle;
235
236 explicit ALTIUM_VERTICE( const VECTOR2I& aPosition )
237 : isRound( false ),
238 radius( 0 ),
239 startangle( 0. ),
240 endangle( 0. ),
241 position( aPosition ),
242 center( VECTOR2I( 0, 0 ) )
243 {
244 }
245
246 explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
247 const VECTOR2I aPosition, const VECTOR2I aCenter )
248 : isRound( aIsRound ),
249 radius( aRadius ),
250 startangle( aStartAngle ),
251 endangle( aEndAngle ),
252 position( aPosition ),
253 center( aCenter )
254 {
255 }
256};
257
258enum class ALTIUM_LAYER : uint32_t
259{
261
294
301
318
321
338
349
350 // V7 format layers
351 V7_START = 0x01000000,
352
353 V7_COPPER_BASE = 0x01000000,
356
357 V7_MECHANICAL_BASE = 0x01020000,
361
362 // V8 format layers
363 V8_OTHER_BASE = 0x01030000,
385};
386
387// Specifies values from LayerKindMapping
389{
391
394
396 BOARD = 0x04,
397
400
403
406
409
412
416
417 FAB_NOTES = 0x12,
418
421
424
425 VALUE_TOP = 0x17,
426 VALUE_BOT = 0x18,
427
428 V_CUT = 0x19,
429
432
434 SHEET = 0x1D,
436};
437
439
446
462
464{
465 uint32_t layerId = 0;
466 wxString name;
467
468 size_t nextId;
469 size_t prevId;
470
471 int32_t copperthick;
472
476
477 bool mechenabled = false;
479
480 explicit ABOARD6_LAYER_STACKUP( const std::map<wxString, wxString>& aProps, const wxString& aPrefix,
481 uint32_t aLayerIdFallback );
482};
483
485{
487 std::vector<ABOARD6_LAYER_STACKUP> stackup;
488 std::set<wxString> layerNames;
489
490 explicit ALIBRARY( ALTIUM_BINARY_PARSER& aReader );
491};
492
494{
496 wxSize sheetsize;
497
499 std::vector<ABOARD6_LAYER_STACKUP> stackup;
500 std::set<wxString> layerNames;
501
502 std::vector<ALTIUM_VERTICE> board_vertices;
503
504 explicit ABOARD6( ALTIUM_BINARY_PARSER& aReader );
505};
506
508{
509 wxString name;
510 wxString uniqueid;
511
513
514 std::vector<wxString> names;
515
516 explicit ACLASS6( ALTIUM_BINARY_PARSER& aReader );
517};
518
540
574
575struct AMODEL
576{
577 wxString name;
578 wxString id;
580
582 double z_offset;
583 int32_t checksum;
584
585 explicit AMODEL( ALTIUM_BINARY_PARSER& aReader );
586};
587
588struct ANET6
589{
590 wxString name;
591
592 explicit ANET6( ALTIUM_BINARY_PARSER& aReader );
593};
594
596{
600 uint16_t net;
601 bool locked;
602
604
605 int32_t gridsize;
606 int32_t trackwidth;
609
610 // Note: Altium pour index is the opposite of KiCad zone priority!
611 int32_t pourindex;
612
613 std::vector<ALTIUM_VERTICE> vertices;
614
615 explicit APOLYGON6( ALTIUM_BINARY_PARSER& aReader );
616};
617
618
619struct ARULE6
620{
621 wxString name;
622 int priority = 0;
623
625
626 wxString scope1expr;
627 wxString scope2expr;
628
629 // ALTIUM_RULE_KIND::CLEARANCE
630 // ALTIUM_RULE_KIND::HOLE_TO_HOLE_CLEARANCE
632
633 // ALTIUM_RULE_KIND::WIDTH
634 // ALTIUM_RULE_KIND::HOLE_SIZE
635 int minLimit = 0;
636 int maxLimit = 0;
637
638 // ALTIUM_RULE_KIND::WIDTH
640
641 // ALTIUM_RULE_KIND::ROUTING_VIAS
642 int width = 0;
643 int minWidth = 0;
644 int maxWidth = 0;
645 int holeWidth = 0;
648
649 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
651
652 // ALTIUM_RULE_KIND::SOLDER_MASK_EXPANSION
654
655 // ALTIUM_RULE_KIND::PASTE_MASK_EXPANSION
657
658 // ALTIUM_RULE_KIND::POLYGON_CONNECT
663
664 // TODO: implement different types of rules we need to parse
665
666 explicit ARULE6( ALTIUM_BINARY_PARSER& aReader );
667};
668
670{
674
676
680 uint16_t net;
681 uint16_t component;
682 uint16_t polygon;
683 uint16_t subpolyindex;
685 uint16_t holecount;
686
687 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
688
689 std::vector<ALTIUM_VERTICE> outline;
690 std::vector<std::vector<ALTIUM_VERTICE>> holes;
691
692 explicit AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices );
693};
694
718
720{
721 uint16_t component = 0;
722
723 wxString body_name;
724 int kind = 0;
726 int unionindex = 0;
728 bool is_shape_based = false;
734 double body_opacity_3d = 0.0;
735 wxString identifier;
736 wxString texture;
742
743 wxString modelId;
745 bool modelIsEmbedded = false;
746 wxString modelName;
747 int modelType = 0;
748 int modelSource = 0;
750
753 double rotation = 0.0;
754
755 explicit ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader );
756};
757
770
817
818struct AVIA6
819{
820 bool is_locked = false;
821 bool is_tent_top = false;
822 bool is_tent_bottom = false;
823 bool is_test_fab_top = false;
824 bool is_test_fab_bottom = false;
825
826 uint16_t net = 0;
827
829 uint32_t pos_tolerance = 2147483640; // 2147483640 is N/A
830 uint32_t neg_tolerance = 2147483640; // 2147483640 is N/A
831 uint32_t diameter = 0;
832 uint32_t holesize = 0;
833
837
842
846
847 // In PAD_MODE::SIMPLE, this is the same as the diameter
848 // In PAD_MODE::TOP_MIDDLE_BOTTOM, layer 0 is top, layer 1 is middle, layer 31 is bottom
849 // In PAD_MODE::FULL_STACK, layers correspond to the layer number
850 uint32_t diameter_by_layer[32]{ 0 };
851
852 explicit AVIA6( ALTIUM_BINARY_PARSER& aReader );
853};
854
876
877struct ATEXT6
878{
880 {
884 };
885
886
890 uint16_t component = 0;
891
893 uint32_t height = 0;
894 double rotation = 0.0;
895 uint32_t strokewidth = 0;
897
898 bool isBold = false;
899 bool isItalic = false;
900 bool isMirrored = false;
901 bool isInverted = false;
902 bool isInvertedRect = false;
903 bool isFrame = false;
904 bool isOffsetBorder = false;
906
908 uint32_t textbox_rect_width = 0;
910 uint32_t text_offset_width = 0;
911
912 // Justification only applies when there is a text box size specified
913 // Then, the text is justified within the box
915
916 uint32_t widestring_index = 0;
917
918 bool isComment = false;
919 bool isDesignator = false;
920
922 wxString fontname;
924
925 // Barcode specific parameters
928 bool barcode_inverted = false;
929 wxString barcode_name;
930 bool barcode_show_text = false;
931
932 wxString text;
933
934 explicit ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
935};
936
955
956
957#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
@ 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