KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_pads.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) 2025 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#pragma once
21
22#include <pcb_io/pcb_io.h>
25#include "pads_layer_mapper.h"
26
27#include <map>
28#include <string>
29#include <vector>
30
31class BOARD;
32class PCB_SHAPE;
33class SHAPE_ARC;
35
36namespace PADS_IO
37{
38class PARSER;
39struct ARC_POINT;
40}
41
43{
44public:
46 ~PCB_IO_PADS() override;
47
48 const IO_FILE_DESC GetBoardFileDesc() const override;
49 const IO_FILE_DESC GetLibraryDesc() const override;
50 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
51
52 bool CanReadBoard( const wxString& aFileName ) const override;
53
54 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
55 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject ) override;
56
67 std::map<wxString, PCB_LAYER_ID> DefaultLayerMappingCallback(
68 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
69
70private:
71 // LoadBoard helper methods -- each handles one logical section of the import
72 int scaleSize( double aVal ) const;
73 int scaleCoord( double aVal, bool aIsX ) const;
74
79 double decalUnitScale( const std::string& aUnits ) const;
80 PCB_LAYER_ID getMappedLayer( int aPadsLayer ) const;
81 void ensureNet( const std::string& aNetName );
82
87 const std::vector<PADS_IO::ARC_POINT>& aPts );
88
91 void setPcbShapeArc( PCB_SHAPE* aShape, const PADS_IO::ARC_POINT& aPrev,
92 const PADS_IO::ARC_POINT& aCurr );
93
99 const PADS_IO::ARC_POINT& aCurr, int aWidth );
100
101 void loadBoardSetup();
102 void loadNets();
103 void loadFootprints();
105 void loadTestPoints();
106 void loadTexts();
107 void loadTracksAndVias();
108 void loadCopperShapes();
109 void loadClusterGroups();
110 void loadZones();
111 void loadBoardOutline();
112 void loadDimensions();
113 void loadKeepouts();
114 void loadGraphicLines();
115 void generateDrcRules( const wxString& aFileName );
116 void reportStatistics();
117 void clearLoadingState();
118
119 // Persistent state
120 std::map<wxString, PCB_LAYER_ID> m_layer_map;
121
122 // Loading state -- valid only during LoadBoard, cleared by clearLoadingState()
123 BOARD* m_loadBoard = nullptr;
124 const PADS_IO::PARSER* m_parser = nullptr;
127 std::vector<PADS_LAYER_INFO> m_layerInfos;
128 double m_scaleFactor = 0.0;
129 double m_originX = 0.0;
130 double m_originY = 0.0;
131 std::map<std::string, std::string> m_pinToNetMap;
132 std::map<std::string, std::string> m_partToBlockMap;
134 int m_minObjectSize = 1000;
135};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
Plugin class for import plugins that support remappable layers.
Maps PADS layer numbers and names to KiCad layer IDs.
Converts PADS file format units to KiCad internal units (nanometers).
double m_scaleFactor
const IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
int scaleSize(double aVal) const
void loadBoardSetup()
std::vector< PADS_LAYER_INFO > m_layerInfos
void loadTestPoints()
void reportStatistics()
~PCB_IO_PADS() override
SHAPE_ARC makeMidpointArc(const PADS_IO::ARC_POINT &aPrev, const PADS_IO::ARC_POINT &aCurr, int aWidth)
Build a SHAPE_ARC from two consecutive PADS points using the midpoint approach.
double m_originY
void loadClusterGroups()
void loadTracksAndVias()
std::map< std::string, std::string > m_partToBlockMap
int scaleCoord(double aVal, bool aIsX) const
void setPcbShapeArc(PCB_SHAPE *aShape, const PADS_IO::ARC_POINT &aPrev, const PADS_IO::ARC_POINT &aCurr)
Configure a PCB_SHAPE as an arc from two consecutive PADS points using board-level scaleCoord.
std::map< std::string, std::string > m_pinToNetMap
PCB_LAYER_ID getMappedLayer(int aPadsLayer) const
int m_testPointIndex
void appendArcPoints(SHAPE_LINE_CHAIN &aChain, const std::vector< PADS_IO::ARC_POINT > &aPts)
Interpolate arc segments from an ARC_POINT vector into polyline vertices on a SHAPE_LINE_CHAIN.
std::map< wxString, PCB_LAYER_ID > m_layer_map
PADS layer names to KiCad layers.
int m_minObjectSize
void generateDrcRules(const wxString &aFileName)
void loadFootprints()
double m_originX
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void loadKeepouts()
void loadCopperShapes()
BOARD * m_loadBoard
const IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
void ensureNet(const std::string &aNetName)
PADS_LAYER_MAPPER m_layerMapper
void clearLoadingState()
void loadGraphicLines()
double decalUnitScale(const std::string &aUnits) const
Resolve a PADS decal/part UNITS letter to a nm-per-unit scale factor.
PADS_UNIT_CONVERTER m_unitConverter
void loadDimensions()
std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
void loadBoardOutline()
const PADS_IO::PARSER * m_parser
void loadReuseBlockGroups()
PCB_IO(const wxString &aName)
Definition pcb_io.h:342
Container for project specific data.
Definition project.h:62
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
Container that describes file type info.
Definition io_base.h:43
A point that may be either a line endpoint or an arc segment.
Definition pads_parser.h:68