KiCad PCB EDA Suite
|
A helper class to export a Gerber set of files to Pcbnew. More...
#include <export_to_pcbnew.h>
Public Member Functions | |
GBR_TO_PCB_EXPORTER (GERBVIEW_FRAME *aFrame, const wxString &aFileName) | |
~GBR_TO_PCB_EXPORTER () | |
bool | ExportPcb (const int *aLayerLookUpTable, int aCopperLayers) |
Save a board from a set of Gerber images. | |
Private Member Functions | |
void | collect_hole (const GERBER_DRAW_ITEM *aGbrItem) |
Collect holes from a drill layer. | |
void | export_via (const EXPORT_VIA &aVia) |
Write a 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 | 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 | writePcbZoneItem (const GERBER_DRAW_ITEM *aGbrItem, int aLayer) |
Write a zone item to the board file. | |
void | export_copper_item (const GERBER_DRAW_ITEM *aGbrItem, int aLayer) |
Write a track (or via) to the board file. | |
void | export_flashed_copper_item (const GERBER_DRAW_ITEM *aGbrItem, int aLayer) |
Write a synthetic pad to the board file. | |
void | export_segline_copper_item (const GERBER_DRAW_ITEM *aGbrItem, int aLayer) |
Write a track (not via) to the board file. | |
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. | |
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 | writePcbHeader (const int *aLayerLookUpTable) |
Write a very basic header to the board file. | |
double | MapToPcbUnits (int aValue) const |
Map GerbView internal units to millimeters for Pcbnew board files. | |
Private Attributes | |
GERBVIEW_FRAME * | m_gerbview_frame |
wxString | m_pcb_file_name |
FILE * | m_fp |
int | m_pcbCopperLayersCount |
std::vector< EXPORT_VIA > | m_vias |
A helper class to export a Gerber set of files to Pcbnew.
Definition at line 50 of file export_to_pcbnew.h.
GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER | ( | GERBVIEW_FRAME * | aFrame, |
const wxString & | aFileName | ||
) |
Definition at line 45 of file export_to_pcbnew.cpp.
References m_fp, m_gerbview_frame, m_pcb_file_name, and m_pcbCopperLayersCount.
GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER | ( | ) |
Definition at line 54 of file export_to_pcbnew.cpp.
|
private |
Collect holes from a drill layer.
We'll use these later when writing pads & vias. Many holes will be pads, but we have no way to create those without footprints, and creating a footprint per pad is not really viable. We use vias to mimic holes, with the loss of any hole shape (as we only have round holes in vias at present). We start out with a via size minimally larger than the hole. We'll leave it this way if the pad gets drawn as a copper polygon, or increase it to the proper size if it has a circular, concentric copper flashing.
Definition at line 267 of file export_to_pcbnew.cpp.
References GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, m_vias, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ExportPcb().
|
private |
Write a track (or via) to the board file.
aGbrItem | is the Gerber item (line, arc, flashed) to export. |
aLayer | is the copper layer to use. |
Definition at line 294 of file export_to_pcbnew.cpp.
References APT_RECT, export_flashed_copper_item(), export_segarc_copper_item(), export_segline_copper_item(), GBR_ARC, GBR_CIRCLE, GBR_POLYGON, GBR_SEGMENT, GBR_SPOT_CIRCLE, GBR_SPOT_MACRO, GBR_SPOT_OVAL, GBR_SPOT_POLY, GBR_SPOT_RECT, GERBER_DRAW_ITEM::GetDcodeDescr(), D_CODE::m_ApertType, GERBER_DRAW_ITEM::m_ShapeAsPolygon, GERBER_DRAW_ITEM::m_ShapeType, SHAPE_POLY_SET::OutlineCount(), writePcbPolygon(), and writePcbZoneItem().
Referenced by ExportPcb().
|
private |
Write a synthetic pad to the board file.
We can't create real pads because the Gerbers don't store grouping/footprint info. So we synthesize a pad with a via for the hole (if present) and a copper polygon for the pad.
aGbrItem | is the flashed Gerber item to export. |
Definition at line 431 of file export_to_pcbnew.cpp.
References D_CODE::ConvertShapeToPolygon(), GBR_SPOT_CIRCLE, GBR_SPOT_OVAL, GERBER_DRAW_ITEM::GetABPosition(), APERTURE_MACRO::GetApertureMacroShape(), GERBER_DRAW_ITEM::GetDcodeDescr(), D_CODE::GetMacro(), D_CODE::m_Polygon, GERBER_DRAW_ITEM::m_ShapeType, D_CODE::m_Size, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, m_vias, SHAPE_LINE_CHAIN::Mirror(), SHAPE_POLY_SET::Outline(), via, writePcbFilledCircle(), writePcbPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item().
|
private |
Write a non copper line or arc to the board file.
aGbrItem | is the Gerber item (line, arc) to export. |
aLayer | is the technical layer to use. |
Definition at line 153 of file export_to_pcbnew.cpp.
References D_CODE::ConvertShapeToPolygon(), FormatDouble2Str(), GBR_ARC, GBR_CIRCLE, GBR_POLYGON, GBR_SEGMENT, GBR_SPOT_CIRCLE, GBR_SPOT_MACRO, GBR_SPOT_OVAL, GBR_SPOT_POLY, GBR_SPOT_RECT, GERBER_DRAW_ITEM::GetABPosition(), GERBER_DRAW_ITEM::GetDcodeDescr(), GetPCBDefaultLayerName(), GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_End, m_fp, D_CODE::m_Polygon, GERBER_DRAW_ITEM::m_ShapeAsPolygon, GERBER_DRAW_ITEM::m_ShapeType, D_CODE::m_Size, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, MapToPcbUnits(), SHAPE_LINE_CHAIN::Mirror(), SHAPE_POLY_SET::Outline(), RAD2DEG(), TO_UTF8, writePcbFilledCircle(), writePcbPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ExportPcb().
|
private |
Write a set of tracks (arcs are approximated by track segments) to the board file.
aGbrItem | is the Gerber item (arc only) to export. |
aLayer | is the copper layer to use |
Definition at line 377 of file export_to_pcbnew.cpp.
References DELTA_ANGLE, GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, RADIANS_T, RotatePoint(), writeCopperLineItem(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item().
|
private |
Write a track (not via) to the board file.
aGbrItem | is the Gerber item (line only) to export. |
aLayer | is the copper layer to use. |
Definition at line 349 of file export_to_pcbnew.cpp.
References GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, writeCopperLineItem(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item().
|
private |
Write a via to the board file.
Some of these will represent actual vias while others are used to represent holes in pads. (We can't generate actual pads because the Gerbers don't contain info on how to group them into footprints.)
Definition at line 274 of file export_to_pcbnew.cpp.
References B_Cu, F_Cu, FormatDouble2Str(), GetPCBDefaultLayerName(), EXPORT_VIA::m_Drill, m_fp, EXPORT_VIA::m_Pos, EXPORT_VIA::m_Size, MapToPcbUnits(), TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ExportPcb().
bool GBR_TO_PCB_EXPORTER::ExportPcb | ( | const int * | aLayerLookUpTable, |
int | aCopperLayers | ||
) |
Save a board from a set of Gerber images.
Definition at line 59 of file export_to_pcbnew.cpp.
References _, collect_hole(), DisplayError(), export_copper_item(), export_non_copper_item(), export_via(), GERBER_FILE_IMAGE_LIST::GetGbrImage(), GERBVIEW_FRAME::GetGerberLayout(), GBR_LAYOUT::GetImagesList(), GERBER_FILE_IMAGE::GetItems(), GERBER_FILE_IMAGE_LIST::ImagesMaxCount(), IsPcbLayer(), m_fp, m_gerbview_frame, m_pcb_file_name, m_pcbCopperLayersCount, m_vias, UNDEFINED_LAYER, via, and writePcbHeader().
Referenced by GERBVIEW_CONTROL::ExportToPcbnew().
|
inlineprivate |
Map GerbView internal units to millimeters for Pcbnew board files.
aValue | is a coordinate value to convert in mm. |
Definition at line 170 of file export_to_pcbnew.h.
References gerbIUScale, and EDA_IU_SCALE::IU_PER_MM.
Referenced by export_non_copper_item(), export_via(), writeCopperLineItem(), writePcbFilledCircle(), writePcbPolygon(), and writePcbZoneItem().
|
private |
Basic write function to write a a PCB_TRACK to the board file from a non flashed item.
Definition at line 364 of file export_to_pcbnew.cpp.
References FormatDouble2Str(), GetPCBDefaultLayerName(), m_fp, MapToPcbUnits(), TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_segarc_copper_item(), and export_segline_copper_item().
|
private |
Write a filled circle to the board file (with line thickness = 0).
aCenterPosition | is the actual position of the filled circle, given by <round_flashed_shape>->GetABPosition() |
aRadius | is the circle radius. |
aLayer | is the layer to use. |
Definition at line 486 of file export_to_pcbnew.cpp.
References FormatDouble2Str(), GetPCBDefaultLayerName(), m_fp, MapToPcbUnits(), TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_flashed_copper_item(), and export_non_copper_item().
|
private |
Write a very basic header to the board file.
Definition at line 502 of file export_to_pcbnew.cpp.
References B_Adhes, B_Cu, GetMajorMinorVersion(), GetPCBDefaultLayerName(), m_fp, m_pcbCopperLayersCount, PCB_LAYER_ID_COUNT, and TO_UTF8.
Referenced by ExportPcb().
|
private |
Write a non-copper polygon to the board file.
aLayer | is the technical layer to use. |
Definition at line 531 of file export_to_pcbnew.cpp.
References SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), FormatDouble2Str(), GetPCBDefaultLayerName(), m_fp, MapToPcbUnits(), MAX_COORD_CNT, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item(), export_flashed_copper_item(), and export_non_copper_item().
|
private |
Write a zone item to the board file.
aGbrItem | is the Gerber item (line, arc) to export. |
aLayer | is the technical layer to use. |
Definition at line 574 of file export_to_pcbnew.cpp.
References SHAPE_POLY_SET::CloneDropTriangulation(), SHAPE_LINE_CHAIN::CPoint(), FormatDouble2Str(), GetPCBDefaultLayerName(), m_fp, GERBER_DRAW_ITEM::m_ShapeAsPolygon, MapToPcbUnits(), MAX_COORD_CNT, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::Simplify(), TO_UTF8, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item().
|
private |
Definition at line 178 of file export_to_pcbnew.h.
Referenced by export_non_copper_item(), export_via(), ExportPcb(), GBR_TO_PCB_EXPORTER(), writeCopperLineItem(), writePcbFilledCircle(), writePcbHeader(), writePcbPolygon(), and writePcbZoneItem().
|
private |
Definition at line 176 of file export_to_pcbnew.h.
Referenced by ExportPcb(), and GBR_TO_PCB_EXPORTER().
|
private |
Definition at line 177 of file export_to_pcbnew.h.
Referenced by ExportPcb(), and GBR_TO_PCB_EXPORTER().
|
private |
Definition at line 179 of file export_to_pcbnew.h.
Referenced by ExportPcb(), GBR_TO_PCB_EXPORTER(), and writePcbHeader().
|
private |
Definition at line 180 of file export_to_pcbnew.h.
Referenced by collect_hole(), export_flashed_copper_item(), and ExportPcb().