KiCad PCB EDA Suite
GERBER_PLOTTER Class Reference

#include <plotter_gerber.h>

Inheritance diagram for GERBER_PLOTTER:
PLOTTER

Public Member Functions

 GERBER_PLOTTER ()
 
virtual PLOT_FORMAT GetPlotterType () const override
 Returns the effective plot engine in use. More...
 
virtual bool StartPlot () override
 Function StartPlot Write GERBER header to file initialize global variable g_Plot_PlotOutputFile. More...
 
virtual bool EndPlot () override
 
virtual void SetCurrentLineWidth (int width, void *aData=NULL) override
 Set the line width for the next drawing. More...
 
virtual void SetDash (PLOT_DASH_TYPE dashed) override
 
virtual void SetColor (COLOR4D color) override
 
virtual void SetViewport (const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
 Set the plot offset and scaling for the current plot. More...
 
virtual void Rect (const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
 
virtual void Circle (const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
 
virtual void Arc (const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
 Generic fallback: arc rendered as a polyline. More...
 
virtual void ThickSegment (const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData) override
 
virtual void ThickArc (const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, OUTLINE_MODE tracemode, void *aData) override
 
virtual void ThickRect (const wxPoint &p1, const wxPoint &p2, int width, OUTLINE_MODE tracemode, void *aData) override
 
virtual void ThickCircle (const wxPoint &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData) override
 
virtual void FilledCircle (const wxPoint &pos, int diametre, OUTLINE_MODE tracemode, void *aData) override
 
virtual void PlotPoly (const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
 Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence. More...
 
virtual void PenTo (const wxPoint &pos, char plume) override
 moveto/lineto primitive, moves the 'pen' to the specified direction More...
 
virtual void Text (const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL) override
 Draws text with the plotter. More...
 
virtual void FlashPadCircle (const wxPoint &pos, int diametre, OUTLINE_MODE trace_mode, void *aData) override
 Filled circular flashes are stored as apertures. More...
 
virtual void FlashPadOval (const wxPoint &aPadPos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
 
virtual void FlashPadRect (const wxPoint &aPadPos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
 
virtual void FlashPadRoundRect (const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadCustom (const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
 
virtual void FlashPadTrapez (const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
 Flash a trapezoidal pad. More...
 
virtual void FlashRegularPolygon (const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
 Flash a regular polygon. More...
 
void FlashPadChamferRoundRect (const wxPoint &aShapePos, const wxSize &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, double aPadOrient, OUTLINE_MODE aPlotMode, void *aData)
 flash a chamfered round rect pad. More...
 
void PlotGerberRegion (const std::vector< wxPoint > &aCornerList, void *aData=NULL)
 Plot a Gerber region: similar to PlotPoly but plot only filled polygon, and add the TA.AperFunction if aData contains this attribute, and clear it after plotting. More...
 
virtual void SetLayerPolarity (bool aPositive) override
 Change the plot polarity and begin a new layer Used to 'scratch off' silk screen away from solder mask. More...
 
virtual void SetGerberCoordinatesFormat (int aResolution, bool aUseInches=false) override
 Function SetGerberCoordinatesFormat selection of Gerber units and resolution (number of digits in mantissa) More...
 
void UseX2format (bool aEnable)
 
void UseX2NetAttributes (bool aEnable)
 
void DisableApertMacros (bool aDisable)
 Disable Aperture Macro (AM) command, only for broken Gerber Readers Regions will be used instead of AM shapes to draw complex shapes. More...
 
virtual void StartBlock (void *aData) override
 calling this function allows one to define the beginning of a group of drawing items (used in X2 format with netlist attributes) More...
 
virtual void EndBlock (void *aData) override
 calling this function allows one to define the end of a group of drawing items the group is started by StartBlock() (used in X2 format with netlist attributes) More...
 
void ClearAllAttributes ()
 Remove (clear) all attributes from object attributes dictionary (TO. More...
 
int GetOrCreateAperture (const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 
int GetOrCreateAperture (const std::vector< wxPoint > &aCorners, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 
virtual void SetNegative (bool aNegative)
 
virtual void SetColorMode (bool aColorMode)
 Plot in B/W or color. More...
 
bool GetColorMode () const
 
void SetRenderSettings (RENDER_SETTINGS *aSettings)
 
RENDER_SETTINGSRenderSettings ()
 
virtual void SetPageSettings (const PAGE_INFO &aPageSettings)
 
PAGE_INFOPageSettings ()
 
virtual int GetCurrentLineWidth () const
 
virtual void SetCreator (const wxString &aCreator)
 
virtual void SetTitle (const wxString &aTitle)
 
void AddLineToHeader (const wxString &aExtraString)
 Add a line to the list of free lines to print at the beginning of the file. More...
 
void ClearHeaderLinesList ()
 Remove all lines from the list of free lines to print at the beginning of the file. More...
 
virtual bool OpenFile (const wxString &aFullFilename)
 Open or create the plot file aFullFilename. More...
 
double GetIUsPerDecimil () const
 The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establishing the viewport. More...
 
int GetPlotterArcLowDef () const
 
int GetPlotterArcHighDef () const
 
virtual void BezierCurve (const wxPoint &aStart, const wxPoint &aControl1, const wxPoint &aControl2, const wxPoint &aEnd, int aTolerance, int aLineThickness=USE_DEFAULT_LINE_WIDTH)
 Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control points: start ctrl1 ctrl2 end. More...
 
void MoveTo (const wxPoint &pos)
 
void LineTo (const wxPoint &pos)
 
void FinishTo (const wxPoint &pos)
 
void PenFinish ()
 
virtual void PlotPoly (const SHAPE_LINE_CHAIN &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)
 Draw a polygon ( filled or not ) More...
 
virtual void PlotImage (const wxImage &aImage, const wxPoint &aPos, double aScaleFactor)
 Only PostScript plotters can plot bitmaps. More...
 
void Marker (const wxPoint &position, int diametre, unsigned aShapeId)
 Draw a pattern shape number aShapeId, to coord position. More...
 
virtual void SetTextMode (PLOT_TEXT_MODE mode)
 Change the current text mode. More...
 
virtual void SetSvgCoordinatesFormat (unsigned aResolution, bool aUseInches=false)
 

Static Public Member Functions

static wxString GetDefaultFileExtension ()
 

Static Public Attributes

static const int DO_NOT_SET_LINE_WIDTH = -2
 
static const int USE_DEFAULT_LINE_WIDTH = -1
 
static const unsigned MARKER_COUNT = 58
 Draw a marker (used for the drill map) More...
 

Protected Member Functions

void plotRoundRectAsRegion (const wxPoint &aRectCenter, const wxSize &aSize, int aCornerRadius, double aOrient)
 Plot a round rect (a round rect shape in fact) as a Gerber region using lines and arcs for corners. More...
 
void plotArc (const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, bool aPlotInRegion)
 Plot a Gerber arc. More...
 
void selectAperture (const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 Pick an existing aperture or create a new one, matching the size, type and attributes. More...
 
void selectAperture (const std::vector< wxPoint > &aCorners, double aPolygonRotation, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 Pick an existing aperture or create a new one, matching the aDiameter, aPolygonRotation, type and attributes. More...
 
void selectAperture (int aDiameter, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 Pick an existing aperture or create a new one, matching the corner list, aRotDegree, type and attributes. More...
 
void emitDcode (const DPOINT &pt, int dcode)
 Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (for n decimal positions, see header generation in start_plot. More...
 
void formatNetAttribute (GBR_NETLIST_METADATA *aData)
 print a Gerber net attribute object record. More...
 
void clearNetAttribute ()
 clear a Gerber net attribute record (clear object attribute dictionary) and output the clear object attribute dictionary command to gerber file has effect only if a net attribute is stored in m_objectAttributesDictionnary More...
 
void writeApertureList ()
 Generate the table of D codes. More...
 
void markerCircle (const wxPoint &pos, int radius)
 Plot a circle centered on the position. More...
 
void markerHBar (const wxPoint &pos, int radius)
 Plot a - bar centered on the position. More...
 
void markerSlash (const wxPoint &pos, int radius)
 Plot a / bar centered on the position. More...
 
void markerBackSlash (const wxPoint &pos, int radius)
 Plot a \ bar centered on the position. More...
 
void markerVBar (const wxPoint &pos, int radius)
 Plot a | bar centered on the position. More...
 
void markerSquare (const wxPoint &position, int radius)
 Plot a square centered on the position. More...
 
void markerLozenge (const wxPoint &position, int radius)
 Plot a lozenge centered on the position. More...
 
void segmentAsOval (const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode)
 Convert a thick segment and plot it as an oval. More...
 
void sketchOval (const wxPoint &pos, const wxSize &size, double orient, int width)
 
virtual DPOINT userToDeviceCoordinates (const wxPoint &aCoordinate)
 Modifies coordinates according to the orientation, scale factor, and offsets trace. More...
 
virtual DPOINT userToDeviceSize (const wxSize &size)
 Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) More...
 
virtual double userToDeviceSize (double size) const
 Modifies size according to the plotter scale factors (simple double version) More...
 
double GetDotMarkLenIU () const
 
double GetDashMarkLenIU () const
 
double GetDashGapLenIU () const
 

Protected Attributes

std::string m_objectAttributesDictionnary
 
int m_apertureAttribute
 
FILE * workFile
 
FILE * finalFile
 
wxString m_workFilename
 
std::vector< APERTUREm_apertures
 
int m_currentApertureIdx
 
bool m_hasApertureRoundRect
 
bool m_hasApertureRotOval
 
bool m_hasApertureRotRect
 
bool m_hasApertureOutline4P
 
bool m_hasApertureChamferedRect
 
bool m_gerberUnitInch
 
int m_gerberUnitFmt
 
bool m_gerberDisableApertMacros
 
bool m_useX2format
 
bool m_useNetAttributes
 
double m_plotScale
 Plot scale - chosen by the user (even implicitly with 'fit in a4') More...
 
double m_IUsPerDecimil
 
double m_iuPerDeviceUnit
 
wxPoint m_plotOffset
 
bool m_plotMirror
 
bool m_mirrorIsHorizontal
 
bool m_yaxisReversed
 
FILE * m_outputFile
 Output file. More...
 
bool m_colorMode
 
bool m_negativeMode
 
int m_currentPenWidth
 
char m_penState
 
wxPoint m_penLastpos
 
wxString m_creator
 
wxString m_filename
 
wxString m_title
 
PAGE_INFO m_pageInfo
 
wxSize m_paperSize
 
wxArrayString m_headerExtraLines
 
RENDER_SETTINGSm_renderSettings
 

Detailed Description

Definition at line 37 of file plotter_gerber.h.

Constructor & Destructor Documentation

◆ GERBER_PLOTTER()

GERBER_PLOTTER::GERBER_PLOTTER ( )

Definition at line 63 of file GERBER_plotter.cpp.

64 {
65  workFile = NULL;
66  finalFile = NULL;
69 
70  // number of digits after the point (number of digits of the mantissa
71  // Be carefull: the Gerber coordinates are stored in an integer
72  // so 6 digits (inches) or 5 digits (mm) is a good value
73  // To avoid overflow, 7 digits (inches) or 6 digits is a max.
74  // with lower values than 6 digits (inches) or 5 digits (mm),
75  // Creating self-intersecting polygons from non-intersecting polygons
76  // happen easily.
77  m_gerberUnitInch = false;
78  m_gerberUnitFmt = 6;
79  m_useX2format = true;
80  m_useNetAttributes = true;
82 
83  m_hasApertureRoundRect = false; // true is at least one round rect aperture is in use
84  m_hasApertureRotOval = false; // true is at least one oval rotated aperture is in use
85  m_hasApertureRotRect = false; // true is at least one rect. rotated aperture is in use
86  m_hasApertureOutline4P = false; // true is at least one rotated rect or trapezoid pad
87  // aperture is in use
88  m_hasApertureChamferedRect = false; // true is at least one chamfered rect
89  // (no rounded corner) is in use
90 }
bool m_hasApertureChamferedRect
bool m_hasApertureOutline4P
bool m_hasApertureRoundRect
#define NULL
bool m_gerberDisableApertMacros

References finalFile, m_apertureAttribute, m_currentApertureIdx, m_gerberDisableApertMacros, m_gerberUnitFmt, m_gerberUnitInch, m_hasApertureChamferedRect, m_hasApertureOutline4P, m_hasApertureRotOval, m_hasApertureRotRect, m_hasApertureRoundRect, m_useNetAttributes, m_useX2format, NULL, and workFile.

Member Function Documentation

◆ AddLineToHeader()

void PLOTTER::AddLineToHeader ( const wxString &  aExtraString)
inlineinherited

Add a line to the list of free lines to print at the beginning of the file.

Parameters
aExtraStringis the string to print

Definition at line 190 of file plotter.h.

191  {
192  m_headerExtraLines.Add( aExtraString );
193  }
wxArrayString m_headerExtraLines
Definition: plotter.h:605

References PLOTTER::m_headerExtraLines.

Referenced by AddGerberX2Attribute(), AddGerberX2Header(), GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ Arc()

void GERBER_PLOTTER::Arc ( const wxPoint &  centre,
double  StAngle,
double  EndAngle,
int  rayon,
FILL_TYPE  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Generic fallback: arc rendered as a polyline.

Reimplemented from PLOTTER.

Definition at line 800 of file GERBER_plotter.cpp.

802 {
803  SetCurrentLineWidth( aWidth );
804 
805  // aFill is not used here.
806  plotArc( aCenter, aStAngle, aEndAngle, aRadius, false );
807 }
void plotArc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, bool aPlotInRegion)
Plot a Gerber arc.
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.

References plotArc(), and SetCurrentLineWidth().

Referenced by Circle(), and ThickArc().

◆ BezierCurve()

void PLOTTER::BezierCurve ( const wxPoint &  aStart,
const wxPoint &  aControl1,
const wxPoint &  aControl2,
const wxPoint &  aEnd,
int  aTolerance,
int  aLineThickness = USE_DEFAULT_LINE_WIDTH 
)
virtualinherited

Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control points: start ctrl1 ctrl2 end.

Reimplemented in SVG_PLOTTER.

Definition at line 203 of file plotter.cpp.

206 {
207  // Generic fallback: Quadratic Bezier curve plotted as a polyline
208  int minSegLen = aLineThickness; // The segment min length to approximate a bezier curve
209 
210  std::vector<wxPoint> ctrlPoints;
211  ctrlPoints.push_back( aStart );
212  ctrlPoints.push_back( aControl1 );
213  ctrlPoints.push_back( aControl2 );
214  ctrlPoints.push_back( aEnd );
215 
216  BEZIER_POLY bezier_converter( ctrlPoints );
217 
218  std::vector<wxPoint> approxPoints;
219  bezier_converter.GetPoly( approxPoints, minSegLen );
220 
221  SetCurrentLineWidth( aLineThickness );
222  MoveTo( aStart );
223 
224  for( unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
225  LineTo( approxPoints[ii] );
226 
227  FinishTo( aEnd );
228 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void LineTo(const wxPoint &pos)
Definition: plotter.h:272
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.

References PLOTTER::FinishTo(), BEZIER_POLY::GetPoly(), PLOTTER::LineTo(), PLOTTER::MoveTo(), and PLOTTER::SetCurrentLineWidth().

Referenced by SVG_PLOTTER::BezierCurve(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), and BRDITEMS_PLOTTER::PlotPcbShape().

◆ Circle()

void GERBER_PLOTTER::Circle ( const wxPoint &  pos,
int  diametre,
FILL_TYPE  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Implements PLOTTER.

Definition at line 794 of file GERBER_plotter.cpp.

795 {
796  Arc( aCenter, 0, 3600, aDiameter / 2, aFill, aWidth );
797 }
virtual void Arc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.

References Arc().

Referenced by FilledCircle(), FlashPadCircle(), and ThickCircle().

◆ ClearAllAttributes()

void GERBER_PLOTTER::ClearAllAttributes ( )

Remove (clear) all attributes from object attributes dictionary (TO.

and TA commands) similar to clearNetAttribute(), this is an unconditional reset of TO. and TA. attributes

Definition at line 132 of file GERBER_plotter.cpp.

133 {
134  // Remove all attributes from object attributes dictionary (TO. and TA commands)
135  if( m_useX2format )
136  fputs( "%TD*%\n", m_outputFile );
137  else
138  fputs( "G04 #@! TD*\n", m_outputFile );
139 
141 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
std::string m_objectAttributesDictionnary

References m_objectAttributesDictionnary, PLOTTER::m_outputFile, and m_useX2format.

Referenced by PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ ClearHeaderLinesList()

void PLOTTER::ClearHeaderLinesList ( )
inlineinherited

Remove all lines from the list of free lines to print at the beginning of the file.

Definition at line 198 of file plotter.h.

199  {
200  m_headerExtraLines.Clear();
201  }
wxArrayString m_headerExtraLines
Definition: plotter.h:605

References PLOTTER::m_headerExtraLines.

Referenced by StartPlotBoard().

◆ clearNetAttribute()

void GERBER_PLOTTER::clearNetAttribute ( )
protected

clear a Gerber net attribute record (clear object attribute dictionary) and output the clear object attribute dictionary command to gerber file has effect only if a net attribute is stored in m_objectAttributesDictionnary

Definition at line 144 of file GERBER_plotter.cpp.

145 {
146  // disable a Gerber net attribute (exists only in X2 with net attributes mode).
147  if( m_objectAttributesDictionnary.empty() ) // No net attribute or not X2 mode
148  return;
149 
150  // Remove all net attributes from object attributes dictionary
151  if( m_useX2format )
152  fputs( "%TD*%\n", m_outputFile );
153  else
154  fputs( "G04 #@! TD*\n", m_outputFile );
155 
157 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
std::string m_objectAttributesDictionnary

References m_objectAttributesDictionnary, PLOTTER::m_outputFile, and m_useX2format.

Referenced by EndBlock(), and formatNetAttribute().

◆ DisableApertMacros()

void GERBER_PLOTTER::DisableApertMacros ( bool  aDisable)
inline

Disable Aperture Macro (AM) command, only for broken Gerber Readers Regions will be used instead of AM shapes to draw complex shapes.

Parameters
aDisable= true to disable Aperture Macro (AM) command.

Definition at line 194 of file plotter_gerber.h.

194 { m_gerberDisableApertMacros = aDisable; }
bool m_gerberDisableApertMacros

References m_gerberDisableApertMacros.

Referenced by StartPlotBoard().

◆ emitDcode()

void GERBER_PLOTTER::emitDcode ( const DPOINT pt,
int  dcode 
)
protected

Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (for n decimal positions, see header generation in start_plot.

Definition at line 126 of file GERBER_plotter.cpp.

127 {
128 
129  fprintf( m_outputFile, "X%dY%dD%02d*\n", KiROUND( pt.x ), KiROUND( pt.y ), dcode );
130 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References KiROUND(), PLOTTER::m_outputFile, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by FlashPadChamferRoundRect(), FlashPadCircle(), FlashPadCustom(), FlashPadOval(), FlashPadRect(), FlashPadRoundRect(), FlashPadTrapez(), FlashRegularPolygon(), and PenTo().

◆ EndBlock()

void GERBER_PLOTTER::EndBlock ( void *  aData)
overridevirtual

calling this function allows one to define the end of a group of drawing items the group is started by StartBlock() (used in X2 format with netlist attributes)

Parameters
aDatacan define any parameter

Reimplemented from PLOTTER.

Definition at line 167 of file GERBER_plotter.cpp.

168 {
169  // Remove all net attributes from object attributes dictionary
171 }
void clearNetAttribute()
clear a Gerber net attribute record (clear object attribute dictionary) and output the clear object a...

References clearNetAttribute().

Referenced by GERBER_WRITER::createDrillFile(), and StartBlock().

◆ EndPlot()

bool GERBER_PLOTTER::EndPlot ( )
overridevirtual

Implements PLOTTER.

Definition at line 284 of file GERBER_plotter.cpp.

285 {
286  char line[1024];
287  wxString msg;
288 
289  wxASSERT( m_outputFile );
290 
291  /* Outfile is actually a temporary file i.e. workFile */
292  fputs( "M02*\n", m_outputFile );
293  fflush( m_outputFile );
294 
295  fclose( workFile );
296  workFile = wxFopen( m_workFilename, wxT( "rt" ));
297  wxASSERT( workFile );
299 
300  // Placement of apertures in RS274X
301  while( fgets( line, 1024, workFile ) )
302  {
303  fputs( line, m_outputFile );
304 
305  char* substr = strtok( line, "\n\r" );
306 
307  if( substr && strcmp( substr, "G04 APERTURE LIST*" ) == 0 )
308  {
309  // Add aperture list macro:
313  {
314  fputs( "G04 Aperture macros list*\n", m_outputFile );
315 
318 
321 
324 
327 
329  {
334  }
335 
336  fputs( "G04 Aperture macros list end*\n", m_outputFile );
337  }
338 
340  fputs( "G04 APERTURE END LIST*\n", m_outputFile );
341  }
342  }
343 
344  fclose( workFile );
345  fclose( finalFile );
346  ::wxRemoveFile( m_workFilename );
347  m_outputFile = 0;
348 
349  return true;
350 }
#define APER_MACRO_ROT_RECT_HEADER
void writeApertureList()
Generate the table of D codes.
bool m_hasApertureChamferedRect
FILE * m_outputFile
Output file.
Definition: plotter.h:590
#define APER_MACRO_OUTLINE6P_HEADER
bool m_hasApertureOutline4P
bool m_hasApertureRoundRect
#define APER_MACRO_SHAPE_OVAL_HEADER
#define APER_MACRO_OUTLINE5P_HEADER
#define APER_MACRO_ROUNDRECT_HEADER
#define APER_MACRO_OUTLINE7P_HEADER
#define APER_MACRO_OUTLINE4P_HEADER
#define APER_MACRO_OUTLINE8P_HEADER
wxString m_workFilename

References APER_MACRO_OUTLINE4P_HEADER, APER_MACRO_OUTLINE5P_HEADER, APER_MACRO_OUTLINE6P_HEADER, APER_MACRO_OUTLINE7P_HEADER, APER_MACRO_OUTLINE8P_HEADER, APER_MACRO_ROT_RECT_HEADER, APER_MACRO_ROUNDRECT_HEADER, APER_MACRO_SHAPE_OVAL_HEADER, finalFile, m_hasApertureChamferedRect, m_hasApertureOutline4P, m_hasApertureRotOval, m_hasApertureRotRect, m_hasApertureRoundRect, PLOTTER::m_outputFile, m_workFilename, workFile, and writeApertureList().

Referenced by GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ FilledCircle()

void GERBER_PLOTTER::FilledCircle ( const wxPoint &  pos,
int  diametre,
OUTLINE_MODE  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 1023 of file GERBER_plotter.cpp.

1025 {
1026  // A filled circle is a graphic item, not a pad.
1027  // So it is drawn, not flashed.
1028  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
1029 
1030  if( gbr_metadata )
1031  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1032 
1033  if( tracemode == FILLED )
1034  {
1035  // Draw a circle of diameter = diametre/2 with a line thickness = radius,
1036  // To create a filled circle
1037  SetCurrentLineWidth( diametre/2, gbr_metadata );
1038  Circle( pos, diametre/2, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
1039  }
1040  else
1041  {
1043  Circle( pos, diametre, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
1044  }
1045 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:135

References Circle(), PLOTTER::DO_NOT_SET_LINE_WIDTH, FILLED, formatNetAttribute(), GBR_METADATA::m_NetlistMetadata, NO_FILL, SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

◆ FinishTo()

◆ FlashPadChamferRoundRect()

void GERBER_PLOTTER::FlashPadChamferRoundRect ( const wxPoint &  aShapePos,
const wxSize &  aPadSize,
int  aCornerRadius,
double  aChamferRatio,
int  aChamferPositions,
double  aPadOrient,
OUTLINE_MODE  aPlotMode,
void *  aData 
)

flash a chamfered round rect pad.

Parameters
aShapePos= position of the pad shape
aPadSize= size of the rectangle
aCornerRadius= radius of rounded corners
aChamferRatio= chamfer value (ratio < 0.5 between smallest size and chamfer)
aChamferPositions= identifier of the corners to chamfer: 0 = no chamfer 1 = TOP_LEFT 2 = TOP_RIGHT 4 = BOTTOM_LEFT 8 = BOTTOM_RIGHT
aPadOrient= rotation in 0.1 degrees of the shape
aPlotMode= FILLED or SKETCH
aData= a reference to Gerber attributes descr

Definition at line 1513 of file GERBER_plotter.cpp.

1518 {
1519  GBR_METADATA gbr_metadata;
1520 
1521  if( aData )
1522  gbr_metadata = *static_cast<GBR_METADATA*>( aData );
1523 
1524  DPOINT pos_dev = userToDeviceCoordinates( aShapePos );
1525 
1526  SHAPE_POLY_SET outline;
1527  // polygon corners list
1528  std::vector<wxPoint> cornerList;
1529 
1530  bool hasRoundedCorner = aCornerRadius != 0 && aChamferPositions != 15;
1531 
1532 #ifdef GBR_USE_MACROS_FOR_CHAMFERED_RECT
1533  // Sketch mode or round rect shape or Apert Macros disabled
1534  if( aPlotMode != FILLED || hasRoundedCorner || m_gerberDisableApertMacros )
1535 #endif
1536  {
1537  TransformRoundChamferedRectToPolygon( outline, aShapePos, aPadSize, aPadOrient,
1538  aCornerRadius, aChamferRatio, aChamferPositions,
1540 
1541  // Build the corner list
1542  const SHAPE_LINE_CHAIN& corners = outline.Outline(0);
1543 
1544  for( int ii = 0; ii < corners.PointCount(); ii++ )
1545  cornerList.emplace_back( corners.CPoint( ii ).x, corners.CPoint( ii ).y );
1546 
1547  // Close the polygon
1548  cornerList.push_back( cornerList[0] );
1549 
1550  if( aPlotMode == SKETCH )
1551  PlotPoly( cornerList, FILL_TYPE::NO_FILL, GetCurrentLineWidth(), &gbr_metadata );
1552  else
1553  {
1554 #ifdef GBR_USE_MACROS_FOR_CHAMFERED_ROUND_RECT
1556  PlotGerberRegion( cornerList, &gbr_metadata );
1557  else
1558  {
1559  // An AM will be created. the shape must be in position 0,0 and orientation 0
1560  // to be able to reuse the same AM for pads having the same shape
1561  for( size_t ii = 0; ii < cornerList.size(); ii++ )
1562  {
1563  cornerList[ii] -= aShapePos;
1564  RotatePoint( &cornerList[ii], -aPadOrient );
1565  }
1566 
1567  selectAperture( cornerList, aPadOrient/10.0,
1568  APERTURE::AM_FREE_POLYGON, gbr_metadata.GetApertureAttrib() );
1569  formatNetAttribute( &gbr_metadata.m_NetlistMetadata );
1570 
1571  emitDcode( pos_dev, 3 );
1572  }
1573 #else
1574  PlotGerberRegion( cornerList, &gbr_metadata );
1575 #endif
1576  }
1577 
1578  return;
1579  }
1580 
1581  // Build the chamfered polygon (4 to 8 corners )
1582  TransformRoundChamferedRectToPolygon( outline, wxPoint( 0, 0 ), aPadSize, 0.0, 0,
1583  aChamferRatio, aChamferPositions,
1585 
1586  // Build the corner list
1587  const SHAPE_LINE_CHAIN& corners = outline.Outline(0);
1588 
1589  // Generate the polygon (4 to 8 corners )
1590  for( int ii = 0; ii < corners.PointCount(); ii++ )
1591  cornerList.emplace_back( corners.CPoint( ii ).x, corners.CPoint( ii ).y );
1592 
1593  switch( cornerList.size() )
1594  {
1595  case 4:
1596  m_hasApertureOutline4P = true;
1597  selectAperture( cornerList, aPadOrient/10.0,
1599  break;
1600 
1601  case 5:
1603  selectAperture( cornerList, aPadOrient/10.0,
1605  break;
1606 
1607  case 6:
1609  selectAperture( cornerList, aPadOrient/10.0,
1611  break;
1612 
1613  case 7:
1615  selectAperture( cornerList, aPadOrient/10.0,
1617  break;
1618 
1619  case 8:
1621  selectAperture( cornerList, aPadOrient/10.0,
1623  break;
1624 
1625  default:
1626  wxLogMessage( "FlashPadChamferRoundRect(): Unexpected number of corners (%d)",
1627  (int)cornerList.size() );
1628  break;
1629  }
1630 
1631  formatNetAttribute( &gbr_metadata.m_NetlistMetadata );
1632 
1633  emitDcode( pos_dev, 3 );
1634 }
bool m_hasApertureChamferedRect
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError, ERROR_LOC aErrorLoc)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
int PointCount() const
Function PointCount()
bool m_hasApertureOutline4P
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
void PlotGerberRegion(const std::vector< wxPoint > &aCornerList, void *aData=NULL)
Plot a Gerber region: similar to PlotPoly but plot only filled polygon, and add the TA....
SHAPE_LINE_CHAIN.
int GetPlotterArcHighDef() const
Definition: plotter.h:233
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
bool m_gerberDisableApertMacros

References APERTURE::AM_FREE_POLYGON, APERTURE::APER_MACRO_OUTLINE4P, APERTURE::APER_MACRO_OUTLINE5P, APERTURE::APER_MACRO_OUTLINE6P, APERTURE::APER_MACRO_OUTLINE7P, APERTURE::APER_MACRO_OUTLINE8P, SHAPE_LINE_CHAIN::CPoint(), emitDcode(), ERROR_INSIDE, FILLED, formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), PLOTTER::GetCurrentLineWidth(), PLOTTER::GetPlotterArcHighDef(), m_gerberDisableApertMacros, m_hasApertureChamferedRect, m_hasApertureOutline4P, GBR_METADATA::m_NetlistMetadata, NO_FILL, SHAPE_POLY_SET::Outline(), PlotGerberRegion(), PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), selectAperture(), SKETCH, TransformRoundChamferedRectToPolygon(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadCircle()

void GERBER_PLOTTER::FlashPadCircle ( const wxPoint &  pos,
int  diametre,
OUTLINE_MODE  trace_mode,
void *  aData 
)
overridevirtual

Filled circular flashes are stored as apertures.

Implements PLOTTER.

Definition at line 1048 of file GERBER_plotter.cpp.

1049 {
1050  wxSize size( diametre, diametre );
1051  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1052 
1053  if( trace_mode == SKETCH )
1054  {
1055  if( gbr_metadata )
1056  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1057 
1059 
1061  }
1062  else
1063  {
1064  DPOINT pos_dev = userToDeviceCoordinates( pos );
1065 
1066  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1067  selectAperture( size, 0, 0.0, APERTURE::AT_CIRCLE, aperture_attrib );
1068 
1069  if( gbr_metadata )
1070  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1071 
1072  emitDcode( pos_dev, 3 );
1073  }
1074 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
int m_currentPenWidth
Definition: plotter.h:595
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:135

References APERTURE::AT_CIRCLE, Circle(), PLOTTER::DO_NOT_SET_LINE_WIDTH, emitDcode(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), PLOTTER::m_currentPenWidth, GBR_METADATA::m_NetlistMetadata, NO_FILL, selectAperture(), SetCurrentLineWidth(), SKETCH, PLOTTER::USE_DEFAULT_LINE_WIDTH, and PLOTTER::userToDeviceCoordinates().

Referenced by GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ FlashPadCustom()

void GERBER_PLOTTER::FlashPadCustom ( const wxPoint &  aPadPos,
const wxSize &  aSize,
double  aPadOrient,
SHAPE_POLY_SET aPolygons,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
Parameters
aPadPosPosition of the shape
aSize= size of round reference pad
aPadOrient= pad rotation, used only with aperture macros (Gerber plotter)
aPolygonsthe shape as polygon set
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 1447 of file GERBER_plotter.cpp.

1451 {
1452  // A Pad custom is plotted as polygon (a region in Gerber language).
1453  GBR_METADATA gbr_metadata;
1454 
1455  if( aData )
1456  gbr_metadata = *static_cast<GBR_METADATA*>( aData );
1457 
1458  SHAPE_POLY_SET polyshape = *aPolygons;
1459 
1460  if( aTraceMode != FILLED )
1461  {
1462  SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
1463  polyshape.Inflate( -GetCurrentLineWidth()/2, 16 );
1464  }
1465 
1466  std::vector< wxPoint > cornerList;
1467 
1468  for( int cnt = 0; cnt < polyshape.OutlineCount(); ++cnt )
1469  {
1470  SHAPE_LINE_CHAIN& poly = polyshape.Outline( cnt );
1471 
1472  cornerList.clear();
1473 
1474  for( int ii = 0; ii < poly.PointCount(); ++ii )
1475  cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
1476 
1477  // Close polygon
1478  cornerList.push_back( cornerList[0] );
1479 
1480  if( aTraceMode == SKETCH )
1481  PlotPoly( cornerList, FILL_TYPE::NO_FILL, GetCurrentLineWidth(), &gbr_metadata );
1482  else
1483  {
1484 #ifdef GBR_USE_MACROS_FOR_CUSTOM_PAD
1486  || cornerList.size() > GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT )
1487  PlotGerberRegion( cornerList, &gbr_metadata );
1488  else
1489  {
1490  // An AM will be created. the shape must be in position 0,0 and orientation 0
1491  // to be able to reuse the same AM for pads having the same shape
1492  for( size_t ii = 0; ii < cornerList.size(); ii++ )
1493  {
1494  cornerList[ii] -= aPadPos;
1495  RotatePoint( &cornerList[ii], -aOrient );
1496  }
1497 
1498  DPOINT pos_dev = userToDeviceCoordinates( aPadPos );
1499  selectAperture( cornerList, aOrient/10.0,
1500  APERTURE::AM_FREE_POLYGON, gbr_metadata.GetApertureAttrib() );
1501  formatNetAttribute( &gbr_metadata.m_NetlistMetadata );
1502 
1503  emitDcode( pos_dev, 3 );
1504  }
1505 #else
1506  PlotGerberRegion( cornerList, &gbr_metadata );
1507 #endif
1508  }
1509  }
1510 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
void Inflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int PointCount() const
Function PointCount()
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
void PlotGerberRegion(const std::vector< wxPoint > &aCornerList, void *aData=NULL)
Plot a Gerber region: similar to PlotPoly but plot only filled polygon, and add the TA....
SHAPE_LINE_CHAIN.
#define GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
bool m_gerberDisableApertMacros

References APERTURE::AM_FREE_POLYGON, SHAPE_LINE_CHAIN::CPoint(), emitDcode(), FILLED, formatNetAttribute(), GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT, GBR_METADATA::GetApertureAttrib(), PLOTTER::GetCurrentLineWidth(), SHAPE_POLY_SET::Inflate(), m_gerberDisableApertMacros, GBR_METADATA::m_NetlistMetadata, NO_FILL, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PlotGerberRegion(), PlotPoly(), SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), selectAperture(), SetCurrentLineWidth(), SKETCH, PLOTTER::USE_DEFAULT_LINE_WIDTH, PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FlashPadOval()

void GERBER_PLOTTER::FlashPadOval ( const wxPoint &  aPadPos,
const wxSize &  aSize,
double  aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
Parameters
aPadPosPosition of the shape (center of the rectangle
aSize= size of oblong shape
aPadOrientThe rotation of the shape
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 1077 of file GERBER_plotter.cpp.

1079 {
1080  wxASSERT( m_outputFile );
1081  wxSize size( aSize );
1082  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1083 
1084  // Flash a vertical or horizontal shape (this is a basic aperture).
1085  if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
1086  && trace_mode == FILLED )
1087  {
1088  if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
1089  std::swap( size.x, size.y );
1090 
1091  DPOINT pos_dev = userToDeviceCoordinates( pos );
1092  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1093  selectAperture( size, 0, 0.0, APERTURE::AT_OVAL, aperture_attrib );
1094 
1095  if( gbr_metadata )
1096  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1097 
1098  emitDcode( pos_dev, 3 );
1099  }
1100  else // Plot pad as region.
1101  // Only regions and flashed items accept a object attribute TO.P for the pin name
1102  {
1103  if( trace_mode == FILLED )
1104  {
1105  #ifdef GBR_USE_MACROS_FOR_ROTATED_OVAL
1107  #endif
1108  {
1109  m_hasApertureRotOval = true;
1110  // We are using a aperture macro that expect size.y < size.x
1111  // i.e draw a horizontal line for rotation = 0.0
1112  // size.x = length, size.y = width
1113  if( size.x < size.y )
1114  {
1115  std::swap( size.x, size.y );
1116  orient += 900;
1117 
1118  if( orient > 1800 )
1119  orient -= 1800;
1120  }
1121 
1122  DPOINT pos_dev = userToDeviceCoordinates( pos );
1123  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1124  selectAperture( size, 0, orient/10.0, APERTURE::AM_ROTATED_OVAL, aperture_attrib );
1125 
1126  if( gbr_metadata )
1127  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1128 
1129  emitDcode( pos_dev, 3 );
1130  return;
1131  }
1132  // Draw the oval as round rect pad with a radius = 50% min size)
1133  // In gerber file, it will be drawn as a region with arcs, and can be
1134  // detected as pads (similar to a flashed pad)
1135  FlashPadRoundRect( pos, aSize, std::min( aSize.x, aSize.y ) /2,
1136  orient, FILLED, aData );
1137  }
1138  else // Non filled shape: plot outlines:
1139  {
1140  if( size.x > size.y )
1141  {
1142  std::swap( size.x, size.y );
1143 
1144  if( orient < 2700 )
1145  orient += 900;
1146  else
1147  orient -= 2700;
1148  }
1149 
1150  sketchOval( pos, size, orient, -1 );
1151  }
1152  }
1153 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
FILE * m_outputFile
Output file.
Definition: plotter.h:590
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
bool m_gerberDisableApertMacros
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
Definition: plotter.cpp:458

References APERTURE::AM_ROTATED_OVAL, APERTURE::AT_OVAL, emitDcode(), FILLED, FlashPadRoundRect(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), m_gerberDisableApertMacros, m_hasApertureRotOval, GBR_METADATA::m_NetlistMetadata, PLOTTER::m_outputFile, selectAperture(), PLOTTER::sketchOval(), and PLOTTER::userToDeviceCoordinates().

Referenced by GERBER_WRITER::createDrillFile().

◆ FlashPadRect()

void GERBER_PLOTTER::FlashPadRect ( const wxPoint &  aPadPos,
const wxSize &  aSize,
double  aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
Parameters
aPadPosPosition of the shape (center of the rectangle
aSize= size of rounded rect
aPadOrientThe rotation of the shape
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 1156 of file GERBER_plotter.cpp.

1159 {
1160  wxASSERT( m_outputFile );
1161  wxSize size( aSize );
1162  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1163 
1164  // Plot as an aperture flash
1165  switch( int( orient ) )
1166  {
1167  case 900:
1168  case 2700: // rotation of 90 degrees or 270 swaps sizes
1169  std::swap( size.x, size.y );
1171 
1172  case 0:
1173  case 1800:
1174  if( trace_mode == SKETCH )
1175  {
1176  if( gbr_metadata )
1177  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1178 
1180  Rect( wxPoint( pos.x - (size.x - GetCurrentLineWidth()) / 2,
1181  pos.y - (size.y - GetCurrentLineWidth()) / 2 ),
1182  wxPoint( pos.x + (size.x - GetCurrentLineWidth()) / 2,
1183  pos.y + (size.y - GetCurrentLineWidth()) / 2 ),
1185  }
1186  else
1187  {
1188  DPOINT pos_dev = userToDeviceCoordinates( pos );
1189  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1190  selectAperture( size, 0, 0.0, APERTURE::AT_RECT, aperture_attrib );
1191 
1192  if( gbr_metadata )
1193  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1194 
1195  emitDcode( pos_dev, 3 );
1196  }
1197  break;
1198 
1199  default:
1200  #ifdef GBR_USE_MACROS_FOR_ROTATED_RECT
1201  if( trace_mode != SKETCH && !m_gerberDisableApertMacros )
1202  {
1203  m_hasApertureRotRect = true;
1204  DPOINT pos_dev = userToDeviceCoordinates( pos );
1205  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1206  selectAperture( size, 0, orient/10.0, APERTURE::AM_ROT_RECT, aperture_attrib );
1207 
1208  if( gbr_metadata )
1209  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1210 
1211  emitDcode( pos_dev, 3 );
1212 
1213  break;
1214  }
1215  #endif
1216  {
1217  // plot pad shape as Gerber region
1218  wxPoint coord[4];
1219  // coord[0] is assumed the lower left
1220  // coord[1] is assumed the upper left
1221  // coord[2] is assumed the upper right
1222  // coord[3] is assumed the lower right
1223 
1224  coord[0].x = -size.x/2; // lower left
1225  coord[0].y = size.y/2;
1226  coord[1].x = -size.x/2; // upper left
1227  coord[1].y = -size.y/2;
1228  coord[2].x = size.x/2; // upper right
1229  coord[2].y = -size.y/2;
1230  coord[3].x = size.x/2; // lower right
1231  coord[3].y = size.y/2;
1232 
1233  FlashPadTrapez( pos, coord, orient, trace_mode, aData );
1234  }
1235  break;
1236  }
1237 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a trapezoidal pad.
FILE * m_outputFile
Output file.
Definition: plotter.h:590
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
bool m_gerberDisableApertMacros

References APERTURE::AM_ROT_RECT, APERTURE::AT_RECT, emitDcode(), FlashPadTrapez(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), PLOTTER::GetCurrentLineWidth(), KI_FALLTHROUGH, m_gerberDisableApertMacros, m_hasApertureRotRect, GBR_METADATA::m_NetlistMetadata, PLOTTER::m_outputFile, NO_FILL, Rect(), selectAperture(), SetCurrentLineWidth(), SKETCH, PLOTTER::USE_DEFAULT_LINE_WIDTH, and PLOTTER::userToDeviceCoordinates().

◆ FlashPadRoundRect()

void GERBER_PLOTTER::FlashPadRoundRect ( const wxPoint &  aPadPos,
const wxSize &  aSize,
int  aCornerRadius,
double  aOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual
Parameters
aPadPosPosition of the shape (center of the rectangle
aSize= size of rounded rect
aCornerRadiusRadius of the rounded corners
aOrientThe rotation of the shape
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 1239 of file GERBER_plotter.cpp.

1243 {
1244  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1245 
1246  if( aTraceMode != FILLED )
1247  {
1248  SHAPE_POLY_SET outline;
1249  TransformRoundChamferedRectToPolygon( outline, aPadPos, aSize, aOrient,
1250  aCornerRadius, 0.0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
1251 
1252  SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
1253  outline.Inflate( -GetCurrentLineWidth()/2, 16 );
1254 
1255  std::vector< wxPoint > cornerList;
1256  // TransformRoundRectToPolygon creates only one convex polygon
1257  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
1258  cornerList.reserve( poly.PointCount() + 1 );
1259 
1260  for( int ii = 0; ii < poly.PointCount(); ++ii )
1261  cornerList.emplace_back( poly.CPoint( ii ).x, poly.CPoint( ii ).y );
1262 
1263  // Close polygon
1264  cornerList.push_back( cornerList[0] );
1265 
1266  // plot outlines
1267  PlotPoly( cornerList, FILL_TYPE::NO_FILL, GetCurrentLineWidth(), gbr_metadata );
1268  }
1269  else
1270  {
1271  #ifdef GBR_USE_MACROS_FOR_ROUNDRECT
1273  #endif
1274  {
1275  m_hasApertureRoundRect = true;
1276 
1277  DPOINT pos_dev = userToDeviceCoordinates( aPadPos );
1278  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1279  selectAperture( aSize, aCornerRadius, aOrient/10.0,
1280  APERTURE::AM_ROUND_RECT, aperture_attrib );
1281 
1282  if( gbr_metadata )
1283  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1284 
1285  emitDcode( pos_dev, 3 );
1286  return;
1287  }
1288  // A Pad RoundRect is plotted as a Gerber region.
1289  // Initialize region metadata:
1290  bool clearTA_AperFunction = false; // true if a TA.AperFunction is used
1291 
1292  if( gbr_metadata )
1293  {
1294  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1295  std::string attrib = gbr_metadata->m_ApertureMetadata.FormatAttribute( !m_useX2format );
1296 
1297  if( !attrib.empty() )
1298  {
1299  fputs( attrib.c_str(), m_outputFile );
1300  clearTA_AperFunction = true;
1301  }
1302  }
1303 
1304  // Plot the region using arcs in corners.
1305  plotRoundRectAsRegion( aPadPos, aSize, aCornerRadius, aOrient );
1306 
1307  // Clear the TA attribute, to avoid the next item to inherit it:
1308  if( clearTA_AperFunction )
1309  {
1310  if( m_useX2format )
1311  fputs( "%TD.AperFunction*%\n", m_outputFile );
1312  else
1313  fputs( "G04 #@! TD.AperFunction*\n", m_outputFile );
1314  }
1315  }
1316 }
void plotRoundRectAsRegion(const wxPoint &aRectCenter, const wxSize &aSize, int aCornerRadius, double aOrient)
Plot a round rect (a round rect shape in fact) as a Gerber region using lines and arcs for corners.
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError, ERROR_LOC aErrorLoc)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
void Inflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int PointCount() const
Function PointCount()
bool m_hasApertureRoundRect
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
SHAPE_LINE_CHAIN.
int GetPlotterArcHighDef() const
Definition: plotter.h:233
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
bool m_gerberDisableApertMacros
GBR_APERTURE_METADATA m_ApertureMetadata
An item to handle aperture attribute.
Definition: gbr_metadata.h:257

References APERTURE::AM_ROUND_RECT, SHAPE_LINE_CHAIN::CPoint(), emitDcode(), ERROR_INSIDE, FILLED, GBR_APERTURE_METADATA::FormatAttribute(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), PLOTTER::GetCurrentLineWidth(), PLOTTER::GetPlotterArcHighDef(), SHAPE_POLY_SET::Inflate(), GBR_METADATA::m_ApertureMetadata, m_gerberDisableApertMacros, m_hasApertureRoundRect, GBR_METADATA::m_NetlistMetadata, PLOTTER::m_outputFile, m_useX2format, NO_FILL, SHAPE_POLY_SET::Outline(), PlotPoly(), plotRoundRectAsRegion(), SHAPE_LINE_CHAIN::PointCount(), selectAperture(), SetCurrentLineWidth(), TransformRoundChamferedRectToPolygon(), PLOTTER::USE_DEFAULT_LINE_WIDTH, PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by FlashPadOval().

◆ FlashPadTrapez()

void GERBER_PLOTTER::FlashPadTrapez ( const wxPoint &  aPadPos,
const wxPoint *  aCorners,
double  aPadOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual

Flash a trapezoidal pad.

Parameters
aPadPos= the position of the shape
aCorners= the list of 4 corners positions, relative to the shape position, pad orientation 0
aPadOrient= the rotation of the shape
aTraceMode= FILLED or SKETCH
aDataan auxiliary info (mainly for gerber format attributes)

Implements PLOTTER.

Definition at line 1637 of file GERBER_plotter.cpp.

1640 {
1641  // polygon corners list
1642  std::vector<wxPoint> cornerList = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
1643 
1644  // Draw the polygon and fill the interior as required
1645  for( unsigned ii = 0; ii < 4; ii++ )
1646  {
1647  RotatePoint( &cornerList[ii], aPadOrient );
1648  cornerList[ii] += aPadPos;
1649  }
1650 
1651  // Close the polygon
1652  cornerList.push_back( cornerList[0] );
1653  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1654 
1655  GBR_METADATA metadata;
1656 
1657  if( gbr_metadata )
1658  metadata = *gbr_metadata;
1659 
1660  if( aTrace_Mode == SKETCH )
1661  {
1662  PlotPoly( cornerList, FILL_TYPE::NO_FILL, GetCurrentLineWidth(), &metadata );
1663  return;
1664  }
1665 
1666  // Plot a filled polygon:
1667  #ifdef GBR_USE_MACROS_FOR_TRAPEZOID
1669  #endif
1670  {
1671  m_hasApertureOutline4P = true;
1672  DPOINT pos_dev = userToDeviceCoordinates( aPadPos );
1673  // polygon corners list
1674  std::vector<wxPoint> corners = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
1675  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1676  selectAperture( corners, aPadOrient/10.0, APERTURE::APER_MACRO_OUTLINE4P, aperture_attrib );
1677 
1678  if( gbr_metadata )
1679  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1680 
1681  emitDcode( pos_dev, 3 );
1682  return;
1683  }
1684 
1685  PlotGerberRegion( cornerList, &metadata );
1686 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
bool m_hasApertureOutline4P
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
void PlotGerberRegion(const std::vector< wxPoint > &aCornerList, void *aData=NULL)
Plot a Gerber region: similar to PlotPoly but plot only filled polygon, and add the TA....
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
bool m_gerberDisableApertMacros

References APERTURE::APER_MACRO_OUTLINE4P, emitDcode(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), PLOTTER::GetCurrentLineWidth(), m_gerberDisableApertMacros, m_hasApertureOutline4P, GBR_METADATA::m_NetlistMetadata, NO_FILL, PlotGerberRegion(), PlotPoly(), RotatePoint(), selectAperture(), SKETCH, and PLOTTER::userToDeviceCoordinates().

Referenced by FlashPadRect().

◆ FlashRegularPolygon()

void GERBER_PLOTTER::FlashRegularPolygon ( const wxPoint &  aShapePos,
int  aDiameter,
int  aCornerCount,
double  aOrient,
OUTLINE_MODE  aTraceMode,
void *  aData 
)
overridevirtual

Flash a regular polygon.

Useful only in Gerber files to flash a regular polygon

Parameters
aShapePosis the center of the circle containing the polygon
aRadiusis the radius of the circle containing the polygon
aCornerCountis the number of vertices
aOrientis the polygon rotation in degrees
aDatais a auxiliary parameter used (if needed) to handle extra info specific to the plotter

Implements PLOTTER.

Definition at line 1689 of file GERBER_plotter.cpp.

1693 {
1694  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1695 
1696  GBR_METADATA metadata;
1697 
1698  if( gbr_metadata )
1699  metadata = *gbr_metadata;
1700 
1701  if( aTraceMode == SKETCH )
1702  {
1703  // Build the polygon:
1704  std::vector< wxPoint > cornerList;
1705 
1706  double angle_delta = 3600.0 / aCornerCount; // in 0.1 degree
1707 
1708  for( int ii = 0; ii < aCornerCount; ii++ )
1709  {
1710  double rot = aOrient + (angle_delta*ii);
1711  wxPoint vertice( aDiameter/2, 0 );
1712  RotatePoint( &vertice, rot );
1713  vertice += aShapePos;
1714  cornerList.push_back( vertice );
1715  }
1716 
1717  cornerList.push_back( cornerList[0] ); // Close the shape
1718 
1719  PlotPoly( cornerList, FILL_TYPE::NO_FILL, GetCurrentLineWidth(), &gbr_metadata );
1720  }
1721  else
1722  {
1723  DPOINT pos_dev = userToDeviceCoordinates( aShapePos );
1724 
1725  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
1726 
1727  APERTURE::APERTURE_TYPE apert_type =
1729  selectAperture( aDiameter, aOrient, apert_type, aperture_attrib );
1730 
1731  if( gbr_metadata )
1732  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1733 
1734  emitDcode( pos_dev, 3 );
1735  }
1736 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262

References APERTURE::AT_REGULAR_POLY3, emitDcode(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), PLOTTER::GetCurrentLineWidth(), GBR_METADATA::m_NetlistMetadata, NO_FILL, PlotPoly(), RotatePoint(), selectAperture(), SKETCH, and PLOTTER::userToDeviceCoordinates().

Referenced by PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ formatNetAttribute()

void GERBER_PLOTTER::formatNetAttribute ( GBR_NETLIST_METADATA aData)
protected

print a Gerber net attribute object record.

In a gerber file, a net attribute is owned by a graphic object formatNetAttribute must be called before creating the object

Parameters
aDatacontains the dato to format. the generated string depends on the type of netlist info

Definition at line 174 of file GERBER_plotter.cpp.

175 {
176  // print a Gerber net attribute record.
177  // it is added to the object attributes dictionary
178  // On file, only modified or new attributes are printed.
179  if( aData == NULL )
180  return;
181 
182  if( !m_useNetAttributes )
183  return;
184 
185  bool useX1StructuredComment = !m_useX2format;
186 
187  bool clearDict;
188  std::string short_attribute_string;
189 
190  if( !FormatNetAttribute( short_attribute_string, m_objectAttributesDictionnary,
191  aData, clearDict, useX1StructuredComment ) )
192  return;
193 
194  if( clearDict )
196 
197  if( !short_attribute_string.empty() )
198  fputs( short_attribute_string.c_str(), m_outputFile );
199 
200  if( m_useX2format && !aData->m_ExtraData.IsEmpty() )
201  {
202  std::string extra_data = TO_UTF8( aData->m_ExtraData );
203  fputs( extra_data.c_str(), m_outputFile );
204  }
205 }
void clearNetAttribute()
clear a Gerber net attribute record (clear object attribute dictionary) and output the clear object a...
FILE * m_outputFile
Output file.
Definition: plotter.h:590
bool FormatNetAttribute(std::string &aPrintedText, std::string &aLastNetAttributes, const GBR_NETLIST_METADATA *aData, bool &aClearPreviousAttributes, bool aUseX1StructuredComment)
Generate the string to set a net attribute for a graphic object to print to a gerber file.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxString m_ExtraData
a string to print after TO object attributes, if not empty it is printed "as this"
#define NULL
std::string m_objectAttributesDictionnary

References clearNetAttribute(), FormatNetAttribute(), GBR_NETLIST_METADATA::m_ExtraData, m_objectAttributesDictionnary, PLOTTER::m_outputFile, m_useNetAttributes, m_useX2format, NULL, and TO_UTF8.

Referenced by FilledCircle(), FlashPadChamferRoundRect(), FlashPadCircle(), FlashPadCustom(), FlashPadOval(), FlashPadRect(), FlashPadRoundRect(), FlashPadTrapez(), FlashRegularPolygon(), PlotPoly(), Text(), ThickArc(), ThickCircle(), ThickRect(), and ThickSegment().

◆ GetColorMode()

◆ GetCurrentLineWidth()

◆ GetDashGapLenIU()

double PLOTTER::GetDashGapLenIU ( ) const
protectedinherited

Definition at line 151 of file plotter.cpp.

152 {
154 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)
Definition: plotter.cpp:124
#define DASH_GAP_LEN(aLineWidth)

References DASH_GAP_LEN, PLOTTER::GetCurrentLineWidth(), and PLOTTER::userToDeviceSize().

Referenced by PS_PLOTTER::SetDash(), PDF_PLOTTER::SetDash(), and SVG_PLOTTER::setSVGPlotStyle().

◆ GetDashMarkLenIU()

double PLOTTER::GetDashMarkLenIU ( ) const
protectedinherited

Definition at line 145 of file plotter.cpp.

146 {
148 }
#define DASH_MARK_LEN(aLineWidth)
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)
Definition: plotter.cpp:124

References DASH_MARK_LEN, PLOTTER::GetCurrentLineWidth(), and PLOTTER::userToDeviceSize().

Referenced by PS_PLOTTER::SetDash(), PDF_PLOTTER::SetDash(), and SVG_PLOTTER::setSVGPlotStyle().

◆ GetDefaultFileExtension()

static wxString GERBER_PLOTTER::GetDefaultFileExtension ( )
inlinestatic

Definition at line 47 of file plotter_gerber.h.

48  {
49  return wxString( wxT( "gbr" ) );
50  }

Referenced by GetDefaultPlotExtension().

◆ GetDotMarkLenIU()

double PLOTTER::GetDotMarkLenIU ( ) const
protectedinherited

Definition at line 139 of file plotter.cpp.

140 {
142 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
#define DOT_MARK_LEN(aLineWidth)
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)
Definition: plotter.cpp:124

References DOT_MARK_LEN, PLOTTER::GetCurrentLineWidth(), and PLOTTER::userToDeviceSize().

Referenced by PS_PLOTTER::SetDash(), PDF_PLOTTER::SetDash(), and SVG_PLOTTER::setSVGPlotStyle().

◆ GetIUsPerDecimil()

double PLOTTER::GetIUsPerDecimil ( ) const
inlineinherited

The IUs per decimil are an essential scaling factor when plotting; they are set and saved when establishing the viewport.

Here they can be get back again

Definition at line 230 of file plotter.h.

230 { return m_IUsPerDecimil; }
double m_IUsPerDecimil
Definition: plotter.h:579

References PLOTTER::m_IUsPerDecimil.

Referenced by PlotWorkSheet().

◆ GetOrCreateAperture() [1/2]

int GERBER_PLOTTER::GetOrCreateAperture ( const wxSize &  aSize,
int  aRadius,
double  aRotDegree,
APERTURE::APERTURE_TYPE  aType,
int  aApertureAttribute 
)
Returns
a index to the aperture in aperture list which meets the size and type of tool if the aperture does not exist, it is created and entered in aperture list
Parameters
aSize= the size of tool
aRadius= the radius used for some shapes tool (oval, roundrect macros)
aRotDegree= the rotation of tool (primitives round, oval rect accept only 0.0)
aType= the type ( shape ) of tool
aApertureAttribute= an aperture attribute of the tool (a tool can have onlu one attribute) 0 = no specific attribute

Definition at line 370 of file GERBER_plotter.cpp.

372 {
373  int last_D_code = 9;
374 
375  // Search an existing aperture
376  for( int idx = 0; idx < (int)m_apertures.size(); ++idx )
377  {
378  APERTURE* tool = &m_apertures[idx];
379  last_D_code = tool->m_DCode;
380 
381  if( (tool->m_Type == aType) && (tool->m_Size == aSize) &&
382  (tool->m_Radius == aRadius) && (tool->m_Rotation == aRotDegree) &&
383  (tool->m_ApertureAttribute == aApertureAttribute) )
384  return idx;
385  }
386 
387  // Allocate a new aperture
388  APERTURE new_tool;
389  new_tool.m_Size = aSize;
390  new_tool.m_Type = aType;
391  new_tool.m_Radius = aRadius;
392  new_tool.m_Rotation = aRotDegree;
393  new_tool.m_DCode = last_D_code + 1;
394  new_tool.m_ApertureAttribute = aApertureAttribute;
395 
396  m_apertures.push_back( new_tool );
397 
398  return m_apertures.size() - 1;
399 }
APERTURE_TYPE m_Type
std::vector< APERTURE > m_apertures

References APERTURE::m_ApertureAttribute, m_apertures, APERTURE::m_DCode, APERTURE::m_Radius, APERTURE::m_Rotation, APERTURE::m_Size, and APERTURE::m_Type.

Referenced by selectAperture().

◆ GetOrCreateAperture() [2/2]

int GERBER_PLOTTER::GetOrCreateAperture ( const std::vector< wxPoint > &  aCorners,
double  aRotDegree,
APERTURE::APERTURE_TYPE  aType,
int  aApertureAttribute 
)
Returns
a index to the aperture in aperture list which meets the data and type of tool if the aperture does not exist, it is created and entered in aperture list
Parameters
aCorners= the corner list
aRotDegree= the rotation of tool
aType= the type ( shape ) of tool that can manage a list of corners (polygon)
aApertureAttribute= an aperture attribute of the tool (a tool can have onlu one attribute) 0 = no specific attribute

Definition at line 402 of file GERBER_plotter.cpp.

404 {
405  int last_D_code = 9;
406 
407  // Search an existing aperture
408  for( int idx = 0; idx < (int)m_apertures.size(); ++idx )
409  {
410  APERTURE* tool = &m_apertures[idx];
411 
412  last_D_code = tool->m_DCode;
413 
414  if( (tool->m_Type == aType) &&
415  (tool->m_Corners.size() == aCorners.size() ) &&
416  (tool->m_Rotation == aRotDegree) &&
417  (tool->m_ApertureAttribute == aApertureAttribute) )
418  {
419  // A candidate is found. the corner lists must be the same
420  bool is_same = true;
421 
422  for( size_t ii = 0; ii < aCorners.size(); ii++ )
423  {
424  if( aCorners[ii] != tool->m_Corners[ii] )
425  {
426  is_same = false;
427  break;
428  }
429  }
430 
431  if( is_same )
432  return idx;
433  }
434  }
435 
436  // Allocate a new aperture
437  APERTURE new_tool;
438 
439  new_tool.m_Corners = aCorners;
440  new_tool.m_Size = wxSize( 0, 0 ); // Not used
441  new_tool.m_Type = aType;
442  new_tool.m_Radius = 0; // Not used
443  new_tool.m_Rotation = aRotDegree;
444  new_tool.m_DCode = last_D_code + 1;
445  new_tool.m_ApertureAttribute = aApertureAttribute;
446 
447  m_apertures.push_back( new_tool );
448 
449  return m_apertures.size() - 1;
450 }
APERTURE_TYPE m_Type
std::vector< APERTURE > m_apertures
std::vector< wxPoint > m_Corners

References APERTURE::m_ApertureAttribute, m_apertures, APERTURE::m_Corners, APERTURE::m_DCode, APERTURE::m_Radius, APERTURE::m_Rotation, APERTURE::m_Size, and APERTURE::m_Type.

◆ GetPlotterArcHighDef()

int PLOTTER::GetPlotterArcHighDef ( ) const
inlineinherited

◆ GetPlotterArcLowDef()

int PLOTTER::GetPlotterArcLowDef ( ) const
inlineinherited

Definition at line 232 of file plotter.h.

232 { return m_IUsPerDecimil * 8; }
double m_IUsPerDecimil
Definition: plotter.h:579

References PLOTTER::m_IUsPerDecimil.

◆ GetPlotterType()

virtual PLOT_FORMAT GERBER_PLOTTER::GetPlotterType ( ) const
inlineoverridevirtual

Returns the effective plot engine in use.

It's not very OO but for now is required since some things are only done with some output devices (like drill marks, emitted only for postscript

Implements PLOTTER.

Definition at line 42 of file plotter_gerber.h.

43  {
44  return PLOT_FORMAT::GERBER;
45  }

References GERBER.

◆ LineTo()

void PLOTTER::LineTo ( const wxPoint &  pos)
inlineinherited

Definition at line 272 of file plotter.h.

273  {
274  PenTo( pos, 'D' );
275  }
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction

References PLOTTER::PenTo().

Referenced by PLOTTER::Arc(), PLOTTER::BezierCurve(), DXF_PLOTTER::FlashPadCustom(), DXF_PLOTTER::FlashPadRect(), DXF_PLOTTER::FlashPadRoundRect(), DXF_PLOTTER::FlashPadTrapez(), SCH_SHEET::Plot(), plotArc(), DXF_PLOTTER::PlotPoly(), HPGL_PLOTTER::PlotPoly(), PlotPoly(), plotRoundRectAsRegion(), LIB_PIN::PlotSymbol(), and DXF_PLOTTER::Rect().

◆ Marker()

void PLOTTER::Marker ( const wxPoint &  position,
int  diametre,
unsigned  aShapeId 
)
inherited

Draw a pattern shape number aShapeId, to coord position.

Diameter diameter = (coord table) hole AShapeId = index (used to generate forms characters)

Definition at line 331 of file plotter.cpp.

332 {
333  int radius = diametre / 2;
334  /* Marker are composed by a series of 'parts' superimposed; not every
335  combination make sense, obviously. Since they are used in order I
336  tried to keep the uglier/more complex constructions at the end.
337  Also I avoided the |/ |\ -/ -\ construction because they're *very*
338  ugly... if needed they could be added anyway... I'd like to see
339  a board with more than 58 drilling/slotting tools!
340  If Visual C++ supported the 0b literals they would be optimally
341  and easily encoded as an integer array. We have to do with octal */
342  static const unsigned char marker_patterns[MARKER_COUNT] = {
343  // Bit order: O Square Lozenge - | \ /
344  // First choice: simple shapes
345  0003, // X
346  0100, // O
347  0014, // +
348  0040, // Sq
349  0020, // Lz
350  // Two simple shapes
351  0103, // X O
352  0017, // X +
353  0043, // X Sq
354  0023, // X Lz
355  0114, // O +
356  0140, // O Sq
357  0120, // O Lz
358  0054, // + Sq
359  0034, // + Lz
360  0060, // Sq Lz
361  // Three simple shapes
362  0117, // X O +
363  0143, // X O Sq
364  0123, // X O Lz
365  0057, // X + Sq
366  0037, // X + Lz
367  0063, // X Sq Lz
368  0154, // O + Sq
369  0134, // O + Lz
370  0074, // + Sq Lz
371  // Four simple shapes
372  0174, // O Sq Lz +
373  0163, // X O Sq Lz
374  0157, // X O Sq +
375  0137, // X O Lz +
376  0077, // X Sq Lz +
377  // This draws *everything *
378  0177, // X O Sq Lz +
379  // Here we use the single bars... so the cross is forbidden
380  0110, // O -
381  0104, // O |
382  0101, // O /
383  0050, // Sq -
384  0044, // Sq |
385  0041, // Sq /
386  0030, // Lz -
387  0024, // Lz |
388  0021, // Lz /
389  0150, // O Sq -
390  0144, // O Sq |
391  0141, // O Sq /
392  0130, // O Lz -
393  0124, // O Lz |
394  0121, // O Lz /
395  0070, // Sq Lz -
396  0064, // Sq Lz |
397  0061, // Sq Lz /
398  0170, // O Sq Lz -
399  0164, // O Sq Lz |
400  0161, // O Sq Lz /
401  // Last resort: the backlash component (easy to confound)
402  0102, // \ O
403  0042, // \ Sq
404  0022, // \ Lz
405  0142, // \ O Sq
406  0122, // \ O Lz
407  0062, // \ Sq Lz
408  0162 // \ O Sq Lz
409  };
410  if( aShapeId >= MARKER_COUNT )
411  {
412  // Fallback shape
413  markerCircle( position, radius );
414  }
415  else
416  {
417  // Decode the pattern and draw the corresponding parts
418  unsigned char pat = marker_patterns[aShapeId];
419  if( pat & 0001 )
420  markerSlash( position, radius );
421  if( pat & 0002 )
422  markerBackSlash( position, radius );
423  if( pat & 0004 )
424  markerVBar( position, radius );
425  if( pat & 0010 )
426  markerHBar( position, radius );
427  if( pat & 0020 )
428  markerLozenge( position, radius );
429  if( pat & 0040 )
430  markerSquare( position, radius );
431  if( pat & 0100 )
432  markerCircle( position, radius );
433  }
434 }
void markerHBar(const wxPoint &pos, int radius)
Plot a - bar centered on the position.
Definition: plotter.cpp:303
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map)
Definition: plotter.h:437
void markerSlash(const wxPoint &pos, int radius)
Plot a / bar centered on the position.
Definition: plotter.cpp:310
void markerLozenge(const wxPoint &position, int radius)
Plot a lozenge centered on the position.
Definition: plotter.cpp:279
void markerCircle(const wxPoint &pos, int radius)
Plot a circle centered on the position.
Definition: plotter.cpp:273
void markerVBar(const wxPoint &pos, int radius)
Plot a | bar centered on the position.
Definition: plotter.cpp:324
void markerSquare(const wxPoint &position, int radius)
Plot a square centered on the position.
Definition: plotter.cpp:248
void markerBackSlash(const wxPoint &pos, int radius)
Plot a \ bar centered on the position.
Definition: plotter.cpp:317

References PLOTTER::MARKER_COUNT, PLOTTER::markerBackSlash(), PLOTTER::markerCircle(), PLOTTER::markerHBar(), PLOTTER::markerLozenge(), PLOTTER::markerSlash(), PLOTTER::markerSquare(), and PLOTTER::markerVBar().

Referenced by GENDRILL_WRITER_BASE::genDrillMapFile(), and GENDRILL_WRITER_BASE::plotDrillMarks().

◆ markerBackSlash()

void PLOTTER::markerBackSlash ( const wxPoint &  pos,
int  radius 
)
protectedinherited

Plot a \ bar centered on the position.

Building block for markers

Definition at line 317 of file plotter.cpp.

318 {
319  MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
320  FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
321 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ markerCircle()

void PLOTTER::markerCircle ( const wxPoint &  pos,
int  radius 
)
protectedinherited

Plot a circle centered on the position.

Building block for markers

Definition at line 273 of file plotter.cpp.

274 {
275  Circle( position, radius * 2, FILL_TYPE::NO_FILL, GetCurrentLineWidth() );
276 }
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0

References PLOTTER::Circle(), PLOTTER::GetCurrentLineWidth(), and NO_FILL.

Referenced by PLOTTER::Marker().

◆ markerHBar()

void PLOTTER::markerHBar ( const wxPoint &  pos,
int  radius 
)
protectedinherited

Plot a - bar centered on the position.

Building block for markers

Definition at line 303 of file plotter.cpp.

304 {
305  MoveTo( wxPoint( pos.x - radius, pos.y ) );
306  FinishTo( wxPoint( pos.x + radius, pos.y ) );
307 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ markerLozenge()

void PLOTTER::markerLozenge ( const wxPoint &  position,
int  radius 
)
protectedinherited

Plot a lozenge centered on the position.

Building block for markers

Definition at line 279 of file plotter.cpp.

280 {
281  std::vector< wxPoint > corner_list;
282  wxPoint corner;
283  corner.x = position.x;
284  corner.y = position.y + radius;
285  corner_list.push_back( corner );
286  corner.x = position.x + radius;
287  corner.y = position.y,
288  corner_list.push_back( corner );
289  corner.x = position.x;
290  corner.y = position.y - radius;
291  corner_list.push_back( corner );
292  corner.x = position.x - radius;
293  corner.y = position.y;
294  corner_list.push_back( corner );
295  corner.x = position.x;
296  corner.y = position.y + radius;
297  corner_list.push_back( corner );
298 
300 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Draw a polygon ( filled or not )
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176

References PLOTTER::GetCurrentLineWidth(), NO_FILL, and PLOTTER::PlotPoly().

Referenced by PLOTTER::Marker().

◆ markerSlash()

void PLOTTER::markerSlash ( const wxPoint &  pos,
int  radius 
)
protectedinherited

Plot a / bar centered on the position.

Building block for markers

Definition at line 310 of file plotter.cpp.

311 {
312  MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
313  FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
314 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ markerSquare()

void PLOTTER::markerSquare ( const wxPoint &  position,
int  radius 
)
protectedinherited

Plot a square centered on the position.

Building block for markers

Definition at line 248 of file plotter.cpp.

249 {
250  double r = KiROUND( radius / 1.4142 );
251  std::vector< wxPoint > corner_list;
252  wxPoint corner;
253  corner.x = position.x + r;
254  corner.y = position.y + r;
255  corner_list.push_back( corner );
256  corner.x = position.x + r;
257  corner.y = position.y - r;
258  corner_list.push_back( corner );
259  corner.x = position.x - r;
260  corner.y = position.y - r;
261  corner_list.push_back( corner );
262  corner.x = position.x - r;
263  corner.y = position.y + r;
264  corner_list.push_back( corner );
265  corner.x = position.x + r;
266  corner.y = position.y + r;
267  corner_list.push_back( corner );
268 
270 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Draw a polygon ( filled or not )
virtual int GetCurrentLineWidth() const
Definition: plotter.h:176
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References PLOTTER::GetCurrentLineWidth(), KiROUND(), NO_FILL, and PLOTTER::PlotPoly().

Referenced by PLOTTER::Marker().

◆ markerVBar()

void PLOTTER::markerVBar ( const wxPoint &  pos,
int  radius 
)
protectedinherited

Plot a | bar centered on the position.

Building block for markers

Definition at line 324 of file plotter.cpp.

325 {
326  MoveTo( wxPoint( pos.x, pos.y - radius ) );
327  FinishTo( wxPoint( pos.x, pos.y + radius ) );
328 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267

References PLOTTER::FinishTo(), and PLOTTER::MoveTo().

Referenced by PLOTTER::Marker().

◆ MoveTo()

◆ OpenFile()

bool PLOTTER::OpenFile ( const wxString &  aFullFilename)
virtualinherited

Open or create the plot file aFullFilename.

Parameters
aFullFilename= the full file name of the file to create
Returns
true if success, false if the file cannot be created/opened

Virtual because some plotters use ascii files, some others binary files (PDF) The base class open the file in text mode

Reimplemented in PDF_PLOTTER.

Definition at line 76 of file plotter.cpp.

77 {
78  m_filename = aFullFilename;
79 
80  wxASSERT( !m_outputFile );
81 
82  // Open the file in text mode (not suitable for all plotters
83  // but only for most of them
84  m_outputFile = wxFopen( m_filename, wxT( "wt" ) );
85 
86  if( m_outputFile == NULL )
87  return false ;
88 
89  return true;
90 }
wxString m_filename
Definition: plotter.h:600
FILE * m_outputFile
Output file.
Definition: plotter.h:590
#define NULL

References PLOTTER::m_filename, PLOTTER::m_outputFile, and NULL.

Referenced by GERBER_WRITER::createDrillFile(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), GENDRILL_WRITER_BASE::genDrillMapFile(), DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL(), DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG(), StartPlotBoard(), and SYMBOL_EDIT_FRAME::SVGPlotSymbol().

◆ PageSettings()

PAGE_INFO& PLOTTER::PageSettings ( )
inlineinherited

◆ PenFinish()

void PLOTTER::PenFinish ( )
inlineinherited

Definition at line 283 of file plotter.h.

284  {
285  // The point is not important with Z motion
286  PenTo( wxPoint( 0, 0 ), 'Z' );
287  }
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction

References PLOTTER::PenTo().

Referenced by HPGL_PLOTTER::Circle(), HPGL_PLOTTER::FlashPadCircle(), DXF_PLOTTER::PlotPoly(), HPGL_PLOTTER::PlotPoly(), PlotPoly(), and HPGL_PLOTTER::Rect().

◆ PenTo()

void GERBER_PLOTTER::PenTo ( const wxPoint &  pos,
char  plume 
)
overridevirtual

moveto/lineto primitive, moves the 'pen' to the specified direction

Parameters
posis the target position
plumespecifies the kind of motion: 'U' only moves the pen, 'D' draw a line from the current position and 'Z' finish the drawing and returns the 'pen' to rest (flushes the trace)

Implements PLOTTER.

Definition at line 754 of file GERBER_plotter.cpp.

755 {
756  wxASSERT( m_outputFile );
757  DPOINT pos_dev = userToDeviceCoordinates( aPos );
758 
759  switch( plume )
760  {
761  case 'Z':
762  break;
763 
764  case 'U':
765  emitDcode( pos_dev, 2 );
766  break;
767 
768  case 'D':
769  emitDcode( pos_dev, 1 );
770  }
771 
772  m_penState = plume;
773 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void emitDcode(const DPOINT &pt, int dcode)
Emit a D-Code record, using proper conversions to format a leading zero omitted gerber coordinate (fo...
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
char m_penState
Definition: plotter.h:596

References emitDcode(), PLOTTER::m_outputFile, PLOTTER::m_penState, and PLOTTER::userToDeviceCoordinates().

◆ plotArc()

void GERBER_PLOTTER::plotArc ( const wxPoint &  aCenter,
double  aStAngle,
double  aEndAngle,
int  aRadius,
bool  aPlotInRegion 
)
protected

Plot a Gerber arc.

if aPlotInRegion = true, the current pen position will not be initialized to the arc start position, and therefore the arc can be used to define a region outline item a line will be created from current ^position to arc start point if aPlotInRegion = false, the current pen position will be initialized to the arc start position, to plot an usual arc item The line thickness is not initialized in plotArc, and must be initialized before calling it if needed.

Definition at line 810 of file GERBER_plotter.cpp.

812 {
813  wxPoint start, end;
814  start.x = aCenter.x + KiROUND( cosdecideg( aRadius, aStAngle ) );
815  start.y = aCenter.y - KiROUND( sindecideg( aRadius, aStAngle ) );
816 
817  if( !aPlotInRegion )
818  MoveTo( start );
819  else
820  LineTo( start );
821 
822  end.x = aCenter.x + KiROUND( cosdecideg( aRadius, aEndAngle ) );
823  end.y = aCenter.y - KiROUND( sindecideg( aRadius, aEndAngle ) );
824  DPOINT devEnd = userToDeviceCoordinates( end );
825  DPOINT devCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start );
826 
827  fprintf( m_outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode
828 
829  if( aStAngle < aEndAngle )
830  fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW
831  else
832  fprintf( m_outputFile, "G02*\n" ); // Active circular interpolation, CW
833 
834  fprintf( m_outputFile, "X%dY%dI%dJ%dD01*\n",
835  KiROUND( devEnd.x ), KiROUND( devEnd.y ),
836  KiROUND( devCenter.x ), KiROUND( devCenter.y ) );
837 
838  fprintf( m_outputFile, "G01*\n" ); // Back to linear interpol (perhaps useless here).
839 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void LineTo(const wxPoint &pos)
Definition: plotter.h:272
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
Definition: plotter.cpp:93
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:439
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:430
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References cosdecideg(), KiROUND(), PLOTTER::LineTo(), PLOTTER::m_outputFile, PLOTTER::MoveTo(), sindecideg(), PLOTTER::userToDeviceCoordinates(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Arc(), and plotRoundRectAsRegion().

◆ PlotGerberRegion()

void GERBER_PLOTTER::PlotGerberRegion ( const std::vector< wxPoint > &  aCornerList,
void *  aData = NULL 
)

Plot a Gerber region: similar to PlotPoly but plot only filled polygon, and add the TA.AperFunction if aData contains this attribute, and clear it after plotting.

Definition at line 842 of file GERBER_plotter.cpp.

844 {
845  if( aCornerList.size() <= 2 )
846  return;
847 
848  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
849 
850  bool clearTA_AperFunction = false; // true if a TA.AperFunction is used
851 
852  if( gbr_metadata )
853  {
854  std::string attrib = gbr_metadata->m_ApertureMetadata.FormatAttribute( !m_useX2format );
855 
856  if( !attrib.empty() )
857  {
858  fputs( attrib.c_str(), m_outputFile );
859  clearTA_AperFunction = true;
860  }
861  }
862 
863  PlotPoly( aCornerList, FILL_TYPE::FILLED_SHAPE, 0, gbr_metadata );
864 
865  // Clear the TA attribute, to avoid the next item to inherit it:
866  if( clearTA_AperFunction )
867  {
868  if( m_useX2format )
869  {
870  fputs( "%TD.AperFunction*%\n", m_outputFile );
871  }
872  else
873  {
874  fputs( "G04 #@! TD.AperFunction*\n", m_outputFile );
875  }
876  }
877 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
GBR_APERTURE_METADATA m_ApertureMetadata
An item to handle aperture attribute.
Definition: gbr_metadata.h:257

References FILLED_SHAPE, GBR_APERTURE_METADATA::FormatAttribute(), GBR_METADATA::m_ApertureMetadata, PLOTTER::m_outputFile, m_useX2format, and PlotPoly().

Referenced by FlashPadChamferRoundRect(), FlashPadCustom(), and FlashPadTrapez().

◆ PlotImage()

void PLOTTER::PlotImage ( const wxImage &  aImage,
const wxPoint &  aPos,
double  aScaleFactor 
)
virtualinherited

Only PostScript plotters can plot bitmaps.

A rectangle is plotted for plotters that cannot plot a bitmap.

Draw an image bitmap

Parameters
aImage= the bitmap
aPos= position of the center of the bitmap
aScaleFactor= the scale factor to apply to the bitmap size (this is not the plot scale factor)

Reimplemented in SVG_PLOTTER, PDF_PLOTTER, and PS_PLOTTER.

Definition at line 231 of file plotter.cpp.

232 {
233  wxSize size( aImage.GetWidth() * aScaleFactor,
234  aImage.GetHeight() * aScaleFactor );
235 
236  wxPoint start = aPos;
237  start.x -= size.x / 2;
238  start.y -= size.y / 2;
239 
240  wxPoint end = start;
241  end.x += size.x;
242  end.y += size.y;
243 
244  Rect( start, end, FILL_TYPE::NO_FILL );
245 }
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0

References NO_FILL, and PLOTTER::Rect().

Referenced by BITMAP_BASE::PlotImage(), and SVG_PLOTTER::PlotImage().

◆ PlotPoly() [1/2]

void GERBER_PLOTTER::PlotPoly ( const std::vector< wxPoint > &  aCornerList,
FILL_TYPE  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = nullptr 
)
overridevirtual

Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.

Implements PLOTTER.

Definition at line 879 of file GERBER_plotter.cpp.

881 {
882  if( aCornerList.size() <= 1 )
883  return;
884 
885  // Gerber format does not know filled polygons with thick outline
886  // Therefore, to plot a filled polygon with outline having a thickness,
887  // one should plot outline as thick segments
888  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
889 
890  if( gbr_metadata )
891  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
892 
893  if( aFill != FILL_TYPE::NO_FILL )
894  {
895  fputs( "G36*\n", m_outputFile );
896 
897  MoveTo( aCornerList[0] );
898  fputs( "G01*\n", m_outputFile ); // Set linear interpolation.
899 
900  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
901  LineTo( aCornerList[ii] );
902 
903  // If the polygon is not closed, close it:
904  if( aCornerList[0] != aCornerList[aCornerList.size()-1] )
905  FinishTo( aCornerList[0] );
906 
907  fputs( "G37*\n", m_outputFile );
908  }
909 
910  if( aWidth > 0 ) // Draw the polyline/polygon outline
911  {
912  SetCurrentLineWidth( aWidth, gbr_metadata );
913 
914  MoveTo( aCornerList[0] );
915 
916  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
917  LineTo( aCornerList[ii] );
918 
919  // Ensure the thick outline is closed for filled polygons
920  // (if not filled, could be only a polyline)
921  if( aFill != FILL_TYPE::NO_FILL &&( aCornerList[aCornerList.size() - 1] != aCornerList[0] ) )
922  LineTo( aCornerList[0] );
923 
924  PenFinish();
925  }
926 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void PenFinish()
Definition: plotter.h:283
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void LineTo(const wxPoint &pos)
Definition: plotter.h:272
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262

References PLOTTER::FinishTo(), formatNetAttribute(), PLOTTER::LineTo(), GBR_METADATA::m_NetlistMetadata, PLOTTER::m_outputFile, PLOTTER::MoveTo(), NO_FILL, PLOTTER::PenFinish(), and SetCurrentLineWidth().

Referenced by FlashPadChamferRoundRect(), FlashPadCustom(), FlashPadRoundRect(), FlashPadTrapez(), FlashRegularPolygon(), PlotGerberRegion(), and Rect().

◆ PlotPoly() [2/2]

void PLOTTER::PlotPoly ( const SHAPE_LINE_CHAIN aCornerList,
FILL_TYPE  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = NULL 
)
virtualinherited

Draw a polygon ( filled or not )

Parameters
aCornerList= corners list (a SHAPE_LINE_CHAIN). must be closed (IsClosed() == true) for a polygon. Otherwise this is a polyline
aFill= type of fill
aWidth= line width
aDataan auxiliary info (mainly for gerber format)

Definition at line 598 of file plotter.cpp.

600 {
601  std::vector<wxPoint> cornerList;
602  cornerList.reserve( aCornerList.PointCount() );
603 
604  for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
605  cornerList.emplace_back( aCornerList.CPoint( ii ) );
606 
607  if( aCornerList.IsClosed() && cornerList.front() != cornerList.back() )
608  cornerList.emplace_back( aCornerList.CPoint( 0 ) );
609 
610  PlotPoly( cornerList, aFill, aWidth, aData );
611 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Draw a polygon ( filled or not )
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
bool IsClosed() const override
Function IsClosed()

References SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::IsClosed(), PLOTTER::PlotPoly(), and SHAPE_LINE_CHAIN::PointCount().

◆ plotRoundRectAsRegion()

void GERBER_PLOTTER::plotRoundRectAsRegion ( const wxPoint &  aRectCenter,
const wxSize &  aSize,
int  aCornerRadius,
double  aOrient 
)
protected

Plot a round rect (a round rect shape in fact) as a Gerber region using lines and arcs for corners.

Parameters
aRectCenteris the center of the rectangle
aSizeis the size of the rectangle
aCornerRadiusis the radius of the corners
aOrientis the rotation of the rectangle Note: only the G36 ... G37 region is created.

Definition at line 1319 of file GERBER_plotter.cpp.

1321 {
1322  // The region outline is generated by 4 sides and 4 90 deg arcs
1323  // 1 --- 2
1324  // | c |
1325  // 4 --- 3
1326 
1327  // Note also in user coordinates the Y axis is from top to bottom
1328  // for historical reasons.
1329 
1330  // A helper structure to handle outlines coordinates (segments and arcs)
1331  // in user coordinates
1332  struct RR_EDGE
1333  {
1334  wxPoint m_start;
1335  wxPoint m_end;
1336  wxPoint m_center;
1337  // in decidegrees: angle start. angle end = m_arc_angle_start+arc_angle
1338  double m_arc_angle_start;
1339  };
1340 
1341  const double arc_angle = -900.0; // in decidegrees
1342  int hsizeX = aSize.x/2;
1343  int hsizeY = aSize.y/2;
1344 
1345  RR_EDGE curr_edge;
1346  std::vector<RR_EDGE> rr_outline;
1347 
1348  // Build outline coordinates, relative to rectangle center, rotation 0:
1349 
1350  // Top left corner 1 (and 4 to 1 left vertical side @ x=-hsizeX)
1351  curr_edge.m_start.x = -hsizeX;
1352  curr_edge.m_start.y = hsizeY - aCornerRadius;
1353  curr_edge.m_end.x = curr_edge.m_start.x;
1354  curr_edge.m_end.y = -hsizeY + aCornerRadius;
1355  curr_edge.m_center.x = -hsizeX + aCornerRadius;
1356  curr_edge.m_center.y = curr_edge.m_end.y;
1357  curr_edge.m_arc_angle_start = aOrient + 1800.0; // En decidegree
1358 
1359  rr_outline.push_back( curr_edge );
1360 
1361  // Top right corner 2 (and 1 to 2 top horizontal side @ y=-hsizeY)
1362  curr_edge.m_start.x = -hsizeX + aCornerRadius;
1363  curr_edge.m_start.y = -hsizeY;
1364  curr_edge.m_end.x = hsizeX - aCornerRadius;
1365  curr_edge.m_end.y = curr_edge.m_start.y;
1366  curr_edge.m_center.x = curr_edge.m_end.x;
1367  curr_edge.m_center.y = -hsizeY + aCornerRadius;
1368  curr_edge.m_arc_angle_start = aOrient + 900.0; // En decidegree
1369 
1370  rr_outline.push_back( curr_edge );
1371 
1372  // bottom right corner 3 (and 2 to 3 right vertical side @ x=hsizeX)
1373  curr_edge.m_start.x = hsizeX;
1374  curr_edge.m_start.y = -hsizeY + aCornerRadius;
1375  curr_edge.m_end.x = curr_edge.m_start.x;
1376  curr_edge.m_end.y = hsizeY - aCornerRadius;
1377  curr_edge.m_center.x = hsizeX - aCornerRadius;
1378  curr_edge.m_center.y = curr_edge.m_end.y;
1379  curr_edge.m_arc_angle_start = aOrient + 0.0; // En decidegree
1380 
1381  rr_outline.push_back( curr_edge );
1382 
1383  // bottom left corner 4 (and 3 to 4 bottom horizontal side @ y=hsizeY)
1384  curr_edge.m_start.x = hsizeX - aCornerRadius;
1385  curr_edge.m_start.y = hsizeY;
1386  curr_edge.m_end.x = -hsizeX + aCornerRadius;
1387  curr_edge.m_end.y = curr_edge.m_start.y;
1388  curr_edge.m_center.x = curr_edge.m_end.x;
1389  curr_edge.m_center.y = hsizeY - aCornerRadius;
1390  curr_edge.m_arc_angle_start = aOrient - 900.0; // En decidegree
1391 
1392  rr_outline.push_back( curr_edge );
1393 
1394  // Move relative coordinates to the actual location and rotation:
1395  wxPoint arc_last_center;
1396  int arc_last_angle = curr_edge.m_arc_angle_start+arc_angle;
1397 
1398  for( RR_EDGE& rr_edge: rr_outline )
1399  {
1400  RotatePoint( &rr_edge.m_start, aOrient );
1401  RotatePoint( &rr_edge.m_end, aOrient );
1402  RotatePoint( &rr_edge.m_center, aOrient );
1403  rr_edge.m_start += aRectCenter;
1404  rr_edge.m_end += aRectCenter;
1405  rr_edge.m_center += aRectCenter;
1406  arc_last_center = rr_edge.m_center;
1407  }
1408 
1409  // Ensure the region is a closed polygon, i.e. the end point of last segment
1410  // (end of arc) is the same as the first point. Rounding issues can create a
1411  // small difference, mainly for rotated pads.
1412  // calculate last point (end of last arc):
1413  wxPoint last_pt;
1414  last_pt.x = arc_last_center.x + KiROUND( cosdecideg( aCornerRadius, arc_last_angle ) );
1415  last_pt.y = arc_last_center.y - KiROUND( sindecideg( aCornerRadius, arc_last_angle ) );
1416 
1417  wxPoint first_pt = rr_outline[0].m_start;
1418 
1419 #if 0 // For test only:
1420  if( last_pt != first_pt )
1421  wxLogMessage( "first pt %d %d last pt %d %d",
1422  first_pt.x, first_pt.y, last_pt.x, last_pt.y );
1423 #endif
1424 
1425  fputs( "G36*\n", m_outputFile ); // Start region
1426  fputs( "G01*\n", m_outputFile ); // Set linear interpolation.
1427  first_pt = last_pt;
1428  MoveTo( first_pt ); // Start point of region, must be same as end point
1429 
1430  for( RR_EDGE& rr_edge: rr_outline )
1431  {
1432  if( aCornerRadius ) // Guard: ensure we do not create arcs with radius = 0
1433  {
1434  // LineTo( rr_edge.m_end ); // made in plotArc()
1435  plotArc( rr_edge.m_center,
1436  rr_edge.m_arc_angle_start, rr_edge.m_arc_angle_start+arc_angle,
1437  aCornerRadius, true );
1438  }
1439  else
1440  LineTo( rr_edge.m_end );
1441  }
1442 
1443  fputs( "G37*\n", m_outputFile ); // Close region
1444 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
void plotArc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, bool aPlotInRegion)
Plot a Gerber arc.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
void LineTo(const wxPoint &pos)
Definition: plotter.h:272
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:439
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:430
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References cosdecideg(), KiROUND(), PLOTTER::LineTo(), PLOTTER::m_outputFile, PLOTTER::MoveTo(), plotArc(), RotatePoint(), and sindecideg().

Referenced by FlashPadRoundRect().

◆ Rect()

void GERBER_PLOTTER::Rect ( const wxPoint &  p1,
const wxPoint &  p2,
FILL_TYPE  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Implements PLOTTER.

Definition at line 776 of file GERBER_plotter.cpp.

777 {
778  std::vector< wxPoint > cornerList;
779 
780  // Build corners list
781  cornerList.push_back( p1 );
782  wxPoint corner(p1.x, p2.y);
783  cornerList.push_back( corner );
784  cornerList.push_back( p2 );
785  corner.x = p2.x;
786  corner.y = p1.y;
787  cornerList.push_back( corner );
788  cornerList.push_back( p1 );
789 
790  PlotPoly( cornerList, fill, width );
791 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.

References PlotPoly().

Referenced by FlashPadRect(), and ThickRect().

◆ RenderSettings()

◆ segmentAsOval()

void PLOTTER::segmentAsOval ( const wxPoint &  start,
const wxPoint &  end,
int  width,
OUTLINE_MODE  tracemode 
)
protectedinherited

Convert a thick segment and plot it as an oval.

Definition at line 437 of file plotter.cpp.

439 {
440  wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
441  wxSize size( end.x - start.x, end.y - start.y );
442  double orient;
443 
444  if( size.y == 0 )
445  orient = 0;
446  else if( size.x == 0 )
447  orient = 900;
448  else
449  orient = -ArcTangente( size.y, size.x );
450 
451  size.x = KiROUND( EuclideanNorm( size ) ) + width;
452  size.y = width;
453 
454  FlashPadOval( center, size, orient, tracemode, NULL );
455 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
#define NULL
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:182

References ArcTangente(), EuclideanNorm(), PLOTTER::FlashPadOval(), KiROUND(), and NULL.

Referenced by ThickSegment(), HPGL_PLOTTER::ThickSegment(), and PLOTTER::ThickSegment().

◆ selectAperture() [1/3]

void GERBER_PLOTTER::selectAperture ( const wxSize &  aSize,
int  aRadius,
double  aRotDegree,
APERTURE::APERTURE_TYPE  aType,
int  aApertureAttribute 
)
protected

Pick an existing aperture or create a new one, matching the size, type and attributes.

write the DCode selection on gerber file

Definition at line 453 of file GERBER_plotter.cpp.

456 {
457  bool change = ( m_currentApertureIdx < 0 ) ||
458  ( m_apertures[m_currentApertureIdx].m_Type != aType ) ||
459  ( m_apertures[m_currentApertureIdx].m_Size != aSize ) ||
460  ( m_apertures[m_currentApertureIdx].m_Radius != aRadius ) ||
461  ( m_apertures[m_currentApertureIdx].m_Rotation != aRotDegree );
462 
463  if( !change )
464  change = m_apertures[m_currentApertureIdx].m_ApertureAttribute != aApertureAttribute;
465 
466  if( change )
467  {
468  // Pick an existing aperture or create a new one
469  m_currentApertureIdx = GetOrCreateAperture( aSize, aRadius, aRotDegree,
470  aType, aApertureAttribute );
471  fprintf( m_outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode );
472  }
473 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
std::vector< APERTURE > m_apertures
int GetOrCreateAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)

References GetOrCreateAperture(), m_apertures, m_currentApertureIdx, and PLOTTER::m_outputFile.

Referenced by FlashPadChamferRoundRect(), FlashPadCircle(), FlashPadCustom(), FlashPadOval(), FlashPadRect(), FlashPadRoundRect(), FlashPadTrapez(), FlashRegularPolygon(), selectAperture(), and SetCurrentLineWidth().

◆ selectAperture() [2/3]

void GERBER_PLOTTER::selectAperture ( const std::vector< wxPoint > &  aCorners,
double  aPolygonRotation,
APERTURE::APERTURE_TYPE  aType,
int  aApertureAttribute 
)
protected

Pick an existing aperture or create a new one, matching the aDiameter, aPolygonRotation, type and attributes.

It apply only to apertures with type = AT_REGULAR_POLY3 to AT_REGULAR_POLY12 write the DCode selection on gerber file

Definition at line 476 of file GERBER_plotter.cpp.

478 {
479  bool change = ( m_currentApertureIdx < 0 ) ||
480  ( m_apertures[m_currentApertureIdx].m_Type != aType ) ||
481  ( m_apertures[m_currentApertureIdx].m_Corners.size() != aCorners.size() ) ||
482  ( m_apertures[m_currentApertureIdx].m_Rotation != aRotDegree );
483 
484  if( !change ) // Compare corner lists
485  {
486  for( size_t ii = 0; ii < aCorners.size(); ii++ )
487  {
488  if( aCorners[ii] != m_apertures[m_currentApertureIdx].m_Corners[ii] )
489  {
490  change = true;
491  break;
492  }
493  }
494  }
495 
496  if( !change )
497  change = m_apertures[m_currentApertureIdx].m_ApertureAttribute != aApertureAttribute;
498 
499  if( change )
500  {
501  // Pick an existing aperture or create a new one
502  m_currentApertureIdx = GetOrCreateAperture( aCorners, aRotDegree,
503  aType, aApertureAttribute );
504  fprintf( m_outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode );
505  }
506 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590
std::vector< APERTURE > m_apertures
int GetOrCreateAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)

References GetOrCreateAperture(), m_apertures, m_currentApertureIdx, and PLOTTER::m_outputFile.

◆ selectAperture() [3/3]

void GERBER_PLOTTER::selectAperture ( int  aDiameter,
double  aRotDegree,
APERTURE::APERTURE_TYPE  aType,
int  aApertureAttribute 
)
protected

Pick an existing aperture or create a new one, matching the corner list, aRotDegree, type and attributes.

It apply only to apertures managing a polygon that differs from AT_REGULAR_POLY3 to AT_REGULAR_POLY12 (for instance APER_MACRO_TRAPEZOID ) write the DCode selection on gerber file

Definition at line 509 of file GERBER_plotter.cpp.

511 {
512  // Pick an existing aperture or create a new one, matching the
513  // aDiameter, aPolygonRotation, type and attributes for type =
514  // AT_REGULAR_POLY3 to AT_REGULAR_POLY12
515 
516  wxASSERT( aType>= APERTURE::APERTURE_TYPE::AT_REGULAR_POLY3 &&
517  aType <= APERTURE::APERTURE_TYPE::AT_REGULAR_POLY12 );
518 
519  wxSize size( aDiameter, (int)( aPolygonRotation * 1000.0 ) );
520  selectAperture( wxSize( 0, 0), aDiameter/2, aPolygonRotation, aType, aApertureAttribute );
521 }
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.

References selectAperture().

◆ SetColor()

virtual void GERBER_PLOTTER::SetColor ( COLOR4D  color)
inlineoverridevirtual

Implements PLOTTER.

Definition at line 66 of file plotter_gerber.h.

66 {}

◆ SetColorMode()

virtual void PLOTTER::SetColorMode ( bool  aColorMode)
inlinevirtualinherited

◆ SetCreator()

◆ SetCurrentLineWidth()

void GERBER_PLOTTER::SetCurrentLineWidth ( int  width,
void *  aData = NULL 
)
overridevirtual

Set the line width for the next drawing.

Parameters
widthis specified in IUs
aDatais an auxiliary parameter, mainly used in gerber plotter

Implements PLOTTER.

Definition at line 353 of file GERBER_plotter.cpp.

354 {
355  if( aWidth == DO_NOT_SET_LINE_WIDTH )
356  return;
357  else if( aWidth == USE_DEFAULT_LINE_WIDTH )
359 
360  wxASSERT_MSG( aWidth >= 0, "Plotter called to set negative pen width" );
361 
362  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
363  int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
364 
365  selectAperture( wxSize( aWidth, aWidth ), 0, 0.0, APERTURE::AT_PLOTTING, aperture_attribute );
366  m_currentPenWidth = aWidth;
367 }
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
int m_currentPenWidth
Definition: plotter.h:595
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:214
RENDER_SETTINGS * m_renderSettings
Definition: plotter.h:607
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void selectAperture(const wxSize &aSize, int aRadius, double aRotDegree, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
int GetDefaultPenWidth() const
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:135

References APERTURE::AT_PLOTTING, PLOTTER::DO_NOT_SET_LINE_WIDTH, GBR_METADATA::GetApertureAttrib(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), PLOTTER::m_currentPenWidth, PLOTTER::m_renderSettings, selectAperture(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

Referenced by Arc(), FilledCircle(), FlashPadCircle(), FlashPadCustom(), FlashPadRect(), FlashPadRoundRect(), PlotPoly(), ThickArc(), ThickCircle(), ThickRect(), and ThickSegment().

◆ SetDash()

virtual void GERBER_PLOTTER::SetDash ( PLOT_DASH_TYPE  dashed)
inlineoverridevirtual

Implements PLOTTER.

Definition at line 62 of file plotter_gerber.h.

63  {
64  }

◆ SetGerberCoordinatesFormat()

void GERBER_PLOTTER::SetGerberCoordinatesFormat ( int  aResolution,
bool  aUseInches = false 
)
overridevirtual

Function SetGerberCoordinatesFormat selection of Gerber units and resolution (number of digits in mantissa)

Parameters
aResolution= number of digits in mantissa of coordinate use 5 or 6 for mm and 6 or 7 for inches do not use value > 6 (mm) or > 7 (in) to avoid overflow
aUseInches= true to use inches, false to use mm (default)

Should be called only after SetViewport() is called

Reimplemented from PLOTTER.

Definition at line 114 of file GERBER_plotter.cpp.

115 {
116  m_gerberUnitInch = aUseInches;
117  m_gerberUnitFmt = aResolution;
118 
119  m_iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );
120 
121  if( ! m_gerberUnitInch )
122  m_iuPerDeviceUnit *= 25.4; // gerber output in mm
123 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
double m_IUsPerDecimil
Definition: plotter.h:579

References m_gerberUnitFmt, m_gerberUnitInch, PLOTTER::m_iuPerDeviceUnit, and PLOTTER::m_IUsPerDecimil.

Referenced by GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ SetLayerPolarity()

void GERBER_PLOTTER::SetLayerPolarity ( bool  aPositive)
overridevirtual

Change the plot polarity and begin a new layer Used to 'scratch off' silk screen away from solder mask.

Reimplemented from PLOTTER.

Definition at line 1755 of file GERBER_plotter.cpp.

1756 {
1757  if( aPositive )
1758  fprintf( m_outputFile, "%%LPD*%%\n" );
1759  else
1760  fprintf( m_outputFile, "%%LPC*%%\n" );
1761 }
FILE * m_outputFile
Output file.
Definition: plotter.h:590

References PLOTTER::m_outputFile.

◆ SetNegative()

virtual void PLOTTER::SetNegative ( bool  aNegative)
inlinevirtualinherited

Definition at line 152 of file plotter.h.

153  {
154  m_negativeMode = aNegative;
155  }
bool m_negativeMode
Definition: plotter.h:594

References PLOTTER::m_negativeMode.

Referenced by FillNegativeKnockout().

◆ SetPageSettings()

◆ SetRenderSettings()

◆ SetSvgCoordinatesFormat()

virtual void PLOTTER::SetSvgCoordinatesFormat ( unsigned  aResolution,
bool  aUseInches = false 
)
inlinevirtualinherited

Reimplemented in SVG_PLOTTER.

Definition at line 473 of file plotter.h.

474  {
475  // NOP for most plotters. Only for SVG plotter
476  }

Referenced by initializePlotter().

◆ SetTextMode()

virtual void PLOTTER::SetTextMode ( PLOT_TEXT_MODE  mode)
inlinevirtualinherited

Change the current text mode.

See the PlotTextMode explanation at the beginning of the file

Reimplemented in DXF_PLOTTER, and PSLIKE_PLOTTER.

Definition at line 463 of file plotter.h.

464  {
465  // NOP for most plotters.
466  }

Referenced by initializePlotter(), and PlotOneBoardLayer().

◆ SetTitle()

virtual void PLOTTER::SetTitle ( const wxString &  aTitle)
inlinevirtualinherited

Definition at line 184 of file plotter.h.

184 { m_title = aTitle; }
wxString m_title
Definition: plotter.h:601

References PLOTTER::m_title.

Referenced by DIALOG_PLOT_SCHEMATIC::createPDFFile().

◆ SetViewport()

void GERBER_PLOTTER::SetViewport ( const wxPoint &  aOffset,
double  aIusPerDecimil,
double  aScale,
bool  aMirror 
)
overridevirtual

Set the plot offset and scaling for the current plot.

Parameters
aOffsetis the plot offset
aIusPerDecimilgives the scaling factor from IUs to device units
aScaleis the user set plot scaling factor (either explicitly or using 'fit to A4')
aMirrorflips the plot in the Y direction (useful for toner transfers or some kind of film)

Implements PLOTTER.

Definition at line 93 of file GERBER_plotter.cpp.

95 {
96  wxASSERT( aMirror == false );
97  m_plotMirror = false;
98  m_plotOffset = aOffset;
99  wxASSERT( aScale == 1 ); // aScale parameter is not used in Gerber
100  m_plotScale = 1; // Plot scale is *always* 1.0
101 
102  m_IUsPerDecimil = aIusPerDecimil;
103  // gives now a default value to iuPerDeviceUnit (because the units of the caller is now known)
104  // which could be modified later by calling SetGerberCoordinatesFormat()
105  m_iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );
106 
107  // We don't handle the filmbox, and it's more useful to keep the
108  // origin at the origin
109  m_paperSize.x = 0;
110  m_paperSize.y = 0;
111 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
double m_IUsPerDecimil
Definition: plotter.h:579
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573
bool m_plotMirror
Definition: plotter.h:584
wxPoint m_plotOffset
Definition: plotter.h:583
wxSize m_paperSize
Definition: plotter.h:603

References m_gerberUnitFmt, PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_IUsPerDecimil, PLOTTER::m_paperSize, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, and PLOTTER::m_plotScale.

Referenced by GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ sketchOval()

void PLOTTER::sketchOval ( const wxPoint &  pos,
const wxSize &  size,
double  orient,
int  width 
)
protectedinherited

Definition at line 458 of file plotter.cpp.

459 {
460  SetCurrentLineWidth( width );
461  width = m_currentPenWidth;
462  int radius, deltaxy, cx, cy;
463  wxSize size( aSize );
464 
465  if( size.x > size.y )
466  {
467  std::swap( size.x, size.y );
468  orient = AddAngles( orient, 900 );
469  }
470 
471  deltaxy = size.y - size.x; /* distance between centers of the oval */
472  radius = ( size.x - width ) / 2;
473  cx = -radius;
474  cy = -deltaxy / 2;
475  RotatePoint( &cx, &cy, orient );
476  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
477  cx = -radius;
478  cy = deltaxy / 2;
479  RotatePoint( &cx, &cy, orient );
480  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
481 
482  cx = radius;
483  cy = -deltaxy / 2;
484  RotatePoint( &cx, &cy, orient );
485  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
486  cx = radius;
487  cy = deltaxy / 2;
488  RotatePoint( &cx, &cy, orient );
489  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
490 
491  cx = 0;
492  cy = deltaxy / 2;
493  RotatePoint( &cx, &cy, orient );
494  Arc( wxPoint( cx + pos.x, cy + pos.y ),
495  orient + 1800, orient + 3600,
496  radius, FILL_TYPE::NO_FILL );
497  cx = 0;
498  cy = -deltaxy / 2;
499  RotatePoint( &cx, &cy, orient );
500  Arc( wxPoint( cx + pos.x, cy + pos.y ),
501  orient, orient + 1800,
502  radius, FILL_TYPE::NO_FILL );
503 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:157
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
int m_currentPenWidth
Definition: plotter.h:595
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:335
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.

References AddAngles(), PLOTTER::Arc(), PLOTTER::FinishTo(), PLOTTER::m_currentPenWidth, PLOTTER::MoveTo(), NO_FILL, RotatePoint(), and PLOTTER::SetCurrentLineWidth().

Referenced by PSLIKE_PLOTTER::FlashPadOval(), DXF_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadOval(), and FlashPadOval().

◆ StartBlock()

void GERBER_PLOTTER::StartBlock ( void *  aData)
overridevirtual

calling this function allows one to define the beginning of a group of drawing items (used in X2 format with netlist attributes)

Parameters
aDatacan define any parameter

Reimplemented from PLOTTER.

Definition at line 160 of file GERBER_plotter.cpp.

161 {
162  // Currently, it is the same as EndBlock(): clear all aperture net attributes
163  EndBlock( aData );
164 }
virtual void EndBlock(void *aData) override
calling this function allows one to define the end of a group of drawing items the group is started b...

References EndBlock().

◆ StartPlot()

bool GERBER_PLOTTER::StartPlot ( )
overridevirtual

Function StartPlot Write GERBER header to file initialize global variable g_Plot_PlotOutputFile.

Implements PLOTTER.

Definition at line 208 of file GERBER_plotter.cpp.

209 {
210  m_hasApertureRoundRect = false; // true is at least one round rect aperture is in use
211  m_hasApertureRotOval = false; // true is at least one oval rotated aperture is in use
212  m_hasApertureRotRect = false; // true is at least one rect. rotated aperture is in use
213  m_hasApertureOutline4P = false; // true is at least one rotated rect/trapezoid aperture is in use
214  m_hasApertureChamferedRect = false; // true is at least one chamfered rect is in use
215 
216  wxASSERT( m_outputFile );
217 
218  finalFile = m_outputFile; // the actual gerber file will be created later
219 
220  // Create a temp file in system temp to avoid potential network share buffer issues for the final read and save
221  m_workFilename = wxFileName::CreateTempFileName( "" );
222  workFile = wxFopen( m_workFilename, wxT( "wt" ));
224  wxASSERT( m_outputFile );
225 
226  if( m_outputFile == NULL )
227  return false;
228 
229  for( unsigned ii = 0; ii < m_headerExtraLines.GetCount(); ii++ )
230  {
231  if( ! m_headerExtraLines[ii].IsEmpty() )
232  fprintf( m_outputFile, "%s\n", TO_UTF8( m_headerExtraLines[ii] ) );
233  }
234 
235  // Set coordinate format to 3.6 or 4.5 absolute, leading zero omitted
236  // the number of digits for the integer part of coordinates is needed
237  // in gerber format, but is not very important when omitting leading zeros
238  // It is fixed here to 3 (inch) or 4 (mm), but is not actually used
239  int leadingDigitCount = m_gerberUnitInch ? 3 : 4;
240 
241  fprintf( m_outputFile, "%%FSLAX%d%dY%d%d*%%\n",
242  leadingDigitCount, m_gerberUnitFmt,
243  leadingDigitCount, m_gerberUnitFmt );
244  fprintf( m_outputFile,
245  "G04 Gerber Fmt %d.%d, Leading zero omitted, Abs format (unit %s)*\n",
246  leadingDigitCount, m_gerberUnitFmt,
247  m_gerberUnitInch ? "inch" : "mm" );
248 
249  wxString Title = m_creator + wxT( " " ) + GetBuildVersion();
250  // In gerber files, ASCII7 chars only are allowed.
251  // So use a ISO date format (using a space as separator between date and time),
252  // not a localized date format
253  wxDateTime date = wxDateTime::Now();
254  fprintf( m_outputFile, "G04 Created by KiCad (%s) date %s*\n",
255  TO_UTF8( Title ), TO_UTF8( date.FormatISOCombined( ' ') ) );
256 
257  /* Mass parameter: unit = INCHES/MM */
258  if( m_gerberUnitInch )
259  fputs( "%MOIN*%\n", m_outputFile );
260  else
261  fputs( "%MOMM*%\n", m_outputFile );
262 
263  // Be sure the usual dark polarity is selected:
264  fputs( "%LPD*%\n", m_outputFile );
265 
266  // Set initial interpolation mode: always G01 (linear):
267  fputs( "G01*\n", m_outputFile );
268 
269  // Add aperture list start point
270  fputs( "G04 APERTURE LIST*\n", m_outputFile );
271 
272  // Give a minimal value to the default pen size, used to plot items in sketch mode
273  if( m_renderSettings )
274  {
275  const int pen_min = 0.1 * m_IUsPerDecimil * 10000 / 25.4; // for min width = 0.1 mm
277  pen_min ) );
278  }
279 
280  return true;
281 }
bool m_hasApertureChamferedRect
FILE * m_outputFile
Output file.
Definition: plotter.h:590
double m_IUsPerDecimil
Definition: plotter.h:579
wxArrayString m_headerExtraLines
Definition: plotter.h:605
bool m_hasApertureOutline4P
bool m_hasApertureRoundRect
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
#define NULL
wxString GetBuildVersion()
Get the full KiCad version string.
RENDER_SETTINGS * m_renderSettings
Definition: plotter.h:607
int GetDefaultPenWidth() const
wxString m_workFilename
void SetDefaultPenWidth(int aWidth)
wxString m_creator
Definition: plotter.h:599

References finalFile, GetBuildVersion(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), PLOTTER::m_creator, m_gerberUnitFmt, m_gerberUnitInch, m_hasApertureChamferedRect, m_hasApertureOutline4P, m_hasApertureRotOval, m_hasApertureRotRect, m_hasApertureRoundRect, PLOTTER::m_headerExtraLines, PLOTTER::m_IUsPerDecimil, PLOTTER::m_outputFile, PLOTTER::m_renderSettings, m_workFilename, NULL, KIGFX::RENDER_SETTINGS::SetDefaultPenWidth(), TO_UTF8, and workFile.

Referenced by GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ Text()

void GERBER_PLOTTER::Text ( const wxPoint &  aPos,
const COLOR4D  aColor,
const wxString &  aText,
double  aOrient,
const wxSize &  aSize,
enum EDA_TEXT_HJUSTIFY_T  aH_justify,
enum EDA_TEXT_VJUSTIFY_T  aV_justify,
int  aPenWidth,
bool  aItalic,
bool  aBold,
bool  aMultilineAllowed = false,
void *  aData = NULL 
)
overridevirtual

Draws text with the plotter.

Function PLOTTER::Text same as GRText, but plot graphic text insteed of draw it.

For convenience it accept the color to use for specific plotters (GERBER) aData is used to pass extra parameters

Parameters
aPos= text position (according to aH_justify, aV_justify)
aColor(COLOR4D) = text color
aText= text to draw
aOrient= angle in 0.1 degree
aSize= text size (size.x or size.y can be < 0 for mirrored texts)
aH_justify= horizontal justification (Left, center, right)
aV_justify= vertical justification (bottom, center, top)
aPenWidth= line width (if = 0, use plot default line width)
aItalic= true to simulate an italic font
aBold= true to use a bold font Useful only with default width value (aWidth = 0)
aMultilineAllowed= true to plot text as multiline, otherwise single line
aData= a parameter used by some plotters in SetCurrentLineWidth(), not directly used here.

Reimplemented from PLOTTER.

Definition at line 1739 of file GERBER_plotter.cpp.

1744 {
1745  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
1746 
1747  if( gbr_metadata )
1748  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1749 
1750  PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
1751  aBold, aMultilineAllowed, aData );
1752 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: gr_text.cpp:219
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262

References formatNetAttribute(), GBR_METADATA::m_NetlistMetadata, and PLOTTER::Text().

◆ ThickArc()

void GERBER_PLOTTER::ThickArc ( const wxPoint &  centre,
double  StAngle,
double  EndAngle,
int  rayon,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 950 of file GERBER_plotter.cpp.

952 {
953  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
954  SetCurrentLineWidth( width, gbr_metadata );
955 
956  if( gbr_metadata )
957  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
958 
959  if( tracemode == FILLED )
960  Arc( centre, StAngle, EndAngle, radius, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
961  else
962  {
964  Arc( centre, StAngle, EndAngle,
965  radius - ( width - m_currentPenWidth ) / 2, FILL_TYPE::NO_FILL,
967  Arc( centre, StAngle, EndAngle, radius + ( width - m_currentPenWidth ) / 2, FILL_TYPE::NO_FILL,
969  }
970 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
int m_currentPenWidth
Definition: plotter.h:595
virtual void Arc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:135

References Arc(), PLOTTER::DO_NOT_SET_LINE_WIDTH, FILLED, formatNetAttribute(), PLOTTER::m_currentPenWidth, GBR_METADATA::m_NetlistMetadata, NO_FILL, SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

◆ ThickCircle()

void GERBER_PLOTTER::ThickCircle ( const wxPoint &  pos,
int  diametre,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 1001 of file GERBER_plotter.cpp.

1003 {
1004  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
1005  SetCurrentLineWidth( width, gbr_metadata );
1006 
1007  if( gbr_metadata )
1008  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
1009 
1010  if( tracemode == FILLED )
1011  Circle( pos, diametre, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
1012  else
1013  {
1015  Circle( pos, diametre - (width - m_currentPenWidth),
1017  Circle( pos, diametre + (width - m_currentPenWidth),
1019  }
1020 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
int m_currentPenWidth
Definition: plotter.h:595
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:135

References Circle(), PLOTTER::DO_NOT_SET_LINE_WIDTH, FILLED, formatNetAttribute(), PLOTTER::m_currentPenWidth, GBR_METADATA::m_NetlistMetadata, NO_FILL, SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

◆ ThickRect()

void GERBER_PLOTTER::ThickRect ( const wxPoint &  p1,
const wxPoint &  p2,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 973 of file GERBER_plotter.cpp.

975 {
976  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
977  SetCurrentLineWidth( width, gbr_metadata );
978 
979  if( gbr_metadata )
980  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
981 
982  if( tracemode == FILLED )
984  else
985  {
987  wxPoint offsetp1( p1.x - (width - m_currentPenWidth) / 2,
988  p1.y - (width - m_currentPenWidth) / 2 );
989  wxPoint offsetp2( p2.x + (width - m_currentPenWidth) / 2,
990  p2.y + (width - m_currentPenWidth) / 2 );
991  Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 );
992  offsetp1.x += (width - m_currentPenWidth);
993  offsetp1.y += (width - m_currentPenWidth);
994  offsetp2.x -= (width - m_currentPenWidth);
995  offsetp2.y -= (width - m_currentPenWidth);
996  Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
997  }
998 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
int m_currentPenWidth
Definition: plotter.h:595
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
static const int DO_NOT_SET_LINE_WIDTH
Definition: plotter.h:135

References PLOTTER::DO_NOT_SET_LINE_WIDTH, FILLED, formatNetAttribute(), PLOTTER::m_currentPenWidth, GBR_METADATA::m_NetlistMetadata, NO_FILL, Rect(), SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

◆ ThickSegment()

void GERBER_PLOTTER::ThickSegment ( const wxPoint &  start,
const wxPoint &  end,
int  width,
OUTLINE_MODE  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 929 of file GERBER_plotter.cpp.

931 {
932  if( tracemode == FILLED )
933  {
934  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
935  SetCurrentLineWidth( width, gbr_metadata );
936 
937  if( gbr_metadata )
938  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
939 
940  MoveTo( start );
941  FinishTo( end );
942  }
943  else
944  {
946  segmentAsOval( start, end, width, tracemode );
947  }
948 }
void segmentAsOval(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode)
Convert a thick segment and plot it as an oval.
Definition: plotter.cpp:437
void FinishTo(const wxPoint &pos)
Definition: plotter.h:277
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plotter.h:136
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:204
void MoveTo(const wxPoint &pos)
Definition: plotter.h:267
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262

References FILLED, PLOTTER::FinishTo(), formatNetAttribute(), GBR_METADATA::m_NetlistMetadata, PLOTTER::MoveTo(), PLOTTER::segmentAsOval(), SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

Referenced by GERBER_WRITER::createDrillFile().

◆ userToDeviceCoordinates()

DPOINT PLOTTER::userToDeviceCoordinates ( const wxPoint &  aCoordinate)
protectedvirtualinherited

Modifies coordinates according to the orientation, scale factor, and offsets trace.

Also convert from a wxPoint to DPOINT, since some output engines needs floating point coordinates.

Definition at line 93 of file plotter.cpp.

94 {
95  wxPoint pos = aCoordinate - m_plotOffset;
96 
97  // Don't allow overflows; they can cause rendering failures in some file viewers
98  // (such as Acrobat)
99  int clampSize = MAX_PAGE_SIZE_MILS * m_IUsPerDecimil * 10 / 2;
100  pos.x = std::max( -clampSize, std::min( pos.x, clampSize ) );
101  pos.y = std::max( -clampSize, std::min( pos.y, clampSize ) );
102 
103  double x = pos.x * m_plotScale;
104  double y = ( m_paperSize.y - pos.y * m_plotScale );
105 
106  if( m_plotMirror )
107  {
109  x = ( m_paperSize.x - pos.x * m_plotScale );
110  else
111  y = pos.y * m_plotScale;
112  }
113 
114  if( m_yaxisReversed )
115  y = m_paperSize.y - y;
116 
117  x *= m_iuPerDeviceUnit;
118  y *= m_iuPerDeviceUnit;
119 
120  return DPOINT( x, y );
121 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
double m_IUsPerDecimil
Definition: plotter.h:579
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573
bool m_yaxisReversed
Definition: plotter.h:587
bool m_plotMirror
Definition: plotter.h:584
wxPoint m_plotOffset
Definition: plotter.h:583
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41
VECTOR2< double > DPOINT
Definition: vector2d.h:628
wxSize m_paperSize
Definition: plotter.h:603
bool m_mirrorIsHorizontal
Definition: plotter.h:586

References PLOTTER::m_iuPerDeviceUnit, PLOTTER::m_IUsPerDecimil, PLOTTER::m_mirrorIsHorizontal, PLOTTER::m_paperSize, PLOTTER::m_plotMirror, PLOTTER::m_plotOffset, PLOTTER::m_plotScale, PLOTTER::m_yaxisReversed, and MAX_PAGE_SIZE_MILS.

Referenced by DXF_PLOTTER::Arc(), HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), PDF_PLOTTER::Arc(), SVG_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), DXF_PLOTTER::Circle(), HPGL_PLOTTER::Circle(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), PSLIKE_PLOTTER::computeTextParameters(), FlashPadChamferRoundRect(), HPGL_PLOTTER::FlashPadCircle(), FlashPadCircle(), FlashPadCustom(), FlashPadOval(), FlashPadRect(), FlashPadRoundRect(), FlashPadTrapez(), FlashRegularPolygon(), DXF_PLOTTER::PenTo(), PenTo(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), plotArc(), PS_PLOTTER::PlotImage(), PDF_PLOTTER::PlotImage(), HPGL_PLOTTER::PlotPoly(), PS_PLOTTER::PlotPoly(), PDF_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), PDF_PLOTTER::Rect(), SVG_PLOTTER::Rect(), DXF_PLOTTER::Text(), PS_PLOTTER::Text(), and SVG_PLOTTER::Text().

◆ userToDeviceSize() [1/2]

◆ userToDeviceSize() [2/2]

double PLOTTER::userToDeviceSize ( double  size) const
protectedvirtualinherited

Modifies size according to the plotter scale factors (simple double version)

Definition at line 131 of file plotter.cpp.

132 {
133  return size * m_plotScale * m_iuPerDeviceUnit;
134 }
double m_iuPerDeviceUnit
Definition: plotter.h:581
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573

References PLOTTER::m_iuPerDeviceUnit, and PLOTTER::m_plotScale.

◆ UseX2format()

void GERBER_PLOTTER::UseX2format ( bool  aEnable)
inline

◆ UseX2NetAttributes()

void GERBER_PLOTTER::UseX2NetAttributes ( bool  aEnable)
inline

◆ writeApertureList()

void GERBER_PLOTTER::writeApertureList ( )
protected

Generate the table of D codes.

Definition at line 523 of file GERBER_plotter.cpp.

524 {
525  wxASSERT( m_outputFile );
526  char cbuf[1024];
527  std::string buffer;
528 
529  bool useX1StructuredComment = false;
530 
531  if( !m_useX2format )
532  useX1StructuredComment = true;
533 
534  // Init
535  for( APERTURE& tool : m_apertures )
536  {
537  // apertude sizes are in inch or mm, regardless the
538  // coordinates format
539  double fscale = 0.0001 * m_plotScale / m_IUsPerDecimil; // inches
540 
541  if(! m_gerberUnitInch )
542  fscale *= 25.4; // size in mm
543 
544  int attribute = tool.m_ApertureAttribute;
545 
546  if( attribute != m_apertureAttribute )
547  {
550  useX1StructuredComment ).c_str(), m_outputFile );
551  }
552 
553  sprintf( cbuf, "%%ADD%d", tool.m_DCode );
554  buffer = cbuf;
555 
556  /* Please note: the Gerber specs for mass parameters say that
557  exponential syntax is *not* allowed and the decimal point should
558  also be always inserted. So the %g format is ruled out, but %f is fine
559  (the # modifier forces the decimal point). Sadly the %f formatter
560  can't remove trailing zeros but thats not a problem, since nothing
561  forbid it (the file is only slightly longer) */
562 
563  switch( tool.m_Type )
564  {
565  case APERTURE::AT_CIRCLE:
566  sprintf( cbuf, "C,%#f*%%\n", tool.GetDiameter() * fscale );
567  break;
568 
569  case APERTURE::AT_RECT:
570  sprintf( cbuf, "R,%#fX%#f*%%\n", tool.m_Size.x * fscale,
571  tool.m_Size.y * fscale );
572  break;
573 
575  sprintf( cbuf, "C,%#f*%%\n", tool.m_Size.x * fscale );
576  break;
577 
578  case APERTURE::AT_OVAL:
579  sprintf( cbuf, "O,%#fX%#f*%%\n", tool.m_Size.x * fscale,
580  tool.m_Size.y * fscale );
581  break;
582 
594  sprintf( cbuf, "P,%#fX%dX%#f*%%\n", tool.GetDiameter() * fscale,
595  tool.GetRegPolyVerticeCount(), tool.GetRotation() );
596  break;
597 
598  case APERTURE::AM_ROUND_RECT: // Aperture macro for round rect pads
599  {
600  // The aperture macro needs coordinates of the centers of the 4 corners
601  std::vector<VECTOR2I> corners;
602  wxSize half_size( tool.m_Size.x/2-tool.m_Radius, tool.m_Size.y/2-tool.m_Radius );
603 
604  corners.emplace_back( -half_size.x, -half_size.y );
605  corners.emplace_back( half_size.x, -half_size.y );
606  corners.emplace_back( half_size.x, half_size.y );
607  corners.emplace_back( -half_size.x, half_size.y );
608 
609  // Rotate the corner coordinates:
610  for( int ii = 0; ii < 4; ii++ )
611  RotatePoint( corners[ii], -tool.m_Rotation*10.0 );
612 
613  sprintf( cbuf, "%s,%#fX", APER_MACRO_ROUNDRECT_NAME,
614  tool.m_Radius * fscale );
615  buffer += cbuf;
616 
617  // Add each corner
618  for( int ii = 0; ii < 4; ii++ )
619  {
620  sprintf( cbuf, "%#fX%#fX",
621  corners[ii].x * fscale, corners[ii].y * fscale );
622  buffer += cbuf;
623  }
624 
625  sprintf( cbuf, "0*%%\n" );
626  }
627  break;
628 
629  case APERTURE::AM_ROT_RECT: // Aperture macro for rotated rect pads
630  sprintf( cbuf, "%s,%#fX%#fX%#f*%%\n", APER_MACRO_ROT_RECT_NAME,
631  tool.m_Size.x * fscale, tool.m_Size.y * fscale,
632  tool.m_Rotation );
633  break;
634 
635  case APERTURE::APER_MACRO_OUTLINE4P: // Aperture macro for trapezoid pads
636  case APERTURE::APER_MACRO_OUTLINE5P: // Aperture macro for chamfered rect pads
637  case APERTURE::APER_MACRO_OUTLINE6P: // Aperture macro for chamfered rect pads
638  case APERTURE::APER_MACRO_OUTLINE7P: // Aperture macro for chamfered rect pads
639  case APERTURE::APER_MACRO_OUTLINE8P: // Aperture macro for chamfered rect pads
640  switch( tool.m_Type )
641  {
643  sprintf( cbuf, "%s,", APER_MACRO_OUTLINE4P_NAME ); break;
645  sprintf( cbuf, "%s,", APER_MACRO_OUTLINE5P_NAME ); break;
647  sprintf( cbuf, "%s,", APER_MACRO_OUTLINE6P_NAME ); break;
649  sprintf( cbuf, "%s,", APER_MACRO_OUTLINE7P_NAME ); break;
651  sprintf( cbuf, "%s,", APER_MACRO_OUTLINE8P_NAME ); break;
652  default:
653  break;
654  }
655 
656  buffer += cbuf;
657 
658  // Output all corners (should be 4 to 8 corners)
659  // Remember: the Y coordinate must be negated, due to the fact in Pcbnew
660  // the Y axis is from top to bottom
661  for( size_t ii = 0; ii < tool.m_Corners.size(); ii++ )
662  {
663  sprintf( cbuf, "%#fX%#fX",
664  tool.m_Corners[ii].x * fscale, -tool.m_Corners[ii].y * fscale );
665  buffer += cbuf;
666  }
667 
668  // close outline and output rotation
669  sprintf( cbuf, "%#f*%%\n", tool.m_Rotation );
670  break;
671 
672  case APERTURE::AM_ROTATED_OVAL: // Aperture macro for rotated oval pads
673  // (not rotated is a primitive)
674  // m_Size.x = full lenght; m_Size.y = width, and the macro aperure expects
675  // the position of ends
676  {
677  // the seg_len is the distance between the 2 circle centers
678  int seg_len = tool.m_Size.x - tool.m_Size.y;
679  // Center of the circle on the segment start point:
680  VECTOR2I start( seg_len/2, 0 );
681  // Center of the circle on the segment end point:
682  VECTOR2I end( - seg_len/2, 0 );
683 
684  RotatePoint( start, tool.m_Rotation*10.0 );
685  RotatePoint( end, tool.m_Rotation*10.0 );
686 
687  sprintf( cbuf, "%s,%#fX%#fX%#fX%#fX%#fX0*%%\n", APER_MACRO_SHAPE_OVAL_NAME,
688  tool.m_Size.y * fscale, // width
689  start.x * fscale, -start.y * fscale, // X,Y corner start pos
690  end.x * fscale, -end.y * fscale ); // X,Y cornerend pos
691  }
692  break;
693 
695  {
696  // Write aperture header
697  fprintf( m_outputFile, "%%%s%d*\n", "AMFp", tool.m_DCode );
698  fprintf( m_outputFile, "4,1,%d,", (int)tool.m_Corners.size() );
699 
700  // Insert a newline after curr_line_count_max coordiantes.
701  int curr_line_corner_count = 0;
702  const int curr_line_count_max = 50; // <= 0 to disable newlines
703 
704  for( size_t ii = 0; ii <= tool.m_Corners.size(); ii++ )
705  {
706  int jj = ii;
707 
708  if( ii >= tool.m_Corners.size() )
709  jj = 0;
710 
711  fprintf( m_outputFile, "%#f,%#f,",
712  tool.m_Corners[jj].x * fscale, -tool.m_Corners[jj].y * fscale );
713  if( curr_line_count_max >= 0
714  && ++curr_line_corner_count >= curr_line_count_max )
715  {
716  fprintf( m_outputFile, "\n" );
717  curr_line_corner_count = 0;
718  }
719  }
720  // output rotation parameter
721  fputs( "$1*%\n", m_outputFile );
722 
723  // Create specialized macro
724  sprintf( cbuf, "%s%d,", "Fp", tool.m_DCode );
725  buffer += cbuf;
726 
727  // close outline and output rotation
728  sprintf( cbuf, "%#f*%%\n", tool.m_Rotation );
729  }
730  break;
731  }
732 
733  buffer += cbuf;
734  fputs( buffer.c_str(), m_outputFile );
735 
736  m_apertureAttribute = attribute;
737 
738  // Currently reset the aperture attribute. Perhaps a better optimization
739  // is to store the last attribute
740  if( attribute )
741  {
742  if( m_useX2format )
743  fputs( "%TD*%\n", m_outputFile );
744  else
745  fputs( "G04 #@! TD*\n", m_outputFile );
746 
748  }
749 
750  }
751 }
#define APER_MACRO_ROUNDRECT_NAME
#define APER_MACRO_SHAPE_OVAL_NAME
FILE * m_outputFile
Output file.
Definition: plotter.h:590
#define APER_MACRO_OUTLINE7P_NAME
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
double m_IUsPerDecimil
Definition: plotter.h:579
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plotter.h:573
std::vector< APERTURE > m_apertures
#define APER_MACRO_OUTLINE5P_NAME
#define APER_MACRO_OUTLINE8P_NAME
#define APER_MACRO_ROT_RECT_NAME
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
#define APER_MACRO_OUTLINE4P_NAME
#define APER_MACRO_OUTLINE6P_NAME

References APERTURE::AM_FREE_POLYGON, APERTURE::AM_ROT_RECT, APERTURE::AM_ROTATED_OVAL, APERTURE::AM_ROUND_RECT, APERTURE::APER_MACRO_OUTLINE4P, APER_MACRO_OUTLINE4P_NAME, APERTURE::APER_MACRO_OUTLINE5P, APER_MACRO_OUTLINE5P_NAME, APERTURE::APER_MACRO_OUTLINE6P, APER_MACRO_OUTLINE6P_NAME, APERTURE::APER_MACRO_OUTLINE7P, APER_MACRO_OUTLINE7P_NAME, APERTURE::APER_MACRO_OUTLINE8P, APER_MACRO_OUTLINE8P_NAME, APER_MACRO_ROT_RECT_NAME, APER_MACRO_ROUNDRECT_NAME, APER_MACRO_SHAPE_OVAL_NAME, APERTURE::AT_CIRCLE, APERTURE::AT_OVAL, APERTURE::AT_PLOTTING, APERTURE::AT_RECT, APERTURE::AT_REGULAR_POLY, APERTURE::AT_REGULAR_POLY10, APERTURE::AT_REGULAR_POLY11, APERTURE::AT_REGULAR_POLY12, APERTURE::AT_REGULAR_POLY3, APERTURE::AT_REGULAR_POLY4, APERTURE::AT_REGULAR_POLY5, APERTURE::AT_REGULAR_POLY6, APERTURE::AT_REGULAR_POLY7, APERTURE::AT_REGULAR_POLY8, APERTURE::AT_REGULAR_POLY9, GBR_APERTURE_METADATA::FormatAttribute(), m_apertureAttribute, m_apertures, m_gerberUnitInch, PLOTTER::m_IUsPerDecimil, PLOTTER::m_outputFile, PLOTTER::m_plotScale, m_useX2format, RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EndPlot().

Member Data Documentation

◆ DO_NOT_SET_LINE_WIDTH

◆ finalFile

FILE* GERBER_PLOTTER::finalFile
protected

Definition at line 329 of file plotter_gerber.h.

Referenced by EndPlot(), GERBER_PLOTTER(), and StartPlot().

◆ m_apertureAttribute

int GERBER_PLOTTER::m_apertureAttribute
protected

Definition at line 326 of file plotter_gerber.h.

Referenced by GERBER_PLOTTER(), and writeApertureList().

◆ m_apertures

std::vector<APERTURE> GERBER_PLOTTER::m_apertures
protected

Definition at line 337 of file plotter_gerber.h.

Referenced by GetOrCreateAperture(), selectAperture(), and writeApertureList().

◆ m_colorMode

◆ m_creator

wxString PLOTTER::m_creator
protectedinherited

◆ m_currentApertureIdx

int GERBER_PLOTTER::m_currentApertureIdx
protected

Definition at line 338 of file plotter_gerber.h.

Referenced by GERBER_PLOTTER(), and selectAperture().

◆ m_currentPenWidth

◆ m_filename

wxString PLOTTER::m_filename
protectedinherited

◆ m_gerberDisableApertMacros

bool GERBER_PLOTTER::m_gerberDisableApertMacros
protected

◆ m_gerberUnitFmt

int GERBER_PLOTTER::m_gerberUnitFmt
protected

◆ m_gerberUnitInch

bool GERBER_PLOTTER::m_gerberUnitInch
protected

◆ m_hasApertureChamferedRect

bool GERBER_PLOTTER::m_hasApertureChamferedRect
protected

Definition at line 344 of file plotter_gerber.h.

Referenced by EndPlot(), FlashPadChamferRoundRect(), GERBER_PLOTTER(), and StartPlot().

◆ m_hasApertureOutline4P

bool GERBER_PLOTTER::m_hasApertureOutline4P
protected

◆ m_hasApertureRotOval

bool GERBER_PLOTTER::m_hasApertureRotOval
protected

Definition at line 340 of file plotter_gerber.h.

Referenced by EndPlot(), FlashPadOval(), GERBER_PLOTTER(), and StartPlot().

◆ m_hasApertureRotRect

bool GERBER_PLOTTER::m_hasApertureRotRect
protected

Definition at line 341 of file plotter_gerber.h.

Referenced by EndPlot(), FlashPadRect(), GERBER_PLOTTER(), and StartPlot().

◆ m_hasApertureRoundRect

bool GERBER_PLOTTER::m_hasApertureRoundRect
protected

Definition at line 339 of file plotter_gerber.h.

Referenced by EndPlot(), FlashPadRoundRect(), GERBER_PLOTTER(), and StartPlot().

◆ m_headerExtraLines

wxArrayString PLOTTER::m_headerExtraLines
protectedinherited

Definition at line 605 of file plotter.h.

Referenced by PLOTTER::AddLineToHeader(), PLOTTER::ClearHeaderLinesList(), and StartPlot().

◆ m_iuPerDeviceUnit

◆ m_IUsPerDecimil

◆ m_mirrorIsHorizontal

bool PLOTTER::m_mirrorIsHorizontal
protectedinherited

◆ m_negativeMode

bool PLOTTER::m_negativeMode
protectedinherited

Definition at line 594 of file plotter.h.

Referenced by PLOTTER::PLOTTER(), PSLIKE_PLOTTER::SetColor(), and PLOTTER::SetNegative().

◆ m_objectAttributesDictionnary

std::string GERBER_PLOTTER::m_objectAttributesDictionnary
protected

Definition at line 323 of file plotter_gerber.h.

Referenced by ClearAllAttributes(), clearNetAttribute(), and formatNetAttribute().

◆ m_outputFile

FILE* PLOTTER::m_outputFile
protectedinherited

Output file.

Definition at line 590 of file plotter.h.

Referenced by DXF_PLOTTER::Arc(), HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), SVG_PLOTTER::Arc(), SVG_PLOTTER::BezierCurve(), DXF_PLOTTER::Circle(), HPGL_PLOTTER::Circle(), PS_PLOTTER::Circle(), SVG_PLOTTER::Circle(), ClearAllAttributes(), clearNetAttribute(), PDF_PLOTTER::ClosePage(), PDF_PLOTTER::closePdfObject(), PDF_PLOTTER::closePdfStream(), emitDcode(), PS_PLOTTER::emitSetRGBColor(), SVG_PLOTTER::EndBlock(), EndPlot(), HPGL_PLOTTER::EndPlot(), DXF_PLOTTER::EndPlot(), PS_PLOTTER::EndPlot(), PDF_PLOTTER::EndPlot(), SVG_PLOTTER::EndPlot(), DXF_PLOTTER::FlashPadCircle(), HPGL_PLOTTER::FlashPadCircle(), PSLIKE_PLOTTER::FlashPadOval(), DXF_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadOval(), FlashPadOval(), DXF_PLOTTER::FlashPadRect(), FlashPadRect(), FlashPadRoundRect(), DXF_PLOTTER::FlashPadTrapez(), formatNetAttribute(), PLOTTER::OpenFile(), PDF_PLOTTER::OpenFile(), DXF_PLOTTER::PenTo(), PenTo(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), plotArc(), PlotGerberRegion(), PS_PLOTTER::PlotImage(), SVG_PLOTTER::PlotImage(), PlotPoly(), PS_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), plotRoundRectAsRegion(), PLOTTER::PLOTTER(), DXF_PLOTTER::Rect(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), SVG_PLOTTER::Rect(), selectAperture(), PS_PLOTTER::SetCurrentLineWidth(), PS_PLOTTER::SetDash(), SetLayerPolarity(), SVG_PLOTTER::setSVGPlotStyle(), PS_PLOTTER::SetViewport(), SVG_PLOTTER::StartBlock(), PDF_PLOTTER::StartPage(), PDF_PLOTTER::startPdfObject(), PDF_PLOTTER::startPdfStream(), StartPlot(), HPGL_PLOTTER::StartPlot(), DXF_PLOTTER::StartPlot(), PS_PLOTTER::StartPlot(), PDF_PLOTTER::StartPlot(), SVG_PLOTTER::StartPlot(), DXF_PLOTTER::Text(), PS_PLOTTER::Text(), SVG_PLOTTER::Text(), HPGL_PLOTTER::ThickSegment(), writeApertureList(), and PLOTTER::~PLOTTER().

◆ m_pageInfo

◆ m_paperSize

◆ m_penLastpos

wxPoint PLOTTER::m_penLastpos
protectedinherited

◆ m_penState

char PLOTTER::m_penState
protectedinherited

◆ m_plotMirror

◆ m_plotOffset

◆ m_plotScale

double PLOTTER::m_plotScale
protectedinherited

◆ m_renderSettings

◆ m_title

wxString PLOTTER::m_title
protectedinherited

Definition at line 601 of file plotter.h.

Referenced by PDF_PLOTTER::EndPlot(), PLOTTER::SetTitle(), and PS_PLOTTER::StartPlot().

◆ m_useNetAttributes

bool GERBER_PLOTTER::m_useNetAttributes
protected

Definition at line 355 of file plotter_gerber.h.

Referenced by formatNetAttribute(), GERBER_PLOTTER(), and UseX2NetAttributes().

◆ m_useX2format

bool GERBER_PLOTTER::m_useX2format
protected

◆ m_workFilename

wxString GERBER_PLOTTER::m_workFilename
protected

Definition at line 330 of file plotter_gerber.h.

Referenced by EndPlot(), and StartPlot().

◆ m_yaxisReversed

bool PLOTTER::m_yaxisReversed
protectedinherited

◆ MARKER_COUNT

const unsigned PLOTTER::MARKER_COUNT = 58
staticinherited

Draw a marker (used for the drill map)

Definition at line 437 of file plotter.h.

Referenced by PLOTTER::Marker().

◆ USE_DEFAULT_LINE_WIDTH

◆ workFile

FILE* GERBER_PLOTTER::workFile
protected

Definition at line 328 of file plotter_gerber.h.

Referenced by EndPlot(), GERBER_PLOTTER(), and StartPlot().


The documentation for this class was generated from the following files: