78 const int pcbCopperLayerMax = 31;
82 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
84 int pcb_layer_number = aLayerLookUpTable[layer];
105 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
109 if( gerber ==
nullptr )
112 int pcb_layer_number = aLayerLookUpTable[layer];
117 if( pcb_layer_number <= pcbCopperLayerMax )
125 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
129 if( gerber ==
nullptr )
132 int pcb_layer_number = aLayerLookUpTable[layer];
134 if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax )
145 fprintf(
m_fp,
")\n" );
156 static D_CODE dummyD_CODE( 0 );
163 if( d_codeDescr ==
nullptr )
164 d_codeDescr = &dummyD_CODE;
175 int radius = d_codeDescr->
m_Size.
x / 2;
203 seg_start.
y = -seg_start.
y;
204 seg_end.
y = -seg_end.
y;
208 fprintf(
m_fp,
"(gr_circle (center %s %s) (end %s %s) (layer %s) (width %s))\n",
218 fprintf(
m_fp,
"(gr_arc (start %s %s) (end %s %s) (angle %s) (layer %s) (width %s))\n",
232 seg_start.
y = -seg_start.
y;
233 seg_end.
y = -seg_end.
y;
235 fprintf(
m_fp,
"(gr_circle (start %s %s) (end %s %s) (layer %s) (width %s))\n",
246 seg_start.
y = -seg_start.
y;
247 seg_end.
y = -seg_end.
y;
249 fprintf(
m_fp,
"(gr_line (start %s %s) (end %s %s) (layer %s) (width %s))\n",
273 via_pos.
y = -via_pos.
y;
276 fprintf(
m_fp,
" (via (at %s %s) (size %s) (drill %s)",
282 fprintf(
m_fp,
" (layers %s %s))\n",
329 seg_end = aGbrItem->
m_End;
332 seg_start.
y = -seg_start.
y;
333 seg_end.
y = -seg_end.
y;
340 int aWidth,
int aLayer )
342 fprintf(
m_fp,
"(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
366 #define SEG_COUNT_CIRCLE 16
367 #define DELTA_ANGLE 2 * M_PI / SEG_COUNT_CIRCLE
381 seg_start = curr_start;
387 seg_start.
y = -seg_start.
y;
388 seg_end.
y = -seg_end.
y;
390 curr_start = curr_end;
393 if( end != curr_start )
395 seg_start = curr_start;
399 seg_start.
y = -seg_start.
y;
400 seg_end.
y = -seg_end.
y;
408 static D_CODE flashed_item_D_CODE( 0 );
412 if( d_codeDescr ==
nullptr )
413 d_codeDescr = &flashed_item_D_CODE;
435 int radius = d_codeDescr->
m_Size.
x / 2;
465 fprintf(
m_fp,
"(gr_circle (center %s %s) (end %s %s)",
472 fprintf(
m_fp,
"(layer %s) (width 0) (fill solid) )\n",
479 fprintf(
m_fp,
"(kicad_pcb (version 4) (generator gerbview)\n\n" );
482 fprintf(
m_fp,
" (layers \n" );
502 fprintf(
m_fp,
" )\n\n" );
517 fprintf(
m_fp,
"(gr_poly (pts " );
519 #define MAX_COORD_CNT 4
527 for(
int ii = 0; ii <= cnt_max; ii++ )
532 fprintf(
m_fp,
"\n" );
535 fprintf(
m_fp,
" (xy %s %s)",
540 fprintf(
m_fp,
")" );
543 fprintf(
m_fp,
"\n" );
557 fprintf(
m_fp,
"(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
560 fprintf(
m_fp,
" (connect_pads (clearance 0.0))\n" );
562 fprintf(
m_fp,
" (min_thickness 0.1) (filled_areas_thickness no)\n"
563 " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
571 fprintf(
m_fp,
" (polygon\n (pts" );
575 #define MAX_COORD_CNT 4
583 for(
int ii = 0; ii <= cnt_max; ii++ )
588 fprintf(
m_fp,
"\n " );
595 fprintf(
m_fp,
")\n" );
597 fprintf(
m_fp,
" )\n)\n" );
Support the "aperture macro" defined within standard RS274X.
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
A gerber DCODE (also called Aperture) definition.
APERTURE_MACRO * GetMacro() const
VECTOR2I m_Size
Horizontal and vertical dimensions.
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
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)
int m_pcbCopperLayersCount
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.
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
VECTOR2I GetABPosition(const VECTOR2I &aXYPosition) const
Return the image position of aPosition for this object.
SHAPE_POLY_SET m_ShapeAsPolygon
GBR_BASIC_SHAPE_TYPE m_ShapeType
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
unsigned ImagesMaxCount()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
Hold the image data and parameters for one gerber file and layer parameters.
GERBER_DRAW_ITEMS & GetItems()
GBR_LAYOUT * GetGerberLayout() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both).
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void Simplify(POLYGON_MODE aFastMode)
SHAPE_LINE_CHAIN & Outline(int aIndex)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
const wxString GetPCBDefaultLayerName(int aLayerNumber)
bool IsPcbLayer(int 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.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
double RAD2DEG(double rad)
Definition of file extensions used in Kicad.