KiCad PCB EDA Suite
GERBER_PLOTTER Class Reference

#include <plot_common.h>

Inheritance diagram for GERBER_PLOTTER:
PLOTTER

Public Member Functions

 GERBER_PLOTTER ()
 
virtual PlotFormat 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 SetDefaultLineWidth (int width) override
 Set the default line width. More...
 
virtual void SetDash (bool 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_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 
virtual void Circle (const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
 
virtual void Arc (const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_T 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, EDA_DRAW_MODE_T tracemode, void *aData) override
 
virtual void ThickArc (const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
 
virtual void ThickRect (const wxPoint &p1, const wxPoint &p2, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
 
virtual void ThickCircle (const wxPoint &pos, int diametre, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
 
virtual void PlotPoly (const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) 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, EDA_DRAW_MODE_T trace_mode, void *aData) override
 Filled circular flashes are stored as apertures. More...
 
virtual void FlashPadOval (const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
 Filled oval flashes are handled as aperture in the 90 degree positions only. More...
 
virtual void FlashPadRect (const wxPoint &pos, const wxSize &size, double orient, EDA_DRAW_MODE_T trace_mode, void *aData) override
 Filled rect flashes are handled as aperture in the 0 90 180 or 270 degree orientation only and as polygon for other orientations TODO: always use flashed shapes (aperture macros) More...
 
virtual void FlashPadRoundRect (const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData) override
 Roundrect pad at the moment are not handled as aperture, since they require aperture macros TODO: always use flashed shapes (aperture macros) More...
 
virtual void FlashPadCustom (const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData) override
 virtual function FlashPadCustom More...
 
virtual void FlashPadTrapez (const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTrace_Mode, void *aData) override
 Trapezoidal pad at the moment are never handled as aperture, since they require aperture macros TODO: always use flashed shapes (aperture macros) 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 UseX2Attributes (bool aEnable)
 
void UseX2NetAttributes (bool aEnable)
 
virtual void StartBlock (void *aData) override
 calling this function allows 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 to define the end of a group of drawing items the group is started by StartBlock() (used in X2 format with netlist attributes) More...
 
virtual void SetNegative (bool _negative)
 
virtual void SetColorMode (bool _color_mode)
 
bool GetColorMode () const
 
virtual void SetPageSettings (const PAGE_INFO &aPageSettings)
 
virtual int GetCurrentLineWidth () const
 
virtual void SetCreator (const wxString &aCreator)
 
virtual void SetTitle (const wxString &aTitle)
 
void AddLineToHeader (const wxString &aExtraString)
 Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file. More...
 
void ClearHeaderLinesList ()
 Function 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...
 
void MoveTo (const wxPoint &pos)
 
void LineTo (const wxPoint &pos)
 
void FinishTo (const wxPoint &pos)
 
void PenFinish ()
 
virtual void PlotImage (const wxImage &aImage, const wxPoint &aPos, double aScaleFactor)
 Function PlotImage Only Postscript plotters can plot bitmaps for plotters that cannot plot a bitmap, a rectangle is plotted. More...
 
void Marker (const wxPoint &position, int diametre, unsigned aShapeId)
 Draw a pattern shape number aShapeId, to coord x0, y0. More...
 
virtual void SetTextMode (PlotTextMode mode)
 Change the current text mode. More...
 

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 selectAperture (const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 Pick an existing aperture or create a new one, matching the size, 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 dictionnary) and output the clear object attribute dictionnary command to gerber file More...
 
std::vector< APERTURE >::iterator getAperture (const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
 Function getAperture returns a reference to the aperture which meets the size anf type of tool if the aperture does not exist, it is created and entered in aperture list. 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, EDA_DRAW_MODE_T tracemode)
 Cdonvert 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 GetDashMarkLenIU () const
 
double GetDashGapLenIU () const
 

Protected Attributes

std::string m_objectAttributesDictionnary
 
int m_apertureAttribute
 
FILE * workFile
 
FILE * finalFile
 
wxString m_workFilename
 
std::vector< APERTUREapertures
 
std::vector< APERTURE >::iterator currentAperture
 
bool m_gerberUnitInch
 
int m_gerberUnitFmt
 
bool m_useX2Attributes
 
bool m_useNetAttributes
 
double plotScale
 Plot scale - chosen by the user (even implicitly with 'fit in a4') More...
 
double m_IUsPerDecimil
 
double iuPerDeviceUnit
 Device scale (from IUs to plotter device units - usually decimils) More...
 
wxPoint plotOffset
 Plot offset (in IUs) More...
 
bool m_plotMirror
 X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG) More...
 
bool m_mirrorIsHorizontal
 
bool m_yaxisReversed
 true to mirror horizontally (else vertically) More...
 
FILE * outputFile
 true if the Y axis is top to bottom (SVG) More...
 
bool colorMode
 
bool negativeMode
 true to plot in color, false to plot in black and white More...
 
int defaultPenWidth
 true to generate a negative image (PS mode mainly) More...
 
int currentPenWidth
 
char penState
 Current pen state: 'U', 'D' or 'Z' (see PenTo) More...
 
wxPoint penLastpos
 Last pen positions; set to -1,-1 when the pen is at rest. More...
 
wxString creator
 
wxString filename
 
wxString title
 
PAGE_INFO pageInfo
 
wxSize paperSize
 Paper size in IU - not in mils. More...
 
wxArrayString m_headerExtraLines
 

Detailed Description

Definition at line 985 of file plot_common.h.

Constructor & Destructor Documentation

GERBER_PLOTTER::GERBER_PLOTTER ( )

Definition at line 46 of file common_plotGERBER_functions.cpp.

References apertures, currentAperture, finalFile, m_apertureAttribute, m_gerberUnitFmt, m_gerberUnitInch, m_useNetAttributes, m_useX2Attributes, and workFile.

47 {
48  workFile = NULL;
49  finalFile = NULL;
50  currentAperture = apertures.end();
52 
53  // number of digits after the point (number of digits of the mantissa
54  // Be carefull: the Gerber coordinates are stored in an integer
55  // so 6 digits (inches) or 5 digits (mm) is a good value
56  // To avoid overflow, 7 digits (inches) or 6 digits is a max.
57  // with lower values than 6 digits (inches) or 5 digits (mm),
58  // Creating self-intersecting polygons from non-intersecting polygons
59  // happen easily.
60  m_gerberUnitInch = false;
61  m_gerberUnitFmt = 6;
62  m_useX2Attributes = false;
63  m_useNetAttributes = true;
64 }
bool m_useNetAttributes
Definition: plot_common.h:1200
std::vector< APERTURE > apertures
Definition: plot_common.h:1192
bool m_useX2Attributes
Definition: plot_common.h:1198
std::vector< APERTURE >::iterator currentAperture
Definition: plot_common.h:1193

Member Function Documentation

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

Function AddLineToHeader 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 166 of file plot_common.h.

References PLOTTER::m_headerExtraLines.

Referenced by AddGerberX2Attribute().

167  {
168  m_headerExtraLines.Add( aExtraString );
169  }
wxArrayString m_headerExtraLines
Definition: plot_common.h:552
void GERBER_PLOTTER::Arc ( const wxPoint centre,
double  StAngle,
double  EndAngle,
int  rayon,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Generic fallback: arc rendered as a polyline.

Reimplemented from PLOTTER.

Definition at line 453 of file common_plotGERBER_functions.cpp.

References cosdecideg(), KiROUND(), PLOTTER::MoveTo(), PLOTTER::outputFile, SetCurrentLineWidth(), sindecideg(), PLOTTER::userToDeviceCoordinates(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by Circle(), and ThickArc().

455 {
456  SetCurrentLineWidth( aWidth );
457 
458  wxPoint start, end;
459  start.x = aCenter.x + KiROUND( cosdecideg( aRadius, aStAngle ) );
460  start.y = aCenter.y - KiROUND( sindecideg( aRadius, aStAngle ) );
461  MoveTo( start );
462  end.x = aCenter.x + KiROUND( cosdecideg( aRadius, aEndAngle ) );
463  end.y = aCenter.y - KiROUND( sindecideg( aRadius, aEndAngle ) );
464  DPOINT devEnd = userToDeviceCoordinates( end );
465  DPOINT devCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start );
466 
467  fprintf( outputFile, "G75*\n" ); // Multiquadrant mode
468 
469  if( aStAngle < aEndAngle )
470  fprintf( outputFile, "G03" );
471  else
472  fprintf( outputFile, "G02" );
473 
474  fprintf( outputFile, "X%dY%dI%dJ%dD01*\n",
475  KiROUND( devEnd.x ), KiROUND( devEnd.y ),
476  KiROUND( devCenter.x ), KiROUND( devCenter.y ) );
477  fprintf( outputFile, "G01*\n" ); // Back to linear interp.
478 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:311
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:302
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
void GERBER_PLOTTER::Circle ( const wxPoint pos,
int  diametre,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Implements PLOTTER.

Definition at line 447 of file common_plotGERBER_functions.cpp.

References Arc().

Referenced by FlashPadCircle(), and ThickCircle().

448 {
449  Arc( aCenter, 0, 3600, aDiameter / 2, aFill, aWidth );
450 }
virtual void Arc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
void PLOTTER::ClearHeaderLinesList ( )
inlineinherited

Function ClearHeaderLinesList remove all lines from the list of free lines to print at the beginning of the file.

Definition at line 175 of file plot_common.h.

References PLOTTER::m_headerExtraLines.

Referenced by StartPlotBoard().

176  {
177  m_headerExtraLines.Clear();
178  }
wxArrayString m_headerExtraLines
Definition: plot_common.h:552
void GERBER_PLOTTER::clearNetAttribute ( )
protected

clear a Gerber net attribute record (clear object attribute dictionnary) and output the clear object attribute dictionnary command to gerber file

Definition at line 110 of file common_plotGERBER_functions.cpp.

References m_objectAttributesDictionnary, and PLOTTER::outputFile.

Referenced by EndBlock(), and formatNetAttribute().

111 {
112  // disable a Gerber net attribute (exists only in X2 with net attributes mode).
113  if( m_objectAttributesDictionnary.empty() ) // No net attribute or not X2 mode
114  return;
115 
116  // Remove all net attributes from object attributes dictionnary
117  fputs( "%TD*%\n", outputFile );
118 
120 }
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
std::string m_objectAttributesDictionnary
Definition: plot_common.h:1178
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 102 of file common_plotGERBER_functions.cpp.

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

Referenced by FlashPadCircle(), FlashPadOval(), FlashPadRect(), and PenTo().

103 {
104 
105  fprintf( outputFile, "X%dY%dD%02d*\n",
106  KiROUND( pt.x ), KiROUND( pt.y ), dcode );
107 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
void GERBER_PLOTTER::EndBlock ( void *  aData)
overridevirtual

calling this function allows 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 130 of file common_plotGERBER_functions.cpp.

References clearNetAttribute().

Referenced by StartBlock().

131 {
132  // Remove all net attributes from object attributes dictionnary
134 }
void clearNetAttribute()
clear a Gerber net attribute record (clear object attribute dictionnary) and output the clear object ...
bool GERBER_PLOTTER::EndPlot ( )
overridevirtual

Implements PLOTTER.

Definition at line 220 of file common_plotGERBER_functions.cpp.

References finalFile, m_workFilename, PLOTTER::outputFile, workFile, and writeApertureList().

221 {
222  char line[1024];
223  wxString msg;
224 
225  wxASSERT( outputFile );
226 
227  /* Outfile is actually a temporary file i.e. workFile */
228  fputs( "M02*\n", outputFile );
229  fflush( outputFile );
230 
231  fclose( workFile );
232  workFile = wxFopen( m_workFilename, wxT( "rt" ));
233  wxASSERT( workFile );
235 
236  // Placement of apertures in RS274X
237  while( fgets( line, 1024, workFile ) )
238  {
239  fputs( line, outputFile );
240 
241  if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
242  {
244  fputs( "G04 APERTURE END LIST*\n", outputFile );
245  }
246  }
247 
248  fclose( workFile );
249  fclose( finalFile );
250  ::wxRemoveFile( m_workFilename );
251  outputFile = 0;
252 
253  return true;
254 }
void writeApertureList()
Generate the table of D codes.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
wxString m_workFilename
Definition: plot_common.h:1185
void GERBER_PLOTTER::FlashPadCircle ( const wxPoint pos,
int  diametre,
EDA_DRAW_MODE_T  trace_mode,
void *  aData 
)
overridevirtual

Filled circular flashes are stored as apertures.

Implements PLOTTER.

Definition at line 622 of file common_plotGERBER_functions.cpp.

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

Referenced by FlashPadCustom(), FlashPadOval(), FlashPadRoundRect(), and FlashPadTrapez().

623 {
624  wxSize size( diametre, diametre );
625  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
626 
627  if( trace_mode == SKETCH )
628  {
630 
631  if( gbr_metadata )
632  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
633 
635  }
636  else
637  {
638  DPOINT pos_dev = userToDeviceCoordinates( pos );
639 
640  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
641  selectAperture( size, APERTURE::Circle, aperture_attrib );
642 
643  if( gbr_metadata )
644  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
645 
646  emitDcode( pos_dev, 3 );
647  }
648 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void selectAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
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.
int currentPenWidth
Definition: plot_common.h:540
GBR_NETLIST_METADATA m_NetlistMetadata
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
static const int DO_NOT_SET_LINE_WIDTH
Definition: plot_common.h:94
void GERBER_PLOTTER::FlashPadCustom ( const wxPoint aPadPos,
const wxSize &  aSize,
SHAPE_POLY_SET aPolygons,
EDA_DRAW_MODE_T  aTraceMode,
void *  aData 
)
overridevirtual

virtual function FlashPadCustom

Parameters
aPadPosPosition of the shape (center of the rectangle
aSize= size of round reference pad
aPolygonsthe shape as polygon set
aTraceModeFILLED or SKETCH
aDataan auxiliary info (mainly for gerber format)

Implements PLOTTER.

Definition at line 842 of file common_plotGERBER_functions.cpp.

References GBR_NETLIST_METADATA::ClearAttribute(), FILLED, FILLED_SHAPE, FlashPadCircle(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR, GBR_METADATA::m_NetlistMetadata, min, NO_FILL, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PlotPoly(), SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), GBR_METADATA::SetApertureAttrib(), PLOTTER::USE_DEFAULT_LINE_WIDTH, VECTOR2< T >::x, and VECTOR2< T >::y.

846 {
847  // A Pad custom is plotted as polygon.
848 
849  // A flashed circle @aPadPos is added (anchor pad)
850  // However, because the anchor pad can be circle or rect, we use only
851  // a circle not bigger than the rect.
852  // the main purpose is to print a flashed DCode as pad anchor
853  FlashPadCircle( aPadPos, std::min( aSize.x, aSize.x ), aTraceMode, aData );
854  GBR_METADATA gbr_metadata;
855 
856  if( aData )
857  {
858  gbr_metadata = *static_cast<GBR_METADATA*>( aData );
860 
861  wxString attrname( ".P" );
862  gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers
863  }
864 
865  std::vector< wxPoint > cornerList;
866 
867  for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
868  {
869  SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
870  cornerList.clear();
871 
872  for( int ii = 0; ii < poly.PointCount(); ++ii )
873  cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
874 
875  // Close polygon
876  cornerList.push_back( cornerList[0] );
877 
878  PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL, USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
879  }
880 }
int PointCount() const
Function PointCount()
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
int OutlineCount() const
Returns the number of outlines in the set
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
virtual void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
aperture used for connected items like tracks (not vias)
Class SHAPE_LINE_CHAIN.
void ClearAttribute(const wxString *aName)
remove the net attribute specified by aName If aName == NULL or empty, remove all attributes ...
VECTOR2I & Point(int aIndex)
Function Point()
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
#define min(a, b)
Definition: auxiliary.h:85
void GERBER_PLOTTER::FlashPadOval ( const wxPoint pos,
const wxSize &  size,
double  orient,
EDA_DRAW_MODE_T  trace_mode,
void *  aData 
)
overridevirtual

Filled oval flashes are handled as aperture in the 90 degree positions only.

Implements PLOTTER.

Definition at line 651 of file common_plotGERBER_functions.cpp.

References GBR_NETLIST_METADATA::ClearAttribute(), delta, emitDcode(), FILLED, FlashPadCircle(), formatNetAttribute(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR, GBR_METADATA::GetApertureAttrib(), GBR_METADATA::m_NetlistMetadata, PLOTTER::outputFile, APERTURE::Oval, RotatePoint(), selectAperture(), GBR_METADATA::SetApertureAttrib(), PLOTTER::sketchOval(), ThickSegment(), PLOTTER::userToDeviceCoordinates(), wxPoint::x, and wxPoint::y.

653 {
654  wxASSERT( outputFile );
655  int x0, y0, x1, y1, delta;
656  wxSize size( aSize );
657  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
658 
659  /* Plot a flashed shape. */
660  if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
661  && trace_mode == FILLED )
662  {
663  if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
664  std::swap( size.x, size.y );
665 
666  DPOINT pos_dev = userToDeviceCoordinates( pos );
667  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
668  selectAperture( size, APERTURE::Oval, aperture_attrib );
669 
670  if( gbr_metadata )
671  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
672 
673  emitDcode( pos_dev, 3 );
674  }
675  else /* Plot pad as a segment. */
676  {
677  if( size.x > size.y )
678  {
679  std::swap( size.x, size.y );
680 
681  if( orient < 2700 )
682  orient += 900;
683  else
684  orient -= 2700;
685  }
686 
687  if( trace_mode == FILLED )
688  {
689  // TODO: use an aperture macro to declare the rotated pad
690  //
691 
692  // Flash a pad anchor, if a netlist attribute is set
693  if( aData )
694  FlashPadCircle( pos, size.x, trace_mode, aData );
695 
696  // The pad is reduced to an segment with dy > dx
697  delta = size.y - size.x;
698  x0 = 0;
699  y0 = -delta / 2;
700  x1 = 0;
701  y1 = delta / 2;
702  RotatePoint( &x0, &y0, orient );
703  RotatePoint( &x1, &y1, orient );
704  GBR_METADATA metadata;
705 
706  if( gbr_metadata )
707  {
708  metadata = *gbr_metadata;
710 
711  // Cleat .P attribute, only allowed for flashed items
712  wxString attrname( ".P" );
713  metadata.m_NetlistMetadata.ClearAttribute( &attrname );
714  }
715 
716  ThickSegment( wxPoint( pos.x + x0, pos.y + y0 ),
717  wxPoint( pos.x + x1, pos.y + y1 ),
718  size.x, trace_mode, &metadata );
719  }
720  else
721  {
722  sketchOval( pos, size, orient, -1 );
723  }
724  }
725 }
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData) override
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void selectAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static const int delta[8][2]
Definition: solve.cpp:112
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
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 void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
aperture used for connected items like tracks (not vias)
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
void ClearAttribute(const wxString *aName)
remove the net attribute specified by aName If aName == NULL or empty, remove all attributes ...
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
void GERBER_PLOTTER::FlashPadRect ( const wxPoint pos,
const wxSize &  size,
double  orient,
EDA_DRAW_MODE_T  trace_mode,
void *  aData 
)
overridevirtual

Filled rect flashes are handled as aperture in the 0 90 180 or 270 degree orientation only and as polygon for other orientations TODO: always use flashed shapes (aperture macros)

Implements PLOTTER.

Definition at line 728 of file common_plotGERBER_functions.cpp.

References PLOTTER::currentPenWidth, emitDcode(), FlashPadTrapez(), formatNetAttribute(), GBR_METADATA::GetApertureAttrib(), GBR_METADATA::m_NetlistMetadata, NO_FILL, PLOTTER::outputFile, APERTURE::Rect, Rect(), selectAperture(), SetCurrentLineWidth(), SKETCH, PLOTTER::USE_DEFAULT_LINE_WIDTH, PLOTTER::userToDeviceCoordinates(), wxPoint::x, and wxPoint::y.

731 {
732  wxASSERT( outputFile );
733  wxSize size( aSize );
734  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
735 
736  // Plot as an aperture flash
737  switch( int( orient ) )
738  {
739  case 900:
740  case 2700: // rotation of 90 degrees or 270 swaps sizes
741  std::swap( size.x, size.y );
742 
743  // Pass through
744  case 0:
745  case 1800:
746  if( trace_mode == SKETCH )
747  {
749 
750  if( gbr_metadata )
751  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
752 
753  Rect( wxPoint( pos.x - (size.x - currentPenWidth) / 2,
754  pos.y - (size.y - currentPenWidth) / 2 ),
755  wxPoint( pos.x + (size.x - currentPenWidth) / 2,
756  pos.y + (size.y - currentPenWidth) / 2 ),
757  NO_FILL );
758  }
759  else
760  {
761  DPOINT pos_dev = userToDeviceCoordinates( pos );
762  int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
763  selectAperture( size, APERTURE::Rect, aperture_attrib );
764 
765  if( gbr_metadata )
766  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
767 
768  emitDcode( pos_dev, 3 );
769  }
770  break;
771 
772  default: // plot pad shape as polygon
773  {
774  // XXX to do: use an aperture macro to declare the rotated pad
775  wxPoint coord[4];
776  // coord[0] is assumed the lower left
777  // coord[1] is assumed the upper left
778  // coord[2] is assumed the upper right
779  // coord[3] is assumed the lower right
780 
781  /* Trace the outline. */
782  coord[0].x = -size.x/2; // lower left
783  coord[0].y = size.y/2;
784  coord[1].x = -size.x/2; // upper left
785  coord[1].y = -size.y/2;
786  coord[2].x = size.x/2; // upper right
787  coord[2].y = -size.y/2;
788  coord[3].x = size.x/2; // lower right
789  coord[3].y = size.y/2;
790 
791  FlashPadTrapez( pos, coord, orient, trace_mode, aData );
792  }
793  break;
794  }
795 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void selectAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTrace_Mode, void *aData) override
Trapezoidal pad at the moment are never handled as aperture, since they require aperture macros TODO:...
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
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.
int currentPenWidth
Definition: plot_common.h:540
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
GBR_NETLIST_METADATA m_NetlistMetadata
void GERBER_PLOTTER::FlashPadRoundRect ( const wxPoint aPadPos,
const wxSize &  aSize,
int  aCornerRadius,
double  aOrient,
EDA_DRAW_MODE_T  aTraceMode,
void *  aData 
)
overridevirtual

Roundrect pad at the moment are not handled as aperture, since they require aperture macros TODO: always use flashed shapes (aperture macros)

Implements PLOTTER.

Definition at line 797 of file common_plotGERBER_functions.cpp.

References GBR_NETLIST_METADATA::ClearAttribute(), FILLED, FILLED_SHAPE, FlashPadCircle(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR, GBR_METADATA::m_NetlistMetadata, min, NO_FILL, SHAPE_POLY_SET::Outline(), PlotPoly(), SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), GBR_METADATA::SetApertureAttrib(), TransformRoundRectToPolygon(), PLOTTER::USE_DEFAULT_LINE_WIDTH, VECTOR2< T >::x, and VECTOR2< T >::y.

801 {
802  // Currently, a Pad RoundRect is plotted as polygon.
803  // TODO: use Aperture macro and flash it
804  SHAPE_POLY_SET outline;
805  const int segmentToCircleCount = 64;
806  TransformRoundRectToPolygon( outline, aPadPos, aSize, aOrient,
807  aCornerRadius, segmentToCircleCount );
808 
809  std::vector< wxPoint > cornerList;
810  cornerList.reserve( segmentToCircleCount + 5 );
811  // TransformRoundRectToPolygon creates only one convex polygon
812  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
813 
814  for( int ii = 0; ii < poly.PointCount(); ++ii )
815  cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
816 
817  // Close polygon
818  cornerList.push_back( cornerList[0] );
819 
820  GBR_METADATA gbr_metadata;
821 
822  if( aData )
823  {
824  gbr_metadata = *static_cast<GBR_METADATA*>( aData );
826 
827  wxString attrname( ".P" );
828  gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers
829  }
830 
831  PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL, USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
832 
833  // Now, flash a pad anchor, if a netlist attribute is set
834  // (remove me when a Aperture macro will be used)
835  if( aData && aTraceMode == FILLED )
836  {
837  int diameter = std::min( aSize.x, aSize.y );
838  FlashPadCircle( aPadPos, diameter, aTraceMode , aData );
839  }
840 }
int PointCount() const
Function PointCount()
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
virtual void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
aperture used for connected items like tracks (not vias)
Class SHAPE_LINE_CHAIN.
void ClearAttribute(const wxString *aName)
remove the net attribute specified by aName If aName == NULL or empty, remove all attributes ...
VECTOR2I & Point(int aIndex)
Function Point()
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
#define min(a, b)
Definition: auxiliary.h:85
void GERBER_PLOTTER::FlashPadTrapez ( const wxPoint aPadPos,
const wxPoint aCorners,
double  aPadOrient,
EDA_DRAW_MODE_T  aTrace_Mode,
void *  aData 
)
overridevirtual

Trapezoidal pad at the moment are never handled as aperture, since they require aperture macros TODO: always use flashed shapes (aperture macros)

Implements PLOTTER.

Definition at line 883 of file common_plotGERBER_functions.cpp.

References GBR_NETLIST_METADATA::ClearAttribute(), dist, FILLED, FILLED_SHAPE, FlashPadCircle(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR, SEG::LineDistance(), GBR_METADATA::m_NetlistMetadata, min, NO_FILL, PlotPoly(), RotatePoint(), GBR_METADATA::SetApertureAttrib(), SetCurrentLineWidth(), and PLOTTER::USE_DEFAULT_LINE_WIDTH.

Referenced by FlashPadRect().

886 {
887  // Currently, a Pad Trapezoid is plotted as polygon.
888  // TODO: use Aperture macro and flash it
889 
890  // polygon corners list
891  std::vector< wxPoint > cornerList;
892 
893  for( int ii = 0; ii < 4; ii++ )
894  cornerList.push_back( aCorners[ii] );
895 
896  // Now, flash a pad anchor, if a netlist attribute is set
897  // (remove me when a Aperture macro will be used)
898  if( aData && (aTrace_Mode==FILLED) )
899  {
900  // Calculate the radius of the circle inside the shape
901  // It is the smaller dist from shape pos to edges
902  int radius = INT_MAX;
903 
904  for( unsigned ii = 0, jj = cornerList.size()-1; ii < cornerList.size();
905  jj = ii, ii++ )
906  {
907  SEG segment( aCorners[ii], aCorners[jj] );
908  int dist = segment.LineDistance( VECTOR2I( 0, 0) );
909  radius = std::min( radius, dist );
910  }
911 
912  FlashPadCircle( aPadPos, radius*2, aTrace_Mode, aData );
913  }
914 
915  // Draw the polygon and fill the interior as required
916  for( unsigned ii = 0; ii < 4; ii++ )
917  {
918  RotatePoint( &cornerList[ii], aPadOrient );
919  cornerList[ii] += aPadPos;
920  }
921 
922  // Close the polygon
923  cornerList.push_back( cornerList[0] );
924  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
925 
926  GBR_METADATA metadata;
927 
928  if( gbr_metadata )
929  {
930  metadata = *gbr_metadata;
932  wxString attrname( ".P" );
933  metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers
934  }
935 
937  PlotPoly( cornerList, aTrace_Mode==FILLED ? FILLED_SHAPE : NO_FILL, USE_DEFAULT_LINE_WIDTH, &metadata );
938 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
static const int dist[10][10]
Definition: dist.cpp:57
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
virtual void FlashPadCircle(const wxPoint &pos, int diametre, EDA_DRAW_MODE_T trace_mode, void *aData) override
Filled circular flashes are stored as apertures.
aperture used for connected items like tracks (not vias)
Definition: seg.h:37
void ClearAttribute(const wxString *aName)
remove the net attribute specified by aName If aName == NULL or empty, remove all attributes ...
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
#define min(a, b)
Definition: auxiliary.h:85
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 137 of file common_plotGERBER_functions.cpp.

References clearNetAttribute(), FormatNetAttribute(), m_objectAttributesDictionnary, m_useNetAttributes, m_useX2Attributes, and PLOTTER::outputFile.

Referenced by FlashPadCircle(), FlashPadOval(), FlashPadRect(), PlotPoly(), Text(), ThickArc(), ThickCircle(), ThickRect(), and ThickSegment().

138 {
139  // print a Gerber net attribute record.
140  // it is added to the object attributes dictionnary
141  // On file, only modified or new attributes are printed.
142  if( aData == NULL || !m_useX2Attributes || !m_useNetAttributes )
143  return;
144 
145  bool clearDict;
146  std::string short_attribute_string;
147 
148  if( !FormatNetAttribute( short_attribute_string, m_objectAttributesDictionnary,
149  aData, clearDict ) )
150  return;
151 
152  if( clearDict )
154 
155  if( !short_attribute_string.empty() )
156  fputs( short_attribute_string.c_str(), outputFile );
157 }
void clearNetAttribute()
clear a Gerber net attribute record (clear object attribute dictionnary) and output the clear object ...
bool m_useNetAttributes
Definition: plot_common.h:1200
bool FormatNetAttribute(std::string &aPrintedText, std::string &aLastNetAttributes, GBR_NETLIST_METADATA *aData, bool &aClearPreviousAttributes)
Generates the string to print to a gerber file, to set a net attribute for a graphic object...
bool m_useX2Attributes
Definition: plot_common.h:1198
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
std::string m_objectAttributesDictionnary
Definition: plot_common.h:1178
std::vector< APERTURE >::iterator GERBER_PLOTTER::getAperture ( const wxSize &  aSize,
APERTURE::APERTURE_TYPE  aType,
int  aApertureAttribute 
)
protected

Function getAperture returns a reference to the aperture which meets the size anf type of tool if the aperture does not exist, it is created and entered in aperture list.

Parameters
aSize= the size of tool
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 284 of file common_plotGERBER_functions.cpp.

References apertures, APERTURE::m_ApertureAttribute, APERTURE::m_DCode, APERTURE::m_Size, and APERTURE::m_Type.

Referenced by selectAperture().

286 {
287  int last_D_code = 9;
288 
289  // Search an existing aperture
290  std::vector<APERTURE>::iterator tool = apertures.begin();
291 
292  while( tool != apertures.end() )
293  {
294  last_D_code = tool->m_DCode;
295 
296  if( (tool->m_Type == aType) && (tool->m_Size == aSize) && (tool->m_ApertureAttribute == aApertureAttribute) )
297  return tool;
298 
299  ++tool;
300  }
301 
302  // Allocate a new aperture
303  APERTURE new_tool;
304  new_tool.m_Size = aSize;
305  new_tool.m_Type = aType;
306  new_tool.m_DCode = last_D_code + 1;
307  new_tool.m_ApertureAttribute = aApertureAttribute;
308 
309  apertures.push_back( new_tool );
310 
311  return apertures.end() - 1;
312 }
APERTURE_TYPE m_Type
Definition: plot_common.h:977
wxSize m_Size
Definition: plot_common.h:976
std::vector< APERTURE > apertures
Definition: plot_common.h:1192
int m_DCode
Definition: plot_common.h:978
int m_ApertureAttribute
Definition: plot_common.h:979
bool PLOTTER::GetColorMode ( ) const
inlineinherited

Definition at line 121 of file plot_common.h.

References PLOTTER::colorMode.

Referenced by PLOT_CONTROLLER::GetColorMode(), LIB_TEXT::Plot(), LIB_PART::Plot(), LIB_PART::PlotLibFields(), and PlotWorkSheet().

122  {
123  return colorMode;
124  }
bool colorMode
Definition: plot_common.h:537
double PLOTTER::GetDashGapLenIU ( ) const
protectedinherited

Definition at line 141 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), PLOTTER::m_dashGapLength_mm, PLOTTER::m_IUsPerDecimil, and PLOTTER::userToDeviceSize().

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

142 {
144 }
double m_IUsPerDecimil
Definition: plot_common.h:519
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
double m_dashGapLength_mm
Dashed line parameter in mm: gap.
Definition: plot_common.h:90
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
double PLOTTER::GetDashMarkLenIU ( ) const
protectedinherited

Definition at line 134 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), PLOTTER::m_dashMarkLength_mm, PLOTTER::m_IUsPerDecimil, and PLOTTER::userToDeviceSize().

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

135 {
137  return ( mark < 0.0 ) ? 0.0 : mark;
138 }
double m_IUsPerDecimil
Definition: plot_common.h:519
double m_dashMarkLength_mm
Dashed line parameter in mm: segment.
Definition: plot_common.h:89
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT) ...
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
static wxString GERBER_PLOTTER::GetDefaultFileExtension ( )
inlinestatic

Definition at line 995 of file plot_common.h.

Referenced by GetDefaultPlotExtension().

996  {
997  return wxString( wxT( "gbr" ) );
998  }
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 207 of file plot_common.h.

References PLOTTER::m_IUsPerDecimil.

Referenced by PlotWorkSheet().

207 { return m_IUsPerDecimil; }
double m_IUsPerDecimil
Definition: plot_common.h:519
virtual PlotFormat 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 990 of file plot_common.h.

References PLOT_FORMAT_GERBER.

991  {
992  return PLOT_FORMAT_GERBER;
993  }
void PLOTTER::LineTo ( const wxPoint pos)
inlineinherited

Definition at line 236 of file plot_common.h.

References PLOTTER::PenTo().

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

237  {
238  PenTo( pos, 'D' );
239  }
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction
void PLOTTER::Marker ( const wxPoint position,
int  diametre,
unsigned  aShapeId 
)
inherited

Draw a pattern shape number aShapeId, to coord x0, y0.

x0, y0 = coordinates tables Diameter diameter = (coord table) hole AShapeId = index (used to generate forms characters)

Definition at line 273 of file class_plotter.cpp.

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

Referenced by EXCELLON_WRITER::GenDrillMapFile(), and EXCELLON_WRITER::plotDrillMarks().

274 {
275  int radius = diametre / 2;
276  /* Marker are composed by a series of 'parts' superimposed; not every
277  combination make sense, obviously. Since they are used in order I
278  tried to keep the uglier/more complex constructions at the end.
279  Also I avoided the |/ |\ -/ -\ construction because they're *very*
280  ugly... if needed they could be added anyway... I'd like to see
281  a board with more than 58 drilling/slotting tools!
282  If Visual C++ supported the 0b literals they would be optimally
283  and easily encoded as an integer array. We have to do with octal */
284  static const unsigned char marker_patterns[MARKER_COUNT] = {
285  // Bit order: O Square Lozenge - | \ /
286  // First choice: simple shapes
287  0003, // X
288  0100, // O
289  0014, // +
290  0040, // Sq
291  0020, // Lz
292  // Two simple shapes
293  0103, // X O
294  0017, // X +
295  0043, // X Sq
296  0023, // X Lz
297  0114, // O +
298  0140, // O Sq
299  0120, // O Lz
300  0054, // + Sq
301  0034, // + Lz
302  0060, // Sq Lz
303  // Three simple shapes
304  0117, // X O +
305  0143, // X O Sq
306  0123, // X O Lz
307  0057, // X + Sq
308  0037, // X + Lz
309  0063, // X Sq Lz
310  0154, // O + Sq
311  0134, // O + Lz
312  0074, // + Sq Lz
313  // Four simple shapes
314  0174, // O Sq Lz +
315  0163, // X O Sq Lz
316  0157, // X O Sq +
317  0137, // X O Lz +
318  0077, // X Sq Lz +
319  // This draws *everything *
320  0177, // X O Sq Lz +
321  // Here we use the single bars... so the cross is forbidden
322  0110, // O -
323  0104, // O |
324  0101, // O /
325  0050, // Sq -
326  0044, // Sq |
327  0041, // Sq /
328  0030, // Lz -
329  0024, // Lz |
330  0021, // Lz /
331  0150, // O Sq -
332  0144, // O Sq |
333  0141, // O Sq /
334  0130, // O Lz -
335  0124, // O Lz |
336  0121, // O Lz /
337  0070, // Sq Lz -
338  0064, // Sq Lz |
339  0061, // Sq Lz /
340  0170, // O Sq Lz -
341  0164, // O Sq Lz |
342  0161, // O Sq Lz /
343  // Last resort: the backlash component (easy to confound)
344  0102, // \ O
345  0042, // \ Sq
346  0022, // \ Lz
347  0142, // \ O Sq
348  0122, // \ O Lz
349  0062, // \ Sq Lz
350  0162 // \ O Sq Lz
351  };
352  if( aShapeId >= MARKER_COUNT )
353  {
354  // Fallback shape
355  markerCircle( position, radius );
356  }
357  else
358  {
359  // Decode the pattern and draw the corresponding parts
360  unsigned char pat = marker_patterns[aShapeId];
361  if( pat & 0001 )
362  markerSlash( position, radius );
363  if( pat & 0002 )
364  markerBackSlash( position, radius );
365  if( pat & 0004 )
366  markerVBar( position, radius );
367  if( pat & 0010 )
368  markerHBar( position, radius );
369  if( pat & 0020 )
370  markerLozenge( position, radius );
371  if( pat & 0040 )
372  markerSquare( position, radius );
373  if( pat & 0100 )
374  markerCircle( position, radius );
375  }
376 }
void markerHBar(const wxPoint &pos, int radius)
Plot a - bar centered on the position.
static const unsigned MARKER_COUNT
Draw a marker (used for the drill map)
Definition: plot_common.h:382
void markerSlash(const wxPoint &pos, int radius)
Plot a / bar centered on the position.
void markerLozenge(const wxPoint &position, int radius)
Plot a lozenge centered on the position.
void markerCircle(const wxPoint &pos, int radius)
Plot a circle centered on the position.
void markerVBar(const wxPoint &pos, int radius)
Plot a | bar centered on the position.
void markerSquare(const wxPoint &position, int radius)
Plot a square centered on the position.
void markerBackSlash(const wxPoint &pos, int radius)
Plot a \ bar centered on the position.
void PLOTTER::markerBackSlash ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a \ bar centered on the position.

Building block for markers

Definition at line 259 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

260 {
261  MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
262  FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
263 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
void PLOTTER::markerCircle ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a circle centered on the position.

Building block for markers

Definition at line 215 of file class_plotter.cpp.

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

Referenced by PLOTTER::Marker().

216 {
217  Circle( position, radius * 2, NO_FILL, GetCurrentLineWidth() );
218 }
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void PLOTTER::markerHBar ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a - bar centered on the position.

Building block for markers

Definition at line 245 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

246 {
247  MoveTo( wxPoint( pos.x - radius, pos.y ) );
248  FinishTo( wxPoint( pos.x + radius, pos.y ) );
249 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
void PLOTTER::markerLozenge ( const wxPoint position,
int  radius 
)
protectedinherited

Plot a lozenge centered on the position.

Building block for markers

Definition at line 221 of file class_plotter.cpp.

References PLOTTER::GetCurrentLineWidth(), NO_FILL, PLOTTER::PlotPoly(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

222 {
223  std::vector< wxPoint > corner_list;
224  wxPoint corner;
225  corner.x = position.x;
226  corner.y = position.y + radius;
227  corner_list.push_back( corner );
228  corner.x = position.x + radius;
229  corner.y = position.y,
230  corner_list.push_back( corner );
231  corner.x = position.x;
232  corner.y = position.y - radius;
233  corner_list.push_back( corner );
234  corner.x = position.x - radius;
235  corner.y = position.y;
236  corner_list.push_back( corner );
237  corner.x = position.x;
238  corner.y = position.y + radius;
239  corner_list.push_back( corner );
240 
241  PlotPoly( corner_list, NO_FILL, GetCurrentLineWidth() );
242 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
void PLOTTER::markerSlash ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a / bar centered on the position.

Building block for markers

Definition at line 252 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

253 {
254  MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
255  FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
256 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
void PLOTTER::markerSquare ( const wxPoint position,
int  radius 
)
protectedinherited

Plot a square centered on the position.

Building block for markers

Definition at line 190 of file class_plotter.cpp.

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

Referenced by PLOTTER::Marker().

191 {
192  double r = KiROUND( radius / 1.4142 );
193  std::vector< wxPoint > corner_list;
194  wxPoint corner;
195  corner.x = position.x + r;
196  corner.y = position.y + r;
197  corner_list.push_back( corner );
198  corner.x = position.x + r;
199  corner.y = position.y - r;
200  corner_list.push_back( corner );
201  corner.x = position.x - r;
202  corner.y = position.y - r;
203  corner_list.push_back( corner );
204  corner.x = position.x - r;
205  corner.y = position.y + r;
206  corner_list.push_back( corner );
207  corner.x = position.x + r;
208  corner.y = position.y + r;
209  corner_list.push_back( corner );
210 
211  PlotPoly( corner_list, NO_FILL, GetCurrentLineWidth() );
212 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
virtual int GetCurrentLineWidth() const
Definition: plot_common.h:142
void PLOTTER::markerVBar ( const wxPoint pos,
int  radius 
)
protectedinherited

Plot a | bar centered on the position.

Building block for markers

Definition at line 266 of file class_plotter.cpp.

References PLOTTER::FinishTo(), PLOTTER::MoveTo(), wxPoint::x, and wxPoint::y.

Referenced by PLOTTER::Marker().

267 {
268  MoveTo( wxPoint( pos.x, pos.y - radius ) );
269  FinishTo( wxPoint( pos.x, pos.y + radius ) );
270 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
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 79 of file class_plotter.cpp.

References PLOTTER::filename, and PLOTTER::outputFile.

Referenced by EXCELLON_WRITER::GenDrillMapFile(), DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL(), DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF(), DIALOG_PLOT_SCHEMATIC::plotOneSheetPS(), DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG(), StartPlotBoard(), and LIB_EDIT_FRAME::SVG_PlotComponent().

80 {
81  filename = aFullFilename;
82 
83  wxASSERT( !outputFile );
84 
85  // Open the file in text mode (not suitable for all plotters
86  // but only for most of them
87  outputFile = wxFopen( filename, wxT( "wt" ) );
88 
89  if( outputFile == NULL )
90  return false ;
91 
92  return true;
93 }
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
wxString filename
Definition: plot_common.h:546
void PLOTTER::PenFinish ( )
inlineinherited

Definition at line 247 of file plot_common.h.

References PLOTTER::PenTo().

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

248  {
249  // The point is not important with Z motion
250  PenTo( wxPoint( 0, 0 ), 'Z' );
251  }
virtual void PenTo(const wxPoint &pos, char plume)=0
moveto/lineto primitive, moves the 'pen' to the specified direction
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 407 of file common_plotGERBER_functions.cpp.

References emitDcode(), PLOTTER::outputFile, PLOTTER::penState, and PLOTTER::userToDeviceCoordinates().

408 {
409  wxASSERT( outputFile );
410  DPOINT pos_dev = userToDeviceCoordinates( aPos );
411 
412  switch( plume )
413  {
414  case 'Z':
415  break;
416 
417  case 'U':
418  emitDcode( pos_dev, 2 );
419  break;
420 
421  case 'D':
422  emitDcode( pos_dev, 1 );
423  }
424 
425  penState = plume;
426 }
char penState
Current pen state: 'U', 'D' or 'Z' (see PenTo)
Definition: plot_common.h:542
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.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
void PLOTTER::PlotImage ( const wxImage &  aImage,
const wxPoint aPos,
double  aScaleFactor 
)
virtualinherited

Function PlotImage Only Postscript plotters can plot bitmaps for plotters that cannot plot a bitmap, a rectangle is plotted.

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 173 of file class_plotter.cpp.

References NO_FILL, PLOTTER::Rect(), wxPoint::x, and wxPoint::y.

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

174 {
175  wxSize size( aImage.GetWidth() * aScaleFactor,
176  aImage.GetHeight() * aScaleFactor );
177 
178  wxPoint start = aPos;
179  start.x -= size.x / 2;
180  start.y -= size.y / 2;
181 
182  wxPoint end = start;
183  end.x += size.x;
184  end.y += size.y;
185 
186  Rect( start, end, NO_FILL );
187 }
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void GERBER_PLOTTER::PlotPoly ( const std::vector< wxPoint > &  aCornerList,
FILL_T  aFill,
int  aWidth = USE_DEFAULT_LINE_WIDTH,
void *  aData = NULL 
)
overridevirtual

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

Implements PLOTTER.

Definition at line 481 of file common_plotGERBER_functions.cpp.

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

Referenced by FlashPadCustom(), FlashPadRoundRect(), FlashPadTrapez(), and Rect().

483 {
484  if( aCornerList.size() <= 1 )
485  return;
486 
487  // Gerber format does not know filled polygons with thick outline
488  // Therefore, to plot a filled polygon with outline having a thickness,
489  // one should plot outline as thick segments
490  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
491 
492  SetCurrentLineWidth( aWidth, gbr_metadata );
493 
494  if( gbr_metadata )
495  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
496 
497  if( aFill )
498  {
499  fputs( "G36*\n", outputFile );
500 
501  MoveTo( aCornerList[0] );
502 
503  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
504  LineTo( aCornerList[ii] );
505 
506  FinishTo( aCornerList[0] );
507  fputs( "G37*\n", outputFile );
508  }
509 
510  if( aWidth > 0 )
511  {
512  MoveTo( aCornerList[0] );
513 
514  for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
515  LineTo( aCornerList[ii] );
516 
517  // Ensure the thick outline is closed for filled polygons
518  // (if not filled, could be only a polyline)
519  if( aFill && ( aCornerList[aCornerList.size()-1] != aCornerList[0] ) )
520  LineTo( aCornerList[0] );
521 
522  PenFinish();
523  }
524 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void PenFinish()
Definition: plot_common.h:247
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
void LineTo(const wxPoint &pos)
Definition: plot_common.h:236
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
GBR_NETLIST_METADATA m_NetlistMetadata
void GERBER_PLOTTER::Rect ( const wxPoint p1,
const wxPoint p2,
FILL_T  fill,
int  width = USE_DEFAULT_LINE_WIDTH 
)
overridevirtual

Implements PLOTTER.

Definition at line 429 of file common_plotGERBER_functions.cpp.

References PlotPoly(), wxPoint::x, and wxPoint::y.

Referenced by FlashPadRect(), and ThickRect().

430 {
431  std::vector< wxPoint > cornerList;
432 
433  // Build corners list
434  cornerList.push_back( p1 );
435  wxPoint corner(p1.x, p2.y);
436  cornerList.push_back( corner );
437  cornerList.push_back( p2 );
438  corner.x = p2.x;
439  corner.y = p1.y;
440  cornerList.push_back( corner );
441  cornerList.push_back( p1 );
442 
443  PlotPoly( cornerList, fill, width );
444 }
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
Gerber polygon: they can (and should) be filled with the appropriate G36/G37 sequence.
void PLOTTER::segmentAsOval ( const wxPoint start,
const wxPoint end,
int  width,
EDA_DRAW_MODE_T  tracemode 
)
protectedinherited

Cdonvert a thick segment and plot it as an oval.

Definition at line 379 of file class_plotter.cpp.

References ArcTangente(), EuclideanNorm(), PLOTTER::FlashPadOval(), KiROUND(), wxPoint::x, and wxPoint::y.

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

381 {
382  wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
383  wxSize size( end.x - start.x, end.y - start.y );
384  double orient;
385 
386  if( size.y == 0 )
387  orient = 0;
388  else if( size.x == 0 )
389  orient = 900;
390  else
391  orient = -ArcTangente( size.y, size.x );
392 
393  size.x = KiROUND( EuclideanNorm( size ) ) + width;
394  size.y = width;
395 
396  FlashPadOval( center, size, orient, tracemode, NULL );
397 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:104
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadOval
void GERBER_PLOTTER::selectAperture ( const wxSize &  aSize,
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 315 of file common_plotGERBER_functions.cpp.

References apertures, currentAperture, getAperture(), m_useNetAttributes, m_useX2Attributes, and PLOTTER::outputFile.

Referenced by FlashPadCircle(), FlashPadOval(), FlashPadRect(), and SetCurrentLineWidth().

318 {
319  bool change = ( currentAperture == apertures.end() ) ||
320  ( currentAperture->m_Type != aType ) ||
321  ( currentAperture->m_Size != aSize );
322 
324  aApertureAttribute = 0;
325  else
326  change = change || ( currentAperture->m_ApertureAttribute != aApertureAttribute );
327 
328  if( change )
329  {
330  // Pick an existing aperture or create a new one
331  currentAperture = getAperture( aSize, aType, aApertureAttribute );
332  fprintf( outputFile, "D%d*\n", currentAperture->m_DCode );
333  }
334 }
std::vector< APERTURE >::iterator getAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Function getAperture returns a reference to the aperture which meets the size anf type of tool if the...
bool m_useNetAttributes
Definition: plot_common.h:1200
std::vector< APERTURE > apertures
Definition: plot_common.h:1192
bool m_useX2Attributes
Definition: plot_common.h:1198
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
std::vector< APERTURE >::iterator currentAperture
Definition: plot_common.h:1193
virtual void GERBER_PLOTTER::SetColor ( COLOR4D  color)
inlineoverridevirtual

Implements PLOTTER.

Definition at line 1012 of file plot_common.h.

1012 {}
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 264 of file common_plotGERBER_functions.cpp.

References PLOTTER::currentPenWidth, PLOTTER::defaultPenWidth, PLOTTER::DO_NOT_SET_LINE_WIDTH, GBR_METADATA::GetApertureAttrib(), APERTURE::Plotting, and selectAperture().

Referenced by Arc(), FlashPadCircle(), FlashPadRect(), FlashPadTrapez(), PlotPoly(), StartPlot(), ThickArc(), ThickCircle(), ThickRect(), and ThickSegment().

265 {
266  if( width == DO_NOT_SET_LINE_WIDTH )
267  return;
268 
269  int pen_width;
270 
271  if( width > 0 )
272  pen_width = width;
273  else
274  pen_width = defaultPenWidth;
275 
276  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
277  int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
278 
279  selectAperture( wxSize( pen_width, pen_width ), APERTURE::Plotting, aperture_attribute );
280  currentPenWidth = pen_width;
281 }
void selectAperture(const wxSize &aSize, APERTURE::APERTURE_TYPE aType, int aApertureAttribute)
Pick an existing aperture or create a new one, matching the size, type and attributes.
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
int currentPenWidth
Definition: plot_common.h:540
int defaultPenWidth
true to generate a negative image (PS mode mainly)
Definition: plot_common.h:539
static const int DO_NOT_SET_LINE_WIDTH
Definition: plot_common.h:94
virtual void GERBER_PLOTTER::SetDash ( bool  dashed)
inlineoverridevirtual

Implements PLOTTER.

Definition at line 1011 of file plot_common.h.

1011 {}
void GERBER_PLOTTER::SetDefaultLineWidth ( int  width)
overridevirtual

Set the default line width.

Used at the beginning and when a width of -1 (USE_DEFAULT_LINE_WIDTH) is requested.

Parameters
widthis specified in IUs

Implements PLOTTER.

Definition at line 257 of file common_plotGERBER_functions.cpp.

References apertures, currentAperture, and PLOTTER::defaultPenWidth.

Referenced by SetViewport().

258 {
259  defaultPenWidth = width;
260  currentAperture = apertures.end();
261 }
std::vector< APERTURE > apertures
Definition: plot_common.h:1192
int defaultPenWidth
true to generate a negative image (PS mode mainly)
Definition: plot_common.h:539
std::vector< APERTURE >::iterator currentAperture
Definition: plot_common.h:1193
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 90 of file common_plotGERBER_functions.cpp.

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

91 {
92  m_gerberUnitInch = aUseInches;
93  m_gerberUnitFmt = aResolution;
94 
95  iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );
96 
97  if( ! m_gerberUnitInch )
98  iuPerDeviceUnit *= 25.4; // gerber output in mm
99 }
double m_IUsPerDecimil
Definition: plot_common.h:519
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:522
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 957 of file common_plotGERBER_functions.cpp.

References PLOTTER::outputFile.

958 {
959  if( aPositive )
960  fprintf( outputFile, "%%LPD*%%\n" );
961  else
962  fprintf( outputFile, "%%LPC*%%\n" );
963 }
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
virtual void PLOTTER::SetNegative ( bool  _negative)
inlinevirtualinherited

Definition at line 111 of file plot_common.h.

References PLOTTER::negativeMode.

Referenced by FillNegativeKnockout().

112  {
113  negativeMode = _negative;
114  }
bool negativeMode
true to plot in color, false to plot in black and white
Definition: plot_common.h:538
void PLOTTER::SetPageSettings ( const PAGE_INFO aPageSettings)
virtualinherited
virtual void PLOTTER::SetTextMode ( PlotTextMode  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 410 of file plot_common.h.

Referenced by initializePlotter(), and PlotOneBoardLayer().

411  {
412  // NOP for most plotters.
413  }
virtual void PLOTTER::SetTitle ( const wxString &  aTitle)
inlinevirtualinherited

Definition at line 156 of file plot_common.h.

References PLOTTER::title.

Referenced by DIALOG_PLOT_SCHEMATIC::createPDFFile().

157  {
158  title = aTitle;
159  }
wxString title
Definition: plot_common.h:547
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 67 of file common_plotGERBER_functions.cpp.

References PLOTTER::iuPerDeviceUnit, m_gerberUnitFmt, PLOTTER::m_IUsPerDecimil, PLOTTER::m_plotMirror, PLOTTER::outputFile, PLOTTER::paperSize, PLOTTER::plotOffset, PLOTTER::plotScale, and SetDefaultLineWidth().

69 {
70  wxASSERT( !outputFile );
71  wxASSERT( aMirror == false );
72  m_plotMirror = false;
73  plotOffset = aOffset;
74  wxASSERT( aScale == 1 ); // aScale parameter is not used in Gerber
75  plotScale = 1; // Plot scale is *always* 1.0
76 
77  m_IUsPerDecimil = aIusPerDecimil;
78  // gives now a default value to iuPerDeviceUnit (because the units of the caller is now known)
79  // which could be modified later by calling SetGerberCoordinatesFormat()
80  iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );
81 
82  // We don't handle the filmbox, and it's more useful to keep the
83  // origin at the origin
84  paperSize.x = 0;
85  paperSize.y = 0;
86  SetDefaultLineWidth( 100 * aIusPerDecimil ); // Arbitrary default
87 }
virtual void SetDefaultLineWidth(int width) override
Set the default line width.
double m_IUsPerDecimil
Definition: plot_common.h:519
wxPoint plotOffset
Plot offset (in IUs)
Definition: plot_common.h:525
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:529
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:513
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:522
wxSize paperSize
Paper size in IU - not in mils.
Definition: plot_common.h:550
void PLOTTER::sketchOval ( const wxPoint pos,
const wxSize &  size,
double  orient,
int  width 
)
protectedinherited

Definition at line 400 of file class_plotter.cpp.

References AddAngles(), PLOTTER::Arc(), PLOTTER::currentPenWidth, PLOTTER::FinishTo(), PLOTTER::MoveTo(), NO_FILL, RotatePoint(), PLOTTER::SetCurrentLineWidth(), wxPoint::x, and wxPoint::y.

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

401 {
402  SetCurrentLineWidth( width );
403  width = currentPenWidth;
404  int radius, deltaxy, cx, cy;
405  wxSize size( aSize );
406 
407  if( size.x > size.y )
408  {
409  std::swap( size.x, size.y );
410  orient = AddAngles( orient, 900 );
411  }
412 
413  deltaxy = size.y - size.x; /* distance between centers of the oval */
414  radius = ( size.x - width ) / 2;
415  cx = -radius;
416  cy = -deltaxy / 2;
417  RotatePoint( &cx, &cy, orient );
418  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
419  cx = -radius;
420  cy = deltaxy / 2;
421  RotatePoint( &cx, &cy, orient );
422  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
423 
424  cx = radius;
425  cy = -deltaxy / 2;
426  RotatePoint( &cx, &cy, orient );
427  MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
428  cx = radius;
429  cy = deltaxy / 2;
430  RotatePoint( &cx, &cy, orient );
431  FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
432 
433  cx = 0;
434  cy = deltaxy / 2;
435  RotatePoint( &cx, &cy, orient );
436  Arc( wxPoint( cx + pos.x, cy + pos.y ),
437  orient + 1800, orient + 3600,
438  radius, NO_FILL );
439  cx = 0;
440  cy = -deltaxy / 2;
441  RotatePoint( &cx, &cy, orient );
442  Arc( wxPoint( cx + pos.x, cy + pos.y ),
443  orient, orient + 1800,
444  radius, NO_FILL );
445 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition: trigo.h:246
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
int currentPenWidth
Definition: plot_common.h:540
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
void GERBER_PLOTTER::StartBlock ( void *  aData)
overridevirtual

calling this function allows 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 123 of file common_plotGERBER_functions.cpp.

References EndBlock().

124 {
125  // Currently, it is the same as EndBlock(): clear all aperture net attributes
126  EndBlock( aData );
127 }
virtual void EndBlock(void *aData) override
calling this function allows to define the end of a group of drawing items the group is started by St...
bool GERBER_PLOTTER::StartPlot ( )
overridevirtual

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

Implements PLOTTER.

Definition at line 160 of file common_plotGERBER_functions.cpp.

References PLOTTER::creator, DateAndTime(), PLOTTER::filename, finalFile, GetBuildVersion(), m_gerberUnitFmt, m_gerberUnitInch, PLOTTER::m_headerExtraLines, m_workFilename, PLOTTER::outputFile, SetCurrentLineWidth(), TO_UTF8, PLOTTER::USE_DEFAULT_LINE_WIDTH, and workFile.

161 {
162  wxASSERT( outputFile );
163 
164  finalFile = outputFile; // the actual gerber file will be created later
165 
166  // Create a temporary filename to store gerber file
167  // note tmpfile() does not work under Vista and W7 in user mode
168  m_workFilename = filename + wxT(".tmp");
169  workFile = wxFopen( m_workFilename, wxT( "wt" ));
171  wxASSERT( outputFile );
172 
173  if( outputFile == NULL )
174  return false;
175 
176  for( unsigned ii = 0; ii < m_headerExtraLines.GetCount(); ii++ )
177  {
178  if( ! m_headerExtraLines[ii].IsEmpty() )
179  fprintf( outputFile, "%s\n", TO_UTF8( m_headerExtraLines[ii] ) );
180  }
181 
182  // Set coordinate format to 3.6 or 4.5 absolute, leading zero omitted
183  // the number of digits for the integer part of coordintes is needed
184  // in gerber format, but is not very important when omitting leading zeros
185  // It is fixed here to 3 (inch) or 4 (mm), but is not actually used
186  int leadingDigitCount = m_gerberUnitInch ? 3 : 4;
187 
188  fprintf( outputFile, "%%FSLAX%d%dY%d%d*%%\n",
189  leadingDigitCount, m_gerberUnitFmt,
190  leadingDigitCount, m_gerberUnitFmt );
191  fprintf( outputFile,
192  "G04 Gerber Fmt %d.%d, Leading zero omitted, Abs format (unit %s)*\n",
193  leadingDigitCount, m_gerberUnitFmt,
194  m_gerberUnitInch ? "inch" : "mm" );
195 
196  wxString Title = creator + wxT( " " ) + GetBuildVersion();
197  fprintf( outputFile, "G04 Created by KiCad (%s) date %s*\n",
198  TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
199 
200  /* Mass parameter: unit = INCHES/MM */
201  if( m_gerberUnitInch )
202  fputs( "%MOIN*%\n", outputFile );
203  else
204  fputs( "%MOMM*%\n", outputFile );
205 
206  // Be sure the usual dark polarity is selected:
207  fputs( "%LPD*%\n", outputFile );
208 
209  // Specify linear interpol (G01):
210  fputs( "G01*\n", outputFile );
211 
212  fputs( "G04 APERTURE LIST*\n", outputFile );
213  /* Select the default aperture */
215 
216  return true;
217 }
wxArrayString m_headerExtraLines
Definition: plot_common.h:552
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534
wxString m_workFilename
Definition: plot_common.h:1185
wxString filename
Definition: plot_common.h:546
wxString creator
Definition: plot_common.h:545
wxString DateAndTime()
Function DateAndTime.
Definition: string.cpp:229
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  aWidth,
bool  aItalic,
bool  aBold,
bool  aMultilineAllowed = false,
void *  aData = NULL 
)
overridevirtual

Draws text with the plotter.

Function PLOTTER::Text same as DrawGraphicText, 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)
aWidth= line width (pen width) (default = 0) if width < 0 : draw segments in sketch mode, width = abs(width) Use a value min(aSize.x, aSize.y) / 5 for a bold text
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

Reimplemented from PLOTTER.

Definition at line 941 of file common_plotGERBER_functions.cpp.

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

946 {
947  GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
948 
949  if( gbr_metadata )
950  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
951 
952  PLOTTER::Text( aPos, aColor, aText, aOrient, aSize,
953  aH_justify, aV_justify, aWidth, aItalic, aBold, aMultilineAllowed, aData );
954 }
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: drawtxt.cpp:227
GBR_NETLIST_METADATA m_NetlistMetadata
void GERBER_PLOTTER::ThickArc ( const wxPoint centre,
double  StAngle,
double  EndAngle,
int  rayon,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 548 of file common_plotGERBER_functions.cpp.

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

550 {
551  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
552  SetCurrentLineWidth( width, gbr_metadata );
553 
554  if( gbr_metadata )
555  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
556 
557  if( tracemode == FILLED )
558  Arc( centre, StAngle, EndAngle, radius, NO_FILL, DO_NOT_SET_LINE_WIDTH );
559  else
560  {
562  Arc( centre, StAngle, EndAngle,
563  radius - ( width - currentPenWidth ) / 2,
565  Arc( centre, StAngle, EndAngle,
566  radius + ( width - currentPenWidth ) / 2, NO_FILL,
568  }
569 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
int currentPenWidth
Definition: plot_common.h:540
virtual void Arc(const wxPoint &aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
GBR_NETLIST_METADATA m_NetlistMetadata
static const int DO_NOT_SET_LINE_WIDTH
Definition: plot_common.h:94
void GERBER_PLOTTER::ThickCircle ( const wxPoint pos,
int  diametre,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 600 of file common_plotGERBER_functions.cpp.

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

602 {
603  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
604  SetCurrentLineWidth( width, gbr_metadata );
605 
606  if( gbr_metadata )
607  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
608 
609  if( tracemode == FILLED )
610  Circle( pos, diametre, NO_FILL, DO_NOT_SET_LINE_WIDTH );
611  else
612  {
614  Circle( pos, diametre - (width - currentPenWidth),
616  Circle( pos, diametre + (width - currentPenWidth),
618  }
619 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
int currentPenWidth
Definition: plot_common.h:540
GBR_NETLIST_METADATA m_NetlistMetadata
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
static const int DO_NOT_SET_LINE_WIDTH
Definition: plot_common.h:94
void GERBER_PLOTTER::ThickRect ( const wxPoint p1,
const wxPoint p2,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 572 of file common_plotGERBER_functions.cpp.

References PLOTTER::currentPenWidth, PLOTTER::DO_NOT_SET_LINE_WIDTH, FILLED, formatNetAttribute(), GBR_METADATA::m_NetlistMetadata, NO_FILL, Rect(), SetCurrentLineWidth(), PLOTTER::USE_DEFAULT_LINE_WIDTH, wxPoint::x, and wxPoint::y.

574 {
575  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
576  SetCurrentLineWidth( width, gbr_metadata );
577 
578  if( gbr_metadata )
579  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
580 
581  if( tracemode == FILLED )
582  Rect( p1, p2, NO_FILL, DO_NOT_SET_LINE_WIDTH );
583  else
584  {
586  wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2,
587  p1.y - (width - currentPenWidth) / 2 );
588  wxPoint offsetp2( p2.x + (width - currentPenWidth) / 2,
589  p2.y + (width - currentPenWidth) / 2 );
590  Rect( offsetp1, offsetp2, NO_FILL, -1 );
591  offsetp1.x += (width - currentPenWidth);
592  offsetp1.y += (width - currentPenWidth);
593  offsetp2.x -= (width - currentPenWidth);
594  offsetp2.y -= (width - currentPenWidth);
595  Rect( offsetp1, offsetp2, NO_FILL, DO_NOT_SET_LINE_WIDTH );
596  }
597 }
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
int currentPenWidth
Definition: plot_common.h:540
GBR_NETLIST_METADATA m_NetlistMetadata
static const int DO_NOT_SET_LINE_WIDTH
Definition: plot_common.h:94
void GERBER_PLOTTER::ThickSegment ( const wxPoint start,
const wxPoint end,
int  width,
EDA_DRAW_MODE_T  tracemode,
void *  aData 
)
overridevirtual

Reimplemented from PLOTTER.

Definition at line 527 of file common_plotGERBER_functions.cpp.

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

Referenced by FlashPadOval().

529 {
530  if( tracemode == FILLED )
531  {
532  GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
533  SetCurrentLineWidth( width, gbr_metadata );
534 
535  if( gbr_metadata )
536  formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
537 
538  MoveTo( start );
539  FinishTo( end );
540  }
541  else
542  {
544  segmentAsOval( start, end, width, tracemode );
545  }
546 }
void FinishTo(const wxPoint &pos)
Definition: plot_common.h:241
void formatNetAttribute(GBR_NETLIST_METADATA *aData)
print a Gerber net attribute object record.
static const int USE_DEFAULT_LINE_WIDTH
Definition: plot_common.h:95
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
Set the line width for the next drawing.
void MoveTo(const wxPoint &pos)
Definition: plot_common.h:231
GBR_NETLIST_METADATA m_NetlistMetadata
void segmentAsOval(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode)
Cdonvert a thick segment and plot it as an oval.
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 96 of file class_plotter.cpp.

References PLOTTER::iuPerDeviceUnit, PLOTTER::m_mirrorIsHorizontal, PLOTTER::m_plotMirror, PLOTTER::m_yaxisReversed, PLOTTER::paperSize, PLOTTER::plotOffset, PLOTTER::plotScale, wxPoint::x, and wxPoint::y.

Referenced by HPGL_PLOTTER::Arc(), PS_PLOTTER::Arc(), PDF_PLOTTER::Arc(), SVG_PLOTTER::Arc(), Arc(), DXF_PLOTTER::Arc(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), DXF_PLOTTER::Circle(), PSLIKE_PLOTTER::computeTextParameters(), HPGL_PLOTTER::FlashPadCircle(), FlashPadCircle(), FlashPadOval(), FlashPadRect(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), PenTo(), DXF_PLOTTER::PenTo(), PS_PLOTTER::PlotImage(), PDF_PLOTTER::PlotImage(), PS_PLOTTER::PlotPoly(), PDF_PLOTTER::PlotPoly(), SVG_PLOTTER::PlotPoly(), HPGL_PLOTTER::Rect(), PS_PLOTTER::Rect(), PDF_PLOTTER::Rect(), SVG_PLOTTER::Rect(), PS_PLOTTER::Text(), and DXF_PLOTTER::Text().

97 {
98  wxPoint pos = aCoordinate - plotOffset;
99 
100  double x = pos.x * plotScale;
101  double y = ( paperSize.y - pos.y * plotScale );
102 
103  if( m_plotMirror )
104  {
106  x = ( paperSize.x - pos.x * plotScale );
107  else
108  y = pos.y * plotScale;
109  }
110 
111  if( m_yaxisReversed )
112  y = paperSize.y - y;
113 
114  x *= iuPerDeviceUnit;
115  y *= iuPerDeviceUnit;
116 
117  return DPOINT( x, y );
118 }
wxPoint plotOffset
Plot offset (in IUs)
Definition: plot_common.h:525
bool m_yaxisReversed
true to mirror horizontally (else vertically)
Definition: plot_common.h:531
bool m_plotMirror
X axis orientation (SVG) and plot mirrored (only for PS, PDF HPGL and SVG)
Definition: plot_common.h:529
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:513
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:522
VECTOR2< double > DPOINT
Definition: vector2d.h:595
wxSize paperSize
Paper size in IU - not in mils.
Definition: plot_common.h:550
bool m_mirrorIsHorizontal
Definition: plot_common.h:530
DPOINT PLOTTER::userToDeviceSize ( const wxSize &  size)
protectedvirtualinherited

Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)

Definition at line 121 of file class_plotter.cpp.

References PLOTTER::iuPerDeviceUnit, and PLOTTER::plotScale.

Referenced by PS_PLOTTER::Arc(), SVG_PLOTTER::Arc(), DXF_PLOTTER::Arc(), HPGL_PLOTTER::Circle(), PS_PLOTTER::Circle(), PDF_PLOTTER::Circle(), SVG_PLOTTER::Circle(), DXF_PLOTTER::Circle(), PSLIKE_PLOTTER::computeTextParameters(), HPGL_PLOTTER::FlashPadCircle(), PLOTTER::GetDashGapLenIU(), PLOTTER::GetDashMarkLenIU(), PDF_PLOTTER::PlotImage(), HPGL_PLOTTER::SetCurrentLineWidth(), PS_PLOTTER::SetCurrentLineWidth(), PDF_PLOTTER::SetCurrentLineWidth(), SVG_PLOTTER::setSVGPlotStyle(), PDF_PLOTTER::StartPage(), HPGL_PLOTTER::StartPlot(), PS_PLOTTER::StartPlot(), PS_PLOTTER::Text(), PDF_PLOTTER::Text(), and DXF_PLOTTER::Text().

122 {
123  return DPOINT( size.x * plotScale * iuPerDeviceUnit,
124  size.y * plotScale * iuPerDeviceUnit );
125 }
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:513
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:522
VECTOR2< double > DPOINT
Definition: vector2d.h:595
double PLOTTER::userToDeviceSize ( double  size) const
protectedvirtualinherited

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

Definition at line 128 of file class_plotter.cpp.

References PLOTTER::iuPerDeviceUnit, and PLOTTER::plotScale.

129 {
130  return size * plotScale * iuPerDeviceUnit;
131 }
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:513
double iuPerDeviceUnit
Device scale (from IUs to plotter device units - usually decimils)
Definition: plot_common.h:522
void GERBER_PLOTTER::UseX2Attributes ( bool  aEnable)
inline

Definition at line 1111 of file plot_common.h.

References m_useX2Attributes.

Referenced by StartPlotBoard().

1111 { m_useX2Attributes = aEnable; }
bool m_useX2Attributes
Definition: plot_common.h:1198
void GERBER_PLOTTER::UseX2NetAttributes ( bool  aEnable)
inline

Definition at line 1112 of file plot_common.h.

References m_useNetAttributes.

Referenced by StartPlotBoard().

1112 { m_useNetAttributes = aEnable; }
bool m_useNetAttributes
Definition: plot_common.h:1200
void GERBER_PLOTTER::writeApertureList ( )
protected

Generate the table of D codes.

Definition at line 337 of file common_plotGERBER_functions.cpp.

References apertures, APERTURE::Circle, GBR_APERTURE_METADATA::FormatAttribute(), m_apertureAttribute, m_gerberUnitInch, PLOTTER::m_IUsPerDecimil, PLOTTER::outputFile, APERTURE::Oval, PLOTTER::plotScale, APERTURE::Plotting, and APERTURE::Rect.

Referenced by EndPlot().

338 {
339  wxASSERT( outputFile );
340  char cbuf[1024];
341 
342  // Init
343  for( std::vector<APERTURE>::iterator tool = apertures.begin();
344  tool != apertures.end(); ++tool )
345  {
346  // apertude sizes are in inch or mm, regardless the
347  // coordinates format
348  double fscale = 0.0001 * plotScale / m_IUsPerDecimil; // inches
349 
350  if(! m_gerberUnitInch )
351  fscale *= 25.4; // size in mm
352 
353  int attribute = tool->m_ApertureAttribute;
354 
355  if( attribute != m_apertureAttribute )
358 
359  char* text = cbuf + sprintf( cbuf, "%%ADD%d", tool->m_DCode );
360 
361  /* Please note: the Gerber specs for mass parameters say that
362  exponential syntax is *not* allowed and the decimal point should
363  also be always inserted. So the %g format is ruled out, but %f is fine
364  (the # modifier forces the decimal point). Sadly the %f formatter
365  can't remove trailing zeros but thats not a problem, since nothing
366  forbid it (the file is only slightly longer) */
367 
368  switch( tool->m_Type )
369  {
370  case APERTURE::Circle:
371  sprintf( text, "C,%#f*%%\n", tool->m_Size.x * fscale );
372  break;
373 
374  case APERTURE::Rect:
375  sprintf( text, "R,%#fX%#f*%%\n",
376  tool->m_Size.x * fscale,
377  tool->m_Size.y * fscale );
378  break;
379 
380  case APERTURE::Plotting:
381  sprintf( text, "C,%#f*%%\n", tool->m_Size.x * fscale );
382  break;
383 
384  case APERTURE::Oval:
385  sprintf( text, "O,%#fX%#f*%%\n",
386  tool->m_Size.x * fscale,
387  tool->m_Size.y * fscale );
388  break;
389  }
390 
391  fputs( cbuf, outputFile );
392 
393  m_apertureAttribute = attribute;
394 
395  // Currently reset the aperture attribute. Perhaps a better optimization
396  // is to store the last attribute
397  if( attribute )
398  {
399  fputs( "%TD*%\n", outputFile );
401  }
402 
403  }
404 }
std::vector< APERTURE > apertures
Definition: plot_common.h:1192
double m_IUsPerDecimil
Definition: plot_common.h:519
double plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
Definition: plot_common.h:513
FILE * outputFile
true if the Y axis is top to bottom (SVG)
Definition: plot_common.h:534

Member Data Documentation

std::vector<APERTURE> GERBER_PLOTTER::apertures
protected
wxString PLOTTER::creator
protectedinherited
std::vector<APERTURE>::iterator GERBER_PLOTTER::currentAperture
protected

Definition at line 1193 of file plot_common.h.

Referenced by GERBER_PLOTTER(), selectAperture(), and SetDefaultLineWidth().

const int PLOTTER::DO_NOT_SET_LINE_WIDTH = -2
staticinherited

Definition at line 94 of file plot_common.h.

Referenced by FlashPadCircle(), SetCurrentLineWidth(), ThickArc(), ThickCircle(), and ThickRect().

FILE* GERBER_PLOTTER::finalFile
protected

Definition at line 1184 of file plot_common.h.

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

int GERBER_PLOTTER::m_apertureAttribute
protected

Definition at line 1181 of file plot_common.h.

Referenced by GERBER_PLOTTER(), and writeApertureList().

int GERBER_PLOTTER::m_gerberUnitFmt
protected

Definition at line 1196 of file plot_common.h.

Referenced by GERBER_PLOTTER(), SetGerberCoordinatesFormat(), SetViewport(), and StartPlot().

bool GERBER_PLOTTER::m_gerberUnitInch
protected
wxArrayString PLOTTER::m_headerExtraLines
protectedinherited
bool PLOTTER::m_mirrorIsHorizontal
protectedinherited
std::string GERBER_PLOTTER::m_objectAttributesDictionnary
protected

Definition at line 1178 of file plot_common.h.

Referenced by clearNetAttribute(), and formatNetAttribute().

bool PLOTTER::m_plotMirror
protectedinherited
bool GERBER_PLOTTER::m_useNetAttributes
protected
bool GERBER_PLOTTER::m_useX2Attributes
protected
wxString GERBER_PLOTTER::m_workFilename
protected

Definition at line 1185 of file plot_common.h.

Referenced by EndPlot(), and StartPlot().

bool PLOTTER::m_yaxisReversed
protectedinherited

true to mirror horizontally (else vertically)

Definition at line 531 of file plot_common.h.

Referenced by SVG_PLOTTER::Arc(), PLOTTER::PLOTTER(), SVG_PLOTTER::SetViewport(), and PLOTTER::userToDeviceCoordinates().

const unsigned PLOTTER::MARKER_COUNT = 58
staticinherited

Draw a marker (used for the drill map)

Definition at line 382 of file plot_common.h.

Referenced by PLOTTER::Marker().

bool PLOTTER::negativeMode
protectedinherited

true to plot in color, false to plot in black and white

Definition at line 538 of file plot_common.h.

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

FILE* PLOTTER::outputFile
protectedinherited

true if the Y axis is top to bottom (SVG)

Output file

Definition at line 534 of file plot_common.h.

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

wxPoint PLOTTER::penLastpos
protectedinherited

Last pen positions; set to -1,-1 when the pen is at rest.

Definition at line 544 of file plot_common.h.

Referenced by HPGL_PLOTTER::penControl(), HPGL_PLOTTER::PenTo(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), and DXF_PLOTTER::PenTo().

char PLOTTER::penState
protectedinherited

Current pen state: 'U', 'D' or 'Z' (see PenTo)

Definition at line 542 of file plot_common.h.

Referenced by HPGL_PLOTTER::penControl(), PS_PLOTTER::PenTo(), PDF_PLOTTER::PenTo(), SVG_PLOTTER::PenTo(), PenTo(), and PLOTTER::PLOTTER().

double PLOTTER::plotScale
protectedinherited
wxString PLOTTER::title
protectedinherited

Definition at line 547 of file plot_common.h.

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

FILE* GERBER_PLOTTER::workFile
protected

Definition at line 1183 of file plot_common.h.

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


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