KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_pads_binary.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#pragma once
21
22#include <pcb_io/pcb_io.h>
24#include <math/vector2d.h>
25#include "pads_pcb_converter.h"
26
27#include <map>
28#include <memory>
29#include <string>
30#include <vector>
31
32class BOARD;
33class PCB_SHAPE;
34class FOOTPRINT;
35class PAD;
36class EDA_ANGLE;
37
38namespace PADS_IO
39{
40class BINARY_PARSER;
41struct ARC_POINT;
42struct PART_DECAL;
43struct PAD_STACK_LAYER;
44} // namespace PADS_IO
45
52{
53public:
56
57 const IO_FILE_DESC GetBoardFileDesc() const override;
58 const IO_FILE_DESC GetLibraryDesc() const override;
59 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
60
61 bool CanReadBoard( const wxString& aFileName ) const override;
62 bool CanReadLibrary( const wxString& aFileName ) const override;
63
64 std::map<wxString, PCB_LAYER_ID>
65 DefaultLayerMappingCallback( const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
66
67protected:
68 void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
69 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject ) override;
70
71private:
73 int scaleSize( double aVal ) const { return m_converter->ScaleSize( aVal ); }
74 int scaleCoord( double aVal, bool aIsX ) const { return m_converter->ScaleCoord( aVal, aIsX ); }
75
77 VECTOR2I scalePoint( double aX, double aY ) const { return m_converter->ScalePoint( aX, aY ); }
78 PCB_LAYER_ID getMappedLayer( int aPadsLayer ) const { return m_converter->GetMappedLayer( aPadsLayer ); }
79
80 void loadBoardSetup();
81 void loadNets();
82 void loadFootprints();
83
86 void buildPad( FOOTPRINT* aFootprint, const PADS_IO::PART_DECAL& aDecal, size_t aTermIdx,
87 const EDA_ANGLE& aPartOrient );
88
90 void applyPadShape( PAD* aPad, const PADS_IO::PAD_STACK_LAYER& aLayer, PCB_LAYER_ID aKiCadLayer );
91
94 void loadClusterGroups();
95
96 void loadBoardOutline();
97 void loadGraphicLines();
98 void setBoardOutlineArc( PCB_SHAPE* aShape, const PADS_IO::ARC_POINT& aPrev, const PADS_IO::ARC_POINT& aCurr );
99 void loadTracksAndVias();
100 void loadCopperShapes();
101 void loadZones();
102 void clearLoadingState();
103
104 // Valid only during LoadBoard, cleared by clearLoadingState().
105 BOARD* m_loadBoard = nullptr;
107 std::unique_ptr<PADS_PCB_CONVERTER> m_converter;
108 int m_minObjectSize = 1000;
109 std::map<wxString, std::string> m_pinToNetMap;
110
111 // One footprint per parser part index, so loadClusterGroups() can resolve the
112 // part-index-keyed cluster membership to a footprint.
113 std::vector<FOOTPRINT*> m_partFootprints;
114};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
Plugin class for import plugins that support remappable layers.
Reader for the PADS PowerPCB binary .pcb format.
Definition pad.h:61
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void loadClusterGroups()
Build one PCB_GROUP per PADS part cluster and add each footprint to the group named by its part's CLS...
void setBoardOutlineArc(PCB_SHAPE *aShape, const PADS_IO::ARC_POINT &aPrev, const PADS_IO::ARC_POINT &aCurr)
const IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
~PCB_IO_PADS_BINARY() override
int scaleSize(double aVal) const
Shorthands for the converter's transform, which the loaders below use everywhere.
const IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
void buildPad(FOOTPRINT *aFootprint, const PADS_IO::PART_DECAL &aDecal, size_t aTermIdx, const EDA_ANGLE &aPartOrient)
Build one terminal's pad on aFootprint from decal terminal aTermIdx, oriented by the part orientation...
const PADS_IO::BINARY_PARSER * m_parser
std::map< wxString, std::string > m_pinToNetMap
"<refdes>.<pin>" to PADS net name
PCB_LAYER_ID getMappedLayer(int aPadsLayer) const
std::unique_ptr< PADS_PCB_CONVERTER > m_converter
int scaleCoord(double aVal, bool aIsX) const
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject) override
Parse aFileName into aBoard.
void applyPadShape(PAD *aPad, const PADS_IO::PAD_STACK_LAYER &aLayer, PCB_LAYER_ID aKiCadLayer)
Apply a pad-stack layer's shape, size and finger offset to aPad.
std::vector< FOOTPRINT * > m_partFootprints
VECTOR2I scalePoint(double aX, double aY) const
Scale a board point to a KiCad position, applying the per-axis origin and the Y-flip.
std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
PCB_IO(const wxString &aName)
Definition pcb_io.h:351
Container for project specific data.
Definition project.h:63
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 polyline point that may instead be an arc segment.
Definition pads_parser.h:64
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683