KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pads_pcb_converter.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) 2026 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PADS_PCB_CONVERTER_H_
21#define PADS_PCB_CONVERTER_H_
22
23#include <map>
24#include <string>
25#include <vector>
26
27#include <math/vector2d.h>
30#include <zones.h>
31
32#include "pads_layer_mapper.h"
33#include "pads_parser.h"
34
35class BOARD;
36class REPORTER;
37class SHAPE_ARC;
39class ZONE;
40
54{
55public:
60 PADS_PCB_CONVERTER( BOARD* aBoard, REPORTER* aReporter );
61
62 BOARD* GetBoard() const { return m_board; }
63
65
70 void SetScaleFactor( double aScaleFactor ) { m_scaleFactor = aScaleFactor; }
71
72 double GetScaleFactor() const { return m_scaleFactor; }
73
74 void SetOrigin( double aX, double aY );
75
76 double GetOriginX() const { return m_originX; }
77
78 double GetOriginY() const { return m_originY; }
79
85 bool SetOriginFromOutlines( const std::vector<PADS_IO::POLYLINE>& aOutlines );
86
87 int ScaleSize( double aVal ) const;
88
89 int ScaleCoord( double aVal, bool aIsX ) const;
90
91 VECTOR2I ScalePoint( double aX, double aY ) const;
92
105 void SetupLayers( const std::vector<PADS_IO::LAYER_INFO>& aPadsLayers, int aPadsLayerCount,
106 const LAYER_MAPPING_HANDLER& aMappingHandler, bool aResolveUnknownTypeByName );
107
108 const std::vector<PADS_LAYER_INFO>& GetLayerInfos() const { return m_layerInfos; }
109
110 PCB_LAYER_ID GetMappedLayer( int aPadsLayer ) const;
111
117 void BuildStackup( const std::vector<PADS_IO::LAYER_INFO>& aPadsLayers );
118
119 void EnsureNet( const std::string& aNetName );
120
125 void AppendArcPoints( SHAPE_LINE_CHAIN& aChain, const std::vector<PADS_IO::ARC_POINT>& aPts ) const;
126
132 int aWidth ) const;
133
134 void LoadTexts( const std::vector<PADS_IO::TEXT>& aTexts );
135
136 void LoadKeepouts( const std::vector<PADS_IO::KEEPOUT>& aKeepouts );
137
138 void LoadDimensions( const std::vector<PADS_IO::DIMENSION>& aDimensions );
139
147 void ApplyPourSettings( ZONE* aZone, const PADS_IO::POUR& aPour, int aMaxPriority,
148 const PADS_IO::PARAMETERS& aParams );
149
154 void WriteDiffPairRules( const wxString& aFileName,
155 const std::vector<PADS_IO::DIFF_PAIR_DEF>& aDiffPairs );
156
157 void ReportStatistics();
158
159private:
162
164 double m_scaleFactor = 0.0;
165 double m_originX = 0.0;
166 double m_originY = 0.0;
167
169 std::vector<PADS_LAYER_INFO> m_layerInfos;
170 std::map<wxString, PCB_LAYER_ID> m_layerMap;
172};
173
174#endif // PADS_PCB_CONVERTER_H_
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
Maps PADS layer numbers and names to KiCad layer IDs.
double GetScaleFactor() const
const std::vector< PADS_LAYER_INFO > & GetLayerInfos() const
BOARD * GetBoard() const
PADS_LAYER_MAPPER m_layerMapper
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...
double GetOriginX() const
VECTOR2I ScalePoint(double aX, double aY) const
PADS_UNIT_CONVERTER m_unitConverter
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.
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...
PCB_LAYER_ID GetMappedLayer(int aPadsLayer) const
PADS_UNIT_CONVERTER & UnitConverter()
std::map< wxString, PCB_LAYER_ID > m_layerMap
PADS_PCB_CONVERTER(BOARD *aBoard, REPORTER *aReporter)
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.
void EnsureNet(const std::string &aNetName)
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 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 LoadKeepouts(const std::vector< PADS_IO::KEEPOUT > &aKeepouts)
double GetOriginY() const
void SetOrigin(double aX, double aY)
std::vector< PADS_LAYER_INFO > m_layerInfos
int ScaleSize(double aVal) const
int ScaleCoord(double aVal, bool aIsX) const
void SetScaleFactor(double aScaleFactor)
Set the nanometers-per-file-unit factor used by the coordinate transform.
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 d...
Converts PADS file units (MILS, METRIC, INCHES, or internal BASIC database units) to KiCad internal u...
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Handle a list of polygons defining a copper zone.
Definition zone.h:70
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
std::function< std::map< wxString, PCB_LAYER_ID >(const std::vector< INPUT_LAYER_DESC > &)> LAYER_MAPPING_HANDLER
Pointer to a function that takes a map of source and KiCad layers and returns a re-mapped version.
A polyline point that may instead be an arc segment.
Definition pads_parser.h:64
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683