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 1788 of file GERBER_plotter.cpp.

1789 {
1790  // Write aperture header
1791  fprintf( aOutput, "%%AM%s%d*\n", AM_FREEPOLY_BASENAME, m_Id );
1792  fprintf( aOutput, "4,1,%d,", (int)m_Corners.size() );
1793 
1794  // Insert a newline after curr_line_count_max coordinates.
1795  int curr_line_corner_count = 0;
1796  const int curr_line_count_max = 20; // <= 0 to disable newlines
1797 
1798  for( size_t ii = 0; ii <= m_Corners.size(); ii++ )
1799  {
1800  int jj = ii;
1801 
1802  if( ii >= m_Corners.size() )
1803  jj = 0;
1804 
1805  // Note: parameter values are always mm or inches
1806  fprintf( aOutput, "%#f,%#f,",
1807  m_Corners[jj].x * aIu2GbrMacroUnit, -m_Corners[jj].y * aIu2GbrMacroUnit );
1808 
1809  if( curr_line_count_max >= 0
1810  && ++curr_line_corner_count >= curr_line_count_max )
1811  {
1812  fprintf( aOutput, "\n" );
1813  curr_line_corner_count = 0;
1814  }
1815  }
1816 
1817  // output rotation parameter
1818  fputs( "$1*%\n", aOutput );
1819 }
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 1782 of file GERBER_plotter.cpp.

1783 {
1784  return polyCompare( m_Corners, aPolygon );
1785 }
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: