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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <pcb_io/pcb_io.h>
29#include "pads_layer_mapper.h"
30
31#include <map>
32#include <string>
33#include <vector>
34
35class BOARD;
36class PCB_SHAPE;
37class SHAPE_ARC;
39
40namespace PADS_IO
41{
42class PARSER;
43struct ARC_POINT;
44}
45
47{
48public:
50 ~PCB_IO_PADS() override;
51
52 const IO_FILE_DESC GetBoardFileDesc() const override;
53 const IO_FILE_DESC GetLibraryDesc() const override;
54 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
55
56 bool CanReadBoard( const wxString& aFileName ) const override;
57
58 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
59 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject ) override;
60
71 std::map<wxString, PCB_LAYER_ID> DefaultLayerMappingCallback(
72 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
73
74private:
75 // LoadBoard helper methods -- each handles one logical section of the import
76 int scaleSize( double aVal ) const;
77 int scaleCoord( double aVal, bool aIsX ) const;
78 PCB_LAYER_ID getMappedLayer( int aPadsLayer ) const;
79 void ensureNet( const std::string& aNetName );
80
85 const std::vector<PADS_IO::ARC_POINT>& aPts );
86
89 void setPcbShapeArc( PCB_SHAPE* aShape, const PADS_IO::ARC_POINT& aPrev,
90 const PADS_IO::ARC_POINT& aCurr );
91
97 const PADS_IO::ARC_POINT& aCurr, int aWidth );
98
99 void loadBoardSetup();
100 void loadNets();
101 void loadFootprints();
103 void loadTestPoints();
104 void loadTexts();
105 void loadTracksAndVias();
106 void loadCopperShapes();
107 void loadClusterGroups();
108 void loadZones();
109 void loadBoardOutline();
110 void loadDimensions();
111 void loadKeepouts();
112 void loadGraphicLines();
113 void generateDrcRules( const wxString& aFileName );
114 void reportStatistics();
115 void clearLoadingState();
116
117 // Persistent state
118 std::map<wxString, PCB_LAYER_ID> m_layer_map;
119
120 // Loading state -- valid only during LoadBoard, cleared by clearLoadingState()
121 BOARD* m_loadBoard = nullptr;
122 const PADS_IO::PARSER* m_parser = nullptr;
125 std::vector<PADS_LAYER_INFO> m_layerInfos;
126 double m_scaleFactor = 0.0;
127 double m_originX = 0.0;
128 double m_originY = 0.0;
129 std::map<std::string, std::string> m_pinToNetMap;
130 std::map<std::string, std::string> m_partToBlockMap;
132 int m_minObjectSize = 1000;
133};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
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()
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:337
Container for project specific data.
Definition project.h:65
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:60
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:72