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;
189 polyshape.
Outline( 0 ).
Mirror( { 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
209 seg_start.
y = -seg_start.
y;
210 seg_end.
y = -seg_end.
y;
212 if( angle == 360.0 || angle == 0 )
214 fprintf(
m_fp,
"(gr_circle (center %s %s) (end %s %s) (layer %s) (width %s))\n",
224 fprintf(
m_fp,
"(gr_arc (start %s %s) (end %s %s) (angle %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_circle (start %s %s) (end %s %s) (layer %s) (width %s))\n",
252 seg_start.
y = -seg_start.
y;
253 seg_end.
y = -seg_end.
y;
255 fprintf(
m_fp,
"(gr_line (start %s %s) (end %s %s) (layer %s) (width %s))\n",
279 via_pos.
y = -via_pos.
y;
282 fprintf(
m_fp,
" (via (at %s %s) (size %s) (drill %s)",
288 fprintf(
m_fp,
" (layers %s %s))\n",
354 seg_end = aGbrItem->
m_End;
357 seg_start.
y = -seg_start.
y;
358 seg_end.
y = -seg_end.
y;
365 int aWidth,
int aLayer )
367 fprintf(
m_fp,
"(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
391 #define SEG_COUNT_CIRCLE 16
392 #define DELTA_ANGLE 2 * M_PI / SEG_COUNT_CIRCLE
406 seg_start = curr_start;
412 seg_start.
y = -seg_start.
y;
413 seg_end.
y = -seg_end.
y;
415 curr_start = curr_end;
418 if( end != curr_start )
420 seg_start = curr_start;
424 seg_start.
y = -seg_start.
y;
425 seg_end.
y = -seg_end.
y;
433 static D_CODE flashed_item_D_CODE( 0 );
437 if( d_codeDescr ==
nullptr )
438 d_codeDescr = &flashed_item_D_CODE;
460 int radius = d_codeDescr->
m_Size.
x / 2;
473 macroShape.
Outline( 0 ).
Mirror( { 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
490 fprintf(
m_fp,
"(gr_circle (center %s %s) (end %s %s)",
497 fprintf(
m_fp,
"(layer %s) (width 0) (fill solid) )\n",
504 fprintf(
m_fp,
"(kicad_pcb (version 4) (generator \"gerbview\") (generator_version \"%s\")\n\n",
GetMajorMinorVersion().c_str().AsChar() );
507 fprintf(
m_fp,
" (layers \n" );
527 fprintf(
m_fp,
" )\n\n" );
542 fprintf(
m_fp,
"(gr_poly (pts " );
544 #define MAX_COORD_CNT 4
552 for(
int ii = 0; ii <= cnt_max; ii++ )
557 fprintf(
m_fp,
"\n" );
560 fprintf(
m_fp,
" (xy %s %s)",
565 fprintf(
m_fp,
")" );
568 fprintf(
m_fp,
"\n" );
582 fprintf(
m_fp,
"(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
585 fprintf(
m_fp,
" (connect_pads (clearance 0.0))\n" );
587 fprintf(
m_fp,
" (min_thickness 0.1) (filled_areas_thickness no)\n"
588 " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
596 fprintf(
m_fp,
" (polygon\n (pts" );
600 #define MAX_COORD_CNT 4
608 for(
int ii = 0; ii <= cnt_max; ii++ )
613 fprintf(
m_fp,
"\n " );
620 fprintf(
m_fp,
")\n" );
622 fprintf(
m_fp,
" )\n)\n" );
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
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.
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
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.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both).
Represent a set of closed polygons.
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
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)
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.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
double RAD2DEG(double rad)
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.