KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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_SLOT( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth ) :
32 m_Start( aStart ),
33 m_End( aEnd ),
34 m_Width( aWidth )
35 { }
36
40};
41
42
44{
45 EXPORT_VIA( const VECTOR2I& aPos, int aSize, int aDrill ) :
46 m_Pos( aPos ),
47 m_Size( aSize ),
48 m_Drill( aDrill )
49 { }
50
52 int m_Size;
54};
55
56
58class GERBVIEW_FRAME;
59
60
65{
66public:
67 GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName );
69
73 bool ExportPcb( const int* aLayerLookUpTable, int aCopperLayers );
74
75private:
86 void collect_hole( const GERBER_DRAW_ITEM* aGbrItem );
87
95 void export_via( const EXPORT_VIA& aVia );
96
97 void export_slot( const EXPORT_SLOT& aSlot );
98
105 void export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
106
113 void export_non_copper_arc( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
114
120 void export_stroke_info( double aWidth );
121
127 void writePcbPolygon( const SHAPE_POLY_SET& aPolys, int aLayer,
128 const VECTOR2I& aOffset = { 0, 0 } );
129
138 void writePcbFilledCircle( const VECTOR2I& aCenterPosition, int aRadius, int aLayer );
139
148 void writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
149
156 void export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
157
167 void export_flashed_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
168
175 void export_segline_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
176
183 void export_segarc_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer );
184
188 void writeCopperLineItem( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
189 int aLayer );
190
194 void writePcbHeader( const int* aLayerLookUpTable );
195
201 double MapToPcbUnits( int aValue ) const
202 {
203 return aValue / gerbIUScale.IU_PER_MM;
204 }
205
206private:
207 GERBVIEW_FRAME* m_gerbview_frame; // the main gerber frame
208 wxString m_pcb_file_name; // BOARD file to write to
209 FILE* m_fp; // the board file
211 std::vector<EXPORT_VIA> m_vias;
212 std::vector<EXPORT_SLOT> m_slots;
213};
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:111
void export_copper_item(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a track (or via) to the board file.
void export_stroke_info(double aWidth)
Write the stroke info (thickness, line type) to the board file.
void export_non_copper_arc(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a non copper arc 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).
std::vector< EXPORT_SLOT > m_slots
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.
void export_slot(const EXPORT_SLOT &aSlot)
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.
EXPORT_SLOT(const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth)
EXPORT_VIA(const VECTOR2I &aPos, int aSize, int aDrill)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695