78 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
80 int pcb_layer_number = aLayerLookUpTable[layer];
102 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
106 if( gerber ==
nullptr )
109 int pcb_layer_number = aLayerLookUpTable[layer];
119 for(
unsigned layer = 0; layer < images->
ImagesMaxCount(); ++layer )
123 if( gerber ==
nullptr )
126 int pcb_layer_number = aLayerLookUpTable[layer];
142 fprintf(
m_fp,
")\n" );
156 static D_CODE dummyD_CODE( 0 );
163 if( d_codeDescr ==
nullptr )
164 d_codeDescr = &dummyD_CODE;
200 seg_start.
y = -seg_start.
y;
201 seg_end.
y = -seg_end.
y;
203 fprintf(
m_fp,
"\t(gr_circle (start %s %s) (end %s %s) (layer %s)\n",
210 fprintf(
m_fp,
"\t)\n" );
228 seg_start.
y = -seg_start.
y;
229 seg_end.
y = -seg_end.
y;
231 fprintf(
m_fp,
"\t(gr_line\n\t\t(start %s %s) (end %s %s) (layer %s)\n",
239 fprintf(
m_fp,
"\t)\n" );
260 if( seg_start == seg_end )
263 arc_center.
y = -arc_center.
y;
264 seg_end.
y = -seg_end.
y;
266 fprintf(
m_fp,
"\t(gr_circle\n\t\t(center %s %s) (end %s %s) (layer %s)\n",
273 fprintf(
m_fp,
"\t)\n" );
281 seg_middle.
y = -seg_middle.
y;
282 seg_start.
y = -seg_start.
y;
283 seg_end.
y = -seg_end.
y;
285 fprintf(
m_fp,
"\t(gr_arc\n\t\t(start %s %s) (mid %s %s) (end %s %s) (layer %s)\n",
295 fprintf(
m_fp,
"\t)\n" );
314 via_pos.
y = -via_pos.
y;
317 fprintf(
m_fp,
"\t(via (at %s %s) (size %s) (drill %s)",
323 fprintf(
m_fp,
" (layers %s %s))\n",
343 fprintf(
m_fp,
"\t(footprint \"slot\" (pad 1 thru_hole oval (at %s %s %s) (size %s %s) (drill oval %s %s)))\n",
417 seg_end = aGbrItem->
m_End;
420 seg_start.
y = -seg_start.
y;
421 seg_end.
y = -seg_end.
y;
428 int aWidth,
int aLayer )
430 fprintf(
m_fp,
"\t(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n",
442 fprintf(
m_fp,
"\t\t(stroke (width %s) (type solid))\n",
465 seg_end.
y = -seg_end.
y;
466 seg_start.
y = -seg_start.
y;
467 seg_middle.
y = -seg_middle.
y;
469 fprintf(
m_fp,
"\t(arc\n\t\t(start %s %s) (mid %s %s) (end %s %s) (layer %s)\n",
478 fprintf(
m_fp,
"\t\t(width %s) (net 0 )\n",
480 fprintf(
m_fp,
"\t)\n" );
486 static D_CODE flashed_item_D_CODE( 0 );
490 if( d_codeDescr ==
nullptr )
491 d_codeDescr = &flashed_item_D_CODE;
542 fprintf(
m_fp,
"\t(gr_circle\n\t\t(center %s %s) (end %s %s)\n",
549 fprintf(
m_fp,
"\t\t(fill yes) (layer %s)",
551 fprintf(
m_fp,
"\n\t)\n" );
558 fprintf(
m_fp,
"(kicad_pcb (version 20240928)\n" );
559 fprintf(
m_fp,
"\t(generator \"gerbview\")\n\t(generator_version \"%s\")\n\n",
563 fprintf(
m_fp,
"\t(layers \n" );
569 fprintf(
m_fp,
"\t\t(%d %s signal)\n",
570 *cu_it,
LSET::Name( *cu_it ).ToStdString().c_str() );
575 fprintf(
m_fp,
"\t\t(%d %s user)\n",
576 *non_cu_it,
LSET::Name( *non_cu_it ).ToStdString().c_str() );
579 fprintf(
m_fp,
"\t)\n\n" );
594 fprintf(
m_fp,
"\t(gr_poly\n\t\t(pts\n\t\t\t" );
596 #define MAX_COORD_CNT 4
604 for(
int ii = 0; ii <= cnt_max; ii++ )
609 fprintf(
m_fp,
"\n\t\t\t" );
612 fprintf(
m_fp,
" (xy %s %s)",
617 fprintf(
m_fp,
")" );
619 fprintf(
m_fp,
"\n" );
621 fprintf(
m_fp,
"\t\t(fill yes) (layer %s)",
623 fprintf(
m_fp,
"\n\t)\n" );
635 fprintf(
m_fp,
"\t(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
638 fprintf(
m_fp,
" (connect_pads (clearance 0.0))\n" );
640 fprintf(
m_fp,
" (min_thickness 0.1) (filled_areas_thickness no)\n"
641 " (fill (thermal_gap 0.3) (thermal_bridge_width 0.3))\n" );
649 fprintf(
m_fp,
" (polygon\n (pts" );
653 #define MAX_COORD_CNT 4
661 for(
int ii = 0; ii <= cnt_max; ii++ )
666 fprintf(
m_fp,
"\n " );
673 fprintf(
m_fp,
")\n" );
675 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.
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).
std::vector< EXPORT_SLOT > m_slots
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.
void export_slot(const EXPORT_SLOT &aSlot)
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
bool GetLayerPolarity() const
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()
LSET is a set of PCB_LAYER_IDs.
copper_layers_iterator copper_layers_end() const
static const LSET & UserMask()
copper_layers_iterator copper_layers_begin() const
non_copper_layers_iterator non_copper_layers_begin() const
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
non_copper_layers_iterator non_copper_layers_end() const
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
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
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
void DisplayError(wxWindow *aParent, const wxString &aText)
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.
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
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.