KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_PCB_CONVERTER Class Reference

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)
 
BOARDGetBoard () const
 
PADS_UNIT_CONVERTERUnitConverter ()
 
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

BOARDm_board
 
REPORTERm_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_INFOm_layerInfos
 
std::map< wxString, PCB_LAYER_IDm_layerMap
 
int m_copperLayerCount = 2
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PADS_PCB_CONVERTER()

PADS_PCB_CONVERTER::PADS_PCB_CONVERTER ( BOARD * aBoard,
REPORTER * aReporter )
Parameters
aBoardreceives every object the converter creates.
aReportercollects import warnings, and may be null.

Definition at line 50 of file pads_pcb_converter.cpp.

References m_board, and m_reporter.

Member Function Documentation

◆ AppendArcPoints()

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().

◆ ApplyPourSettings()

◆ BuildStackup()

◆ EnsureNet()

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.

◆ GetBoard()

BOARD * PADS_PCB_CONVERTER::GetBoard ( ) const
inline

Definition at line 62 of file pads_pcb_converter.h.

References m_board.

◆ GetLayerInfos()

const std::vector< PADS_LAYER_INFO > & PADS_PCB_CONVERTER::GetLayerInfos ( ) const
inline

Definition at line 108 of file pads_pcb_converter.h.

References m_layerInfos.

◆ GetMappedLayer()

PCB_LAYER_ID PADS_PCB_CONVERTER::GetMappedLayer ( int aPadsLayer) const

◆ GetOriginX()

double PADS_PCB_CONVERTER::GetOriginX ( ) const
inline

Definition at line 76 of file pads_pcb_converter.h.

References m_originX.

◆ GetOriginY()

double PADS_PCB_CONVERTER::GetOriginY ( ) const
inline

Definition at line 78 of file pads_pcb_converter.h.

References m_originY.

◆ GetScaleFactor()

double PADS_PCB_CONVERTER::GetScaleFactor ( ) const
inline

Definition at line 72 of file pads_pcb_converter.h.

References m_scaleFactor.

◆ LoadDimensions()

◆ LoadKeepouts()

◆ LoadTexts()

◆ MakeMidpointArc()

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().

◆ ReportStatistics()

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.

◆ ScaleCoord()

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().

◆ ScalePoint()

VECTOR2I PADS_PCB_CONVERTER::ScalePoint ( double aX,
double aY ) const

◆ ScaleSize()

int PADS_PCB_CONVERTER::ScaleSize ( double aVal) const

◆ SetOrigin()

void PADS_PCB_CONVERTER::SetOrigin ( double aX,
double aY )

Definition at line 57 of file pads_pcb_converter.cpp.

References m_originX, and m_originY.

◆ SetOriginFromOutlines()

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.

◆ SetScaleFactor()

void PADS_PCB_CONVERTER::SetScaleFactor ( double aScaleFactor)
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().

◆ SetupLayers()

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.

Parameters
aPadsLayersis the layer table as read from the file.
aPadsLayerCountis the file's copper layer count, which selects the bottom copper layer and seeds the layer mapper.
aMappingHandleris the plugin's layer remapping callback, which may be empty.
aResolveUnknownTypeByNameparses 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.

◆ UnitConverter()

PADS_UNIT_CONVERTER & PADS_PCB_CONVERTER::UnitConverter ( )
inline

Definition at line 64 of file pads_pcb_converter.h.

References m_unitConverter.

Referenced by BOOST_AUTO_TEST_CASE().

◆ WriteDiffPairRules()

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.

Member Data Documentation

◆ m_board

◆ m_copperLayerCount

int PADS_PCB_CONVERTER::m_copperLayerCount = 2
private

Definition at line 171 of file pads_pcb_converter.h.

Referenced by BuildStackup(), and SetupLayers().

◆ m_layerInfos

std::vector<PADS_LAYER_INFO> PADS_PCB_CONVERTER::m_layerInfos
private

Definition at line 169 of file pads_pcb_converter.h.

Referenced by GetLayerInfos(), GetMappedLayer(), and SetupLayers().

◆ m_layerMap

std::map<wxString, PCB_LAYER_ID> PADS_PCB_CONVERTER::m_layerMap
private

Definition at line 170 of file pads_pcb_converter.h.

Referenced by GetMappedLayer(), and SetupLayers().

◆ m_layerMapper

PADS_LAYER_MAPPER PADS_PCB_CONVERTER::m_layerMapper
private

Definition at line 168 of file pads_pcb_converter.h.

Referenced by GetMappedLayer(), and SetupLayers().

◆ m_originX

double PADS_PCB_CONVERTER::m_originX = 0.0
private

Definition at line 165 of file pads_pcb_converter.h.

Referenced by GetOriginX(), ScaleCoord(), SetOrigin(), and SetOriginFromOutlines().

◆ m_originY

double PADS_PCB_CONVERTER::m_originY = 0.0
private

Definition at line 166 of file pads_pcb_converter.h.

Referenced by GetOriginY(), ScaleCoord(), SetOrigin(), and SetOriginFromOutlines().

◆ m_reporter

REPORTER* PADS_PCB_CONVERTER::m_reporter
private

◆ m_scaleFactor

double PADS_PCB_CONVERTER::m_scaleFactor = 0.0
private

◆ m_unitConverter

PADS_UNIT_CONVERTER PADS_PCB_CONVERTER::m_unitConverter
private

Definition at line 163 of file pads_pcb_converter.h.

Referenced by ScaleSize(), and UnitConverter().


The documentation for this class was generated from the following files: