41 #include <compoundfilereader.h> 46 #include <wx/docview.h> 47 #include <wx/mstream.h> 48 #include <wx/wfstream.h> 49 #include <wx/zstream.h> 53 const std::map<ALTIUM_PCB_DIR, std::string>& aFileMapping )
56 FILE* fp = wxFopen( aFileName,
"rb" );
64 fseek( fp, 0, SEEK_END );
65 long len = ftell( fp );
70 THROW_IO_ERROR(
"Reading error, cannot determine length of file" );
73 std::unique_ptr<unsigned char[]> buffer(
new unsigned char[len] );
74 fseek( fp, 0, SEEK_SET );
76 size_t bytesRead = fread( buffer.get(),
sizeof(
unsigned char ), len, fp );
79 if( static_cast<size_t>( len ) != bytesRead )
86 CFB::CompoundFileReader reader( buffer.get(), bytesRead );
90 pcb.Parse( reader, aFileMapping );
92 catch( CFB::CFBException& exception )
124 "of %d existing components",
142 FP_SHAPE* fpShape = dynamic_cast<FP_SHAPE*>( aShape );
166 for(
auto& vertice : aVertices )
168 if( vertice.isRound )
172 double startradiant =
DEG2RAD( vertice.startangle );
173 double endradiant =
DEG2RAD( vertice.endangle );
174 wxPoint arcStartOffset = wxPoint(
KiROUND( std::cos( startradiant ) * vertice.radius ),
175 -
KiROUND( std::sin( startradiant ) * vertice.radius ) );
177 wxPoint arcEndOffset = wxPoint(
KiROUND( std::cos( endradiant ) * vertice.radius ),
178 -
KiROUND( std::sin( endradiant ) * vertice.radius ) );
180 wxPoint arcStart = vertice.center + arcStartOffset;
181 wxPoint arcEnd = vertice.center + arcEndOffset;
195 aLine.
Append( vertice.position );
205 auto override =
m_layermap.find( aAltiumLayer );
208 return override->second;
211 switch( aAltiumLayer )
320 const std::map<ALTIUM_PCB_DIR, std::string>& aFileMapping )
323 const std::vector<std::tuple<bool, ALTIUM_PCB_DIR, PARSE_FUNCTION_POINTER_fp>> parserOrder = {
325 [
this](
auto aReader,
auto fileHeader ) {
329 [
this](
auto aReader,
auto fileHeader ) {
333 [
this](
auto aReader,
auto fileHeader ) {
337 [
this, aFileMapping](
auto aReader,
auto fileHeader ) {
343 [
this](
auto aReader,
auto fileHeader ) {
347 [
this](
auto aReader,
auto fileHeader ) {
351 [
this](
auto aReader,
auto fileHeader ) {
355 [
this](
auto aReader,
auto fileHeader ) {
359 [
this](
auto aReader,
auto fileHeader ) {
363 [
this](
auto aReader,
auto fileHeader ) {
367 [
this](
auto aReader,
auto fileHeader ) {
371 [
this](
auto aReader,
auto fileHeader ) {
375 [
this](
auto aReader,
auto fileHeader ) {
379 [
this](
auto aReader,
auto fileHeader ) {
383 [
this](
auto aReader,
auto fileHeader ) {
387 [
this](
auto aReader,
auto fileHeader ) {
391 [
this](
auto aReader,
auto fileHeader ) {
395 [
this](
auto aReader,
auto fileHeader ) {
399 [
this](
auto aReader,
auto fileHeader ) {
405 for(
const std::tuple<bool, ALTIUM_PCB_DIR, PARSE_FUNCTION_POINTER_fp>& cur : parserOrder )
410 std::tie( isRequired, directory, fp ) = cur;
412 const auto& mappedDirectory = aFileMapping.find( directory );
413 if( mappedDirectory == aFileMapping.end() )
415 wxASSERT_MSG( !isRequired,
wxString::Format(
"Altium Directory of kind %d was expected, " 416 "but no mapping is present in the code",
421 const CFB::COMPOUND_FILE_ENTRY* file =
422 FindStream( aReader, mappedDirectory->second.c_str() );
423 if( file !=
nullptr )
427 else if( isRequired )
429 wxLogError(
wxString::Format(
_(
"File not found: '%s'" ), mappedDirectory->second ) );
440 if( zone->GetPriority() == 1000 )
451 zone->SetPriority( priority >= 0 ? priority : 0 );
457 zone.second->SetPriority( 0 );
466 int desired_x = ( w - bbbox.
GetWidth() ) / 2;
467 int desired_y = ( h - bbbox.
GetHeight() ) / 2;
469 wxPoint movementVector( desired_x - bbbox.
GetX(), desired_y - bbbox.
GetY() );
486 "Netcode with id %d does not exist. Only %d nets are known", aId,
m_num_nets ) );
496 const auto rules =
m_rules.find( aKind );
501 for(
const ARULE6& rule : rules->second )
503 if( rule.
name == aName )
513 const auto rules =
m_rules.find( aKind );
518 for(
const ARULE6& rule : rules->second )
529 const CFB::COMPOUND_FILE_ENTRY* aEntry )
548 const CFB::COMPOUND_FILE_ENTRY* aEntry )
563 size_t layercount = 0;
565 i < elem.
stackup.size() && i != 0; i = elem.
stackup[i - 1].nextId, layercount++ )
567 size_t kicadLayercount = ( layercount % 2 == 0 ) ? layercount : layercount + 1;
577 auto it = stackup.
GetList().begin();
582 auto curLayer = static_cast<int>(
F_Cu );
584 altiumLayerId < elem.
stackup.size() && altiumLayerId != 0;
585 altiumLayerId = elem.
stackup[altiumLayerId - 1].nextId )
591 if( layer.
nextId == 0 && layercount != kicadLayercount )
597 THROW_IO_ERROR(
"Board6 stream, unexpected item while parsing stackup" );
599 ( *it )->SetThickness( 0 );
604 THROW_IO_ERROR(
"Board6 stream, unexpected item while parsing stackup" );
606 ( *it )->SetThickness( 0, 0 );
607 ( *it )->SetThicknessLocked(
true, 0 );
611 m_layermap.insert( { static_cast<ALTIUM_LAYER>( altiumLayerId ),
612 static_cast<PCB_LAYER_ID>( curLayer++ ) } );
616 THROW_IO_ERROR(
"Board6 stream, unexpected item while parsing stackup" );
620 ALTIUM_LAYER alayer = static_cast<ALTIUM_LAYER>( altiumLayerId );
638 THROW_IO_ERROR(
"Board6 stream, unexpected id while parsing last stackup layer" );
648 THROW_IO_ERROR(
"Board6 stream, unexpected item while parsing stackup" );
666 ALTIUM_LAYER alayer = static_cast<ALTIUM_LAYER>( altiumLayerId );
678 ALTIUM_LAYER alayer = static_cast<ALTIUM_LAYER>( altiumLayerId );
689 if( !aVertices.empty() )
692 for(
size_t i = 0; i < aVertices.size(); i++ )
694 const ALTIUM_VERTICE* cur = &aVertices.at( ( i + 1 ) % aVertices.size() );
714 wxPoint arcStartOffset = wxPoint(
KiROUND( std::cos( startradiant ) * cur->
radius ),
716 wxPoint arcStart = cur->
center + arcStartOffset;
723 wxPoint arcEndOffset = wxPoint(
KiROUND( std::cos( endradiant ) * cur->
radius ),
725 wxPoint arcEnd = cur->
center + arcEndOffset;
737 if( lineLengthStart > lineLengthEnd )
753 const CFB::COMPOUND_FILE_ENTRY* aEntry )
763 NETCLASSPTR nc = std::make_shared<NETCLASS>( elem.
name );
789 const CFB::COMPOUND_FILE_ENTRY* aEntry )
793 uint16_t componentId = 0;
812 if( reference.find_first_not_of(
"0123456789" ) == wxString::npos )
813 reference.Prepend(
"UNK" );
832 const CFB::COMPOUND_FILE_ENTRY* aEntry )
848 "ComponentsBodies6 stream tries to access component id %d of %d existing components",
861 "ComponentsBodies6 stream tries to access model id %s which does not exist",
866 const wxPoint& fpPosition = footprint->
GetPosition();
870 modelSettings.
m_Filename = modelTuple->second;
881 orientation = -orientation;
893 footprint->
Models().push_back( modelSettings );
907 THROW_IO_ERROR(
"Incorrect number of reference points for linear dimension object" );
914 wxLogWarning(
wxString::Format(
_(
"Dimension on Altium layer %d has no KiCad equivalent. " 915 "Put it on Eco1_User instead" ),
928 dimension->
SetStart( referencePoint0 );
930 if( referencePoint0 != aElem.
xy1 )
941 wxPoint direction = aElem.
xy1 - referencePoint0;
942 wxPoint directionNormalVector = wxPoint( -direction.y, direction.x );
943 SEG segm1( referencePoint0, referencePoint0 + directionNormalVector );
944 SEG segm2( referencePoint1, referencePoint1 + direction );
945 wxPoint intersection( segm1.
Intersect( segm2,
true,
true ).get() );
946 dimension->
SetEnd( intersection );
950 if( direction.x <= 0 && direction.y <= 0 )
959 dimension->
SetEnd( referencePoint1 );
991 wxLogWarning(
wxString::Format(
_(
"Dimension on Altium layer %d has no KiCad equivalent. " 992 "Put it on Eco1_User instead" ),
1002 wxPoint last = referencePoint0;
1019 if( dirVec.x != 0 || dirVec.y != 0 )
1023 wxPoint(
KiROUND( dirVec.x / scaling ),
KiROUND( dirVec.y / scaling ) );
1031 shape1->
SetStart( referencePoint0 );
1032 shape1->
SetEnd( referencePoint0 + arrVec );
1041 shape2->
SetStart( referencePoint0 );
1042 shape2->
SetEnd( referencePoint0 + arrVec );
1049 wxLogError(
"No text position present for leader dimension object" );
1069 wxLogWarning(
wxString::Format(
_(
"Dimension on Altium layer %d has no KiCad equivalent. " 1070 "Put it on Eco1_User instead" ),
1092 wxLogWarning(
wxString::Format(
_(
"Dimension on Altium layer %d has no KiCad equivalent. " 1093 "Put it on Eco1_User instead" ),
1098 wxPoint vec = wxPoint( 0, aElem.
height / 2 );
1111 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1148 const CFB::COMPOUND_FILE_ENTRY* aEntry,
const wxString aRootDir )
1162 const wxString altiumModelDir =
"ALTIUM_EMBEDDED_MODELS";
1164 wxFileName altiumModelsPath = wxFileName::DirName( projectPath );
1165 wxString kicadModelPrefix =
"${KIPRJMOD}/" + altiumModelDir +
"/";
1166 if( !altiumModelsPath.AppendDir( altiumModelDir ) )
1168 THROW_IO_ERROR(
"Cannot construct directory path for step models" );
1172 if( !altiumModelsPath.DirExists() )
1174 if( !altiumModelsPath.Mkdir() )
1177 _(
"Cannot create directory \"%s\" -> no 3D-models will be imported." ),
1178 altiumModelsPath.GetFullPath() ) );
1188 wxString stepPath = aRootDir + std::to_string( idx++ );
1190 const CFB::COMPOUND_FILE_ENTRY* stepEntry =
FindStream( aReader, stepPath.c_str() );
1192 size_t stepSize = static_cast<size_t>( stepEntry->size );
1193 std::unique_ptr<char[]> stepContent(
new char[stepSize] );
1196 aReader.ReadFile( stepEntry, 0, stepContent.get(), stepSize );
1198 wxFileName storagePath( altiumModelsPath.GetPath(), elem.
name );
1199 if( !storagePath.IsDirWritable() )
1202 wxString::Format(
_(
"You do not have write permissions to save file \"%s\"." ),
1203 storagePath.GetFullPath() ) );
1207 wxMemoryInputStream stepStream( stepContent.get(), stepSize );
1208 wxZlibInputStream zlibInputStream( stepStream );
1210 wxFFileOutputStream outputStream( storagePath.GetFullPath() );
1211 outputStream.Write( zlibInputStream );
1212 outputStream.Close();
1225 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1232 ANET6 elem( reader );
1244 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1255 wxLogWarning(
wxString::Format(
_(
"Polygon on Altium layer %d has no KiCad equivalent. " 1256 "Ignore it instead" ),
1267 wxLogError(
wxString::Format(
_(
"Polygon has only %d point extracted from %ld vertices. " 1268 "At least 2 points are required." ),
1293 if( clearanceRule !=
nullptr )
1300 if( polygonConnectRule !=
nullptr )
1336 cur_outer_plane->second->GetBoundingBox() ) )
1373 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1387 std::sort( val.second.begin(), val.second.end(),
1388 [](
const auto& lhs,
const auto& rhs )
1390 return lhs.priority < rhs.priority;
1401 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1419 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1439 _(
"ShapeBasedRegion has only %d point extracted from %ld vertices. At least 2 points are required." ),
1469 "equivalent. Put it on Eco1_User instead" ),
1487 "equivalent. Put it on Eco1_User instead" ),
1497 wxLogError(
wxString::Format(
_(
"Polygon has only %d point extracted from %ld " 1498 "vertices. At least 2 points are required." ),
1515 wxLogError(
wxString::Format(
"Ignore polygon shape of kind %d on layer %s, because " 1516 "not implemented yet",
1524 THROW_IO_ERROR(
"ShapeBasedRegions6 stream is not fully parsed" );
1529 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1548 "Region stream tries to access polygon id %d of %d existing polygons",
1554 if( zone ==
nullptr )
1576 for(
const std::vector<ALTIUM_VERTICE>& hole : elem.
holes )
1583 hole_linechain.
Append( hole.at( 0 ).position );
1585 rawPolys.
AddHole( hole_linechain );
1613 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1619 AARC6 elem( reader );
1647 wxPoint arcStartOffset = wxPoint(
KiROUND( std::cos( startradiant ) * elem.
radius ),
1674 "KiCad equivalent. Put it on Eco1_User instead" ),
1692 wxLogWarning(
wxString::Format(
_(
"Arc on Altium layer %d has no KiCad equivalent. " 1693 "Put it on Eco1_User instead" ),
1698 if( klayer >=
F_Cu && klayer <=
B_Cu )
1702 wxPoint arcStartOffset = wxPoint(
KiROUND( std::cos( startradiant ) * elem.
radius ),
1731 wxPoint arcStartOffset = wxPoint(
KiROUND( std::cos( startradiant ) * elem.
radius ),
1748 const CFB::COMPOUND_FILE_ENTRY* aEntry )
1754 APAD6 elem( reader );
1778 "of %d existing components",
1785 PAD* pad =
new PAD( footprint );
1808 "Pad '%s' of Footprint %s is not marked as multilayer, but it is an THT pad",
1823 wxFAIL_MSG(
"Round holes are handled before the switch" );
1827 wxLogWarning(
wxString::Format(
_(
"Pad '%s' of Footprint %s has a square hole. " 1828 "KiCad does not support this yet" ),
1839 double normalizedSlotrotation =
1841 if( normalizedSlotrotation == 0. || normalizedSlotrotation == 180. )
1847 if( normalizedSlotrotation != 90. && normalizedSlotrotation != 270. )
1850 "hole-rotation of %f degree. KiCad " 1851 "only supports 90 degree angles" ),
1854 normalizedSlotrotation ) );
1865 "Pad '%s' of Footprint %s uses a hole of unknown kind %d", elem.
name,
1882 _(
"Pad '%s' of Footprint %s uses a complex pad stack (kind %d), which is not supported yet" ),
1896 double ratio = elem.
sizeAndShape->cornerradius[0] / 200.;
1915 wxLogError(
wxString::Format(
"Pad '%s' of Footprint %s uses a unknown pad-shape",
1920 switch( elem.
layer )
1973 wxLogWarning(
wxString::Format(
_(
"Non-Copper Pad on Altium layer %d has no KiCad " 1974 "equivalent. Put it on Eco1_User instead" ),
1981 wxLogError(
wxString::Format(
"Non-Copper Pad '%s' is connected to a net. This is not " 1988 wxLogError(
wxString::Format(
_(
"Non-Copper Pad '%s' has a hole. This should not happen" ),
1994 wxLogWarning(
wxString::Format(
_(
"Non-Copper Pad '%s' uses a complex pad stack (kind %d). " 1995 "This should not happen" ),
2028 int cornerradius = aElem.
sizeAndShape->cornerradius[0];
2029 int offset = ( std::min( aElem.
topsize.x, aElem.
topsize.y ) * cornerradius ) / 200;
2035 if( cornerradius < 100 )
2037 int offsetX = aElem.
topsize.x / 2 - offset;
2038 int offsetY = aElem.
topsize.y / 2 - offset;
2040 wxPoint p11 = aElem.
position + wxPoint( offsetX, offsetY );
2041 wxPoint p12 = aElem.
position + wxPoint( offsetX, -offsetY );
2042 wxPoint p22 = aElem.
position + wxPoint( -offsetX, -offsetY );
2043 wxPoint p21 = aElem.
position + wxPoint( -offsetX, offsetY );
2062 wxPoint pointOffset( 0, ( aElem.
topsize.y - aElem.
topsize.x ) / 2 );
2070 wxPoint pointOffset( ( aElem.
topsize.x - aElem.
topsize.y ) / 2, 0 );
2135 wxPoint chamferX( chamfer, 0 );
2136 wxPoint chamferY( 0, chamfer );
2138 shape->
SetPolyPoints( { p11 - chamferX, p11 - chamferY, p12 + chamferY, p12 - chamferX,
2139 p22 + chamferX, p22 + chamferY, p21 - chamferY, p21 + chamferX } );
2157 const CFB::COMPOUND_FILE_ENTRY* aEntry )
2163 AVIA6 elem( reader );
2179 if( start_layer_outside && end_layer_outside )
2183 else if( ( !start_layer_outside ) && ( !end_layer_outside ) )
2197 "Via from layer %d <-> %d uses non-copper layer. This should not happen.",
2213 const CFB::COMPOUND_FILE_ENTRY* aEntry )
2260 _(
"Track Keepout on Altium layer %d has no KiCad equivalent. Put it on Eco1_User instead" ),
2278 _(
"Track on Altium layer %d has no KiCad equivalent. Put it on Eco1_User instead" ),
2283 if( klayer >=
F_Cu && klayer <=
B_Cu )
2315 const CFB::COMPOUND_FILE_ENTRY* aEntry )
2326 _(
"Ignore Barcode on Altium layer %d because it is not supported right now." ),
2347 "of %d existing components",
2361 fpText = &footprint->
Value();
2365 fpText =
new FP_TEXT( footprint );
2375 wxString trimmedText = elem.
text.Trim();
2376 if( !elem.
isDesignator && trimmedText.CmpNoCase(
".Designator" ) == 0 )
2378 tx->
SetText(
"${REFERENCE}" );
2380 else if( !elem.
isComment && trimmedText.CmpNoCase(
".Comment" ) == 0 )
2384 else if( trimmedText.CmpNoCase(
".Layer_Name" ) == 0 )
2398 FP_TEXT* fpText = dynamic_cast<FP_TEXT*>( tx );
2415 _(
"Text on Altium layer %d has no KiCad equivalent. Put it on Eco1_User instead" ),
2462 wxLogError(
"Unexpected horizontal Text Position. This should never happen." );
2484 wxLogError(
"Unexpected vertical text position. This should never happen." );
2497 const CFB::COMPOUND_FILE_ENTRY* aEntry )
2505 wxPoint p11( elem.
pos1.x, elem.
pos1.y );
2506 wxPoint p12( elem.
pos1.x, elem.
pos2.y );
2507 wxPoint p22( elem.
pos2.x, elem.
pos2.y );
2508 wxPoint p21( elem.
pos2.x, elem.
pos1.y );
2510 wxPoint center( ( elem.
pos1.x + elem.
pos2.x ) / 2, ( elem.
pos1.y + elem.
pos2.y ) / 2 );
2515 wxLogWarning(
wxString::Format(
_(
"Fill on Altium layer %d has no KiCad equivalent. " 2516 "Put it on Eco1_User instead" ),
2532 const int outlineIdx = -1;
void SetMirrored(bool isMirrored)
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
void HelperParseDimensions6Datum(const ADIMENSION6 &aElem)
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
FP_3DMODEL::VECTOR3D modelPosition
int32_t soldermaskexpansionmanual
void SetOffset(const wxPoint &aOffset)
void Parse(const CFB::CompoundFileReader &aReader, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
int planeclearanceClearance
void SetHatchThickness(int aThickness)
void ParseVias6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
const PAGE_INFO & GetPageSettings() const
LSET FlipLayerMask(LSET aMask, int aCopperLayersCount)
Calculate the mask layer when flipping a footprint.
void ParseShapeBasedRegions6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
ALTIUM_PAD_SHAPE topshape
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
std::vector< ZONE * > m_polygons
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
wxPoint m_GridOrigin
origin for grid offsets
const ARULE6 * GetRule(ALTIUM_RULE_KIND aKind, const wxString &aName) const
void SetDoNotAllowTracks(bool aEnable)
virtual void SetStart(const wxPoint &aPoint)
SHAPE_POLY_SET & GetPolyShape()
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
void ParseComponents6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
virtual void SetPosition(const wxPoint &aPos) override
void ParseRules6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
this class manage the layers needed to make a physical board they are solder mask,...
void SetPosition(const wxPoint &aPoint) override
ALTIUM_DIMENSION_KIND kind
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual void SetPosition(const wxPoint &aPos)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetEnd(const wxPoint &aEnd)
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetBorderDisplayStyle sets all hatch parameters for the zone.
const EDA_RECT GetBoardEdgesBoundingBox() const
Returns the board bounding box calculated using exclusively the board edges (graphics on Edge....
void ParsePolygons6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
void SetFilled(bool aFlag)
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
void SetTextAngle(double aAngle) override
size_t GetRemainingBytes() const
void SetLayerSet(LSET aLayerSet) override
SHAPE_POLY_SET * Outline()
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetItalic(bool isItalic)
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
void SetOrientationDegrees(double aOrientation)
Set orientation in degrees.
Smd pad, appears on the solder paste layer (default)
int32_t polygonconnectAirgapwidth
polygon (not yet used for tracks, but could be in microwave apps)
void SetVisible(bool aVisible)
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
double GetTextAngle() const
void SetCopperLayerCount(int aCount)
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
std::vector< std::vector< ALTIUM_VERTICE > > holes
usual segment : line with rounded ends
wxString sourcedesignator
const uint16_t ALTIUM_POLYGON_NONE
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void ParseComponentsBodies6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
ALTIUM_PAD_RULE soldermaskexpansionmode
void SetUnits(EDA_UNITS aUnits)
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void SetTextSize(const wxSize &aNewSize)
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
void SetSize(const wxSize &aSize)
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
wxString sourcefootprintlibrary
void RotatePoint(int *pX, int *pY, double angle)
like PAD_PTH, but not plated mechanical use only, no connection allowed
A logical library item identifier and consists of various portions much like a URI.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
PCB_LAYER_ID GetKicadLayer(ALTIUM_LAYER aAltiumLayer) const
int PointCount() const
Function PointCount()
void SetPriority(unsigned aPriority)
Function SetPriority.
const wxString & GetFileName() const
VECTOR3D m_Offset
3D model offset (mm)
void ParseArcs6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
void SetFillMode(ZONE_FILL_MODE aFillMode)
std::map< ALTIUM_LAYER, ZONE * > m_outer_plane
bool Contains(const wxPoint &aPoint) const
const ARULE6 * GetRuleDefault(ALTIUM_RULE_KIND aKind) const
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
ALTIUM_CONNECT_STYLE polygonconnectStyle
wxString dielectricmaterial
void SetWidth(int aWidth)
int GetNetCode(uint16_t aId) const
std::vector< wxString > names
std::vector< wxPoint > textPoint
void SetIsRuleArea(bool aEnable)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
std::map< wxString, wxString > m_models
void Rotate(const wxPoint &aCentre, double aAngle) override
Function Rotate Move the outlines.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
const CFB::COMPOUND_FILE_ENTRY * FindStream(const CFB::CompoundFileReader &aReader, const char *aStreamName)
void SetLocalSolderMaskMargin(int aMargin)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
void ParsePads6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
void SetClosed(bool aClosed)
Function SetClosed()
void HelperParseDimensions6Leader(const ADIMENSION6 &aElem)
std::vector< FOOTPRINT * > m_components
void ParseRegions6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
size_t ReadAndSetSubrecordLength()
BOARD_STACKUP & GetStackupDescriptor()
PCB_LAYER_ID
A quick note on layer IDs:
double NormalizeAngleDegreesPos(double Angle)
Normalize angle to be in the 0.0 .
ALTIUM_PAD_RULE pastemaskexpansionmode
void SetHeight(int aHeight)
Sets the distance from the feature points to the crossbar line.
LSET is a set of PCB_LAYER_IDs.
std::map< ALTIUM_LAYER, PCB_LAYER_ID > m_layermap
pads are covered by copper
void ParseDimensions6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
int GetMinThickness() const
virtual void SetText(const wxString &aText)
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox (virtual)
void SetHatchGap(int aStep)
void Move(const VECTOR2I &aVector) override
void SetShape(PCB_SHAPE_TYPE_T aShape)
void ParseTexts6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
void SetLocalCoord()
< Set relative coordinates.
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
wxString NotSpecifiedPrm()
void SetDoNotAllowPads(bool aEnable)
Represent a set of closed polygons.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
void SetDrillSize(const wxSize &aSize)
const uint16_t ALTIUM_NET_UNCONNECTED
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
void ParseClasses6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
void HelperShapeLineChainFromAltiumVertices(SHAPE_LINE_CHAIN &aLine, const std::vector< ALTIUM_VERTICE > &aVertices)
void ParseFileHeader(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
static LSET PTHMask()
layer set for a through hole pad
void ParseBoardRegionsData(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
virtual void SetEnd(const wxPoint &aPoint)
void SetDoNotAllowVias(bool aEnable)
NETCLASSES & GetNetClasses() const
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_layer contains the top layer, the other layer is in m_bottomLayer.
void Simplify(POLYGON_MODE aFastMode)
ZONE handles a list of polygons defining a copper zone.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
LIB_ID AltiumToKiCadLibID(wxString aLibName, wxString aLibReference)
void SetMinThickness(int aMinThickness)
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
void SetIsFilled(bool isFilled)
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Return the area of this poly set.
void HelperParseDimensions6Center(const ADIMENSION6 &aElem)
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
int m_highest_pour_index
Altium stores pour order across all layers.
FP_3DMODEL::VECTOR3D modelRotation
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxString m_Filename
The 3D shape filename in 3D library.
void ParseModelsData(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry, const wxString aRootDir)
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void Move(const wxPoint &aMoveVector) override
Move this object.
Use thermal relief for pads.
bool Add(const NETCLASSPTR &aNetclass)
Add aNetclass and puts it into this NETCLASSES container.
void SetKeepUpright(bool aKeepUpright)
void ParseTracks6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
Handle the data for a net.
void SetPadConnection(ZONE_CONNECTION aPadConnection)
std::vector< ALTIUM_VERTICE > vertices
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
void SetLayerSet(LSET aLayers) override
void HelperParseDimensions6Linear(const ADIMENSION6 &aElem)
void SetPosition(const wxPoint &aPos) override
void RemoveAll()
Delete all items in list and clear the list.
ALTIUM_TEXT_POSITION textposition
VECTOR3D m_Rotation
3D model rotation (degrees)
double DEG2RAD(double deg)
void HelperParsePad6NonCopper(const APAD6 &aElem)
void SetLocalSolderPasteMargin(int aMargin)
void SetStart(const wxPoint &aStart)
void ParseNets6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
Information pertinent to a Pcbnew printed circuit board.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
void SetDoNotAllowCopperPour(bool aEnable)
void SetPrecision(int aPrecision)
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
std::vector< ALTIUM_VERTICE > outline
void SetPosition(const wxPoint &aPos) override
int32_t pastemaskexpansionmanual
Handle the component boundary box.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
void SetWidth(int aWidth)
void HelperCreateBoardOutline(const std::vector< ALTIUM_VERTICE > &aVertices)
void SetHatchOrientation(double aStep)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
SHAPE_POLY_SET & RawPolysList(PCB_LAYER_ID aLayer)
bool IsAltiumLayerCopper(ALTIUM_LAYER aLayer)
void SetFillVersion(int aVersion)
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void SetThermalReliefGap(int aThermalReliefGap)
std::map< ALTIUM_RULE_KIND, std::vector< ARULE6 > > m_rules
std::unique_ptr< APAD6_SIZE_AND_SHAPE > sizeAndShape
void SetStart(const wxPoint &aStart)
void SetLocalCoord()
Set relative coordinates from draw coordinates.
void ParseFills6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
std::vector< ALTIUM_VERTICE > board_vertices
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetPolyShape(const SHAPE_POLY_SET &aShape)
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
const int ALTIUM_COMPONENT_NONE
void SetNeedRefill(bool aNeedRefill)
void SetLocalClearance(int aClearance)
virtual void SetTextAngle(double aAngle)
void SetLineThickness(int aWidth)
void SetRawPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Function SetFilledPolysList sets the list of filled polygons.
std::vector< wxPoint > referencePoint
std::vector< ABOARD6_LAYER_STACKUP > stackup
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
void ParseAltiumPcb(BOARD *aBoard, const wxString &aFileName, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
Helper method which opens a Altium Board File and parses it.
For better understanding of the points that make a dimension:
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Creates a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
void ParseBoard6Data(const CFB::CompoundFileReader &aReader, const CFB::COMPOUND_FILE_ENTRY *aEntry)
BOARD_ITEM_CONTAINER * GetParent() const
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
bool IsAltiumLayerAPlane(ALTIUM_LAYER aLayer)
void SetViaType(VIATYPE aViaType)
static LSET SMDMask()
layer set for a SMD pad on Front layer
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
#define THROW_IO_ERROR(msg)
PCB_SHAPE * HelperCreateAndAddDrawsegment(uint16_t aComponent)
ALTIUM_TEXT_TYPE fonttype
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
void HelperDrawsegmentSetLocalCoord(PCB_SHAPE *aShape, uint16_t aComponent)
wxPoint m_AuxOrigin
origin for plot exports
void SetEnd(const wxPoint &aEnd)
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
std::function< void(const CFB::CompoundFileReader &, const CFB::COMPOUND_FILE_ENTRY *)> PARSE_FUNCTION_POINTER_fp
void SetDoNotAllowFootprints(bool aEnable)
bool GetFilledPolysUseThickness() const
Container for design settings for a BOARD object.
int32_t polygonconnectReliefconductorwidth
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
ALTIUM_PCB(BOARD *aBoard)
Marks the center of a circle or arc with a cross shape The size and orientation of the cross is adjus...
void SetAttribute(PAD_ATTR_T aAttribute)