KiCad PCB EDA Suite
APER_MACRO_FREEPOLY Class Reference

A class to define an aperture macros based on a free polygon, i.e. More...

#include <gbr_plotter_apertures.h>

Public Member Functions

 APER_MACRO_FREEPOLY (const std::vector< wxPoint > &aPolygon, int aId)
 
bool IsSamePoly (const std::vector< wxPoint > &aPolygon) const
 
void Format (FILE *aOutput, double aIu2GbrMacroUnit)
 print the aperture macro definition to aOutput More...
 
int CornersCount () const
 

Public Attributes

std::vector< wxPoint > m_Corners
 
int m_Id
 

Detailed Description

A class to define an aperture macros based on a free polygon, i.e.

using a primitive 4 to describe a free polygon with a rotation. the aperture macro has only one parameter: rotation and is defined on the fly for aGerber file

Definition at line 159 of file gbr_plotter_apertures.h.

Constructor & Destructor Documentation

◆ APER_MACRO_FREEPOLY()

APER_MACRO_FREEPOLY::APER_MACRO_FREEPOLY ( const std::vector< wxPoint > &  aPolygon,
int  aId 
)
inline

Definition at line 162 of file gbr_plotter_apertures.h.

163  {
164  m_Corners = aPolygon;
165  m_Id = aId;
166  }
std::vector< wxPoint > m_Corners

References m_Corners, and m_Id.

Member Function Documentation

◆ CornersCount()

int APER_MACRO_FREEPOLY::CornersCount ( ) const
inline

Definition at line 183 of file gbr_plotter_apertures.h.

183 { return (int)m_Corners.size(); }
std::vector< wxPoint > m_Corners

References m_Corners.

◆ Format()

void APER_MACRO_FREEPOLY::Format ( FILE *  aOutput,
double  aIu2GbrMacroUnit 
)

print the aperture macro definition to aOutput

Parameters
aOutputis the FILE to write
aIu2GbrMacroUnitis the scaling factor from coordinates value to the Gerber file macros units (always mm or inches)

Definition at line 1957 of file GERBER_plotter.cpp.

1958 {
1959  // Write aperture header
1960  fprintf( aOutput, "%%AM%s%d*\n", AM_FREEPOLY_BASENAME, m_Id );
1961  fprintf( aOutput, "4,1,%d,", (int)m_Corners.size() );
1962 
1963  // Insert a newline after curr_line_count_max coordinates.
1964  int curr_line_corner_count = 0;
1965  const int curr_line_count_max = 20; // <= 0 to disable newlines
1966 
1967  for( size_t ii = 0; ii <= m_Corners.size(); ii++ )
1968  {
1969  int jj = ii;
1970 
1971  if( ii >= m_Corners.size() )
1972  jj = 0;
1973 
1974  // Note: parameter values are always mm or inches
1975  fprintf( aOutput, "%#f,%#f,",
1976  m_Corners[jj].x * aIu2GbrMacroUnit, -m_Corners[jj].y * aIu2GbrMacroUnit );
1977 
1978  if( curr_line_count_max >= 0 && ++curr_line_corner_count >= curr_line_count_max )
1979  {
1980  fprintf( aOutput, "\n" );
1981  curr_line_corner_count = 0;
1982  }
1983  }
1984 
1985  // output rotation parameter
1986  fputs( "$1*%\n", aOutput );
1987 }
std::vector< wxPoint > m_Corners
#define AM_FREEPOLY_BASENAME

References AM_FREEPOLY_BASENAME, m_Corners, and m_Id.

◆ IsSamePoly()

bool APER_MACRO_FREEPOLY::IsSamePoly ( const std::vector< wxPoint > &  aPolygon) const
Returns
true if aPolygon is the same as this, i.e. if the aPolygon is the same as m_Corners
Parameters
aOtheris the candidate to compare

Definition at line 1951 of file GERBER_plotter.cpp.

1952 {
1953  return polyCompare( m_Corners, aPolygon );
1954 }
static bool polyCompare(const std::vector< wxPoint > &aPolygon, const std::vector< wxPoint > &aTestPolygon)
std::vector< wxPoint > m_Corners

References m_Corners, and polyCompare().

Member Data Documentation

◆ m_Corners

std::vector<wxPoint> APER_MACRO_FREEPOLY::m_Corners

Definition at line 185 of file gbr_plotter_apertures.h.

Referenced by APER_MACRO_FREEPOLY(), CornersCount(), Format(), and IsSamePoly().

◆ m_Id

int APER_MACRO_FREEPOLY::m_Id

Definition at line 186 of file gbr_plotter_apertures.h.

Referenced by APER_MACRO_FREEPOLY(), and Format().


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