KiCad PCB EDA Suite
export_to_pcbnew.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) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
26#include <layer_ids.h>
27
28
30{
31 EXPORT_VIA( const VECTOR2I& aPos, int aSize, int aDrill ) :
32 m_Pos( aPos ),
33 m_Size( aSize ),
34 m_Drill( aDrill )
35 { }
36
38 int m_Size;
40};
41
42
44class GERBVIEW_FRAME;
45
46
51{
52public:
53 GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
55
59 bool ExportPcb( const int* aLayerLookUpTable, int aCopperLayers );
60
61private:
72 void collect_hole( const GERBER_DRAW_ITEM* aGbrItem );
73
81 void export_via( const EXPORT_VIA& aVia );
82
89 void export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
90
96 void writePcbPolygon( const SHAPE_POLY_SET& aPolys, int aLayer,
97 const VECTOR2I& aOffset = { 0, 0 } );
98
107 void writePcbFilledCircle( const VECTOR2I& aCenterPosition, int aRadius, int aLayer );
108
117 void writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
118
125 void export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
126
136 void export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
137
144 void export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
145
152 void export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
153
157 void writeCopperLineItem( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
158 int aLayer );
159
163 void writePcbHeader( const int* aLayerLookUpTable );
164
170 double MapToPcbUnits( int aValue ) const
171 {
172 return aValue / gerbIUScale.IU_PER_MM;
173 }
174
175private:
176 GERBVIEW_FRAME* m_gerbview_frame; // the main gerber frame
177 wxString m_pcb_file_name; // BOARD file to write to
178 FILE* m_fp; // the board file
180 std::vector<EXPORT_VIA> m_vias;
181};
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:108
A helper class to export a Gerber set of files to Pcbnew.
void export_copper_item(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a track (or via) to the board file.
void export_non_copper_item(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a non copper line or arc to the board file.
void writePcbZoneItem(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a zone item to the board file.
GERBVIEW_FRAME * m_gerbview_frame
void export_segarc_copper_item(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a set of tracks (arcs are approximated by track segments) to the board file.
GBR_TO_PCB_EXPORTER(GERBVIEW_FRAME *aFrame, const wxString &aFileName)
void export_flashed_copper_item(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a synthetic pad to the board file.
double MapToPcbUnits(int aValue) const
Map GerbView internal units to millimeters for Pcbnew board files.
std::vector< EXPORT_VIA > m_vias
void collect_hole(const GERBER_DRAW_ITEM *aGbrItem)
Collect holes from a drill layer.
void writePcbPolygon(const SHAPE_POLY_SET &aPolys, int aLayer, const VECTOR2I &aOffset={ 0, 0 })
Write a non-copper polygon to the board file.
void writePcbFilledCircle(const VECTOR2I &aCenterPosition, int aRadius, int aLayer)
Write a filled circle to the board file (with line thickness = 0).
void export_segline_copper_item(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a track (not via) to the board file.
void writePcbHeader(const int *aLayerLookUpTable)
Write a very basic header to the board file.
bool ExportPcb(const int *aLayerLookUpTable, int aCopperLayers)
Save a board from a set of Gerber images.
void writeCopperLineItem(const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aLayer)
Basic write function to write a a PCB_TRACK to the board file from a non flashed item.
void export_via(const EXPORT_VIA &aVia)
Write a via to the board file.
Represent a set of closed polygons.
const double IU_PER_MM
Definition: base_units.h:77
VECTOR2I m_Pos
EXPORT_VIA(const VECTOR2I &aPos, int aSize, int aDrill)