|
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 (GERBER_FILE_IMAGE_LIST *aImages, wxWindow *aParent, 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_slot (const EXPORT_SLOT &aSlot) |
| void | export_non_copper_item (const GERBER_DRAW_ITEM *aGbrItem, size_t aIndex, int aLayer) |
| Write a non copper line or arc to the board file. | |
| void | collect_clear_shapes (const GERBER_FILE_IMAGE *aImage) |
| Convert every clear polarity item of an image to a polygon, in file order. | |
| void | write_trimmed_polygon (const GERBER_DRAW_ITEM *aGbrItem, size_t aIndex, int aLayer) |
| Write a dark region to the board file, minus the clear items drawn after it. | |
| void | export_non_copper_arc (const GERBER_DRAW_ITEM *aGbrItem, int aLayer) |
| Write a non copper arc to the board file. | |
| void | export_stroke_info (double aWidth) |
| Write the stroke info (thickness, line type) 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, size_t aIndex, 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 | |
| GERBER_FILE_IMAGE_LIST * | m_images |
| wxWindow * | m_parent |
| wxString | m_pcb_file_name |
| FILE * | m_fp |
| int | m_pcbCopperLayersCount |
| std::vector< EXPORT_VIA > | m_vias |
| std::vector< EXPORT_SLOT > | m_slots |
| std::vector< CLEAR_SHAPE > | m_clearShapes |
A helper class to export a Gerber set of files to Pcbnew.
Definition at line 70 of file export_to_pcbnew.h.
| GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER | ( | GERBER_FILE_IMAGE_LIST * | aImages, |
| wxWindow * | aParent, | ||
| const wxString & | aFileName ) |
Definition at line 39 of file export_to_pcbnew.cpp.
References m_fp, m_images, m_parent, m_pcb_file_name, and m_pcbCopperLayersCount.
| GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER | ( | ) |
Definition at line 50 of file export_to_pcbnew.cpp.
|
private |
Convert every clear polarity item of an image to a polygon, in file order.
Definition at line 592 of file export_to_pcbnew.cpp.
References APT_RECT, SHAPE_POLY_SET::BBox(), GERBER_DRAW_ITEM::ConvertSegmentToPolygon(), D_CODE::ConvertShapeToPolygon(), VECTOR2< T >::Distance(), ERROR_OUTSIDE, GBR_ARC, GBR_CIRCLE, GBR_POLYGON, GBR_SEGMENT, gerbIUScale, GERBER_DRAW_ITEM::GetDcodeDescr(), GERBER_FILE_IMAGE::GetItems(), GERBER_DRAW_ITEM::GetLayerPolarity(), GetRotated(), SHAPE_POLY_SET::IsEmpty(), KiROUND(), D_CODE::m_ApertType, GERBER_DRAW_ITEM::m_ArcCentre, m_clearShapes, GERBER_DRAW_ITEM::m_End, M_PI, D_CODE::m_Polygon, GERBER_DRAW_ITEM::m_ShapeAsPolygon, GERBER_DRAW_ITEM::m_ShapeType, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, SHAPE_POLY_SET::Move(), RADIANS_T, TransformArcToPolygon(), TransformOvalToPolygon(), TransformRingToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ExportPcb().
|
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 306 of file export_to_pcbnew.cpp.
References GBR_SEGMENT, GBR_SPOT_CIRCLE, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_ShapeType, GERBER_DRAW_ITEM::m_Size, m_slots, GERBER_DRAW_ITEM::m_Start, m_vias, and VECTOR2< T >::x.
Referenced by ExportPcb().
|
private |
Write a track (or via) to the board file.
| aGbrItem | is the Gerber item (line, arc, flashed) to export. |
| aIndex | is the position of the item in its image's item list. |
| aLayer | is the copper layer to use. |
Definition at line 360 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(), GERBER_DRAW_ITEM::GetLayerPolarity(), D_CODE::m_ApertType, GERBER_DRAW_ITEM::m_ShapeAsPolygon, GERBER_DRAW_ITEM::m_ShapeType, SHAPE_POLY_SET::OutlineCount(), write_trimmed_polygon(), 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. |
| aLayer | is the layer ID to export. |
Definition at line 490 of file export_to_pcbnew.cpp.
References center, 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(), SHAPE_POLY_SET::OutlineCount(), radius, TOP_BOTTOM, via, writePcbFilledCircle(), writePcbPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item().
|
private |
Write a non copper arc to the board file.
| aGbrItem | is the Gerber item (line, arc) to export. |
| aLayer | is the technical layer to use. |
Definition at line 252 of file export_to_pcbnew.cpp.
References export_stroke_info(), FormatDouble2Str(), GetRotated(), GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_End, m_fp, M_PI, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, MapToPcbUnits(), LSET::Name(), RADIANS_T, ToStdString(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_non_copper_item().
|
private |
Write a non copper line or arc to the board file.
| aGbrItem | is the Gerber item (line, arc) to export. |
| aIndex | is the position of the item in its image's item list. |
| aLayer | is the technical layer to use. |
Definition at line 154 of file export_to_pcbnew.cpp.
References APT_RECT, center, GERBER_DRAW_ITEM::ConvertSegmentToPolygon(), D_CODE::ConvertShapeToPolygon(), export_non_copper_arc(), export_stroke_info(), 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(), GERBER_DRAW_ITEM::GetLayerPolarity(), D_CODE::m_ApertType, GERBER_DRAW_ITEM::m_End, m_fp, D_CODE::m_Polygon, GERBER_DRAW_ITEM::m_ShapeType, D_CODE::m_Size, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, MapToPcbUnits(), SHAPE_LINE_CHAIN::Mirror(), LSET::Name(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), radius, TOP_BOTTOM, ToStdString(), write_trimmed_polygon(), 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 453 of file export_to_pcbnew.cpp.
References FormatDouble2Str(), GetRotated(), GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_End, m_fp, M_PI, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, MapToPcbUnits(), LSET::Name(), RADIANS_T, ToStdString(), 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 418 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 |
Definition at line 335 of file export_to_pcbnew.cpp.
References center, end, VECTOR2< T >::EuclideanNorm(), FormatDouble2Str(), EXPORT_SLOT::m_End, m_fp, EXPORT_SLOT::m_Start, EXPORT_SLOT::m_Width, MapToPcbUnits(), and VECTOR2< T >::y.
Referenced by ExportPcb().
|
private |
Write the stroke info (thickness, line type) to the board file.
| aWidth | is the line thickness gerber units). |
Definition at line 446 of file export_to_pcbnew.cpp.
References FormatDouble2Str(), m_fp, and MapToPcbUnits().
Referenced by export_non_copper_arc(), export_non_copper_item(), writePcbFilledCircle(), and writePcbPolygon().
|
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 315 of file export_to_pcbnew.cpp.
References B_Cu, F_Cu, FormatDouble2Str(), EXPORT_VIA::m_Drill, m_fp, EXPORT_VIA::m_Pos, EXPORT_VIA::m_Size, MapToPcbUnits(), LSET::Name(), ToStdString(), 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 55 of file export_to_pcbnew.cpp.
References _, collect_clear_shapes(), collect_hole(), DisplayError(), export_copper_item(), export_non_copper_item(), export_slot(), export_via(), GERBER_FILE_IMAGE_LIST::GetGbrImage(), GERBER_FILE_IMAGE::GetItems(), GERBER_FILE_IMAGE_LIST::ImagesMaxCount(), IsCopperLayer(), IsPcbLayer(), m_fp, m_images, m_parent, m_pcb_file_name, m_pcbCopperLayersCount, m_slots, m_vias, UNDEFINED_LAYER, via, and writePcbHeader().
Referenced by BOOST_AUTO_TEST_CASE(), and 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 222 of file export_to_pcbnew.h.
References gerbIUScale.
Referenced by export_non_copper_arc(), export_non_copper_item(), export_segarc_copper_item(), export_slot(), export_stroke_info(), export_via(), writeCopperLineItem(), writePcbFilledCircle(), writePcbPolygon(), and writePcbZoneItem().
|
private |
Write a dark region to the board file, minus the clear items drawn after it.
Definition at line 674 of file export_to_pcbnew.cpp.
References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BBox(), SHAPE_POLY_SET::BooleanSubtract(), clear(), SHAPE_POLY_SET::COutline(), SHAPE_POLY_SET::Fracture(), SHAPE_POLY_SET::IsEmpty(), m_clearShapes, GERBER_DRAW_ITEM::m_ShapeAsPolygon, SHAPE_POLY_SET::OutlineCount(), and writePcbPolygon().
Referenced by export_copper_item(), and export_non_copper_item().
|
private |
Basic write function to write a a PCB_TRACK to the board file from a non flashed item.
Definition at line 433 of file export_to_pcbnew.cpp.
References FormatDouble2Str(), m_fp, MapToPcbUnits(), LSET::Name(), ToStdString(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by 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 548 of file export_to_pcbnew.cpp.
References export_stroke_info(), FormatDouble2Str(), m_fp, MapToPcbUnits(), LSET::Name(), ToStdString(), 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 564 of file export_to_pcbnew.cpp.
References LSET::AllCuMask(), LSET::AllTechMask(), LSET::copper_layers_begin(), LSET::copper_layers_end(), GetMajorMinorVersion(), m_fp, m_pcbCopperLayersCount, LSET::Name(), LSET::non_copper_layers_begin(), LSET::non_copper_layers_end(), and LSET::UserMask().
Referenced by ExportPcb().
|
private |
Write a non-copper polygon to the board file.
| aPolys | are the polygons to write. |
| aLayer | is the technical layer to use. |
| aOffset | is the optional polygon offset. |
Definition at line 700 of file export_to_pcbnew.cpp.
References SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), export_stroke_info(), FormatDouble2Str(), m_fp, MapToPcbUnits(), MAX_COORD_CNT, LSET::Name(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), ToStdString(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item(), export_flashed_copper_item(), export_non_copper_item(), and write_trimmed_polygon().
|
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 744 of file export_to_pcbnew.cpp.
References SHAPE_POLY_SET::CloneDropTriangulation(), SHAPE_LINE_CHAIN::CPoint(), FormatDouble2Str(), m_fp, GERBER_DRAW_ITEM::m_ShapeAsPolygon, MapToPcbUnits(), MAX_COORD_CNT, LSET::Name(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::Simplify(), ToStdString(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by export_copper_item().
|
private |
Definition at line 235 of file export_to_pcbnew.h.
Referenced by collect_clear_shapes(), and write_trimmed_polygon().
|
private |
Definition at line 231 of file export_to_pcbnew.h.
Referenced by export_non_copper_arc(), export_non_copper_item(), export_segarc_copper_item(), export_slot(), export_stroke_info(), export_via(), ExportPcb(), GBR_TO_PCB_EXPORTER(), writeCopperLineItem(), writePcbFilledCircle(), writePcbHeader(), writePcbPolygon(), and writePcbZoneItem().
|
private |
Definition at line 228 of file export_to_pcbnew.h.
Referenced by ExportPcb(), and GBR_TO_PCB_EXPORTER().
|
private |
Definition at line 229 of file export_to_pcbnew.h.
Referenced by ExportPcb(), and GBR_TO_PCB_EXPORTER().
|
private |
Definition at line 230 of file export_to_pcbnew.h.
Referenced by ExportPcb(), and GBR_TO_PCB_EXPORTER().
|
private |
Definition at line 232 of file export_to_pcbnew.h.
Referenced by ExportPcb(), GBR_TO_PCB_EXPORTER(), and writePcbHeader().
|
private |
Definition at line 234 of file export_to_pcbnew.h.
Referenced by collect_hole(), and ExportPcb().
|
private |
Definition at line 233 of file export_to_pcbnew.h.
Referenced by collect_hole(), export_flashed_copper_item(), and ExportPcb().