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{
217 const bool isRound;
218 const int32_t radius;
219 const double startangle;
220 const double endangle;
223
224 explicit ALTIUM_VERTICE( const VECTOR2I& aPosition )
225 : isRound( false ),
226 radius( 0 ),
227 startangle( 0. ),
228 endangle( 0. ),
229 position( aPosition ),
230 center( VECTOR2I( 0, 0 ) )
231 {
232 }
233
234 explicit ALTIUM_VERTICE( bool aIsRound, int32_t aRadius, double aStartAngle, double aEndAngle,
235 const VECTOR2I aPosition, const VECTOR2I aCenter )
236 : isRound( aIsRound ),
237 radius( aRadius ),
238 startangle( aStartAngle ),
239 endangle( aEndAngle ),
240 position( aPosition ),
241 center( aCenter )
242 {
243 }
244};
245
246enum class ALTIUM_LAYER
247{
249
282
289
306
309
326
337};
338
340
347
363
365{
366 wxString name;
367
368 size_t nextId;
369 size_t prevId;
370
371 int32_t copperthick;
372
376};
377
379{
381 wxSize sheetsize;
382
384 std::vector<ABOARD6_LAYER_STACKUP> stackup;
385 std::set<wxString> layerNames;
386
387 std::vector<ALTIUM_VERTICE> board_vertices;
388
389 explicit ABOARD6( ALTIUM_BINARY_PARSER& aReader );
390};
391
393{
394 wxString name;
395 wxString uniqueid;
396
398
399 std::vector<wxString> names;
400
401 explicit ACLASS6( ALTIUM_BINARY_PARSER& aReader );
402};
403
425
427{
430
431 wxString textformat;
432 wxString textprefix;
433 wxString textsuffix;
434
435 int32_t height;
436 double angle;
437
438 uint32_t linewidth;
439 uint32_t textheight;
442 uint32_t textgap;
445
446 int32_t arrowsize;
447
449
451
452 std::vector<VECTOR2I> referencePoint;
453 std::vector<VECTOR2I> textPoint;
454
455 explicit ADIMENSION6( ALTIUM_BINARY_PARSER& aReader );
456};
457
458struct AMODEL
459{
460 wxString name;
461 wxString id;
463
465 double z_offset;
466 int32_t checksum;
467
468 explicit AMODEL( ALTIUM_BINARY_PARSER& aReader );
469};
470
471struct ANET6
472{
473 wxString name;
474
475 explicit ANET6( ALTIUM_BINARY_PARSER& aReader );
476};
477
479{
481 uint16_t net;
482 bool locked;
483
485
486 int32_t gridsize;
487 int32_t trackwidth;
490
491 // Note: Altium pour index is the opposite of KiCad zone priority!
492 int32_t pourindex;
493
494 std::vector<ALTIUM_VERTICE> vertices;
495
496 explicit APOLYGON6( ALTIUM_BINARY_PARSER& aReader );
497};
498
499
500struct ARULE6
501{
502 wxString name;
503 int priority = 0;
504
506
507 wxString scope1expr;
508 wxString scope2expr;
509
510 // ALTIUM_RULE_KIND::CLEARANCE
511 // ALTIUM_RULE_KIND::HOLE_TO_HOLE_CLEARANCE
513
514 // ALTIUM_RULE_KIND::WIDTH
515 // ALTIUM_RULE_KIND::HOLE_SIZE
516 int minLimit = 0;
517 int maxLimit = 0;
518
519 // ALTIUM_RULE_KIND::WIDTH
521
522 // ALTIUM_RULE_KIND::ROUTING_VIAS
523 int width = 0;
524 int minWidth = 0;
525 int maxWidth = 0;
526 int holeWidth = 0;
529
530 // ALTIUM_RULE_KIND::PLANE_CLEARANCE
532
533 // ALTIUM_RULE_KIND::SOLDER_MASK_EXPANSION
535
536 // ALTIUM_RULE_KIND::PASTE_MASK_EXPANSION
538
539 // ALTIUM_RULE_KIND::POLYGON_CONNECT
544
545 // TODO: implement different types of rules we need to parse
546
547 explicit ARULE6( ALTIUM_BINARY_PARSER& aReader );
548};
549
551{
554
556
558 uint16_t net;
559 uint16_t component;
560 uint16_t polygon;
561 uint16_t subpolyindex;
563 uint16_t holecount;
564
565 ALTIUM_REGION_KIND kind; // I assume this means if normal or keepout?
566
567 std::vector<ALTIUM_VERTICE> outline;
568 std::vector<std::vector<ALTIUM_VERTICE>> holes;
569
570 explicit AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices );
571};
572
573struct AARC6
574{
578
580 uint16_t net;
581 uint16_t component;
582 uint16_t polygon;
583 uint16_t subpolyindex;
585
587 uint32_t radius;
589 double endangle;
590 uint32_t width;
591
592 explicit AARC6( ALTIUM_BINARY_PARSER& aReader );
593};
594
596{
597 uint16_t component = 0;
598
599 wxString body_name;
600 int kind = 0;
602 int unionindex = 0;
604 bool is_shape_based = false;
610 double body_opacity_3d = 0.0;
611 wxString identifier;
612 wxString texture;
618
619 wxString modelId;
621 bool modelIsEmbedded = false;
622 wxString modelName;
623 int modelType = 0;
624 int modelSource = 0;
626
629 double rotation = 0.0;
630
631 explicit ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader );
632};
633
646
688
689struct AVIA6
690{
691 bool is_locked = false;
692 bool is_tent_top = false;
693 bool is_tent_bottom = false;
694 bool is_test_fab_top = false;
695 bool is_test_fab_bottom = false;
696
697 uint16_t net = 0;
698
700 uint32_t pos_tolerance = 2147483640; // 2147483640 is N/A
701 uint32_t neg_tolerance = 2147483640; // 2147483640 is N/A
702 uint32_t diameter = 0;
703 uint32_t holesize = 0;
704
708
713
717
718 // In PAD_MODE::SIMPLE, this is the same as the diameter
719 // In PAD_MODE::TOP_MIDDLE_BOTTOM, layer 0 is top, layer 1 is middle, layer 31 is bottom
720 // In PAD_MODE::FULL_STACK, layers correspond to the layer number
721 uint32_t diameter_by_layer[32];
722
723 explicit AVIA6( ALTIUM_BINARY_PARSER& aReader );
724};
725
727{
731
733 uint16_t net;
734 uint16_t component;
735 uint16_t polygon;
736 uint16_t subpolyindex;
738
741 uint32_t width;
742
743 explicit ATRACK6( ALTIUM_BINARY_PARSER& aReader );
744};
745
746struct ATEXT6
747{
749 {
753 };
754
755
757 uint16_t component = 0;
758
760 uint32_t height = 0;
761 double rotation = 0.0;
762 uint32_t strokewidth = 0;
764
765 bool isBold = false;
766 bool isItalic = false;
767 bool isMirrored = false;
768 bool isInverted = false;
769 bool isInvertedRect = false;
770 bool isFrame = false;
771 bool isOffsetBorder = false;
773
775 uint32_t textbox_rect_width = 0;
777 uint32_t text_offset_width = 0;
778
779 // Justification only applies when there is a text box size specified
780 // Then, the text is justified within the box
782
783 uint32_t widestring_index = 0;
784
785 bool isComment = false;
786 bool isDesignator = false;
787
789 wxString fontname;
790
791 wxString text;
792
793 explicit ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable );
794};
795
796struct AFILL6
797{
800
802 uint16_t component;
803 uint16_t net;
805
808 double rotation;
809
810 explicit AFILL6( ALTIUM_BINARY_PARSER& aReader );
811};
812
813
814#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
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
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 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
uint32_t textbox_rect_height
uint16_t component
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_LAYER layer
VECTOR2I position
ALTIUM_TEXT_TYPE fonttype
STROKE_FONT_TYPE strokefonttype
bool isOffsetBorder
ATEXT6(ALTIUM_BINARY_PARSER &aReader, std::map< uint32_t, wxString > &aStringTable)
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