78 const int pcbCopperLayerMax = 31;
82 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
86 if( excellon ==
nullptr )
94 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
98 if( gerber ==
nullptr )
101 LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
106 if( pcb_layer_number <= pcbCopperLayerMax )
114 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
118 if( gerber ==
nullptr )
121 LAYER_NUM pcb_layer_number = aLayerLookUpTable[layer];
123 if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax )
134 fprintf(
m_fp,
")\n" );
146 static D_CODE dummyD_CODE( 0 );
148 wxPoint seg_start = aGbrItem->
m_Start;
149 wxPoint seg_end = aGbrItem->
m_End;
153 if( d_codeDescr ==
nullptr )
154 d_codeDescr = &dummyD_CODE;
165 int radius = d_codeDescr->
m_Size.x / 2;
193 seg_start.y = -seg_start.y;
194 seg_end.y = -seg_end.y;
198 fprintf(
m_fp,
"(gr_circle (center %s %s) (end %s %s) (layer %s) (width %s))\n",
209 fprintf(
m_fp,
"(gr_arc (start %s %s) (end %s %s) (angle %s) (layer %s) (width %s))\n",
224 seg_start.y = -seg_start.y;
225 seg_end.y = -seg_end.y;
227 fprintf(
m_fp,
"(gr_circle (start %s %s) (end %s %s) (layer %s) (width %s))\n",
238 seg_start.y = -seg_start.y;
239 seg_end.y = -seg_end.y;
241 fprintf(
m_fp,
"(gr_line (start %s %s) (end %s %s) (layer %s) (width %s))\n",
255 int size = std::min( aGbrItem->
m_Size.x, aGbrItem->
m_Size.y );
262 wxPoint via_pos = aVia.
m_Pos;
265 via_pos.y = -via_pos.y;
268 fprintf(
m_fp,
" (via (at %s %s) (size %s) (drill %s)",
274 fprintf(
m_fp,
" (layers %s %s))\n",
317 wxPoint seg_start, seg_end;
320 seg_end = aGbrItem->
m_End;
323 seg_start.y = -seg_start.y;
324 seg_end.y = -seg_end.y;
334 fprintf(
m_fp,
"(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
352 wxPoint start = aGbrItem->
m_Start;
353 wxPoint end = aGbrItem->
m_End;
359 #define SEG_COUNT_CIRCLE 16 360 #define DELTA_ANGLE 2 * M_PI / SEG_COUNT_CIRCLE 367 wxPoint curr_start = start;
368 wxPoint seg_start, seg_end;
374 seg_start = curr_start;
375 wxPoint curr_end = start;
381 seg_start.y = -seg_start.y;
382 seg_end.y = -seg_end.y;
384 curr_start = curr_end;
387 if( end != curr_start )
389 seg_start = curr_start;
393 seg_start.y = -seg_start.y;
394 seg_end.y = -seg_end.y;
403 static D_CODE flashed_item_D_CODE( 0 );
408 if( d_codeDescr ==
nullptr )
409 d_codeDescr = &flashed_item_D_CODE;
418 via.m_Size = std::max(
via.m_Size, aGbrItem->
m_Size.x );
429 int radius = d_codeDescr->
m_Size.x / 2;
443 fprintf(
m_fp,
"(gr_circle (center %s %s) (end %s %s)",
450 fprintf(
m_fp,
"(layer %s) (width 0) (fill solid) )\n",
457 fprintf(
m_fp,
"(kicad_pcb (version 4) (generator gerbview)\n\n" );
460 fprintf(
m_fp,
" (layers \n" );
480 fprintf(
m_fp,
" )\n\n" );
485 const wxPoint& aOffset )
493 fprintf(
m_fp,
"(gr_poly (pts " );
495 #define MAX_COORD_CNT 4 503 for(
int ii = 0; ii <= cnt_max; ii++ )
508 fprintf(
m_fp,
"\n" );
511 fprintf(
m_fp,
" (xy %s %s)",
516 fprintf(
m_fp,
")" );
519 fprintf(
m_fp,
"\n" );
533 fprintf(
m_fp,
"(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
536 fprintf(
m_fp,
" (connect_pads (clearance 0.0))\n" );
538 fprintf(
m_fp,
" (min_thickness 0.1) (filled_areas_thickness no)\n" 539 " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
547 fprintf(
m_fp,
" (polygon\n (pts" );
551 #define MAX_COORD_CNT 4 559 for(
int ii = 0; ii <= cnt_max; ii++ )
564 fprintf(
m_fp,
"\n " );
571 fprintf(
m_fp,
")\n" );
573 fprintf(
m_fp,
" )\n)\n" );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
double MapToPcbUnits(int aValue) const
Map GerbView internal units to millimeters for Pcbnew board files.
std::vector< EXPORT_VIA > m_vias
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void writePcbPolygon(const SHAPE_POLY_SET &aPolys, LAYER_NUM aLayer, const wxPoint &aOffset={ 0, 0 })
Write a non-copper polygon to the board file.
GERBER_DRAW_ITEMS & GetItems()
This file is part of the common library.
wxSize m_Size
Horizontal and vertical dimensions.
GBR_TO_PCB_EXPORTER(GERBVIEW_FRAME *aFrame, const wxString &aFileName)
double RAD2DEG(double rad)
Hold the image data and parameters for one gerber file and layer parameters.
double RAD2DECIDEG(double rad)
int LAYER_NUM
This can be replaced with int and removed.
void export_via(const EXPORT_VIA &aVia)
Write a via to the board file.
void RotatePoint(int *pX, int *pY, double angle)
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
int PointCount() const
Return the number of points (vertices) in this line chain.
int m_pcbCopperLayersCount
bool IsPcbLayer(LAYER_NUM aLayer)
Test whether a layer is a valid layer for Pcbnew.
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return the image position of aPosition for this object.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
unsigned ImagesMaxCount()
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
void export_copper_item(const GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Write a track (or via) to the board file.
GERBVIEW_FRAME * m_gerbview_frame
Definition of file extensions used in Kicad.
void collect_hole(const GERBER_DRAW_ITEM *aGbrItem)
Collect holes from a drill layer.
void Simplify(POLYGON_MODE aFastMode)
void export_flashed_copper_item(const GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Write a synthetic pad to the board file.
void export_segline_copper_item(const GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Write a track (not via) to the board file.
void export_segarc_copper_item(const GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Write a set of tracks (arcs are approximated by track segments) to the board file.
GBR_LAYOUT * GetGerberLayout() const
void writePcbZoneItem(const GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Write a zone item to the board file.
void export_non_copper_item(const GERBER_DRAW_ITEM *aGbrItem, LAYER_NUM aLayer)
Write a non copper line or arc to the board file.
A gerber DCODE (also called Aperture) definition.
void writeCopperLineItem(const wxPoint &aStart, const wxPoint &aEnd, int aWidth, LAYER_NUM aLayer)
Basic write function to write a a PCB_TRACK to the board file from a non flashed item.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void writePcbFilledCircle(const VECTOR2I &aCenterPosition, int aRadius, LAYER_NUM aLayer)
Write a filled circle to the board file (with line thickness = 0).
const wxString GetPCBDefaultLayerName(LAYER_NUM aLayerNumber)
GERBER_FILE_IMAGE_LIST * GetImagesList() const
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
bool ExportPcb(const LAYER_NUM *aLayerLookUpTable, int aCopperLayers)
Save a board from a set of Gerber images.
void ConvertShapeToPolygon()
Convert a shape to an equivalent polygon.
void writePcbHeader(const LAYER_NUM *aLayerLookUpTable)
Write a very basic header to the board file.