|
KiCad PCB EDA Suite
|
Builds KiCad board objects from the PADS_IO model structs. More...
#include <pads_pcb_converter.h>
Public Member Functions | |
| PADS_PCB_CONVERTER (BOARD *aBoard, REPORTER *aReporter) | |
| BOARD * | GetBoard () const |
| PADS_UNIT_CONVERTER & | UnitConverter () |
| void | SetScaleFactor (double aScaleFactor) |
| Set the nanometers-per-file-unit factor used by the coordinate transform. | |
| double | GetScaleFactor () const |
| void | SetOrigin (double aX, double aY) |
| double | GetOriginX () const |
| double | GetOriginY () const |
| bool | SetOriginFromOutlines (const std::vector< PADS_IO::POLYLINE > &aOutlines) |
| Move the origin to the center of the board outline bounding box, which places the imported board near the KiCad page origin when the file has no useful origin of its own. | |
| int | ScaleSize (double aVal) const |
| int | ScaleCoord (double aVal, bool aIsX) const |
| VECTOR2I | ScalePoint (double aX, double aY) const |
| void | SetupLayers (const std::vector< PADS_IO::LAYER_INFO > &aPadsLayers, int aPadsLayerCount, const LAYER_MAPPING_HANDLER &aMappingHandler, bool aResolveUnknownTypeByName) |
| Resolve the PADS layer table to KiCad layers and apply the copper layer count to the board. | |
| const std::vector< PADS_LAYER_INFO > & | GetLayerInfos () const |
| PCB_LAYER_ID | GetMappedLayer (int aPadsLayer) const |
| void | BuildStackup (const std::vector< PADS_IO::LAYER_INFO > &aPadsLayers) |
| Build the board stackup from the PADS physical layer data, if that data carries real thicknesses or dielectric constants. | |
| void | EnsureNet (const std::string &aNetName) |
| void | AppendArcPoints (SHAPE_LINE_CHAIN &aChain, const std::vector< PADS_IO::ARC_POINT > &aPts) const |
| Append PADS vertices to a chain, converting arc entries to polylines and expanding a lone full-circle entry to a 36-segment polygon. | |
| SHAPE_ARC | MakeMidpointArc (const PADS_IO::ARC_POINT &aPrev, const PADS_IO::ARC_POINT &aCurr, int aWidth) const |
| Build a SHAPE_ARC from two consecutive PADS points. | |
| void | LoadTexts (const std::vector< PADS_IO::TEXT > &aTexts) |
| void | LoadKeepouts (const std::vector< PADS_IO::KEEPOUT > &aKeepouts) |
| void | LoadDimensions (const std::vector< PADS_IO::DIMENSION > &aDimensions) |
| void | ApplyPourSettings (ZONE *aZone, const PADS_IO::POUR &aPour, int aMaxPriority, const PADS_IO::PARAMETERS &aParams) |
Apply the cutout or fill settings of aPour to a zone whose outline the caller has already built. | |
| void | WriteDiffPairRules (const wxString &aFileName, const std::vector< PADS_IO::DIFF_PAIR_DEF > &aDiffPairs) |
Write a .kicad_dru beside aFileName carrying one clearance rule per differential pair with a gap. | |
| void | ReportStatistics () |
Private Attributes | |
| BOARD * | m_board |
| REPORTER * | m_reporter |
| PADS_UNIT_CONVERTER | m_unitConverter |
| double | m_scaleFactor = 0.0 |
| double | m_originX = 0.0 |
| double | m_originY = 0.0 |
| PADS_LAYER_MAPPER | m_layerMapper |
| std::vector< PADS_LAYER_INFO > | m_layerInfos |
| std::map< wxString, PCB_LAYER_ID > | m_layerMap |
| int | m_copperLayerCount = 2 |
Builds KiCad board objects from the PADS_IO model structs.
The ASCII and binary PADS readers fill the same model, so everything downstream of the reader is shared: the unit and coordinate transform, the layer mapping, the net table and the model-to-BOARD conversion itself. Each plugin owns one converter for the duration of a LoadBoard call and drives it with the structs its parser produced.
The transform is not usable until SetupLayers(), the units and SetOrigin() are configured, because a PADS coordinate only becomes a KiCad position once the file's units and origin are known.
Definition at line 53 of file pads_pcb_converter.h.
| aBoard | receives every object the converter creates. |
| aReporter | collects import warnings, and may be null. |
Definition at line 50 of file pads_pcb_converter.cpp.
References m_board, and m_reporter.
| void PADS_PCB_CONVERTER::AppendArcPoints | ( | SHAPE_LINE_CHAIN & | aChain, |
| const std::vector< PADS_IO::ARC_POINT > & | aPts ) const |
Append PADS vertices to a chain, converting arc entries to polylines and expanding a lone full-circle entry to a 36-segment polygon.
Definition at line 346 of file pads_pcb_converter.cpp.
References std::abs(), SHAPE_LINE_CHAIN::Append(), center, SHAPE_ARC::ConvertToPolyline(), SHAPE_LINE_CHAIN::CPoint(), PADS_IO::ARC_POINT::is_arc, KiROUND(), M_PI, MakeMidpointArc(), SHAPE_LINE_CHAIN::PointCount(), radius, ScalePoint(), ScaleSize(), PADS_IO::ARC_POINT::x, VECTOR2< T >::x, PADS_IO::ARC_POINT::y, and VECTOR2< T >::y.
Referenced by LoadKeepouts().
| void PADS_PCB_CONVERTER::ApplyPourSettings | ( | ZONE * | aZone, |
| const PADS_IO::POUR & | aPour, | ||
| int | aMaxPriority, | ||
| const PADS_IO::PARAMETERS & | aParams ) |
Apply the cutout or fill settings of aPour to a zone whose outline the caller has already built.
| aMaxPriority | is the largest priority in the pour set, used to invert the PADS convention where the lowest number fills on top. |
Definition at line 672 of file pads_pcb_converter.cpp.
References PADS_COMMON::ConvertInvertedNetName(), PADS_COMMON::ConvertText(), FULL, PADS_IO::POUR::is_cutout, m_board, PADS_IO::POUR::net_name, PADS_IO::POUR::owner_pour, PADS_IO::POUR::priority, ScaleSize(), ZONE::SetAssignedPriority(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetDoNotAllowZoneFills(), ZONE::SetIsRuleArea(), ZONE::SetMinThickness(), ZONE::SetNet(), ZONE::SetPadConnection(), ZONE::SetThermalReliefGap(), ZONE::SetThermalReliefSpokeWidth(), ZONE::SetZoneName(), PADS_IO::PARAMETERS::thermal_line_width, PADS_IO::PARAMETERS::thermal_min_clearance, and PADS_IO::POUR::width.
| void PADS_PCB_CONVERTER::BuildStackup | ( | const std::vector< PADS_IO::LAYER_INFO > & | aPadsLayers | ) |
Build the board stackup from the PADS physical layer data, if that data carries real thicknesses or dielectric constants.
Requires SetupLayers() and the units to be configured, since the layer thicknesses are scaled here.
Definition at line 248 of file pads_pcb_converter.cpp.
References BS_ITEM_TYPE_COPPER, BS_ITEM_TYPE_DIELECTRIC, BS_ITEM_TYPE_SILKSCREEN, BS_ITEM_TYPE_SOLDERMASK, BOARD_STACKUP::BuildBoardThicknessFromStackup(), BOARD_STACKUP::BuildDefaultStackupList(), PADS_IO::LAYER_INFO::dielectric_constant, BOARD_STACKUP::GetList(), GetMappedLayer(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), PADS_IO::LAYER_INFO::layer_thickness, m_board, m_copperLayerCount, BOARD_DESIGN_SETTINGS::m_HasStackup, BOARD_STACKUP::RemoveAll(), ScaleSize(), BOARD_DESIGN_SETTINGS::SetBoardThickness(), and UNDEFINED_LAYER.
| void PADS_PCB_CONVERTER::EnsureNet | ( | const std::string & | aNetName | ) |
Definition at line 331 of file pads_pcb_converter.cpp.
References PADS_COMMON::ConvertInvertedNetName(), and m_board.
|
inline |
Definition at line 62 of file pads_pcb_converter.h.
References m_board.
|
inline |
Definition at line 108 of file pads_pcb_converter.h.
References m_layerInfos.
| PCB_LAYER_ID PADS_PCB_CONVERTER::GetMappedLayer | ( | int | aPadsLayer | ) | const |
Definition at line 229 of file pads_pcb_converter.cpp.
References PADS_COMMON::ConvertText(), info, m_layerInfos, m_layerMap, m_layerMapper, and UNDEFINED_LAYER.
Referenced by BuildStackup(), LoadDimensions(), LoadKeepouts(), and LoadTexts().
|
inline |
Definition at line 76 of file pads_pcb_converter.h.
References m_originX.
|
inline |
Definition at line 78 of file pads_pcb_converter.h.
References m_originY.
|
inline |
Definition at line 72 of file pads_pcb_converter.h.
References m_scaleFactor.
| void PADS_PCB_CONVERTER::LoadDimensions | ( | const std::vector< PADS_IO::DIMENSION > & | aDimensions | ) |
Definition at line 602 of file pads_pcb_converter.cpp.
References Cmts_User, PADS_COMMON::ConvertText(), DEGREES_T, end, ADVANCED_CFG::GetCfg(), GetMappedLayer(), IsCopperLayer(), m_board, ADVANCED_CFG::m_PadsPcbTextHeightScale, ADVANCED_CFG::m_PadsPcbTextWidthScale, PCB_DIM_ALIGNED_T, pcbIUScale, ScalePoint(), ScaleSize(), PCB_DIMENSION_BASE::SetEnd(), PCB_DIM_ALIGNED::SetHeight(), BOARD_ITEM::SetLayer(), PCB_DIMENSION_BASE::SetLineThickness(), PCB_DIMENSION_BASE::SetOverrideText(), PCB_DIMENSION_BASE::SetOverrideTextEnabled(), PCB_DIMENSION_BASE::SetStart(), PCB_TEXT::SetTextAngle(), PCB_TEXT::SetTextSize(), PCB_TEXT::SetTextThickness(), UNDEFINED_LAYER, PCB_DIMENSION_BASE::Update(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE().
| void PADS_PCB_CONVERTER::LoadKeepouts | ( | const std::vector< PADS_IO::KEEPOUT > & | aKeepouts | ) |
Definition at line 503 of file pads_pcb_converter.cpp.
References _, std::abs(), SHAPE_POLY_SET::AddOutline(), PADS_IO::ALL, LSET::AllCuMask(), SHAPE_LINE_CHAIN::Append(), AppendArcPoints(), PADS_IO::COPPER, DIAGONAL_EDGE, ZONE::GetDefaultHatchPitch(), GetMappedLayer(), m_board, m_reporter, ZONE::Outline(), PADS_IO::PLACEMENT, PADS_IO::ROUTE, RPT_SEVERITY_WARNING, ScalePoint(), BASE_SET::set(), ZONE::SetBorderDisplayStyle(), SHAPE_LINE_CHAIN::SetClosed(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetDoNotAllowZoneFills(), ZONE::SetIsRuleArea(), ZONE::SetLayer(), ZONE::SetLayerSet(), ZONE::SetZoneName(), UNDEFINED_LAYER, PADS_IO::VIA, PADS_IO::ARC_POINT::x, and PADS_IO::ARC_POINT::y.
| void PADS_PCB_CONVERTER::LoadTexts | ( | const std::vector< PADS_IO::TEXT > & | aTexts | ) |
Definition at line 437 of file pads_pcb_converter.cpp.
References _, Cmts_User, PADS_COMMON::ConvertText(), DEGREES_T, ADVANCED_CFG::GetCfg(), GetMappedLayer(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, m_board, ADVANCED_CFG::m_PadsPcbTextHeightScale, ADVANCED_CFG::m_PadsPcbTextWidthScale, m_reporter, RotatePoint(), RPT_SEVERITY_WARNING, ScalePoint(), ScaleSize(), text, and UNDEFINED_LAYER.
| SHAPE_ARC PADS_PCB_CONVERTER::MakeMidpointArc | ( | const PADS_IO::ARC_POINT & | aPrev, |
| const PADS_IO::ARC_POINT & | aCurr, | ||
| int | aWidth ) const |
Build a SHAPE_ARC from two consecutive PADS points.
The midpoint is computed in PADS space before the Y-axis flip so the 3-point constructor gets the correct winding.
Definition at line 391 of file pads_pcb_converter.cpp.
References PADS_IO::ARC_POINT::arc, PADS_IO::ARC::cx, PADS_IO::ARC::cy, PADS_IO::ARC::delta_angle, end, M_PI, PADS_IO::ARC::radius, ScalePoint(), PADS_IO::ARC_POINT::x, and PADS_IO::ARC_POINT::y.
Referenced by AppendArcPoints().
| void PADS_PCB_CONVERTER::ReportStatistics | ( | ) |
Definition at line 833 of file pads_pcb_converter.cpp.
References _, m_board, m_reporter, PCB_VIA_T, and RPT_SEVERITY_INFO.
| int PADS_PCB_CONVERTER::ScaleCoord | ( | double | aVal, |
| bool | aIsX ) const |
Definition at line 103 of file pads_pcb_converter.cpp.
References m_originX, m_originY, m_scaleFactor, and PADS_COMMON::PadsScaleCoord().
Referenced by ScalePoint().
| VECTOR2I PADS_PCB_CONVERTER::ScalePoint | ( | double | aX, |
| double | aY ) const |
Definition at line 109 of file pads_pcb_converter.cpp.
References ScaleCoord().
Referenced by AppendArcPoints(), LoadDimensions(), LoadKeepouts(), LoadTexts(), and MakeMidpointArc().
| int PADS_PCB_CONVERTER::ScaleSize | ( | double | aVal | ) | const |
Definition at line 95 of file pads_pcb_converter.cpp.
References m_unitConverter.
Referenced by AppendArcPoints(), ApplyPourSettings(), BuildStackup(), LoadDimensions(), and LoadTexts().
| void PADS_PCB_CONVERTER::SetOrigin | ( | double | aX, |
| double | aY ) |
Definition at line 57 of file pads_pcb_converter.cpp.
| bool PADS_PCB_CONVERTER::SetOriginFromOutlines | ( | const std::vector< PADS_IO::POLYLINE > & | aOutlines | ) |
Move the origin to the center of the board outline bounding box, which places the imported board near the KiCad page origin when the file has no useful origin of its own.
Returns false, leaving the origin untouched, if the outlines are degenerate.
Definition at line 64 of file pads_pcb_converter.cpp.
References m_originX, m_originY, PADS_IO::ARC_POINT::x, and PADS_IO::ARC_POINT::y.
|
inline |
Set the nanometers-per-file-unit factor used by the coordinate transform.
This must agree with the unit converter's own mode.
Definition at line 70 of file pads_pcb_converter.h.
References m_scaleFactor.
Referenced by BOOST_AUTO_TEST_CASE().
| void PADS_PCB_CONVERTER::SetupLayers | ( | const std::vector< PADS_IO::LAYER_INFO > & | aPadsLayers, |
| int | aPadsLayerCount, | ||
| const LAYER_MAPPING_HANDLER & | aMappingHandler, | ||
| bool | aResolveUnknownTypeByName ) |
Resolve the PADS layer table to KiCad layers and apply the copper layer count to the board.
| aPadsLayers | is the layer table as read from the file. |
| aPadsLayerCount | is the file's copper layer count, which selects the bottom copper layer and seeds the layer mapper. |
| aMappingHandler | is the plugin's layer remapping callback, which may be empty. |
| aResolveUnknownTypeByName | parses the layer name, then falls back to a documentation layer, for layers whose function neither the file nor the layer number declares. Only the binary format leaves layers in that state. |
Definition at line 115 of file pads_pcb_converter.cpp.
References _, PADS_IO::ASSEMBLY, ASSEMBLY_BOTTOM, ASSEMBLY_TOP, COPPER_BOTTOM, COPPER_INNER, COPPER_TOP, PADS_IO::DOCUMENTATION, DOCUMENTATION, PADS_IO::DRILL, DRILL_DRAWING, info, m_board, m_copperLayerCount, m_layerInfos, m_layerMap, m_layerMapper, m_reporter, MAX_CU_LAYERS, PADS_IO::MIXED, PASTE_BOTTOM, PADS_IO::PASTE_MASK, PASTE_TOP, PADS_IO::PLANE, PADS_IO::ROUTING, RPT_SEVERITY_WARNING, PADS_IO::SILK_SCREEN, SILKSCREEN_BOTTOM, SILKSCREEN_TOP, PADS_IO::SOLDER_MASK, SOLDERMASK_BOTTOM, SOLDERMASK_TOP, PADS_IO::UNASSIGNED, PADS_IO::UNKNOWN, and UNKNOWN.
|
inline |
Definition at line 64 of file pads_pcb_converter.h.
References m_unitConverter.
Referenced by BOOST_AUTO_TEST_CASE().
| void PADS_PCB_CONVERTER::WriteDiffPairRules | ( | const wxString & | aFileName, |
| const std::vector< PADS_IO::DIFF_PAIR_DEF > & | aDiffPairs ) |
Write a .kicad_dru beside aFileName carrying one clearance rule per differential pair with a gap.
No file is written when no pair yields a rule.
Definition at line 707 of file pads_pcb_converter.cpp.
References _, PADS_COMMON::ConvertInvertedNetName(), PADS_COMMON::ConvertText(), FormatDouble2Str(), m_reporter, m_scaleFactor, PADS_UNIT_CONVERTER::MM_TO_NM, and RPT_SEVERITY_WARNING.
|
private |
Definition at line 160 of file pads_pcb_converter.h.
Referenced by ApplyPourSettings(), BuildStackup(), EnsureNet(), GetBoard(), LoadDimensions(), LoadKeepouts(), LoadTexts(), PADS_PCB_CONVERTER(), ReportStatistics(), and SetupLayers().
|
private |
Definition at line 171 of file pads_pcb_converter.h.
Referenced by BuildStackup(), and SetupLayers().
|
private |
Definition at line 169 of file pads_pcb_converter.h.
Referenced by GetLayerInfos(), GetMappedLayer(), and SetupLayers().
|
private |
Definition at line 170 of file pads_pcb_converter.h.
Referenced by GetMappedLayer(), and SetupLayers().
|
private |
Definition at line 168 of file pads_pcb_converter.h.
Referenced by GetMappedLayer(), and SetupLayers().
|
private |
Definition at line 165 of file pads_pcb_converter.h.
Referenced by GetOriginX(), ScaleCoord(), SetOrigin(), and SetOriginFromOutlines().
|
private |
Definition at line 166 of file pads_pcb_converter.h.
Referenced by GetOriginY(), ScaleCoord(), SetOrigin(), and SetOriginFromOutlines().
|
private |
Definition at line 161 of file pads_pcb_converter.h.
Referenced by LoadKeepouts(), LoadTexts(), PADS_PCB_CONVERTER(), ReportStatistics(), SetupLayers(), and WriteDiffPairRules().
|
private |
Definition at line 164 of file pads_pcb_converter.h.
Referenced by GetScaleFactor(), ScaleCoord(), SetScaleFactor(), and WriteDiffPairRules().
|
private |
Definition at line 163 of file pads_pcb_converter.h.
Referenced by ScaleSize(), and UnitConverter().