80 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
82 int pcb_layer_number = aLayerLookUpTable[layer];
104 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
108 if( gerber ==
nullptr )
111 int pcb_layer_number = aLayerLookUpTable[layer];
121 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
125 if( gerber ==
nullptr )
128 int pcb_layer_number = aLayerLookUpTable[layer];
141 fprintf(
m_fp,
")\n" );
152 static D_CODE dummyD_CODE( 0 );
159 if( d_codeDescr ==
nullptr )
160 d_codeDescr = &dummyD_CODE;
185 polyshape.
Outline( 0 ).
Mirror( { 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
196 seg_start.
y = -seg_start.
y;
197 seg_end.
y = -seg_end.
y;
199 fprintf(
m_fp,
"\t(gr_circle (start %s %s) (end %s %s) (layer %s)\n",
206 fprintf(
m_fp,
"\t)\n" );
224 seg_start.
y = -seg_start.
y;
225 seg_end.
y = -seg_end.
y;
227 fprintf(
m_fp,
"\t(gr_line\n\t\t(start %s %s) (end %s %s) (layer %s)\n",
235 fprintf(
m_fp,
"\t)\n" );
256 if( seg_start == seg_end )
259 arc_center.
y = -arc_center.
y;
260 seg_end.
y = -seg_end.
y;
262 fprintf(
m_fp,
"\t(gr_circle\n\t\t(center %s %s) (end %s %s) (layer %s)\n",
269 fprintf(
m_fp,
"\t)\n" );
277 seg_middle.
y = -seg_middle.
y;
278 seg_start.
y = -seg_start.
y;
279 seg_end.
y = -seg_end.
y;
281 fprintf(
m_fp,
"\t(gr_arc\n\t\t(start %s %s) (mid %s %s) (end %s %s) (layer %s)\n",
291 fprintf(
m_fp,
"\t)\n" );
308 via_pos.
y = -via_pos.
y;
311 fprintf(
m_fp,
" (via (at %s %s) (size %s) (drill %s)",
317 fprintf(
m_fp,
" (layers %s %s))\n",
383 seg_end = aGbrItem->
m_End;
386 seg_start.
y = -seg_start.
y;
387 seg_end.
y = -seg_end.
y;
394 int aWidth,
int aLayer )
396 fprintf(
m_fp,
"\t(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
408 fprintf(
m_fp,
"\t\t(stroke (width %s) (type solid))\n",
431 seg_end.
y = -seg_end.
y;
432 seg_start.
y = -seg_start.
y;
433 seg_middle.
y = -seg_middle.
y;
435 fprintf(
m_fp,
"\t(arc\n\t\t(start %s %s) (mid %s %s) (end %s %s) (layer %s)\n",
444 fprintf(
m_fp,
"\t\t(width %s) (net 0 )\n",
446 fprintf(
m_fp,
"\t)\n" );
452 static D_CODE flashed_item_D_CODE( 0 );
456 if( d_codeDescr ==
nullptr )
457 d_codeDescr = &flashed_item_D_CODE;
492 macroShape.
Outline( 0 ).
Mirror( { 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
508 fprintf(
m_fp,
"\t(gr_circle\n\t\t(center %s %s) (end %s %s)\n",
515 fprintf(
m_fp,
"\t\t(fill yes) (layer %s)",
517 fprintf(
m_fp,
"\n\t)\n" );
524 fprintf(
m_fp,
"(kicad_pcb (version 20240928)\n" );
525 fprintf(
m_fp,
"\t(generator \"gerbview\")\n\t(generator_version \"%s\")\n\n",
529 fprintf(
m_fp,
"\t(layers \n" );
535 fprintf(
m_fp,
"\t\t(%d %s signal)\n",
536 *cu_it,
LSET::Name( *cu_it ).ToStdString().c_str() );
541 fprintf(
m_fp,
"\t\t(%d %s user)\n",
542 *non_cu_it,
LSET::Name( *non_cu_it ).ToStdString().c_str() );
545 fprintf(
m_fp,
"\t)\n\n" );
560 fprintf(
m_fp,
"\t(gr_poly\n\t\t(pts\n\t\t\t" );
562 #define MAX_COORD_CNT 4
570 for(
int ii = 0; ii <= cnt_max; ii++ )
575 fprintf(
m_fp,
"\n\t\t\t" );
578 fprintf(
m_fp,
" (xy %s %s)",
583 fprintf(
m_fp,
")" );
585 fprintf(
m_fp,
"\n" );
587 fprintf(
m_fp,
"\t\t(fill yes) (layer %s)",
589 fprintf(
m_fp,
"\n\t)\n" );
601 fprintf(
m_fp,
"\t(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
604 fprintf(
m_fp,
" (connect_pads (clearance 0.0))\n" );
606 fprintf(
m_fp,
" (min_thickness 0.1) (filled_areas_thickness no)\n"
607 " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
615 fprintf(
m_fp,
" (polygon\n (pts" );
619 #define MAX_COORD_CNT 4
627 for(
int ii = 0; ii <= cnt_max; ii++ )
632 fprintf(
m_fp,
"\n " );
639 fprintf(
m_fp,
")\n" );
641 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_stroke_info(double aWidth)
Write the stroke info (thickness, line type) to the board file.
void export_non_copper_arc(const GERBER_DRAW_ITEM *aGbrItem, int aLayer)
Write a non copper arc 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
void ConvertSegmentToPolygon()
Convert a line to an equivalent polygon.
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.
LSET is a set of PCB_LAYER_IDs.
copper_layers_iterator copper_layers_end() const
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
copper_layers_iterator copper_layers_begin() const
non_copper_layers_iterator non_copper_layers_begin() const
non_copper_layers_iterator non_copper_layers_end() const
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
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()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
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.
bool IsPcbLayer(int aLayer)
Test whether a layer is a valid layer for Pcbnew.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
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...
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.